summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Klug <john.klug@multitech.com>2018-04-20 15:26:43 -0500
committerJohn Klug <john.klug@multitech.com>2018-04-20 15:32:40 -0500
commit24297c1295873ecdb729903aa2f53fe0ec1203d5 (patch)
tree923f73903033abb2b166fb87808b1dfa3f1d8c9f
parent90d4811e95b58f5bb0124cd793e7045dc1ff6b3d (diff)
downloadmts-io-24297c1295873ecdb729903aa2f53fe0ec1203d5.tar.gz
mts-io-24297c1295873ecdb729903aa2f53fe0ec1203d5.tar.bz2
mts-io-24297c1295873ecdb729903aa2f53fe0ec1203d5.zip
Add has-radio flag to mts-io, and remove compiler warnings
-rw-r--r--io-module/mtac_lora.c2
-rw-r--r--io-module/mtac_mfser.c1
-rw-r--r--io-module/mtcap.c3
-rw-r--r--io-module/mtcdt.c25
-rw-r--r--io-module/mtr.c21
-rw-r--r--io-module/mts_capab.c3
-rw-r--r--io-module/mts_io.c205
-rw-r--r--io-module/mts_io.h36
-rw-r--r--io-module/mts_lora.c20
9 files changed, 246 insertions, 70 deletions
diff --git a/io-module/mtac_lora.c b/io-module/mtac_lora.c
index 0541f3d..60bab06 100644
--- a/io-module/mtac_lora.c
+++ b/io-module/mtac_lora.c
@@ -121,9 +121,9 @@ static bool lora_setup(enum ap port) {
attrs[index++] = &attr->attr;
}
else if (lora_hw_version == MTAC_LORA_1_5) {
+ int ipin = 0;
// Substitute pins for this port
log_info("Substitute pins");
- int ipin = 0;
while(*(lora_h[port_index][ipin].name)) {
struct gpio_pin *p;
p = gpio_pin_by_num(lora_h[port_index][ipin].pin.gpio);
diff --git a/io-module/mtac_mfser.c b/io-module/mtac_mfser.c
index 27ca4dc..26fd339 100644
--- a/io-module/mtac_mfser.c
+++ b/io-module/mtac_mfser.c
@@ -20,6 +20,7 @@ static char* mfser_gpio_pin_name_by_attr_name(const char* name, int port) {
return "";
}
}
+ return "";
}
static ssize_t mts_attr_show_mfser_mode(struct kobject *kobj,
diff --git a/io-module/mtcap.c b/io-module/mtcap.c
index b28e8eb..fd278c8 100644
--- a/io-module/mtcap.c
+++ b/io-module/mtcap.c
@@ -435,6 +435,7 @@ static struct attribute *mtcap_0_0_platform_attributes[] = {
&dev_attr_hw_version.attr,
&dev_attr_imei.attr,
&dev_attr_eth_mac.attr,
+ &dev_attr_has_radio.attr,
&dev_attr_reset.attr,
&dev_attr_reset_monitor.attr,
&dev_attr_reset_monitor_intervals.attr,
@@ -460,7 +461,7 @@ static struct attribute *mtcap_0_0_platform_attributes[] = {
};
static int
-is_radio_power_attr(struct attribute *attr)
+is_radio_power_attr_mtcap(struct attribute *attr)
{
return (attr == &dev_attr_radio_power_mtcap.attr);
}
diff --git a/io-module/mtcdt.c b/io-module/mtcdt.c
index b84e67a..0fca7aa 100644
--- a/io-module/mtcdt.c
+++ b/io-module/mtcdt.c
@@ -679,15 +679,10 @@ static struct attribute *mtcdt_platform_attributes[] = {
&dev_attr_hw_version.attr,
&dev_attr_imei.attr,
&dev_attr_eth_mac.attr,
+ &dev_attr_has_radio.attr,
&dev_attr_reset.attr,
&dev_attr_reset_monitor.attr,
&dev_attr_reset_monitor_intervals.attr,
- &dev_attr_radio_power.attr,
- &dev_attr_radio_reset.attr,
-
- &dev_attr_radio_reset_backoffs.attr,
- &dev_attr_radio_reset_backoff_index.attr,
- &dev_attr_radio_reset_backoff_seconds.attr,
&dev_attr_led_status.attr,
&dev_attr_led_cd_gpio.attr,
@@ -700,6 +695,13 @@ static struct attribute *mtcdt_platform_attributes[] = {
&dev_attr_led_c_gpio.attr,
&dev_attr_led_d_gpio.attr,
&dev_attr_eth_reset.attr,
+
+ &dev_attr_radio_power.attr,
+ &dev_attr_radio_reset.attr,
+
+ &dev_attr_radio_reset_backoffs.attr,
+ &dev_attr_radio_reset_backoff_index.attr,
+ &dev_attr_radio_reset_backoff_seconds.attr,
NULL,
};
@@ -711,6 +713,7 @@ static struct attribute *mtcdt_0_1_platform_attributes[] = {
&dev_attr_hw_version.attr,
&dev_attr_imei.attr,
&dev_attr_eth_mac.attr,
+ &dev_attr_has_radio.attr,
&dev_attr_reset.attr,
&dev_attr_reset_monitor.attr,
&dev_attr_reset_monitor_intervals.attr,
@@ -731,9 +734,9 @@ static struct attribute *mtcdt_0_1_platform_attributes[] = {
// radio feature is last to be able to
// easily remove radio.
- // is_radio_power_attr_mtcdt() truncates
- // this list.
- &dev_attr_radio_power.attr,
+ // is_radio_power_attr_mtcdt() searches
+ // for this for truncation.
+ &dev_attr_radio_power.attr, /* Must be first radio attribute */
&dev_attr_radio_reset.attr,
&dev_attr_radio_reset_backoffs.attr,
@@ -748,7 +751,7 @@ static struct attribute *mtcdt_0_1_wifi_bt_attributes[] = {
&dev_attr_wifi_bt_ulpwkup.attr,
&dev_attr_wifi_bt_reset.attr,
&dev_attr_wifi_bt_lpmode.attr,
- &dev_attr_wifi_bt_int,
+ &dev_attr_wifi_bt_int.attr,
};
static struct attribute *mtcdt_0_1_gnss_attributes[] = {
@@ -769,4 +772,4 @@ static int
is_radio_power_attr_mtcdt(struct attribute *attr)
{
return (attr == &dev_attr_radio_power.attr);
-} \ No newline at end of file
+}
diff --git a/io-module/mtr.c b/io-module/mtr.c
index 4e44988..15c295f 100644
--- a/io-module/mtr.c
+++ b/io-module/mtr.c
@@ -1191,6 +1191,11 @@ static DEVICE_ATTR_MTS(dev_attr_usbhub_reset_mtr, "usbhub-reset",
static DEVICE_ATTR_RO_MTS(dev_attr_gnss_int_mtr, "gnss-int",
mts_attr_show_gpio_pin);
+static int
+is_radio_power_attr_mtr(struct attribute *attr)
+{
+ return (attr == &dev_attr_radio_power_mtr.attr);
+}
static struct attribute *mtr_platform_attributes[] = {
&dev_attr_vendor_id.attr,
@@ -1200,16 +1205,11 @@ static struct attribute *mtr_platform_attributes[] = {
&dev_attr_hw_version.attr,
&dev_attr_imei.attr,
&dev_attr_eth_mac.attr,
+ &dev_attr_has_radio.attr,
&dev_attr_wifi_mac_mtr.attr,
&dev_attr_reset.attr,
&dev_attr_reset_monitor.attr,
&dev_attr_reset_monitor_intervals.attr,
- &dev_attr_radio_power_mtr.attr,
- &dev_attr_radio_reset_mtr.attr,
-
- &dev_attr_radio_reset_backoffs.attr,
- &dev_attr_radio_reset_backoff_index.attr,
- &dev_attr_radio_reset_backoff_seconds.attr,
&dev_attr_extserial_ri_gpio_mtr.attr,
&dev_attr_extserial_dtr_mtr.attr,
@@ -1234,6 +1234,14 @@ static struct attribute *mtr_platform_attributes[] = {
&dev_attr_led_e_gpio.attr,
&dev_attr_led_f_gpio_mtr.attr,
+ /* Radio stuff moved to end for possible removal */
+ &dev_attr_radio_power_mtr.attr, /* radio_power must be first */
+ &dev_attr_radio_reset_mtr.attr,
+
+ &dev_attr_radio_reset_backoffs.attr,
+ &dev_attr_radio_reset_backoff_index.attr,
+ &dev_attr_radio_reset_backoff_seconds.attr,
+
NULL,
};
@@ -1250,6 +1258,7 @@ static struct attribute *mtrv1_0_1_platform_attributes[] = {
&dev_attr_hw_version.attr,
&dev_attr_imei.attr,
&dev_attr_eth_mac.attr,
+ &dev_attr_has_radio.attr,
&dev_attr_wifi_mac_mtr.attr,
&dev_attr_reset.attr,
diff --git a/io-module/mts_capab.c b/io-module/mts_capab.c
index e4ddb6f..8495d87 100644
--- a/io-module/mts_capab.c
+++ b/io-module/mts_capab.c
@@ -27,9 +27,10 @@ static struct capab_map_s capabilities_map[] = {
{ CAPA_LORA, "lora"},
};
-static ssize_t capab_show_value(struct kobject *kobj, struct kobj_attribute *attr, char *buf) {
+static ssize_t capab_show_value(struct device *dev, struct device_attribute *at, char *buf) {
int i;
const int count = sizeof(capabilities_map)/sizeof(capabilities_map[0]);
+ struct kobj_attribute *attr = (struct kobj_attribute *)at;
for (i = 0; i < count; i++) {
if (strcmp(capabilities_map[i].name, attr->attr.name) == 0) {
diff --git a/io-module/mts_io.c b/io-module/mts_io.c
index fba83de..abac4bb 100644
--- a/io-module/mts_io.c
+++ b/io-module/mts_io.c
@@ -47,7 +47,7 @@
#include "mts_io.h"
-#define DRIVER_VERSION "v2.0.0"
+#define DRIVER_VERSION "v2.0.1"
#define DRIVER_AUTHOR "James Maki <jmaki@multitech.com>"
#define DRIVER_DESC "MTS-IO Controller"
#define DRIVER_NAME "mts-io"
@@ -116,6 +116,62 @@ static void reset_callback(struct work_struct *ignored);
static DECLARE_DELAYED_WORK(reset_work, reset_callback);
+/*
+ * This function takes the product_id and tries to check
+ * for a modem. If there is an error, assume there is a
+ * modem. Saying there is a modem when there is not
+ * just results in a slower boot.
+ * If no hyphen in product ID, or no product ID,
+ * assume we have a radio.
+ * If there is a hyphen test the character after the
+ * first hyphen:
+ * If the character is numeric, we have no modem.
+ * if the chracter is not a B, we have a modem.
+ * If the character is a B, and it is followed
+ * by a numeric, we have no modem.
+ * If the B is the last character or is followed
+ * by a numeric, we have no modem.
+ * All other cases, we have a modem.
+ */
+static int
+has_radio(const char *product_id, size_t len)
+{
+ char *p;
+ if (!product_id || ! *product_id)
+ return 1; /* No Product ID? */
+ p = memchr(product_id,'-',len);
+ if (p) { /* Found a hyphen */
+ log_debug("Found hyphen");
+ p++;
+ if (p >= product_id+len) {
+ log_debug("End of string -- hyphen");
+ return 1; /* Last character was hyphen */
+ }
+ if (isdigit(*p)) {
+ log_debug("Found digit after hypen");
+ return 0; /* Modem name never starts with a digit */
+ }
+ if (*p != 'B') {
+ log_debug("Found neither B nor digit after hypen");
+ return 1; /* Modem starting with a letter, but not B */
+ }
+ /* Found a B */
+ p++;
+ if (p >= product_id+len) {
+ log_debug("B at end of product-id string");
+ return 1; /* Last character was B */
+ }
+ if (isdigit(*p)) {
+ log_debug("B followed by digit after hyphen - no modem");
+ return 0; /* B[numeric] is MTR Build number */
+ }
+ log_debug("B followed by non-digit after hyphen - has modem");
+ return 1; /* B[non-numeric] so assume a modem that starts with B */
+ } /* End of found hyphen case */
+ log_debug("Undefined product-id - has modem");
+ return 1; /* Product id invalid or empty, so instantiate a radio anyway */
+}
+
static void reset_callback(struct work_struct *ignored)
{
struct gpio_pin *pin;
@@ -173,7 +229,7 @@ static ssize_t mts_attr_show_reset_monitor_intervals(struct device *dev, struct
return ret;
}
-static ssize_t mts_attr_store_reset_monitor_intervals(struct device *dev, struct device_attribute *attr, char *buf, size_t count)
+static ssize_t mts_attr_store_reset_monitor_intervals(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
{
int short_int;
int long_int;
@@ -571,6 +627,9 @@ static ssize_t mts_attr_show_product_info(struct device *dev,
value = sprintf(buf, "%.32s\n", id_eeprom.vendor_id);
} else if (strcmp(attr->attr.name, "product-id") == 0) {
value = sprintf(buf, "%.32s\n", id_eeprom.product_id);
+ } else if (strcmp(attr->attr.name, "has-radio") == 0) {
+ value = sprintf(buf, "%1d\n",
+ has_radio(id_eeprom.product_id,sizeof id_eeprom.product_id));
} else if (strcmp(attr->attr.name, "device-id") == 0) {
value = sprintf(buf, "%.32s\n", id_eeprom.device_id);
} else if (strcmp(attr->attr.name, "uuid") == 0) {
@@ -631,6 +690,8 @@ static DEVICE_ATTR_RO_MTS(dev_attr_vendor_id, "vendor-id",
mts_attr_show_product_info);
static DEVICE_ATTR_RO_MTS(dev_attr_product_id, "product-id",
mts_attr_show_product_info);
+static DEVICE_ATTR_RO_MTS(dev_attr_has_radio, "has-radio",
+ mts_attr_show_product_info);
static DEVICE_ATTR_RO_MTS(dev_attr_device_id, "device-id",
mts_attr_show_product_info);
static DEVICE_ATTR_RO_MTS(dev_attr_uuid, "uuid",
@@ -642,7 +703,7 @@ static DEVICE_ATTR_RO_MTS(dev_attr_imei, "imei",
static DEVICE_ATTR_RO_MTS(dev_attr_eth_mac, "mac-eth",
mts_attr_show_product_info);
-static int get_radio_model_from_product_id() {
+static int get_radio_model_from_product_id(void) {
int rc = RADIO_UNKNOWN;
if (strstr(id_eeprom.product_id, "LEU1")) rc = RADIO_LEU1;
@@ -825,21 +886,25 @@ mts_id_eeprom_load(void)
int current_count; // Number of items in array
struct attribute **all_attrs = NULL;
char *tmp;
+ int noradio;
//The mts_id_eeprom buffer is initialize once on boot
//reloading the mts_io.ko module will not reinitialize this buffer
//only rebooting will reinitialize this buffer
memcpy(&id_eeprom, mts_id_eeprom, sizeof(mts_id_eeprom));
- if (mts_id_eeprom[0] == 0xFF) {
- log_error("uninitialized eeprom");
- return -EIO;
- } else if (((tmp=HW_VERSION_MTCAP_0_0),strncmp(id_eeprom.hw_version, tmp, strlen(tmp)) == 0) ||
+ if (mts_id_eeprom[0] == 0xFF) {
+ log_error("uninitialized eeprom");
+ return -EIO;
+ }
+
+ noradio = ! has_radio(id_eeprom.product_id,sizeof id_eeprom.product_id);
+ log_debug("mts_id_eeprom: noradio=%d",noradio);
+
+ if (((tmp=HW_VERSION_MTCAP_0_0),strncmp(id_eeprom.hw_version, tmp, strlen(tmp)) == 0) ||
((tmp=HW_VERSION_MTCAP_0_1),strncmp(id_eeprom.hw_version, tmp, strlen(tmp)) == 0)) {
/* See if we have no radio, and if so, prune out the stuff that follows */
- if((strncmp(id_eeprom.product_id, PRODUCT_ID_MTCAP, sizeof PRODUCT_ID_MTCAP - 1) == 0) &&
- (id_eeprom.product_id[sizeof PRODUCT_ID_MTCAP-1] == '-') &&
- isdigit(id_eeprom.product_id[sizeof PRODUCT_ID_MTCAP])) {
+ if(noradio) {
struct attribute **ap = mtcap_0_0_platform_attribute_group.attrs;
while(1) {
if(ap[j] == NULL) {
@@ -847,7 +912,7 @@ mts_id_eeprom_load(void)
break;
}
j++;
- if (is_radio_power_attr(ap[j])) {
+ if (is_radio_power_attr_mtcap(ap[j])) {
log_info("Pruning radio feature from mts-io",j);
ap[j] = NULL;
break;
@@ -861,21 +926,117 @@ mts_id_eeprom_load(void)
}
log_info("detected board %s", tmp);
} else if (strncmp(id_eeprom.hw_version, HW_VERSION_MTR_0_0, strlen(HW_VERSION_MTR_0_0)) == 0) {
+ if(noradio) {
+ struct attribute **ap = mtcap_0_0_platform_attribute_group.attrs;
+ while(1) {
+ if(ap[j] == NULL) {
+ log_info("Did not find radio power attribute. Possible driver fault.");
+ break;
+ }
+ j++;
+ if (is_radio_power_attr_mtr(ap[j])) {
+ log_info("Pruning radio feature from mts-io",j);
+ ap[j] = NULL;
+ break;
+ }
+ }
+ }
+
attr_group = &mtr_platform_attribute_group;
gpio_pins = gpio_pins_mtr_0_0;
mts_hw_version = MTR_0_0;
log_info("detected board %s", HW_VERSION_MTR_0_0);
} else if (strncmp(id_eeprom.hw_version, HW_VERSION_MTR_0_1, strlen(HW_VERSION_MTR_0_1)) == 0) {
+ if(noradio) {
+ struct attribute **ap = mtr_platform_attribute_group.attrs;
+ while(1) {
+ if(ap[j] == NULL) {
+ log_info("Did not find radio power attribute. Possible driver fault.");
+ break;
+ }
+ j++;
+ if (is_radio_power_attr_mtr(ap[j])) {
+ log_info("Pruning radio feature from mts-io",j);
+ ap[j] = NULL;
+ break;
+ }
+ }
+ }
+
attr_group = &mtr_platform_attribute_group;
gpio_pins = gpio_pins_mtr_0_1;
mts_hw_version = MTR_0_1;
log_info("detected board %s", HW_VERSION_MTR_0_1);
} else if (strncmp(id_eeprom.hw_version, HW_VERSION_MTRV1_0_0, strlen(HW_VERSION_MTRV1_0_0)) == 0) {
- attr_group = &mtr_platform_attribute_group;
- gpio_pins = gpio_pins_mtrv1_0_0;
- mts_hw_version = MTRV1_0_0;
- log_info("detected board %s", HW_VERSION_MTRV1_0_0);
+ if(noradio) {
+ struct attribute **ap = mtr_platform_attribute_group.attrs;
+ while(1) {
+ if(ap[j] == NULL) {
+ log_info("Did not find radio power attribute. Possible driver fault.");
+ break;
+ }
+ j++;
+ if (is_radio_power_attr_mtr(ap[j])) {
+ log_info("Pruning radio feature from mts-io",j);
+ ap[j] = NULL;
+ break;
+ }
+ }
+ }
+
+ attr_group = &mtr_platform_attribute_group;
+ gpio_pins = gpio_pins_mtrv1_0_0;
+ mts_hw_version = MTRV1_0_0;
+ log_info("detected board %s", HW_VERSION_MTRV1_0_0);
} else if (strncmp(id_eeprom.hw_version, HW_VERSION_MTRV1_0_1, strlen(HW_VERSION_MTRV1_0_1)) == 0) {
+ current_blength = attr_blength = sizeof mtrv1_0_1_platform_attributes;
+ current_blength -= sizeof(struct attribute *); /* Length without terminating NULL */
+
+ /* See if we have no radio, and if so, prune out the stuff that follows */
+ if(noradio) {
+ struct attribute **ap = mtrv1_0_1_platform_attribute_group.attrs;
+ while(1) {
+ if(ap[j] == NULL) {
+ log_info("Did not find radio power attribute. Possible driver fault.");
+ break;
+ }
+ j++;
+ if (is_radio_power_attr_mtr(ap[j])) {
+ log_info("Pruning radio feature from mts-io",j);
+ ap[j] = NULL;
+ current_blength = attr_blength = j * sizeof (ap[j]);
+ break;
+ }
+ }
+ }
+
+ /* mtcdt gnss and wifi for future devices. We assume the same
+ * pinout as mtcdt on MTR. */
+ if(DEVICE_CAPA(id_eeprom.capa, CAPA_WIFI)) {
+ attr_blength += sizeof mtcdt_0_1_wifi_bt_attributes;
+ }
+ if(DEVICE_CAPA(id_eeprom.capa, CAPA_GPS)) {
+ attr_blength += sizeof mtcdt_0_1_gnss_attributes;
+ }
+ if (current_blength+(sizeof(struct attribute *)) != attr_blength) {
+ freelater = all_attrs = kmalloc(attr_blength,GFP_KERNEL);
+ current_count = current_blength/(sizeof (struct attribute *));
+ memcpy(all_attrs,mtrv1_0_1_platform_attributes,current_blength);
+ if(DEVICE_CAPA(id_eeprom.capa, CAPA_WIFI)) {
+ log_info("Adding WiFi/BT to mts-io driver");
+ memcpy(all_attrs + current_count,mtcdt_0_1_wifi_bt_attributes,sizeof mtcdt_0_1_wifi_bt_attributes);
+ current_count += sizeof mtcdt_0_1_wifi_bt_attributes / (sizeof (struct attribute *));
+ }
+ if(DEVICE_CAPA(id_eeprom.capa, CAPA_GPS)) {
+ log_info("Adding GPS to mts-io driver");
+ attr_blength += sizeof mtcdt_0_1_gnss_attributes;
+ memcpy(all_attrs + current_count,mtcdt_0_1_gnss_attributes,sizeof mtcdt_0_1_gnss_attributes);
+ current_count += sizeof mtcdt_0_1_gnss_attributes / (sizeof (struct attribute *));
+ }
+ all_attrs[current_count] = (struct attribute *)NULL;
+ mtrv1_0_1_platform_attribute_group.attrs = all_attrs;
+ }
+
attr_group = &mtrv1_0_1_platform_attribute_group;
gpio_pins = gpio_pins_mtrv1_0_1;
mts_hw_version = MTRV1_0_1;
@@ -886,9 +1047,7 @@ mts_id_eeprom_load(void)
current_blength -= sizeof(struct attribute *); /* Length without terminating NULL */
/* See if we have no radio, and if so, prune out the stuff that follows */
- if((strncmp(id_eeprom.product_id, PRODUCT_ID_MTCDT, sizeof PRODUCT_ID_MTCDT - 1) == 0) &&
- (id_eeprom.product_id[sizeof PRODUCT_ID_MTCDT-1] == '-') &&
- isdigit(id_eeprom.product_id[sizeof PRODUCT_ID_MTCDT])) {
+ if(noradio) {
struct attribute **ap = mtcdt_0_1_platform_attribute_group.attrs;
while(1) {
if(ap[j] == NULL) {
@@ -938,9 +1097,7 @@ mts_id_eeprom_load(void)
current_blength -= sizeof(struct attribute *); /* Length without terminating NULL */
/* See if we have no radio, and if so, prune out the stuff that follows */
- if((strncmp(id_eeprom.product_id, PRODUCT_ID_MTCDTIPHP, sizeof PRODUCT_ID_MTCDTIPHP - 1) == 0) &&
- (id_eeprom.product_id[sizeof PRODUCT_ID_MTCDTIPHP-1] == '-') &&
- isdigit(id_eeprom.product_id[sizeof PRODUCT_ID_MTCDTIPHP])) {
+ if(noradio) {
struct attribute **ap = mtcdt_0_1_platform_attribute_group.attrs;
while(1) {
if(ap[j] == NULL) {
@@ -981,10 +1138,8 @@ mts_id_eeprom_load(void)
}
log_info("detected board %s", tmp);
} else {
- if((strncmp(id_eeprom.product_id, PRODUCT_ID_MTCDT, sizeof PRODUCT_ID_MTCDT - 1) == 0) &&
- (id_eeprom.product_id[sizeof PRODUCT_ID_MTCDT-1] == '-') &&
- isdigit(id_eeprom.product_id[sizeof PRODUCT_ID_MTCDT])) {
- struct attribute **ap = mtcdt_0_1_platform_attribute_group.attrs;
+ if(noradio) {
+ struct attribute **ap = mtcdt_platform_attribute_group.attrs;
while(1) {
if(ap[j] == NULL) {
log_info("Did not find radio power attribute. Possible driver fault.");
diff --git a/io-module/mts_io.h b/io-module/mts_io.h
index 241ed1d..5870146 100644
--- a/io-module/mts_io.h
+++ b/io-module/mts_io.h
@@ -10,33 +10,33 @@
printk(level "[" name "] " DRIVER_NAME ":%s:%d: " format "\n" , \
__func__ , __LINE__ , ## args)
-#define log_emerg(format, args...) __log(KERN_EMERG, "EMERG", format , ## args)
-#define log_alert(format, args...) __log(KERN_ALERT, "ALERT", format , ## args)
-#define log_crit(format, args...) __log(KERN_CRIT, "CRIT", format , ## args)
-#define log_error(format, args...) __log(KERN_ERR, "ERROR", format , ## args)
-#define log_warning(format, args...) __log(KERN_WARNING, "WARNING", format , ## args)
-#define log_notice(format, args...) __log(KERN_NOTICE, "NOTICE", format , ## args)
-#define log_info(format, args...) __log(KERN_INFO, "INFO", format , ## args)
+#define log_emerg(format, ...) __log(KERN_EMERG, "EMERG", format , ## __VA_ARGS__)
+#define log_alert(format, ...) __log(KERN_ALERT, "ALERT", format , ## __VA_ARGS__)
+#define log_crit(format, ...) __log(KERN_CRIT, "CRIT", format , ## __VA_ARGS__)
+#define log_error(format, ...) __log(KERN_ERR, "ERROR", format , ## __VA_ARGS__)
+#define log_warning(format, ...) __log(KERN_WARNING, "WARNING", format , ## __VA_ARGS__)
+#define log_notice(format, ...) __log(KERN_NOTICE, "NOTICE", format , ## __VA_ARGS__)
+#define log_info(format, ...) __log(KERN_INFO, "INFO", format , ## __VA_ARGS__)
#if DEBUG
-# define log_debug(format, args...) __log(KERN_DEBUG, "DEBUG", format , ## args)
+# define log_debug(format, ...) __log(KERN_DEBUG, "DEBUG", format , ## __VA_ARGS__)
#else
-# define log_debug(format, args...) do {} while (0)
+# define log_debug(format, ...) do {} while (0)
#endif
#define MTS_ATTR_MODE_RW S_IWUSR | S_IRUGO
#define MTS_ATTR_MODE_RO S_IRUGO
-#define DEVICE_ATTR_MTS(_dev_name, _name, _show, _store) \
-struct device_attribute _dev_name = { \
- .attr = { .name = _name, .mode = MTS_ATTR_MODE_RW }, \
- .show = _show, \
- .store = _store, \
+#define DEVICE_ATTR_MTS(mts_dev_name, mts_name, mts_show, mts_store) \
+struct device_attribute mts_dev_name = { \
+ .attr = { .name = mts_name, .mode = MTS_ATTR_MODE_RW }, \
+ .show = mts_show, \
+ .store = mts_store, \
}
-#define DEVICE_ATTR_RO_MTS(_dev_name, _name, _show) \
-struct device_attribute _dev_name = { \
- .attr = { .name = _name, .mode = MTS_ATTR_MODE_RO }, \
- .show = _show, \
+#define DEVICE_ATTR_RO_MTS(mts_dev_name, mts_name, mts_show) \
+struct device_attribute mts_dev_name = { \
+ .attr = { .name = mts_name, .mode = MTS_ATTR_MODE_RO }, \
+ .show = mts_show, \
}
#define VENDOR_ID_MULTITECH "Multi-Tech Systems"
diff --git a/io-module/mts_lora.c b/io-module/mts_lora.c
index 7b7e204..4cd65a7 100644
--- a/io-module/mts_lora.c
+++ b/io-module/mts_lora.c
@@ -18,12 +18,14 @@ static void mts_teardown_lora_port(void)
}
}
-static ssize_t mts_attr_show_lora_product_info(struct kobject *kobj,
- struct kobj_attribute *attr, char *buf)
+static ssize_t mts_attr_show_lora_product_info(struct device *dev,
+ struct device_attribute *at, char *buf)
{
ssize_t value;
-
char label[32];
+ struct kobject *kobj = (struct kobject *)dev;
+ struct kobj_attribute *attr = (struct kobj_attribute *)at;
+
snprintf(label, sizeof label, "%s/%s", kobj->name, attr->attr.name);
if (strcmp(label, "lora/eui") == 0) {
@@ -50,12 +52,14 @@ static ssize_t mts_attr_show_lora_product_info(struct kobject *kobj,
return value;
}
-static ssize_t mts_attr_show_lora_gpio_pin(struct kobject *kobj,
- struct kobj_attribute *attr,
+static ssize_t mts_attr_show_lora_gpio_pin(struct device *dev,
+ struct device_attribute *at,
char *buf)
{
int value;
struct gpio_pin *pin;
+ struct kobject *kobj = (struct kobject *)dev;
+ struct kobj_attribute *attr = (struct kobj_attribute *)at;
char pin_label[32];
snprintf(pin_label, sizeof pin_label, "%s/%s", kobj->name, attr->attr.name); // ex. lora/reset
@@ -82,12 +86,14 @@ static ssize_t mts_attr_show_lora_gpio_pin(struct kobject *kobj,
return sprintf(buf, "%d\n", value);
}
-static ssize_t mts_attr_store_lora_gpio_pin(struct kobject *kobj,
- struct kobj_attribute *attr, const char *buf, size_t count)
+static ssize_t mts_attr_store_lora_gpio_pin(struct device *dev,
+ struct device_attribute *at, const char *buf, size_t count)
{
int value;
struct gpio_pin *pin;
char pin_label[32];
+ struct kobject *kobj = (struct kobject *)dev;
+ struct kobj_attribute *attr = (struct kobj_attribute *)at;
snprintf(pin_label, sizeof pin_label, "%s/%s", kobj->name, attr->attr.name); // ex. lora/reset