rapidio: add udev notification
authorAlexandre Bounine <alexandre.bounine@idt.com>
Wed, 3 Jul 2013 22:08:58 +0000 (15:08 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 3 Jul 2013 23:08:05 +0000 (16:08 -0700)
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>
drivers/rapidio/rio-driver.c
drivers/rapidio/rio-sysfs.c
include/linux/mod_devicetable.h
include/linux/rio.h
include/linux/rio_ids.h
scripts/mod/devicetable-offsets.c
scripts/mod/file2alias.c

index a0c875563d7669fbf69916c95bd0b0219417d985..3e9b6a78ad18a4dcff861886d0828b5622aad267 100644 (file)
@@ -199,6 +199,23 @@ static int rio_match_bus(struct device *dev, struct device_driver *drv)
       out:return 0;
 }
 
+static int rio_uevent(struct device *dev, struct kobj_uevent_env *env)
+{
+       struct rio_dev *rdev;
+
+       if (!dev)
+               return -ENODEV;
+
+       rdev = to_rio_dev(dev);
+       if (!rdev)
+               return -ENODEV;
+
+       if (add_uevent_var(env, "MODALIAS=rapidio:v%04Xd%04Xav%04Xad%04X",
+                          rdev->vid, rdev->did, rdev->asm_vid, rdev->asm_did))
+               return -ENOMEM;
+       return 0;
+}
+
 struct device rio_bus = {
        .init_name = "rapidio",
 };
@@ -210,6 +227,7 @@ struct bus_type rio_bus_type = {
        .bus_attrs = rio_bus_attrs,
        .probe = rio_device_probe,
        .remove = rio_device_remove,
+       .uevent = rio_uevent,
 };
 
 /**
index 0c4473e54f8616e5fd3a018429fb7fb0a2d83cf8..9331be646dc34d4075df3b6512975efe3eec8c1a 100644 (file)
@@ -84,6 +84,15 @@ static ssize_t lnext_show(struct device *dev,
        return str - buf;
 }
 
+static ssize_t modalias_show(struct device *dev,
+                            struct device_attribute *attr, char *buf)
+{
+       struct rio_dev *rdev = to_rio_dev(dev);
+
+       return sprintf(buf, "rapidio:v%04Xd%04Xav%04Xad%04X\n",
+                      rdev->vid, rdev->did, rdev->asm_vid, rdev->asm_did);
+}
+
 struct device_attribute rio_dev_attrs[] = {
        __ATTR_RO(did),
        __ATTR_RO(vid),
@@ -93,6 +102,7 @@ struct device_attribute rio_dev_attrs[] = {
        __ATTR_RO(asm_rev),
        __ATTR_RO(lprev),
        __ATTR_RO(destid),
+       __ATTR_RO(modalias),
        __ATTR_NULL,
 };
 
index b3bd7e737e8b847ebb356d1674047f3de33f3602..b62d4af6c667c27bbbd3620fde9813c9d6b529b8 100644 (file)
@@ -579,4 +579,23 @@ struct mei_cl_device_id {
        kernel_ulong_t driver_info;
 };
 
+/* RapidIO */
+
+#define RIO_ANY_ID     0xffff
+
+/**
+ * struct rio_device_id - RIO device identifier
+ * @did: RapidIO device ID
+ * @vid: RapidIO vendor ID
+ * @asm_did: RapidIO assembly device ID
+ * @asm_vid: RapidIO assembly vendor ID
+ *
+ * Identifies a RapidIO device based on both the device/vendor IDs and
+ * the assembly device/vendor IDs.
+ */
+struct rio_device_id {
+       __u16 did, vid;
+       __u16 asm_did, asm_vid;
+};
+
 #endif /* LINUX_MOD_DEVICETABLE_H */
index 8d3db1b7b998d2b9b5eaa1295b4f5ccf9d078eb4..e2faf7b8fe80dfefab31b93b70ba8c666ac55090 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/errno.h>
 #include <linux/device.h>
 #include <linux/rio_regs.h>
+#include <linux/mod_devicetable.h>
 #ifdef CONFIG_RAPIDIO_DMA_ENGINE
 #include <linux/dmaengine.h>
 #endif
@@ -396,21 +397,6 @@ struct rio_driver {
 
 #define        to_rio_driver(drv) container_of(drv,struct rio_driver, driver)
 
-/**
- * struct rio_device_id - RIO device identifier
- * @did: RIO device ID
- * @vid: RIO vendor ID
- * @asm_did: RIO assembly device ID
- * @asm_vid: RIO assembly vendor ID
- *
- * Identifies a RIO device based on both the device/vendor IDs and
- * the assembly device/vendor IDs.
- */
-struct rio_device_id {
-       u16 did, vid;
-       u16 asm_did, asm_vid;
-};
-
 union rio_pw_msg {
        struct {
                u32 comptag;    /* Component Tag CSR */
index b66d13d1bdc04199a78665022f676e238960fa74..2543bc163d5434e0f6c42689456e747055da35d7 100644 (file)
@@ -13,8 +13,6 @@
 #ifndef LINUX_RIO_IDS_H
 #define LINUX_RIO_IDS_H
 
-#define RIO_ANY_ID                     0xffff
-
 #define RIO_VID_FREESCALE              0x0002
 #define RIO_DID_MPC8560                        0x0003
 
index e66d4d258e1a5eec2a8584e3403c9727cb1580eb..bb5d115ca671c5b19073526fa815baa5f728fb2c 100644 (file)
@@ -177,5 +177,11 @@ int main(void)
        DEVID(mei_cl_device_id);
        DEVID_FIELD(mei_cl_device_id, name);
 
+       DEVID(rio_device_id);
+       DEVID_FIELD(rio_device_id, did);
+       DEVID_FIELD(rio_device_id, vid);
+       DEVID_FIELD(rio_device_id, asm_did);
+       DEVID_FIELD(rio_device_id, asm_vid);
+
        return 0;
 }
index 45f9a3377dcd8d60f1df08542ca804537e443225..d9e67b719f08e013d4d8da8aaf579332e19f9c23 100644 (file)
@@ -1145,6 +1145,26 @@ static int do_mei_entry(const char *filename, void *symval,
 }
 ADD_TO_DEVTABLE("mei", mei_cl_device_id, do_mei_entry);
 
+/* Looks like: rapidio:vNdNavNadN */
+static int do_rio_entry(const char *filename,
+                       void *symval, char *alias)
+{
+       DEF_FIELD(symval, rio_device_id, did);
+       DEF_FIELD(symval, rio_device_id, vid);
+       DEF_FIELD(symval, rio_device_id, asm_did);
+       DEF_FIELD(symval, rio_device_id, asm_vid);
+
+       strcpy(alias, "rapidio:");
+       ADD(alias, "v", vid != RIO_ANY_ID, vid);
+       ADD(alias, "d", did != RIO_ANY_ID, did);
+       ADD(alias, "av", asm_vid != RIO_ANY_ID, asm_vid);
+       ADD(alias, "ad", asm_did != RIO_ANY_ID, asm_did);
+
+       add_wildcard(alias);
+       return 1;
+}
+ADD_TO_DEVTABLE("rapidio", rio_device_id, do_rio_entry);
+
 /* Does namelen bytes of name exactly match the symbol? */
 static bool sym_is(const char *name, unsigned namelen, const char *symbol)
 {
This page took 0.03101 seconds and 5 git commands to generate.