From a21c24fa2486e4d4a3b25d0dcbf873ae62fdbcec Mon Sep 17 00:00:00 2001 From: Mike Fiore Date: Tue, 23 Sep 2014 10:35:11 -0500 Subject: mts-io: clean up accessory card support use custom kernel config option MTS_NUM_ACCESSORY_PORTS to find out how many slots exist (mostly) dynamically handle any number of accessory cards streamline code to make it easier to add accessory cards in the future --- io-module/mtac.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 io-module/mtac.c (limited to 'io-module/mtac.c') diff --git a/io-module/mtac.c b/io-module/mtac.c new file mode 100644 index 0000000..b9a2520 --- /dev/null +++ b/io-module/mtac.c @@ -0,0 +1,22 @@ +static struct kobj_attribute* create_attribute(const char* _name, umode_t _mode) { + char* attr_name; + struct kobj_attribute* _attr; + + _attr = kzalloc(sizeof(struct kobj_attribute), GFP_KERNEL); + if (! _attr) { + log_error("kzalloc of attribute %s failed", _name); + return NULL; + } + + sysfs_attr_init(_attr); + attr_name = kstrdup(_name, GFP_KERNEL); + if (! attr_name) { + log_error("GFP_KERNEL dup failed for attribute [%s]", _name); + return NULL; + } + + _attr->attr.name = attr_name; + _attr->attr.mode = _mode; + + return _attr; +} -- cgit v1.2.3