]> git.karo-electronics.de Git - linux-beck.git/commitdiff
powerpc/vio: Add modalias support
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>
Wed, 7 Apr 2010 04:44:28 +0000 (14:44 +1000)
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>
Wed, 7 Apr 2010 04:44:28 +0000 (14:44 +1000)
BenH: Added to vio_cmo_dev_attrs as well

Provide a modalias entry for VIO devices in sysfs.  I believe
this was another initrd generation bugfix for anaconda.
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
arch/powerpc/kernel/vio.c

index 82237176a2a3db8c2eadc29db867b5ed0415398f..2f57956714bd9c2ee2377ca7e948e0c139e2ef37 100644 (file)
@@ -958,9 +958,12 @@ viodev_cmo_rd_attr(allocated);
 
 static ssize_t name_show(struct device *, struct device_attribute *, char *);
 static ssize_t devspec_show(struct device *, struct device_attribute *, char *);
+static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
+                            char *buf);
 static struct device_attribute vio_cmo_dev_attrs[] = {
        __ATTR_RO(name),
        __ATTR_RO(devspec),
+       __ATTR_RO(modalias),
        __ATTR(cmo_desired,       S_IWUSR|S_IRUSR|S_IWGRP|S_IRGRP|S_IROTH,
               viodev_cmo_desired_show, viodev_cmo_desired_set),
        __ATTR(cmo_entitled,      S_IRUGO, viodev_cmo_entitled_show,      NULL),
@@ -1320,9 +1323,27 @@ static ssize_t devspec_show(struct device *dev,
        return sprintf(buf, "%s\n", of_node ? of_node->full_name : "none");
 }
 
+static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
+                            char *buf)
+{
+       const struct vio_dev *vio_dev = to_vio_dev(dev);
+       struct device_node *dn;
+       const char *cp;
+
+       dn = dev->archdata.of_node;
+       if (!dn)
+               return -ENODEV;
+       cp = of_get_property(dn, "compatible", NULL);
+       if (!cp)
+               return -ENODEV;
+
+       return sprintf(buf, "vio:T%sS%s\n", vio_dev->type, cp);
+}
+
 static struct device_attribute vio_dev_attrs[] = {
        __ATTR_RO(name),
        __ATTR_RO(devspec),
+       __ATTR_RO(modalias),
        __ATTR_NULL
 };