summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mtac.c33
1 files changed, 20 insertions, 13 deletions
diff --git a/mtac.c b/mtac.c
index 4b74c69..7697085 100644
--- a/mtac.c
+++ b/mtac.c
@@ -1,4 +1,4 @@
-#define DRIVER_VERSION "v4.0.3"
+#define DRIVER_VERSION "v4.0.4"
#define DRIVER_AUTHOR "John Klug <john.klug@multitech.com>"
#define DRIVER_DESC "MTS driver to supervise MTAC slots"
#define DRIVER_NAME "mtac-slots"
@@ -46,7 +46,8 @@ void mtac_clear_port_pins(int port_index)
/* Find all the GPIO pins for this port and
* free them all.
*/
- log_debug("mtac_clear_port_pins: State of mtac mutex is %d",(*(int *)(&mtac_mutex.count)));
+ log_debug("mtac_clear_port_pins: State of mtac mutex is %s",
+ mutex_is_locked(&mtac_mutex) ? "locked" : "unlocked");
mutex_lock(&mtac_mutex);
pins = mtac_port_info[port_index]->gpio_pins;
for (pin = pins; *pin->name; pin++) {
@@ -62,7 +63,8 @@ EXPORT_SYMBOL(mtac_clear_port_pins);
void mtac_set_port_pins(int port_index, struct gpio_pin *pins, struct kobject *subdir)
{
- log_debug("mtac_set_port_pins: State of mtac mutex is %d",(*(int *)(&mtac_mutex.count)));
+ log_debug("mtac_set_port_pins: State of mtac mutex is %s",
+ mutex_is_locked(&mtac_mutex) ? "locked" : "unlocked");
mtac_port_info[port_index]->gpio_pins = pins;
mtac_port_info[port_index]->subdirs = subdir;
}
@@ -202,7 +204,8 @@ struct gpio_pin *mtac_gpio_pin_by_attr_name(const char *name, int port) {
int port_index = port - 1;
struct gpio_pin *port_gpio_pins;
- log_debug("mtac_gpio_pin_by_attr_name: State of mtac mutex is %d",(*(int *)(&mtac_mutex.count)));
+ log_debug("mtac_gpio_pin_by_attr_name: State of mtac mutex is %s",
+ mutex_is_locked(&mtac_mutex) ? "locked" : "unlocked");
mutex_lock(&mtac_mutex);
pin_attr_name = mtac_port_info[port_index]->gpio_pin_name_by_attr_name(name, port);
port_gpio_pins = mtac_port_info[port_index]->gpio_pins;
@@ -239,7 +242,8 @@ ssize_t mtac_attr_show_ap_gpio_pin(struct kobject *kobj,
return -ENODEV;
}
- log_debug("mtac_attr_show_ap_gpio_pin: State of mtac mutex is %d",(*(int *)(&mtac_mutex.count)));
+ log_debug("mtac_attr_show_ap_gpio_pin: State of mtac mutex is %s",
+ mutex_is_locked(&mtac_mutex) ? "locked" : "unlocked");
mutex_lock(&mtac_mutex);
value = gpio_get_value(pin->pin.gpio);
@@ -285,7 +289,8 @@ ssize_t mtac_attr_store_ap_gpio_pin(struct kobject *kobj,
value = !value;
}
- log_debug("mtac_attr_store_ap_gpio_pin: State of mtac mutex is %d",(*(int *)(&mtac_mutex.count)));
+ log_debug("mtac_attr_store_ap_gpio_pin: State of mtac mutex is %s",
+ mutex_is_locked(&mtac_mutex) ? "locked" : "unlocked");
mutex_lock(&mtac_mutex);
gpio_set_value(pin->pin.gpio, value);
@@ -302,9 +307,8 @@ static void display_port(int port_index) {
/* Our caller has locked the mtac_mutex */
- if((*(int *)(&mtac_mutex.count)) != 0) {
- log_error("Must always hold the mtac_mutex here, count is %d not 0",(*(int *)(&mtac_mutex.count)));
- }
+ if(!mutex_is_locked(&mtac_mutex))
+ log_error("display_port: Must always hold the mtac_mutex here, but mutex was not locked");
app = (struct mts_ap_eeprom_layout *)mts_ap_eeprom[port_index];
@@ -336,7 +340,8 @@ static void acquire_gpio(struct gpio_pin *pins, int port_index)
struct gpio_pin *mtac_gpio_pin_by_name(const char *name, int port_index) {
struct gpio_pin *pin;
- log_debug("mtac_gpio_pin_by_name: State of mtac mutex is %d",(*(int *)(&mtac_mutex.count)));
+ log_debug("mtac_gpio_pin_by_name: State of mtac mutex is %s",
+ mutex_is_locked(&mtac_mutex) ? "locked" : "unlocked");
mutex_lock(&mtac_mutex);
for (pin = mtac_port_info[port_index]->gpio_pins; *pin->name; pin++) {
if (!strcmp(pin->name, name)) {
@@ -359,7 +364,8 @@ struct gpio_pin *mtac_gpio_pin_by_num(unsigned num, int port_index) {
int ipin = 0;
struct gpio_pin *port_gpio_pins;
- log_debug("mtac_gpio_pin_by_num: State of mtac mutex is %d",(*(int *)(&mtac_mutex.count)));
+ log_debug("mtac_gpio_pin_by_num: State of mtac mutex is %s",
+ mutex_is_locked(&mtac_mutex) ? "locked" : "unlocked");
mutex_lock(&mtac_mutex);
port_gpio_pins = mtac_port_info[port_index]->gpio_pins;
while(*(port_gpio_pins[ipin].name)) {
@@ -387,8 +393,9 @@ int mtac_find(void(*set_info)(struct ap_info* info), const char *target_product_
log_debug("mtac_find enter");
for (port_index = 0; port_index < NUM_AP; port_index++) {
- log_debug("mtac_find: port_index: %d State of mtac mutex is %d",
- port_index, (*(int *)(&mtac_mutex.count)));
+ log_debug("mtac_find: port_index: %d State of mtac mutex is %s",
+ port_index,
+ mutex_is_locked(&mtac_mutex) ? "locked" : "unlocked");
mutex_lock(&mtac_mutex);
if (mtac_port_info[port_index] != NULL) {
log_debug("Accessory Port %d of %d is in use",port_index+1,NUM_AP);