diff options
author | John Klug <john.klug@multitech.com> | 2016-12-02 17:22:01 -0600 |
---|---|---|
committer | John Klug <john.klug@multitech.com> | 2016-12-02 17:22:01 -0600 |
commit | 765d88576c6dbc9247ce216ca542e52814f09126 (patch) | |
tree | 8509f3246fc1b669f8c222e50d845b4261752dc2 /io-module | |
parent | 3da4f0384f9ee1890fece5ebd9fe9784e1910116 (diff) | |
download | mts-io-765d88576c6dbc9247ce216ca542e52814f09126.tar.gz mts-io-765d88576c6dbc9247ce216ca542e52814f09126.tar.bz2 mts-io-765d88576c6dbc9247ce216ca542e52814f09126.zip |
Ethernet AC buffer overrun, and add capability directory to platform1.5.5
Diffstat (limited to 'io-module')
-rw-r--r-- | io-module/mtac_eth.c | 3 | ||||
-rw-r--r-- | io-module/mts_capab.c | 63 | ||||
-rw-r--r-- | io-module/mts_eeprom.h | 1 | ||||
-rw-r--r-- | io-module/mts_io.c | 26 | ||||
-rw-r--r-- | io-module/mts_io.mod.c | 23 |
5 files changed, 90 insertions, 26 deletions
diff --git a/io-module/mtac_eth.c b/io-module/mtac_eth.c index 09b52ee..6738080 100644 --- a/io-module/mtac_eth.c +++ b/io-module/mtac_eth.c @@ -7,8 +7,9 @@ static char* eth_gpio_pin_name_by_attr_name(const char* name, int port) { // 1 product-id // 1 device-id // 1 hw-version +// 1 mac-addr or eui // NULL -static size_t ap_eth_attrs_size = 5; +static size_t ap_eth_attrs_size = 6; static bool eth_setup(enum ap port) { int i; diff --git a/io-module/mts_capab.c b/io-module/mts_capab.c new file mode 100644 index 0000000..646f707 --- /dev/null +++ b/io-module/mts_capab.c @@ -0,0 +1,63 @@ +/* + * capab.c + * + * Created on: Dec 1, 2016 + * Author: jklug + * + * capabilities from EE-PROM, enumerated in /sys/devices/platform/mts-io/capability + * an associative array, written the hard way in C. + */ + +/* This array is not in any order. */ +struct capab_map_s { + unsigned int bitvalue; + const char *name; +}; + +/* + * Should match mts_eeprom.h capabilities + */ +static struct capab_map_s capabilities_map[] = { + { CAPA_GPS, "gps"}, + { CAPA_DIN, "din"}, + { CAPA_DOUT, "dout"}, + { CAPA_ADC, "adc"}, + { CAPA_BLUETOOTH, "bluetooth"}, + { CAPA_WIFI, "wifi"}, + { CAPA_WIFI_BT, "wifi_bt"}, + { CAPA_GNSS, "gnss"}, + { CAPA_LORA, "lora"}, +}; +static const unsigned capabilities_count = sizeof(capabilities_map)/sizeof(capabilities_map[0]); + +static ssize_t capab_show_value(struct kobject *kobj, struct kobj_attribute *attr, char *buf) { + int i; + const int count = sizeof(capabilities_map)/sizeof(capabilities_map[0]); + + for(i=0;i<count;i++) { + if (! strcmp(capabilities_map[i].name, attr->attr.name)) { + return snprintf(buf, 32, "%u\n", DEVICE_CAPA(id_eeprom.capa, capabilities_map[i].bitvalue) != 0); + } + } + + return (ssize_t)-1; +} + +static bool capab_add_attributes(struct attribute** attrs) { + struct kobj_attribute* kobj_attr; + int i; + int count = capabilities_count; + + // We must keep the number of attributes in sync + BUG_ON(CAPA_COUNT != count); + for(i=0;i<count;i++) { + kobj_attr = create_attribute(capabilities_map[i].name, MTS_ATTR_MODE_RO); + if (! kobj_attr) { + log_error("failed to create attribute [%s]", capabilities_map[i].name); + return false; + } + kobj_attr->show = capab_show_value; + attrs[i] = &kobj_attr->attr; + } + return true; +} diff --git a/io-module/mts_eeprom.h b/io-module/mts_eeprom.h index 89f2439..f616e83 100644 --- a/io-module/mts_eeprom.h +++ b/io-module/mts_eeprom.h @@ -55,6 +55,7 @@ do { \ #define DEVICE_CAPA_VALUE(index, bit) ((((index) & 0x1F) << 3) | ((bit) & 0x07)) +#define CAPA_COUNT 9 // See also attribute_names in capab.c #define CAPA_GPS DEVICE_CAPA_VALUE(0, 7) #define CAPA_DIN DEVICE_CAPA_VALUE(0, 6) #define CAPA_DOUT DEVICE_CAPA_VALUE(0, 5) diff --git a/io-module/mts_io.c b/io-module/mts_io.c index b71eabb..85f9474 100644 --- a/io-module/mts_io.c +++ b/io-module/mts_io.c @@ -47,7 +47,7 @@ #include "mts_io.h" -#define DRIVER_VERSION "v1.5.4" +#define DRIVER_VERSION "v1.5.5" #define DRIVER_AUTHOR "James Maki <jmaki@multitech.com>" #define DRIVER_DESC "MTS-IO Controller" #define DRIVER_NAME "mts-io" @@ -653,6 +653,8 @@ static struct kobject *ap_subdirs[NUM_AP]; static struct attribute_group ap_attr_groups[NUM_AP]; /* info for accessory port (contains function pointers for setup and teardown and and useful info) */ static struct ap_info* port_info[NUM_AP]; +static struct kobject *capab; +static struct attribute_group capab_group; /* accessory card support */ #include "mtac.c" @@ -660,6 +662,7 @@ static struct ap_info* port_info[NUM_AP]; #include "mtac_mfser.c" #include "mtac_eth.c" #include "mtac_lora.c" +#include "mts_capab.c" static bool load_port(int port) { int port_index = port - 1; @@ -934,7 +937,9 @@ static void cleanup(void) kfree(freelater); freelater = NULL; } - log_info("done cleaning up...."); + + if(capab_group.attrs) + kfree((struct kobject *)capab_group.attrs); } static int __init mts_io_init(void) @@ -965,6 +970,23 @@ static int __init mts_io_init(void) init_ports(); + capab = kobject_create_and_add("capability", &mts_io_platform_device->dev.kobj); + if (capab == NULL) { + log_error("kobject_create_and_add for capability directory failed"); + return false; + } + + capab_group.attrs = kzalloc(sizeof(struct attribute*) * (capabilities_count+1), GFP_KERNEL); + if (! capab_add_attributes(capab_group.attrs)) { + return false; + } + + if (sysfs_create_group(capab, &capab_group)) { + cleanup(); + log_error("sysfs_create_group failed to create capability group"); + return false; + } + ret = sysfs_create_group(&mts_io_platform_device->dev.kobj, attr_group); if (ret) { cleanup(); diff --git a/io-module/mts_io.mod.c b/io-module/mts_io.mod.c deleted file mode 100644 index 3a3ab0a..0000000 --- a/io-module/mts_io.mod.c +++ /dev/null @@ -1,23 +0,0 @@ -#include <linux/module.h> -#include <linux/vermagic.h> -#include <linux/compiler.h> - -MODULE_INFO(vermagic, VERMAGIC_STRING); - -struct module __this_module -__attribute__((section(".gnu.linkonce.this_module"))) = { - .name = KBUILD_MODNAME, - .init = init_module, -#ifdef CONFIG_MODULE_UNLOAD - .exit = cleanup_module, -#endif - .arch = MODULE_ARCH_INIT, -}; - -static const char __module_depends[] -__used -__attribute__((section(".modinfo"))) = -"depends="; - - -MODULE_INFO(srcversion, "D7BC1A1F207E0D4DA8EBD43"); |