Jesse Keating 3494df0
From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Jesse Keating 3494df0
Date: Wed, 7 Apr 2010 04:44:28 +0000 (+1000)
Jesse Keating 3494df0
Subject: powerpc/vio: Add modalias support
Jesse Keating 3494df0
X-Git-Tag: v2.6.35-rc1~450^2~88
Jesse Keating 3494df0
X-Git-Url: http://git.kernel.org/?p=linux%2Fkernel%2Fgit%2Ftorvalds%2Flinux-2.6.git;a=commitdiff_plain;h=578b7cd1518f8d1b17a7fb1671d3d756c9cb49f1
Jesse Keating 3494df0
Jesse Keating 3494df0
powerpc/vio: Add modalias support
Jesse Keating 3494df0
Jesse Keating 3494df0
BenH: Added to vio_cmo_dev_attrs as well
Jesse Keating 3494df0
Jesse Keating 3494df0
Provide a modalias entry for VIO devices in sysfs.  I believe
Jesse Keating 3494df0
this was another initrd generation bugfix for anaconda.
Jesse Keating 3494df0
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Jesse Keating 3494df0
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Jesse Keating 3494df0
---
Jesse Keating 3494df0
Jesse Keating 3494df0
diff --git a/arch/powerpc/kernel/vio.c b/arch/powerpc/kernel/vio.c
Jesse Keating 3494df0
index 8223717..2f57956 100644
Jesse Keating 3494df0
--- a/arch/powerpc/kernel/vio.c
Jesse Keating 3494df0
+++ b/arch/powerpc/kernel/vio.c
Jesse Keating 3494df0
@@ -958,9 +958,12 @@ viodev_cmo_rd_attr(allocated);
Jesse Keating 3494df0
 
Jesse Keating 3494df0
 static ssize_t name_show(struct device *, struct device_attribute *, char *);
Jesse Keating 3494df0
 static ssize_t devspec_show(struct device *, struct device_attribute *, char *);
Jesse Keating 3494df0
+static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
Jesse Keating 3494df0
+			     char *buf);
Jesse Keating 3494df0
 static struct device_attribute vio_cmo_dev_attrs[] = {
Jesse Keating 3494df0
 	__ATTR_RO(name),
Jesse Keating 3494df0
 	__ATTR_RO(devspec),
Jesse Keating 3494df0
+	__ATTR_RO(modalias),
Jesse Keating 3494df0
 	__ATTR(cmo_desired,       S_IWUSR|S_IRUSR|S_IWGRP|S_IRGRP|S_IROTH,
Jesse Keating 3494df0
 	       viodev_cmo_desired_show, viodev_cmo_desired_set),
Jesse Keating 3494df0
 	__ATTR(cmo_entitled,      S_IRUGO, viodev_cmo_entitled_show,      NULL),
Jesse Keating 3494df0
@@ -1320,9 +1323,27 @@ static ssize_t devspec_show(struct device *dev,
Jesse Keating 3494df0
 	return sprintf(buf, "%s\n", of_node ? of_node->full_name : "none");
Jesse Keating 3494df0
 }
Jesse Keating 3494df0
 
Jesse Keating 3494df0
+static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
Jesse Keating 3494df0
+			     char *buf)
Jesse Keating 3494df0
+{
Jesse Keating 3494df0
+	const struct vio_dev *vio_dev = to_vio_dev(dev);
Jesse Keating 3494df0
+	struct device_node *dn;
Jesse Keating 3494df0
+	const char *cp;
Jesse Keating 3494df0
+
Jesse Keating 3494df0
+	dn = dev->archdata.of_node;
Jesse Keating 3494df0
+	if (!dn)
Jesse Keating 3494df0
+		return -ENODEV;
Jesse Keating 3494df0
+	cp = of_get_property(dn, "compatible", NULL);
Jesse Keating 3494df0
+	if (!cp)
Jesse Keating 3494df0
+		return -ENODEV;
Jesse Keating 3494df0
+
Jesse Keating 3494df0
+	return sprintf(buf, "vio:T%sS%s\n", vio_dev->type, cp);
Jesse Keating 3494df0
+}
Jesse Keating 3494df0
+
Jesse Keating 3494df0
 static struct device_attribute vio_dev_attrs[] = {
Jesse Keating 3494df0
 	__ATTR_RO(name),
Jesse Keating 3494df0
 	__ATTR_RO(devspec),
Jesse Keating 3494df0
+	__ATTR_RO(modalias),
Jesse Keating 3494df0
 	__ATTR_NULL
Jesse Keating 3494df0
 };
Jesse Keating 3494df0