summaryrefslogtreecommitdiff
path: root/io-module/mts_io.c
diff options
context:
space:
mode:
Diffstat (limited to 'io-module/mts_io.c')
-rw-r--r--io-module/mts_io.c41
1 files changed, 38 insertions, 3 deletions
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);