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

rapidio: add udev notification

Add RapidIO-specific modalias generation to enable udev notifications
about RapidIO-specific events.

The RapidIO modalias string format is shown below:

"rapidio:vNNNNdNNNNavNNNNadNNNN"

Where:
v - Device Vendor ID (16 bit),
d - Device ID (16 bit),
av - Assembly Vendor ID (16 bit),
ad - Assembly ID (16 bit),

as they are reported in corresponding Capability Registers (CARs)
of each RapidIO device.

Signed-off-by: Alexandre Bounine <alexandre.bounine@idt.com>
Cc: Matt Porter <mporter@kernel.crashing.org>
Cc: Li Yang <leoli@freescale.com>
Cc: Kumar Gala <galak@kernel.crashing.org>
Cc: Andre van Herk <andre.van.herk@Prodrive.nl>
Cc: Micha Nelissen <micha.nelissen@Prodrive.nl>
Cc: Stef van Os <stef.van.os@Prodrive.nl>
Cc: Jean Delvare <jdelvare@suse.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Alexandre Bounine and committed by
Linus Torvalds
3bdbb62f fdf90abc

+74 -17
+18
drivers/rapidio/rio-driver.c
··· 199 199 out:return 0; 200 200 } 201 201 202 + static int rio_uevent(struct device *dev, struct kobj_uevent_env *env) 203 + { 204 + struct rio_dev *rdev; 205 + 206 + if (!dev) 207 + return -ENODEV; 208 + 209 + rdev = to_rio_dev(dev); 210 + if (!rdev) 211 + return -ENODEV; 212 + 213 + if (add_uevent_var(env, "MODALIAS=rapidio:v%04Xd%04Xav%04Xad%04X", 214 + rdev->vid, rdev->did, rdev->asm_vid, rdev->asm_did)) 215 + return -ENOMEM; 216 + return 0; 217 + } 218 + 202 219 struct device rio_bus = { 203 220 .init_name = "rapidio", 204 221 }; ··· 227 210 .bus_attrs = rio_bus_attrs, 228 211 .probe = rio_device_probe, 229 212 .remove = rio_device_remove, 213 + .uevent = rio_uevent, 230 214 }; 231 215 232 216 /**
+10
drivers/rapidio/rio-sysfs.c
··· 84 84 return str - buf; 85 85 } 86 86 87 + static ssize_t modalias_show(struct device *dev, 88 + struct device_attribute *attr, char *buf) 89 + { 90 + struct rio_dev *rdev = to_rio_dev(dev); 91 + 92 + return sprintf(buf, "rapidio:v%04Xd%04Xav%04Xad%04X\n", 93 + rdev->vid, rdev->did, rdev->asm_vid, rdev->asm_did); 94 + } 95 + 87 96 struct device_attribute rio_dev_attrs[] = { 88 97 __ATTR_RO(did), 89 98 __ATTR_RO(vid), ··· 102 93 __ATTR_RO(asm_rev), 103 94 __ATTR_RO(lprev), 104 95 __ATTR_RO(destid), 96 + __ATTR_RO(modalias), 105 97 __ATTR_NULL, 106 98 }; 107 99
+19
include/linux/mod_devicetable.h
··· 579 579 kernel_ulong_t driver_info; 580 580 }; 581 581 582 + /* RapidIO */ 583 + 584 + #define RIO_ANY_ID 0xffff 585 + 586 + /** 587 + * struct rio_device_id - RIO device identifier 588 + * @did: RapidIO device ID 589 + * @vid: RapidIO vendor ID 590 + * @asm_did: RapidIO assembly device ID 591 + * @asm_vid: RapidIO assembly vendor ID 592 + * 593 + * Identifies a RapidIO device based on both the device/vendor IDs and 594 + * the assembly device/vendor IDs. 595 + */ 596 + struct rio_device_id { 597 + __u16 did, vid; 598 + __u16 asm_did, asm_vid; 599 + }; 600 + 582 601 #endif /* LINUX_MOD_DEVICETABLE_H */
+1 -15
include/linux/rio.h
··· 20 20 #include <linux/errno.h> 21 21 #include <linux/device.h> 22 22 #include <linux/rio_regs.h> 23 + #include <linux/mod_devicetable.h> 23 24 #ifdef CONFIG_RAPIDIO_DMA_ENGINE 24 25 #include <linux/dmaengine.h> 25 26 #endif ··· 396 395 }; 397 396 398 397 #define to_rio_driver(drv) container_of(drv,struct rio_driver, driver) 399 - 400 - /** 401 - * struct rio_device_id - RIO device identifier 402 - * @did: RIO device ID 403 - * @vid: RIO vendor ID 404 - * @asm_did: RIO assembly device ID 405 - * @asm_vid: RIO assembly vendor ID 406 - * 407 - * Identifies a RIO device based on both the device/vendor IDs and 408 - * the assembly device/vendor IDs. 409 - */ 410 - struct rio_device_id { 411 - u16 did, vid; 412 - u16 asm_did, asm_vid; 413 - }; 414 398 415 399 union rio_pw_msg { 416 400 struct {
-2
include/linux/rio_ids.h
··· 13 13 #ifndef LINUX_RIO_IDS_H 14 14 #define LINUX_RIO_IDS_H 15 15 16 - #define RIO_ANY_ID 0xffff 17 - 18 16 #define RIO_VID_FREESCALE 0x0002 19 17 #define RIO_DID_MPC8560 0x0003 20 18
+6
scripts/mod/devicetable-offsets.c
··· 177 177 DEVID(mei_cl_device_id); 178 178 DEVID_FIELD(mei_cl_device_id, name); 179 179 180 + DEVID(rio_device_id); 181 + DEVID_FIELD(rio_device_id, did); 182 + DEVID_FIELD(rio_device_id, vid); 183 + DEVID_FIELD(rio_device_id, asm_did); 184 + DEVID_FIELD(rio_device_id, asm_vid); 185 + 180 186 return 0; 181 187 }
+20
scripts/mod/file2alias.c
··· 1145 1145 } 1146 1146 ADD_TO_DEVTABLE("mei", mei_cl_device_id, do_mei_entry); 1147 1147 1148 + /* Looks like: rapidio:vNdNavNadN */ 1149 + static int do_rio_entry(const char *filename, 1150 + void *symval, char *alias) 1151 + { 1152 + DEF_FIELD(symval, rio_device_id, did); 1153 + DEF_FIELD(symval, rio_device_id, vid); 1154 + DEF_FIELD(symval, rio_device_id, asm_did); 1155 + DEF_FIELD(symval, rio_device_id, asm_vid); 1156 + 1157 + strcpy(alias, "rapidio:"); 1158 + ADD(alias, "v", vid != RIO_ANY_ID, vid); 1159 + ADD(alias, "d", did != RIO_ANY_ID, did); 1160 + ADD(alias, "av", asm_vid != RIO_ANY_ID, asm_vid); 1161 + ADD(alias, "ad", asm_did != RIO_ANY_ID, asm_did); 1162 + 1163 + add_wildcard(alias); 1164 + return 1; 1165 + } 1166 + ADD_TO_DEVTABLE("rapidio", rio_device_id, do_rio_entry); 1167 + 1148 1168 /* Does namelen bytes of name exactly match the symbol? */ 1149 1169 static bool sym_is(const char *name, unsigned namelen, const char *symbol) 1150 1170 {