diff options
-rw-r--r-- | io-module/mtcdt.c | 21 | ||||
-rw-r--r-- | io-module/mts_io.c | 41 |
2 files changed, 52 insertions, 10 deletions
diff --git a/io-module/mtcdt.c b/io-module/mtcdt.c index 21edcfe..d8ea8b9 100644 --- a/io-module/mtcdt.c +++ b/io-module/mtcdt.c @@ -723,18 +723,25 @@ static struct attribute *mtcdt_0_1_platform_attributes[] = { &dev_attr_led_c_gpio.attr, &dev_attr_led_d_gpio.attr, - &dev_attr_wifi_bt_lpwkup.attr, - &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_gnss_reset.attr, - &dev_attr_gnss_int.attr, &dev_attr_usbhub_reset.attr, &dev_attr_eth_reset.attr, NULL, }; +static struct attribute *mtcdt_0_1_wifi_bt_attributes[] = { + &dev_attr_wifi_bt_lpwkup.attr, + &dev_attr_wifi_bt_ulpwkup.attr, + &dev_attr_wifi_bt_reset.attr, + &dev_attr_wifi_bt_lpmode.attr, + &dev_attr_wifi_bt_int, +}; + +static struct attribute *mtcdt_0_1_gnss_attributes[] = { + &dev_attr_gnss_reset.attr, + &dev_attr_gnss_int.attr, +}; + + static struct attribute_group mtcdt_platform_attribute_group = { .attrs = mtcdt_platform_attributes }; diff --git a/io-module/mts_io.c b/io-module/mts_io.c index 1122127..e509731 100644 --- a/io-module/mts_io.c +++ b/io-module/mts_io.c @@ -503,7 +503,7 @@ static ssize_t mts_attr_show_radio_reset_backoff_seconds(struct device *dev, if (strcmp(attr->attr.name, "radio-reset-backoff-seconds") == 0) { if (radio_reset_timer_is_start == 1) { - value = sprintf(buf, "%u", (timings_data_stop_seconds - time_now_secs())); + value = sprintf(buf, "%lu", (timings_data_stop_seconds - time_now_secs())); } else { value = sprintf(buf, "%d", 0); } @@ -754,11 +754,17 @@ static void init_accessory_ports(void) {} static void teardown_accessory_ports(void) {} #endif -static int mts_id_eeprom_load(void) +struct attribute *freelater = NULL; // Storage to free when driver is unloaded. + +static int mts_id_eeprom_load() { int i; char buf[64] = {0}; char* ptr; + int attr_blength; // Byte length of base attribute array + int current_blength; // Current length in bytes of attribute array + int current_count; // Number of items in array + struct attribute **all_attrs = NULL; mts_hw_version = MTCDT_0_0; //The mts_id_eeprom buffer is initialize once on boot @@ -776,6 +782,31 @@ static int mts_id_eeprom_load(void) log_info("detected board %s", HW_VERSION_MTP_0_0); } else if (strncmp(id_eeprom.hw_version, HW_VERSION_MTCDT_0_1, strlen(HW_VERSION_MTCDT_0_1)) == 0) { + attr_blength = sizeof mtcdt_0_1_platform_attributes; + if(DEVICE_CAPA(id_eeprom.capa, CAPA_WIFI_BT)) { + attr_blength += sizeof mtcdt_0_1_wifi_bt_attributes; + } + if(DEVICE_CAPA(id_eeprom.capa, CAPA_GNSS)) { + attr_blength += sizeof mtcdt_0_1_gnss_attributes; + } + if (attr_blength != sizeof mtcdt_0_1_platform_attributes) { + freelater = all_attrs = kmalloc(attr_blength,GFP_KERNEL); + current_blength = sizeof mtcdt_0_1_platform_attributes - sizeof (struct attribute *); + current_count = current_blength/(sizeof (struct attribute *)); + memcpy(all_attrs,mtcdt_0_1_platform_attributes,current_blength); + if(DEVICE_CAPA(id_eeprom.capa, CAPA_WIFI_BT)) { + 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_GNSS)) { + 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_wifi_bt_attributes / (sizeof (struct attribute *)); + } + all_attrs[current_count] = (struct attribute *)NULL; + mtcdt_0_1_platform_attribute_group.attrs = all_attrs; + } + attr_group = &mtcdt_0_1_platform_attribute_group; gpio_pins = gpio_pins_mtcdt_0_1; mts_hw_version = MTCDT_0_1; @@ -843,13 +874,17 @@ static void cleanup(void) } teardown_accessory_ports(); - + if(freelater) { + kfree(freelater); + freelater = NULL; + } log_info("done cleaning up...."); } static int __init mts_io_init(void) { struct gpio_pin *pin; + int ret; log_info("init: " DRIVER_VERSION); |