diff options
Diffstat (limited to 'io-module/mts_capab.c')
-rw-r--r-- | io-module/mts_capab.c | 38 |
1 files changed, 27 insertions, 11 deletions
diff --git a/io-module/mts_capab.c b/io-module/mts_capab.c index 8495d87..38e8442 100644 --- a/io-module/mts_capab.c +++ b/io-module/mts_capab.c @@ -25,6 +25,7 @@ static struct capab_map_s capabilities_map[] = { { CAPA_BLUETOOTH, "bluetooth"}, { CAPA_WIFI, "wifi"}, { CAPA_LORA, "lora"}, + { CAPA_BATTERY, "battery"}, }; static ssize_t capab_show_value(struct device *dev, struct device_attribute *at, char *buf) { @@ -48,6 +49,7 @@ static DEVICE_ATTR_RO_MTS(capa_attr_adc, "adc", capab_show_value); static DEVICE_ATTR_RO_MTS(capa_attr_bt, "bluetooth", capab_show_value); static DEVICE_ATTR_RO_MTS(capa_attr_wifi, "wifi", capab_show_value); static DEVICE_ATTR_RO_MTS(capa_attr_lora, "lora", capab_show_value); +static DEVICE_ATTR_RO_MTS(capa_attr_battery, "battery", capab_show_value); static struct attribute *mts_capa_attributes[] = { &capa_attr_gps.attr, @@ -57,6 +59,7 @@ static struct attribute *mts_capa_attributes[] = { &capa_attr_bt.attr, &capa_attr_wifi.attr, &capa_attr_lora.attr, + &capa_attr_battery.attr, NULL, }; @@ -65,21 +68,34 @@ static struct attribute_group mts_capa_attr_group = { }; static struct kobject *mts_capa_kobject = NULL; +EXPORT_SYMBOL(mts_capa_kobject); -static int mts_capab_dir_create(void) +static int mts_capab_dir_create(uint8_t hw_version) { - mts_capa_kobject = kobject_create_and_add("capability", &mts_io_platform_device->dev.kobj); - if (!mts_capa_kobject) { - log_error("kobject_create_and_add for capability directory failed"); - return -ENOMEM; - } + int i,j; + + if (hw_version == MTCPM_0_0) { + for (i=0; mts_capa_attributes[i]; i++) { + /* Remove capa_lora for MTCPM mts-io driver */ + if (mts_capa_attributes[i] == &capa_attr_lora.attr) { + for(j=i; mts_capa_attributes[j]; j++) + mts_capa_attributes[j] = mts_capa_attributes[j+1]; + break; + } + } + } + mts_capa_kobject = kobject_create_and_add("capability", &mts_io_platform_device->dev.kobj); + if (!mts_capa_kobject) { + log_error("kobject_create_and_add for capability directory failed"); + return -ENOMEM; + } - if (sysfs_create_group(mts_capa_kobject, &mts_capa_attr_group)) { - log_error("sysfs_create_group failed to create capability group"); - return -ENOMEM; - } + if (sysfs_create_group(mts_capa_kobject, &mts_capa_attr_group)) { + log_error("sysfs_create_group failed to create capability group"); + return -ENOMEM; + } - return 0; + return 0; } static void mts_capab_dir_delete(void) |