[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1346770881-4723-16-git-send-email-siglesias@igalia.com>
Date: Tue, 4 Sep 2012 17:01:20 +0200
From: Samuel Iglesias Gonsálvez
<siglesias@...lia.com>
To: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc: devel@...verdev.osuosl.org, linux-kernel@...r.kernel.org,
industrypack-devel@...ts.sourceforge.net,
Jens Taprogge <jens.taprogge@...rogge.org>,
Samuel Iglesias Gonsálvez
<siglesias@...lia.com>
Subject: [PATCH 15/16] Staging: ipack: Expose modalias through sysfs.
From: Jens Taprogge <jens.taprogge@...rogge.org>
Also include it in the hotplug event so that udev can
provide the respective driver.
Signed-off-by: Jens Taprogge <jens.taprogge@...rogge.org>
Signed-off-by: Samuel Iglesias Gonsálvez <siglesias@...lia.com>
---
drivers/staging/ipack/ipack.c | 36 ++++++++++++++++++++++++++++++++++++
1 file changed, 36 insertions(+)
diff --git a/drivers/staging/ipack/ipack.c b/drivers/staging/ipack/ipack.c
index a328629..a5ef28f 100644
--- a/drivers/staging/ipack/ipack.c
+++ b/drivers/staging/ipack/ipack.c
@@ -86,6 +86,31 @@ static int ipack_bus_remove(struct device *device)
return 0;
}
+#ifdef CONFIG_HOTPLUG
+
+static int ipack_uevent(struct device *dev, struct kobj_uevent_env *env)
+{
+ struct ipack_device *idev;
+
+ if (!dev)
+ return -ENODEV;
+
+ idev = to_ipack_dev(dev);
+
+ if (add_uevent_var(env,
+ "MODALIAS=ipack:f%02Xv%08Xd%08X", idev->id_format,
+ idev->id_vendor, idev->id_device))
+ return -ENOMEM;
+
+ return 0;
+}
+
+#else /* !CONFIG_HOTPLUG */
+
+#define ipack_uevent NULL
+
+#endif /* !CONFIG_HOTPLUG */
+
#define ipack_device_attr(field, format_string) \
static ssize_t \
field##_show(struct device *dev, struct device_attribute *attr, \
@@ -123,12 +148,22 @@ id_device_show(struct device *dev, struct device_attribute *attr, char *buf)
}
}
+static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
+ char *buf)
+{
+ struct ipack_device *idev = to_ipack_dev(dev);
+
+ return sprintf(buf, "ipac:f%02Xv%08Xd%08X", idev->id_format,
+ idev->id_vendor, idev->id_device);
+}
+
ipack_device_attr(id_format, "0x%hhu\n");
static struct device_attribute ipack_dev_attrs[] = {
__ATTR_RO(id_device),
__ATTR_RO(id_format),
__ATTR_RO(id_vendor),
+ __ATTR_RO(modalias),
};
static struct bus_type ipack_bus_type = {
@@ -137,6 +172,7 @@ static struct bus_type ipack_bus_type = {
.match = ipack_bus_match,
.remove = ipack_bus_remove,
.dev_attrs = ipack_dev_attrs,
+ .uevent = ipack_uevent,
};
struct ipack_bus_device *ipack_bus_register(struct device *parent, int slots,
--
1.7.10.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists