aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomas Winkler <tomas.winkler@intel.com>2015-05-07 08:54:02 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2015-05-24 14:15:54 -0400
commitc93b76b34b4d8dbe8e3443eb27e49ac60034342b (patch)
tree018e5514a107c1db6329900afcfcb5905f55b0ac
parent41c95b04385863f694fcf96e08994ebc722b7b9f (diff)
mei: bus: report also uuid in module alias
In order to automate modules matching add device uuid which is reported in client enumeration, keep also the name that is needed in for nfc distinguishing radio vendor Report mei:name:uuid Cc: linux-api@vger.kernel.org Cc: Samuel Ortiz <sameo@linux.intel.com> Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--Documentation/ABI/testing/sysfs-bus-mei2
-rw-r--r--drivers/misc/mei/bus.c42
-rw-r--r--drivers/misc/mei/mei_dev.h2
-rw-r--r--drivers/nfc/mei_phy.h3
-rw-r--r--drivers/nfc/microread/mei.c2
-rw-r--r--drivers/nfc/pn544/mei.c2
-rw-r--r--include/linux/mod_devicetable.h13
-rw-r--r--scripts/mod/devicetable-offsets.c1
-rw-r--r--scripts/mod/file2alias.c18
9 files changed, 72 insertions, 13 deletions
diff --git a/Documentation/ABI/testing/sysfs-bus-mei b/Documentation/ABI/testing/sysfs-bus-mei
index 2066f0bbd453..91967a70313a 100644
--- a/Documentation/ABI/testing/sysfs-bus-mei
+++ b/Documentation/ABI/testing/sysfs-bus-mei
@@ -4,4 +4,4 @@ KernelVersion: 3.10
4Contact: Samuel Ortiz <sameo@linux.intel.com> 4Contact: Samuel Ortiz <sameo@linux.intel.com>
5 linux-mei@linux.intel.com 5 linux-mei@linux.intel.com
6Description: Stores the same MODALIAS value emitted by uevent 6Description: Stores the same MODALIAS value emitted by uevent
7 Format: mei:<mei device name> 7 Format: mei:<mei device name>:<device uuid>:
diff --git a/drivers/misc/mei/bus.c b/drivers/misc/mei/bus.c
index 1101d6efaf27..17b00baa53b1 100644
--- a/drivers/misc/mei/bus.c
+++ b/drivers/misc/mei/bus.c
@@ -30,23 +30,40 @@
30#define to_mei_cl_driver(d) container_of(d, struct mei_cl_driver, driver) 30#define to_mei_cl_driver(d) container_of(d, struct mei_cl_driver, driver)
31#define to_mei_cl_device(d) container_of(d, struct mei_cl_device, dev) 31#define to_mei_cl_device(d) container_of(d, struct mei_cl_device, dev)
32 32
33static inline uuid_le uuid_le_cast(const __u8 uuid[16])
34{
35 return *(uuid_le *)uuid;
36}
37
33static int mei_cl_device_match(struct device *dev, struct device_driver *drv) 38static int mei_cl_device_match(struct device *dev, struct device_driver *drv)
34{ 39{
35 struct mei_cl_device *device = to_mei_cl_device(dev); 40 struct mei_cl_device *device = to_mei_cl_device(dev);
36 struct mei_cl_driver *driver = to_mei_cl_driver(drv); 41 struct mei_cl_driver *driver = to_mei_cl_driver(drv);
37 const struct mei_cl_device_id *id; 42 const struct mei_cl_device_id *id;
43 const uuid_le *uuid;
44 const char *name;
38 45
39 if (!device) 46 if (!device)
40 return 0; 47 return 0;
41 48
49 uuid = mei_me_cl_uuid(device->me_cl);
50 name = device->name;
51
42 if (!driver || !driver->id_table) 52 if (!driver || !driver->id_table)
43 return 0; 53 return 0;
44 54
45 id = driver->id_table; 55 id = driver->id_table;
46 56
47 while (id->name[0]) { 57 while (uuid_le_cmp(NULL_UUID_LE, uuid_le_cast(id->uuid))) {
48 if (!strncmp(dev_name(dev), id->name, sizeof(id->name))) 58
49 return 1; 59 if (!uuid_le_cmp(*uuid, uuid_le_cast(id->uuid))) {
60 if (id->name[0]) {
61 if (!strncmp(name, id->name, sizeof(id->name)))
62 return 1;
63 } else {
64 return 1;
65 }
66 }
50 67
51 id++; 68 id++;
52 } 69 }
@@ -69,7 +86,7 @@ static int mei_cl_device_probe(struct device *dev)
69 86
70 dev_dbg(dev, "Device probe\n"); 87 dev_dbg(dev, "Device probe\n");
71 88
72 strlcpy(id.name, dev_name(dev), sizeof(id.name)); 89 strlcpy(id.name, device->name, sizeof(id.name));
73 90
74 return driver->probe(device, &id); 91 return driver->probe(device, &id);
75} 92}
@@ -100,9 +117,12 @@ static int mei_cl_device_remove(struct device *dev)
100static ssize_t modalias_show(struct device *dev, struct device_attribute *a, 117static ssize_t modalias_show(struct device *dev, struct device_attribute *a,
101 char *buf) 118 char *buf)
102{ 119{
103 int len; 120 struct mei_cl_device *device = to_mei_cl_device(dev);
121 const uuid_le *uuid = mei_me_cl_uuid(device->me_cl);
122 size_t len;
104 123
105 len = snprintf(buf, PAGE_SIZE, "mei:%s\n", dev_name(dev)); 124 len = snprintf(buf, PAGE_SIZE, "mei:%s:" MEI_CL_UUID_FMT ":",
125 device->name, MEI_CL_UUID_ARGS(uuid->b));
106 126
107 return (len >= PAGE_SIZE) ? (PAGE_SIZE - 1) : len; 127 return (len >= PAGE_SIZE) ? (PAGE_SIZE - 1) : len;
108} 128}
@@ -116,7 +136,11 @@ ATTRIBUTE_GROUPS(mei_cl_dev);
116 136
117static int mei_cl_uevent(struct device *dev, struct kobj_uevent_env *env) 137static int mei_cl_uevent(struct device *dev, struct kobj_uevent_env *env)
118{ 138{
119 if (add_uevent_var(env, "MODALIAS=mei:%s", dev_name(dev))) 139 struct mei_cl_device *device = to_mei_cl_device(dev);
140 const uuid_le *uuid = mei_me_cl_uuid(device->me_cl);
141
142 if (add_uevent_var(env, "MODALIAS=mei:%s:" MEI_CL_UUID_FMT ":",
143 device->name, MEI_CL_UUID_ARGS(uuid->b)))
120 return -ENOMEM; 144 return -ENOMEM;
121 145
122 return 0; 146 return 0;
@@ -185,7 +209,9 @@ struct mei_cl_device *mei_cl_add_device(struct mei_device *dev,
185 device->dev.bus = &mei_cl_bus_type; 209 device->dev.bus = &mei_cl_bus_type;
186 device->dev.type = &mei_cl_device_type; 210 device->dev.type = &mei_cl_device_type;
187 211
188 dev_set_name(&device->dev, "%s", name); 212 strlcpy(device->name, name, sizeof(device->name));
213
214 dev_set_name(&device->dev, "mei:%s:%pUl", name, mei_me_cl_uuid(me_cl));
189 215
190 status = device_register(&device->dev); 216 status = device_register(&device->dev);
191 if (status) { 217 if (status) {
diff --git a/drivers/misc/mei/mei_dev.h b/drivers/misc/mei/mei_dev.h
index 79ab78184523..ab719e674edf 100644
--- a/drivers/misc/mei/mei_dev.h
+++ b/drivers/misc/mei/mei_dev.h
@@ -376,6 +376,7 @@ struct mei_cl *mei_cl_bus_find_cl_by_uuid(struct mei_device *dev, uuid_le uuid);
376 * @dev: linux driver model device pointer 376 * @dev: linux driver model device pointer
377 * @me_cl: me client 377 * @me_cl: me client
378 * @cl: mei client 378 * @cl: mei client
379 * @name: device name
379 * @ops: ME transport ops 380 * @ops: ME transport ops
380 * @event_work: async work to execute event callback 381 * @event_work: async work to execute event callback
381 * @event_cb: Drivers register this callback to get asynchronous ME 382 * @event_cb: Drivers register this callback to get asynchronous ME
@@ -389,6 +390,7 @@ struct mei_cl_device {
389 390
390 struct mei_me_client *me_cl; 391 struct mei_me_client *me_cl;
391 struct mei_cl *cl; 392 struct mei_cl *cl;
393 char name[MEI_CL_NAME_SIZE];
392 394
393 const struct mei_cl_ops *ops; 395 const struct mei_cl_ops *ops;
394 396
diff --git a/drivers/nfc/mei_phy.h b/drivers/nfc/mei_phy.h
index d669900f8278..06608c28ff14 100644
--- a/drivers/nfc/mei_phy.h
+++ b/drivers/nfc/mei_phy.h
@@ -3,7 +3,10 @@
3 3
4#include <linux/mei_cl_bus.h> 4#include <linux/mei_cl_bus.h>
5#include <net/nfc/hci.h> 5#include <net/nfc/hci.h>
6#include <linux/uuid.h>
6 7
8#define MEI_NFC_UUID __UUID_LE(0x0bb17a78, 0x2a8e, 0x4c50, \
9 0x94, 0xd4, 0x50, 0x26, 0x67, 0x23, 0x77, 0x5c)
7#define MEI_NFC_HEADER_SIZE 10 10#define MEI_NFC_HEADER_SIZE 10
8#define MEI_NFC_MAX_HCI_PAYLOAD 300 11#define MEI_NFC_MAX_HCI_PAYLOAD 300
9 12
diff --git a/drivers/nfc/microread/mei.c b/drivers/nfc/microread/mei.c
index 2d1395be64ae..f9f5fc97cdd7 100644
--- a/drivers/nfc/microread/mei.c
+++ b/drivers/nfc/microread/mei.c
@@ -67,7 +67,7 @@ static int microread_mei_remove(struct mei_cl_device *device)
67} 67}
68 68
69static struct mei_cl_device_id microread_mei_tbl[] = { 69static struct mei_cl_device_id microread_mei_tbl[] = {
70 { MICROREAD_DRIVER_NAME }, 70 { MICROREAD_DRIVER_NAME, MEI_NFC_UUID},
71 71
72 /* required last entry */ 72 /* required last entry */
73 { } 73 { }
diff --git a/drivers/nfc/pn544/mei.c b/drivers/nfc/pn544/mei.c
index 330cd4031009..101a37e12efa 100644
--- a/drivers/nfc/pn544/mei.c
+++ b/drivers/nfc/pn544/mei.c
@@ -67,7 +67,7 @@ static int pn544_mei_remove(struct mei_cl_device *device)
67} 67}
68 68
69static struct mei_cl_device_id pn544_mei_tbl[] = { 69static struct mei_cl_device_id pn544_mei_tbl[] = {
70 { PN544_DRIVER_NAME }, 70 { PN544_DRIVER_NAME, MEI_NFC_UUID},
71 71
72 /* required last entry */ 72 /* required last entry */
73 { } 73 { }
diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
index 3bfd56778c29..2d2b2b571d61 100644
--- a/include/linux/mod_devicetable.h
+++ b/include/linux/mod_devicetable.h
@@ -599,9 +599,22 @@ struct ipack_device_id {
599 599
600#define MEI_CL_MODULE_PREFIX "mei:" 600#define MEI_CL_MODULE_PREFIX "mei:"
601#define MEI_CL_NAME_SIZE 32 601#define MEI_CL_NAME_SIZE 32
602#define MEI_CL_UUID_FMT "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x"
603#define MEI_CL_UUID_ARGS(_u) \
604 _u[0], _u[1], _u[2], _u[3], _u[4], _u[5], _u[6], _u[7], \
605 _u[8], _u[9], _u[10], _u[11], _u[12], _u[13], _u[14], _u[15]
602 606
607/**
608 * struct mei_cl_device_id - MEI client device identifier
609 * @name: helper name
610 * @uuid: client uuid
611 * @driver_info: information used by the driver.
612 *
613 * identifies mei client device by uuid and name
614 */
603struct mei_cl_device_id { 615struct mei_cl_device_id {
604 char name[MEI_CL_NAME_SIZE]; 616 char name[MEI_CL_NAME_SIZE];
617 __u8 uuid[16];
605 kernel_ulong_t driver_info; 618 kernel_ulong_t driver_info;
606}; 619};
607 620
diff --git a/scripts/mod/devicetable-offsets.c b/scripts/mod/devicetable-offsets.c
index fce36d0f6898..091f6290a651 100644
--- a/scripts/mod/devicetable-offsets.c
+++ b/scripts/mod/devicetable-offsets.c
@@ -182,6 +182,7 @@ int main(void)
182 182
183 DEVID(mei_cl_device_id); 183 DEVID(mei_cl_device_id);
184 DEVID_FIELD(mei_cl_device_id, name); 184 DEVID_FIELD(mei_cl_device_id, name);
185 DEVID_FIELD(mei_cl_device_id, uuid);
185 186
186 DEVID(rio_device_id); 187 DEVID(rio_device_id);
187 DEVID_FIELD(rio_device_id, did); 188 DEVID_FIELD(rio_device_id, did);
diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
index 78691d51a479..62c517f4b592 100644
--- a/scripts/mod/file2alias.c
+++ b/scripts/mod/file2alias.c
@@ -131,6 +131,15 @@ static inline void add_wildcard(char *str)
131 strcat(str + len, "*"); 131 strcat(str + len, "*");
132} 132}
133 133
134static inline void add_uuid(char *str, __u8 uuid[16])
135{
136 int len = strlen(str);
137 int i;
138
139 for (i = 0; i < 16; i++)
140 sprintf(str + len + (i << 1), "%02x", uuid[i]);
141}
142
134/** 143/**
135 * Check that sizeof(device_id type) are consistent with size of section 144 * Check that sizeof(device_id type) are consistent with size of section
136 * in .o file. If in-consistent then userspace and kernel does not agree 145 * in .o file. If in-consistent then userspace and kernel does not agree
@@ -1160,13 +1169,18 @@ static int do_cpu_entry(const char *filename, void *symval, char *alias)
1160} 1169}
1161ADD_TO_DEVTABLE("cpu", cpu_feature, do_cpu_entry); 1170ADD_TO_DEVTABLE("cpu", cpu_feature, do_cpu_entry);
1162 1171
1163/* Looks like: mei:S */ 1172/* Looks like: mei:S:uuid */
1164static int do_mei_entry(const char *filename, void *symval, 1173static int do_mei_entry(const char *filename, void *symval,
1165 char *alias) 1174 char *alias)
1166{ 1175{
1167 DEF_FIELD_ADDR(symval, mei_cl_device_id, name); 1176 DEF_FIELD_ADDR(symval, mei_cl_device_id, name);
1177 DEF_FIELD_ADDR(symval, mei_cl_device_id, uuid);
1178
1179 sprintf(alias, MEI_CL_MODULE_PREFIX);
1180 sprintf(alias + strlen(alias), "%s:", (*name)[0] ? *name : "*");
1181 add_uuid(alias, *uuid);
1168 1182
1169 sprintf(alias, MEI_CL_MODULE_PREFIX "%s", *name); 1183 strcat(alias, ":*");
1170 1184
1171 return 1; 1185 return 1;
1172} 1186}