summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Klug <john.klug@multitech.com>2022-03-02 13:49:13 -0600
committerJohn Klug <john.klug@multitech.com>2022-03-02 14:18:20 -0600
commit1e3ad41a155b4172fcd67f77b62d92efceac49b7 (patch)
tree3e63626393f2bc2704af7e255898c6c2f84df35e
parent7bee6fc54da5dffa6802002720209cfc31a3202f (diff)
downloadmtac-1e3ad41a155b4172fcd67f77b62d92efceac49b7.tar.gz
mtac-1e3ad41a155b4172fcd67f77b62d92efceac49b7.tar.bz2
mtac-1e3ad41a155b4172fcd67f77b62d92efceac49b7.zip
Reduce default messages and use dynamic debug4.1.4
-rw-r--r--README10
-rw-r--r--configure.ac2
-rw-r--r--mtac.c113
3 files changed, 66 insertions, 59 deletions
diff --git a/README b/README
index cedae0e..68e6519 100644
--- a/README
+++ b/README
@@ -6,4 +6,12 @@ MTAC modules.
This module has a dependency on the at24
driver's Multitech EEPROM patch, and the
EEPROM data array it creates called
-"mts_ap_eeprom". \ No newline at end of file
+"mts_ap_eeprom".
+
+To turn on debug add the following lines to
+the end of /etc/modprobe.d/mts-io.conf:
+
+options mts-io dyndbg=+p
+options mtac dyndbg=+p
+options mtac-xdot dyndbg=+p
+options mtac-lora dyndbg=+p
diff --git a/configure.ac b/configure.ac
index f9fae41..519667b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,4 +1,4 @@
-AC_INIT([mtac], [4.1.3])
+AC_INIT([mtac], [4.1.4])
AM_INIT_AUTOMAKE
AM_CONFIG_HEADER([config.h])
diff --git a/mtac.c b/mtac.c
index 5ef87f7..5bb6ea7 100644
--- a/mtac.c
+++ b/mtac.c
@@ -1,8 +1,7 @@
-#define DRIVER_VERSION "v4.1.3"
+#define DRIVER_VERSION "v4.1.4"
#define DRIVER_AUTHOR "Multi-Tech"
#define DRIVER_DESC "MTS driver to supervise MTAC slots"
#define DRIVER_NAME "mtac-slots"
-#define DEBUG 0
#include <linux/types.h>
#include <linux/gpio.h>
@@ -52,7 +51,7 @@ 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 %s",
+ dev_dbg(&mts_io_platform_device->dev,"mtac_clear_port_pins: State of mtac mutex is %s\n",
mutex_is_locked(&mtac_mutex) ? "locked" : "unlocked");
mutex_lock(&mtac_mutex);
pins = mtac_port_info[port_index]->gpio_pins;
@@ -66,14 +65,14 @@ void mtac_clear_port_pins(int port_index)
}
}
mtac_port_info[port_index]->gpio_pins = NULL;
- log_debug("Unlock mtac_mutex");
+ dev_dbg(&mts_io_platform_device->dev,"Unlock mtac_mutex\n");
mutex_unlock(&mtac_mutex);
}
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 %s",
+ dev_dbg(&mts_io_platform_device->dev,"mtac_set_port_pins: State of mtac mutex is %s\n",
mutex_is_locked(&mtac_mutex) ? "locked" : "unlocked");
mtac_port_info[port_index]->gpio_pins = pins;
mtac_port_info[port_index]->subdirs = subdir;
@@ -86,13 +85,13 @@ struct kobj_attribute* mtac_create_attribute(const char* _name, umode_t _mode) {
_attr = kzalloc(sizeof(struct kobj_attribute), GFP_KERNEL);
if (! _attr) {
- log_error("kzalloc of attribute [%s] failed", _name);
+ dev_err(&mts_io_platform_device->dev,"kzalloc of attribute [%s] failed\n", _name);
return NULL;
}
sysfs_attr_init(_attr);
attr_name = kstrdup(_name, GFP_KERNEL);
if (! attr_name) {
- log_error("GFP_KERNEL dup failed for attribute [%s]", _name);
+ dev_err(&mts_io_platform_device->dev,"GFP_KERNEL dup failed for attribute [%s]\n", _name);
return NULL;
}
_attr->attr.name = attr_name;
@@ -108,17 +107,17 @@ int mtac_port_from_kobject(struct kobject *kobj) {
name = kobj->name;
if (! name) {
- log_error("kobject->name is NULL");
+ dev_err(&mts_io_platform_device->dev,"kobject->name is NULL\n");
return -1;
}
if (sscanf(name, "ap%d", &port) < 1) {
- log_error("failed to scan port from kobject->name [%s]", name);
+ dev_err(&mts_io_platform_device->dev,"failed to scan port from kobject->name [%s]\n", name);
return -1;
}
if (port < 1 || port > NUM_AP) {
- log_error("port number %d is invalid", port);
+ dev_err(&mts_io_platform_device->dev,"port number %d is invalid\n", port);
return -1;
}
@@ -138,7 +137,7 @@ ssize_t mtac_show_product_info(struct kobject *kobj, struct kobj_attribute *attr
port = mtac_port_from_kobject(kobj);
if (port < 1) {
- log_error("mtac_port_from_kobject returned %d", port);
+ dev_err(&mts_io_platform_device->dev,"mtac_port_from_kobject returned %d\n", port);
return -1;
}
port_index = port - 1;
@@ -153,7 +152,7 @@ ssize_t mtac_show_product_info(struct kobject *kobj, struct kobj_attribute *attr
} else if (! strcmp(attr->attr.name, "hw-version")) {
value = snprintf(buf, 32, "%s\n", app->hw_version);
} else {
- log_error("attribute [%s] not found", attr->attr.name);
+ dev_err(&mts_io_platform_device->dev,"attribute [%s] not found\n", attr->attr.name);
value = -1;
}
return value;
@@ -167,7 +166,7 @@ bool mtac_add_product_info_attributes(int port, struct attribute** attrs, int* i
sprintf(buf, "vendor-id");
kobj_attr = mtac_create_attribute(buf, MTS_ATTR_MODE_RO);
if (! kobj_attr) {
- log_error("failed to create attribute [%s] in port %d", buf, port);
+ dev_err(&mts_io_platform_device->dev,"failed to create attribute [%s] in port %d\n", buf, port);
return false;
}
kobj_attr->show = mtac_show_product_info;
@@ -176,7 +175,7 @@ bool mtac_add_product_info_attributes(int port, struct attribute** attrs, int* i
sprintf(buf, "product-id");
kobj_attr = mtac_create_attribute(buf, MTS_ATTR_MODE_RO);
if (! kobj_attr) {
- log_error("failed to create attribute [%s] in port %d", buf, port);
+ dev_err(&mts_io_platform_device->dev,"failed to create attribute [%s] in port %d\n", buf, port);
return false;
}
kobj_attr->show = mtac_show_product_info;
@@ -185,7 +184,7 @@ bool mtac_add_product_info_attributes(int port, struct attribute** attrs, int* i
sprintf(buf, "device-id");
kobj_attr = mtac_create_attribute(buf, MTS_ATTR_MODE_RO);
if (! kobj_attr) {
- log_error("failed to create attribute [%s] in port %d", buf, port);
+ dev_err(&mts_io_platform_device->dev,"failed to create attribute [%s] in port %d\n", buf, port);
return false;
}
kobj_attr->show = mtac_show_product_info;
@@ -194,7 +193,7 @@ bool mtac_add_product_info_attributes(int port, struct attribute** attrs, int* i
sprintf(buf, "hw-version");
kobj_attr = mtac_create_attribute(buf, MTS_ATTR_MODE_RO);
if (! kobj_attr) {
- log_error("failed to create attribute [%s] in port %d", buf, port);
+ dev_err(&mts_io_platform_device->dev,"failed to create attribute [%s] in port %d\n", buf, port);
return false;
}
kobj_attr->show = mtac_show_product_info;
@@ -214,7 +213,7 @@ 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 %s",
+ dev_dbg(&mts_io_platform_device->dev,"mtac_gpio_pin_by_attr_name: State of mtac mutex is %s\n",
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);
@@ -228,7 +227,7 @@ struct gpio_pin *mtac_gpio_pin_by_attr_name(const char *name, int port) {
}
mutex_unlock(&mtac_mutex);
- log_error("pin with attr name [%s] not found", name);
+ dev_err(&mts_io_platform_device->dev,"pin with attr name [%s] not found\n", name);
return NULL;
}
EXPORT_SYMBOL(mtac_gpio_pin_by_attr_name);
@@ -243,7 +242,7 @@ ssize_t mtac_attr_show_ap_gpio_pin(struct kobject *kobj,
port = mtac_port_from_kobject(kobj);
if (port < 1) {
- log_error("mtac_port_from_kobject returned %d", port);
+ dev_err(&mts_io_platform_device->dev,"mtac_port_from_kobject returned %d\n", port);
return -EINVAL;
}
@@ -252,7 +251,7 @@ 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 %s",
+ dev_dbg(&mts_io_platform_device->dev,"mtac_attr_show_ap_gpio_pin: State of mtac mutex is %s\n",
mutex_is_locked(&mtac_mutex) ? "locked" : "unlocked");
mutex_lock(&mtac_mutex);
@@ -286,7 +285,7 @@ ssize_t mtac_attr_store_ap_gpio_pin(struct kobject *kobj,
port = mtac_port_from_kobject(kobj);
if (port < 1) {
- log_error("mtac_port_from_kobject returned %d", port);
+ dev_err(&mts_io_platform_device->dev,"mtac_port_from_kobject returned %d\n", port);
return -EINVAL;
}
@@ -303,7 +302,7 @@ 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 %s",
+ dev_dbg(&mts_io_platform_device->dev,"mtac_attr_store_ap_gpio_pin: State of mtac mutex is %s\n",
mutex_is_locked(&mtac_mutex) ? "locked" : "unlocked");
mutex_lock(&mtac_mutex);
@@ -325,14 +324,14 @@ static void display_port(int port_index) {
/* Our caller has locked the mtac_mutex */
if(!mutex_is_locked(&mtac_mutex))
- log_error("display_port: Must always hold the mtac_mutex here, but mutex was not locked");
+ dev_err(&mts_io_platform_device->dev,"display_port: Must always hold the mtac_mutex here, but mutex was not locked\n");
app = (struct mts_ap_eeprom_layout *)mts_ap_eeprom[port_index];
- log_info("accessory card %d vendor-id: %.32s", port, app->vendor_id);
- log_info("accessory card %d product-id: %.32s", port, app->product_id);
- log_info("accessory card %d device-id: %.32s", port, app->device_id);
- log_info("accessory card %d hw-version: %.32s", port, app->hw_version);
+ dev_info(&mts_io_platform_device->dev,"accessory card %d vendor-id: %.32s\n", port, app->vendor_id);
+ dev_info(&mts_io_platform_device->dev,"accessory card %d product-id: %.32s\n", port, app->product_id);
+ dev_info(&mts_io_platform_device->dev,"accessory card %d device-id: %.32s\n", port, app->device_id);
+ dev_info(&mts_io_platform_device->dev,"accessory card %d hw-version: %.32s\n", port, app->hw_version);
}
static void acquire_gpio(struct gpio_pin *pins, int port_index)
@@ -345,23 +344,23 @@ static void acquire_gpio(struct gpio_pin *pins, int port_index)
for (pin = pins; *pin->name; pin++) {
if (!memcmp(pin->name,buf,strlen(buf))) {
if (pin->do_gpio_desc) {
- log_debug("Request name:%s label: %s", pin->name, pin->pin.label);
+ dev_dbg(&mts_io_platform_device->dev,"Request name:%s label: %s\n", pin->name, pin->pin.label);
pin->desc = devm_gpiod_get_optional(&mts_io_platform_device->dev, pin->name, pin->pin.flags);
if (IS_ERR(pin->desc)) {
dev_dbg(&mts_io_platform_device->dev,
"%s: Could not get gpio %s: Error: %ld\n", __func__, pin->name, PTR_ERR(pin->desc));
} else {
if (pin->desc == NULL)
- dev_dbg(&mts_io_platform_device->dev,"gpio_desc is null for name: %s, label: %s\n",
+ dev_dbg(&mts_io_platform_device->dev,"gpio_desc is null for name: %s, label: %s\n\n",
pin->name, pin->pin.label);
else
- dev_dbg(&mts_io_platform_device->dev,"Found gpio %s\n", pin->name);
+ dev_dbg(&mts_io_platform_device->dev,"Found gpio %s\n\n", pin->name);
}
} else {
- log_debug("Request name:%s label: %s pin: %d", pin->name, pin->pin.label, pin->pin.gpio);
+ dev_dbg(&mts_io_platform_device->dev,"Request name:%s label: %s pin: %d\n", pin->name, pin->pin.label, pin->pin.gpio);
ret = gpio_request_one(pin->pin.gpio, pin->pin.flags, pin->pin.label);
if (ret)
- log_debug("could not request pin %s (%d) but it could have already been requested under a different pin name", pin->name, ret);
+ dev_dbg(&mts_io_platform_device->dev,"could not request pin %s (%d) but it could have already been requested under a different pin name\n", pin->name, ret);
}
}
}
@@ -372,7 +371,7 @@ 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 %s",
+ dev_dbg(&mts_io_platform_device->dev,"mtac_gpio_pin_by_name: State of mtac mutex is %s\n",
mutex_is_locked(&mtac_mutex) ? "locked" : "unlocked");
mutex_lock(&mtac_mutex);
for (pin = mtac_port_info[port_index]->gpio_pins; *pin->name; pin++) {
@@ -383,7 +382,7 @@ struct gpio_pin *mtac_gpio_pin_by_name(const char *name, int port_index) {
}
mutex_unlock(&mtac_mutex);
- log_error("pin named %s not found", name);
+ dev_err(&mts_io_platform_device->dev,"pin named %s not found\n", name);
return NULL;
}
@@ -396,7 +395,7 @@ 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 %s",
+ dev_dbg(&mts_io_platform_device->dev,"mtac_gpio_pin_by_num: State of mtac mutex is %s\n",
mutex_is_locked(&mtac_mutex) ? "locked" : "unlocked");
mutex_lock(&mtac_mutex);
port_gpio_pins = mtac_port_info[port_index]->gpio_pins;
@@ -408,7 +407,7 @@ struct gpio_pin *mtac_gpio_pin_by_num(unsigned num, int port_index) {
ipin++;
}
mutex_unlock(&mtac_mutex);
- log_error("pin numbered %u not found", num);
+ dev_err(&mts_io_platform_device->dev,"pin numbered %u not found\n", num);
return NULL;
}
@@ -423,38 +422,38 @@ int mtac_find(void(*set_info)(struct ap_info* info), const char *target_product_
struct mts_ap_eeprom_layout *app;
int slot_count = 0;
- log_debug("mtac_find enter");
+ dev_dbg(&mts_io_platform_device->dev,"mtac_find enter\n");
for (port_index = 0; port_index < NUM_AP; port_index++) {
- log_debug("mtac_find: port_index: %d State of mtac mutex is %s",
+ dev_dbg(&mts_io_platform_device->dev,"mtac_find: port_index: %d State of mtac mutex is %s\n",
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);
+ dev_dbg(&mts_io_platform_device->dev,"Accessory Port %d of %d is in use\n",port_index+1,NUM_AP);
mutex_unlock(&mtac_mutex);
continue;
}
app = (struct mts_ap_eeprom_layout *)mts_ap_eeprom[port_index];
- log_debug("target_product_id=%s, eeprom=%s",target_product_id,app->product_id);
+ dev_dbg(&mts_io_platform_device->dev,"target_product_id=%s, eeprom=%s\n",target_product_id,app->product_id);
if (mts_ap_eeprom[port_index][0] == 0xFF) {
- log_info("uninitialized eeprom on accessory card %d", port_index);
+ dev_info(&mts_io_platform_device->dev,"uninitialized eeprom on accessory card %d\n", port_index);
mutex_unlock(&mtac_mutex);
continue;
} else if (mts_ap_eeprom[port_index][0] == 0x0) {
- log_debug("no accessory card inserted in port_index %d", port_index);
+ dev_dbg(&mts_io_platform_device->dev,"no accessory card inserted in port_index %d\n", port_index);
mutex_unlock(&mtac_mutex);
continue;
} else if (strstr(app->product_id, target_product_id)) {
- log_debug("strstr matches");
+ dev_dbg(&mts_io_platform_device->dev,"strstr matches\n");
mtac_port_info[port_index] = kzalloc(sizeof(struct ap_info), GFP_KERNEL);
if (! mtac_port_info[port_index]) {
- log_error("alloc of port info failed");
+ dev_err(&mts_io_platform_device->dev,"alloc of port info failed\n");
mutex_unlock(&mtac_mutex);
return -ENOSPC;
}
set_info(mtac_port_info[port_index]);
if (! mtac_port_info[port_index]->setup(port_index+1)) {
- log_error("accessory port %d setup failed", port_index+1);
+ dev_err(&mts_io_platform_device->dev,"accessory port %d setup failed\n", port_index+1);
mtac_port_info[port_index]->teardown(port_index+1);
kfree(mtac_port_info[port_index]);
mtac_port_info[port_index] = NULL;
@@ -463,10 +462,10 @@ int mtac_find(void(*set_info)(struct ap_info* info), const char *target_product_
} else {
acquire_gpio(mtac_port_info[port_index]->gpio_pins,port_index);
slot_count++;
- log_debug("slot_count=%d",slot_count);
+ dev_dbg(&mts_io_platform_device->dev,"slot_count=%d\n",slot_count);
}
} else
- log_debug("len prod_id: %d eeprom pr id: %d",strlen(target_product_id),strlen(app->product_id));
+ dev_dbg(&mts_io_platform_device->dev,"len prod_id: %d eeprom pr id: %d\n",strlen(target_product_id),strlen(app->product_id));
mutex_unlock(&mtac_mutex);
}
return slot_count;
@@ -478,19 +477,19 @@ void mtac_free(const char *product_id, bool(* setup)(enum ap port), const char *
int port_index, count, port;
char buf[32];
struct mts_ap_eeprom_layout *app;
- log_debug("mtac_free enter");
+ dev_dbg(&mts_io_platform_device->dev,"mtac_free enter\n");
count = 0;
for (port_index = 0; port_index < NUM_AP; port_index++) {
port = port_index + 1;
app = (struct mts_ap_eeprom_layout *)mts_ap_eeprom[port_index];
if (app && strstr(app->product_id, product_id)) {
count++;
- log_debug("Free port %d product_id: %s mtac_port_info: %p",
+ dev_dbg(&mts_io_platform_device->dev,"Free port %d product_id: %s mtac_port_info: %p\n",
port_index + 1, product_id,mtac_port_info[port_index]);
if(mtac_port_info[port_index])
- log_debug("setup: %p setup ptr: %p",mtac_port_info[port_index]->setup,setup);
+ dev_dbg(&mts_io_platform_device->dev,"setup: %p setup ptr: %p\n",mtac_port_info[port_index]->setup,setup);
if (mtac_port_info[port_index] && (mtac_port_info[port_index]->setup == setup)) {
- log_debug("port_index %d is occupied by us, teardown next",port_index);
+ dev_dbg(&mts_io_platform_device->dev,"port_index %d is occupied by us, teardown next\n",port_index);
if (count > 1) {
sprintf(buf, "%s-%d",link,port);
@@ -517,7 +516,7 @@ static int __init mtac_init(void)
const struct firmware* fw = NULL;
int ret;
- log_debug("init: " DRIVER_VERSION);
+ dev_dbg(&mts_io_platform_device->dev,"init: \n" DRIVER_VERSION);
mutex_lock(&mtac_mutex);
for (port_index = 0; port_index < NUM_AP; port_index++) {
@@ -525,19 +524,19 @@ static int __init mtac_init(void)
if((ret = request_firmware_direct(&fw, eeprom_file_name[port_index], &mts_io_platform_device->dev)) == 0) {
if(fw->size == sizeof(mts_ap_eeprom[0])) {
memcpy(mts_ap_eeprom[port_index], fw->data, sizeof(mts_ap_eeprom[0]));
- log_info("EEPROM contents loaded (%s)", eeprom_file_name[port_index]);
+ dev_info(&mts_io_platform_device->dev,"EEPROM contents loaded (%s)\n", eeprom_file_name[port_index]);
} else {
- log_error("EEPROM invalid size (%s:%d)", eeprom_file_name[port_index], fw->size);
+ dev_err(&mts_io_platform_device->dev,"EEPROM invalid size (%s:%d)\n", eeprom_file_name[port_index], fw->size);
}
release_firmware(fw);
} else {
- log_error("EEPROM unable to read (%s:%d)", eeprom_file_name[port_index], ret);
+ dev_err(&mts_io_platform_device->dev,"EEPROM unable to read (%s:%d)\n", eeprom_file_name[port_index], ret);
}
if (mts_ap_eeprom[port_index][0] == 0xFF)
log_alert("uninitialized eeprom on accessory card %d", port_index);
else if (mts_ap_eeprom[port_index][0] == 0x0)
- log_info("no accessory card inserted in port %d", port_index+1);
+ dev_info(&mts_io_platform_device->dev,"no accessory card inserted in port %d\n", port_index+1);
else
display_port(port_index);
}
@@ -548,7 +547,7 @@ static int __init mtac_init(void)
static void __exit mtac_exit(void)
{
- log_info("exiting");
+ dev_info(&mts_io_platform_device->dev,"exiting\n");
}
module_init(mtac_init);
module_exit(mtac_exit);