Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Tomas Winkler and committed by
Greg Kroah-Hartman
c93b76b3 41c95b04

+72 -13
+1 -1
Documentation/ABI/testing/sysfs-bus-mei
··· 4 4 Contact: Samuel Ortiz <sameo@linux.intel.com> 5 5 linux-mei@linux.intel.com 6 6 Description: Stores the same MODALIAS value emitted by uevent 7 - Format: mei:<mei device name> 7 + Format: mei:<mei device name>:<device uuid>:
+34 -8
drivers/misc/mei/bus.c
··· 30 30 #define to_mei_cl_driver(d) container_of(d, struct mei_cl_driver, driver) 31 31 #define to_mei_cl_device(d) container_of(d, struct mei_cl_device, dev) 32 32 33 + static inline uuid_le uuid_le_cast(const __u8 uuid[16]) 34 + { 35 + return *(uuid_le *)uuid; 36 + } 37 + 33 38 static int mei_cl_device_match(struct device *dev, struct device_driver *drv) 34 39 { 35 40 struct mei_cl_device *device = to_mei_cl_device(dev); 36 41 struct mei_cl_driver *driver = to_mei_cl_driver(drv); 37 42 const struct mei_cl_device_id *id; 43 + const uuid_le *uuid; 44 + const char *name; 38 45 39 46 if (!device) 40 47 return 0; 48 + 49 + uuid = mei_me_cl_uuid(device->me_cl); 50 + name = device->name; 41 51 42 52 if (!driver || !driver->id_table) 43 53 return 0; 44 54 45 55 id = driver->id_table; 46 56 47 - while (id->name[0]) { 48 - if (!strncmp(dev_name(dev), id->name, sizeof(id->name))) 49 - return 1; 57 + while (uuid_le_cmp(NULL_UUID_LE, uuid_le_cast(id->uuid))) { 58 + 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 68 id++; 52 69 } ··· 86 69 87 70 dev_dbg(dev, "Device probe\n"); 88 71 89 - strlcpy(id.name, dev_name(dev), sizeof(id.name)); 72 + strlcpy(id.name, device->name, sizeof(id.name)); 90 73 91 74 return driver->probe(device, &id); 92 75 } ··· 117 100 static ssize_t modalias_show(struct device *dev, struct device_attribute *a, 118 101 char *buf) 119 102 { 120 - int len; 103 + struct mei_cl_device *device = to_mei_cl_device(dev); 104 + const uuid_le *uuid = mei_me_cl_uuid(device->me_cl); 105 + size_t len; 121 106 122 - len = snprintf(buf, PAGE_SIZE, "mei:%s\n", dev_name(dev)); 107 + len = snprintf(buf, PAGE_SIZE, "mei:%s:" MEI_CL_UUID_FMT ":", 108 + device->name, MEI_CL_UUID_ARGS(uuid->b)); 123 109 124 110 return (len >= PAGE_SIZE) ? (PAGE_SIZE - 1) : len; 125 111 } ··· 136 116 137 117 static int mei_cl_uevent(struct device *dev, struct kobj_uevent_env *env) 138 118 { 139 - if (add_uevent_var(env, "MODALIAS=mei:%s", dev_name(dev))) 119 + struct mei_cl_device *device = to_mei_cl_device(dev); 120 + const uuid_le *uuid = mei_me_cl_uuid(device->me_cl); 121 + 122 + if (add_uevent_var(env, "MODALIAS=mei:%s:" MEI_CL_UUID_FMT ":", 123 + device->name, MEI_CL_UUID_ARGS(uuid->b))) 140 124 return -ENOMEM; 141 125 142 126 return 0; ··· 209 185 device->dev.bus = &mei_cl_bus_type; 210 186 device->dev.type = &mei_cl_device_type; 211 187 212 - dev_set_name(&device->dev, "%s", name); 188 + strlcpy(device->name, name, sizeof(device->name)); 189 + 190 + dev_set_name(&device->dev, "mei:%s:%pUl", name, mei_me_cl_uuid(me_cl)); 213 191 214 192 status = device_register(&device->dev); 215 193 if (status) {
+2
drivers/misc/mei/mei_dev.h
··· 376 376 * @dev: linux driver model device pointer 377 377 * @me_cl: me client 378 378 * @cl: mei client 379 + * @name: device name 379 380 * @ops: ME transport ops 380 381 * @event_work: async work to execute event callback 381 382 * @event_cb: Drivers register this callback to get asynchronous ME ··· 390 389 391 390 struct mei_me_client *me_cl; 392 391 struct mei_cl *cl; 392 + char name[MEI_CL_NAME_SIZE]; 393 393 394 394 const struct mei_cl_ops *ops; 395 395
+3
drivers/nfc/mei_phy.h
··· 3 3 4 4 #include <linux/mei_cl_bus.h> 5 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 10 #define MEI_NFC_HEADER_SIZE 10 8 11 #define MEI_NFC_MAX_HCI_PAYLOAD 300 9 12
+1 -1
drivers/nfc/microread/mei.c
··· 67 67 } 68 68 69 69 static struct mei_cl_device_id microread_mei_tbl[] = { 70 - { MICROREAD_DRIVER_NAME }, 70 + { MICROREAD_DRIVER_NAME, MEI_NFC_UUID}, 71 71 72 72 /* required last entry */ 73 73 { }
+1 -1
drivers/nfc/pn544/mei.c
··· 67 67 } 68 68 69 69 static struct mei_cl_device_id pn544_mei_tbl[] = { 70 - { PN544_DRIVER_NAME }, 70 + { PN544_DRIVER_NAME, MEI_NFC_UUID}, 71 71 72 72 /* required last entry */ 73 73 { }
+13
include/linux/mod_devicetable.h
··· 599 599 600 600 #define MEI_CL_MODULE_PREFIX "mei:" 601 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 + */ 603 615 struct mei_cl_device_id { 604 616 char name[MEI_CL_NAME_SIZE]; 617 + __u8 uuid[16]; 605 618 kernel_ulong_t driver_info; 606 619 }; 607 620
+1
scripts/mod/devicetable-offsets.c
··· 182 182 183 183 DEVID(mei_cl_device_id); 184 184 DEVID_FIELD(mei_cl_device_id, name); 185 + DEVID_FIELD(mei_cl_device_id, uuid); 185 186 186 187 DEVID(rio_device_id); 187 188 DEVID_FIELD(rio_device_id, did);
+16 -2
scripts/mod/file2alias.c
··· 131 131 strcat(str + len, "*"); 132 132 } 133 133 134 + static 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 144 * Check that sizeof(device_id type) are consistent with size of section 136 145 * in .o file. If in-consistent then userspace and kernel does not agree ··· 1169 1160 } 1170 1161 ADD_TO_DEVTABLE("cpu", cpu_feature, do_cpu_entry); 1171 1162 1172 - /* Looks like: mei:S */ 1163 + /* Looks like: mei:S:uuid */ 1173 1164 static int do_mei_entry(const char *filename, void *symval, 1174 1165 char *alias) 1175 1166 { 1176 1167 DEF_FIELD_ADDR(symval, mei_cl_device_id, name); 1168 + DEF_FIELD_ADDR(symval, mei_cl_device_id, uuid); 1177 1169 1178 - sprintf(alias, MEI_CL_MODULE_PREFIX "%s", *name); 1170 + sprintf(alias, MEI_CL_MODULE_PREFIX); 1171 + sprintf(alias + strlen(alias), "%s:", (*name)[0] ? *name : "*"); 1172 + add_uuid(alias, *uuid); 1173 + 1174 + strcat(alias, ":*"); 1179 1175 1180 1176 return 1; 1181 1177 }