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

mei: bus: add name and uuid into device attributes

Export name and uuid via sysfs and uevent

Cc: linux-api@vger.kernel.org
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
007d64eb c93b76b3

+47
+14
Documentation/ABI/testing/sysfs-bus-mei
··· 5 5 linux-mei@linux.intel.com 6 6 Description: Stores the same MODALIAS value emitted by uevent 7 7 Format: mei:<mei device name>:<device uuid>: 8 + 9 + What: /sys/bus/mei/devices/.../name 10 + Date: May 2015 11 + KernelVersion: 4.2 12 + Contact: Tomas Winkler <tomas.winkler@intel.com> 13 + Description: Stores mei client device name 14 + Format: string 15 + 16 + What: /sys/bus/mei/devices/.../uuid 17 + Date: May 2015 18 + KernelVersion: 4.2 19 + Contact: Tomas Winkler <tomas.winkler@intel.com> 20 + Description: Stores mei client device uuid 21 + Format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
+33
drivers/misc/mei/bus.c
··· 114 114 return driver->remove(device); 115 115 } 116 116 117 + static ssize_t name_show(struct device *dev, struct device_attribute *a, 118 + char *buf) 119 + { 120 + struct mei_cl_device *device = to_mei_cl_device(dev); 121 + size_t len; 122 + 123 + len = snprintf(buf, PAGE_SIZE, "%s", device->name); 124 + 125 + return (len >= PAGE_SIZE) ? (PAGE_SIZE - 1) : len; 126 + } 127 + static DEVICE_ATTR_RO(name); 128 + 129 + static ssize_t uuid_show(struct device *dev, struct device_attribute *a, 130 + char *buf) 131 + { 132 + struct mei_cl_device *device = to_mei_cl_device(dev); 133 + const uuid_le *uuid = mei_me_cl_uuid(device->me_cl); 134 + size_t len; 135 + 136 + len = snprintf(buf, PAGE_SIZE, "%pUl", uuid); 137 + 138 + return (len >= PAGE_SIZE) ? (PAGE_SIZE - 1) : len; 139 + } 140 + static DEVICE_ATTR_RO(uuid); 141 + 117 142 static ssize_t modalias_show(struct device *dev, struct device_attribute *a, 118 143 char *buf) 119 144 { ··· 154 129 static DEVICE_ATTR_RO(modalias); 155 130 156 131 static struct attribute *mei_cl_dev_attrs[] = { 132 + &dev_attr_name.attr, 133 + &dev_attr_uuid.attr, 157 134 &dev_attr_modalias.attr, 158 135 NULL, 159 136 }; ··· 165 138 { 166 139 struct mei_cl_device *device = to_mei_cl_device(dev); 167 140 const uuid_le *uuid = mei_me_cl_uuid(device->me_cl); 141 + 142 + if (add_uevent_var(env, "MEI_CL_UUID=%pUl", uuid)) 143 + return -ENOMEM; 144 + 145 + if (add_uevent_var(env, "MEI_CL_NAME=%s", device->name)) 146 + return -ENOMEM; 168 147 169 148 if (add_uevent_var(env, "MODALIAS=mei:%s:" MEI_CL_UUID_FMT ":", 170 149 device->name, MEI_CL_UUID_ARGS(uuid->b)))