* [PATCH] create modalias file in sysfs for bus of_platform
@ 2008-01-22 14:21 Olaf Hering
2008-01-22 14:40 ` [PATCH v2] " Olaf Hering
0 siblings, 1 reply; 14+ messages in thread
From: Olaf Hering @ 2008-01-22 14:21 UTC (permalink / raw)
To: linuxppc-dev
Create /sys/bus/of_platform/devices/*/modalias file to allow autoloading
of modules. modalias files are already present for many other bus types.
Signed-off-by: Olaf Hering <olaf@aepfle.de>
---
drivers/of/device.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
--- a/drivers/of/device.c
+++ b/drivers/of/device.c
@@ -86,7 +86,19 @@ static ssize_t dev_show_devspec(struct d
return sprintf(buf, "%s", ofdev->node->full_name);
}
+static ssize_t dev_show_modalias(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct of_device *ofdev = to_of_device(dev);
+ ssize_t len = 0;
+
+ if (ofdev)
+ len = of_device_get_modalias(ofdev, buf, PAGE_SIZE);
+ return len;
+}
+
static DEVICE_ATTR(devspec, S_IRUGO, dev_show_devspec, NULL);
+static DEVICE_ATTR(modalias, S_IRUGO, dev_show_modalias, NULL);
/**
* of_release_dev - free an of device structure when all users of it are finished.
@@ -116,6 +128,11 @@ int of_device_register(struct of_device
return rc;
rc = device_create_file(&ofdev->dev, &dev_attr_devspec);
+ if (rc) {
+ device_unregister(&ofdev->dev);
+ return rc;
+ }
+ rc = device_create_file(&ofdev->dev, &dev_attr_modalias);
if (rc)
device_unregister(&ofdev->dev);
@@ -126,6 +143,7 @@ EXPORT_SYMBOL(of_device_register);
void of_device_unregister(struct of_device *ofdev)
{
device_remove_file(&ofdev->dev, &dev_attr_devspec);
+ device_remove_file(&ofdev->dev, &dev_attr_modalias);
device_unregister(&ofdev->dev);
}
EXPORT_SYMBOL(of_device_unregister);
^ permalink raw reply [flat|nested] 14+ messages in thread* [PATCH v2] create modalias file in sysfs for bus of_platform 2008-01-22 14:21 [PATCH] create modalias file in sysfs for bus of_platform Olaf Hering @ 2008-01-22 14:40 ` Olaf Hering 2008-01-22 14:58 ` Stephen Rothwell 2008-01-22 19:09 ` [PATCH v3] " Olaf Hering 0 siblings, 2 replies; 14+ messages in thread From: Olaf Hering @ 2008-01-22 14:40 UTC (permalink / raw) To: linuxppc-dev Create /sys/bus/of_platform/devices/*/modalias file to allow autoloading of modules. modalias files are already present for many other bus types. Signed-off-by: Olaf Hering <olaf@aepfle.de> --- drivers/of/device.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) --- a/drivers/of/device.c +++ b/drivers/of/device.c @@ -86,7 +86,20 @@ static ssize_t dev_show_devspec(struct d return sprintf(buf, "%s", ofdev->node->full_name); } +static ssize_t dev_show_modalias(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct of_device *ofdev = to_of_device(dev); + ssize_t len = 0; + + len = of_device_get_modalias(ofdev, buf, PAGE_SIZE); + buf[len] = '\n'; + buf[len+1] = 0; + return len+1; +} + static DEVICE_ATTR(devspec, S_IRUGO, dev_show_devspec, NULL); +static DEVICE_ATTR(modalias, S_IRUGO, dev_show_modalias, NULL); /** * of_release_dev - free an of device structure when all users of it are finished. @@ -116,6 +129,11 @@ int of_device_register(struct of_device return rc; rc = device_create_file(&ofdev->dev, &dev_attr_devspec); + if (rc) { + device_unregister(&ofdev->dev); + return rc; + } + rc = device_create_file(&ofdev->dev, &dev_attr_modalias); if (rc) device_unregister(&ofdev->dev); @@ -126,6 +144,7 @@ EXPORT_SYMBOL(of_device_register); void of_device_unregister(struct of_device *ofdev) { device_remove_file(&ofdev->dev, &dev_attr_devspec); + device_remove_file(&ofdev->dev, &dev_attr_modalias); device_unregister(&ofdev->dev); } EXPORT_SYMBOL(of_device_unregister); ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v2] create modalias file in sysfs for bus of_platform 2008-01-22 14:40 ` [PATCH v2] " Olaf Hering @ 2008-01-22 14:58 ` Stephen Rothwell 2008-01-22 19:09 ` [PATCH v3] " Olaf Hering 1 sibling, 0 replies; 14+ messages in thread From: Stephen Rothwell @ 2008-01-22 14:58 UTC (permalink / raw) To: Olaf Hering; +Cc: sparclinux, linuxppc-dev [-- Attachment #1: Type: text/plain, Size: 2185 bytes --] Hi Olaf, Thanks for doing this. Patches to drivers/of should also be cc'd to the Sparc guys as they share this stuff with is, now. Also, drivers/macintosh/macio_sysfs.c does this for itself, so that should probably be removed. On Tue, 22 Jan 2008 15:40:53 +0100 Olaf Hering <olaf@aepfle.de> wrote: > > Create /sys/bus/of_platform/devices/*/modalias file to allow autoloading > of modules. modalias files are already present for many other bus types. > > Signed-off-by: Olaf Hering <olaf@aepfle.de> > > --- > drivers/of/device.c | 19 +++++++++++++++++++ > 1 file changed, 19 insertions(+) > > --- a/drivers/of/device.c > +++ b/drivers/of/device.c > @@ -86,7 +86,20 @@ static ssize_t dev_show_devspec(struct d > return sprintf(buf, "%s", ofdev->node->full_name); > } > > +static ssize_t dev_show_modalias(struct device *dev, > + struct device_attribute *attr, char *buf) > +{ > + struct of_device *ofdev = to_of_device(dev); > + ssize_t len = 0; > + > + len = of_device_get_modalias(ofdev, buf, PAGE_SIZE); Should you pass (PAGE_SIZE - 1 (or 2)) here? > + buf[len] = '\n'; > + buf[len+1] = 0; > + return len+1; > +} > + > static DEVICE_ATTR(devspec, S_IRUGO, dev_show_devspec, NULL); > +static DEVICE_ATTR(modalias, S_IRUGO, dev_show_modalias, NULL); > > /** > * of_release_dev - free an of device structure when all users of it are finished. > @@ -116,6 +129,11 @@ int of_device_register(struct of_device > return rc; > > rc = device_create_file(&ofdev->dev, &dev_attr_devspec); > + if (rc) { > + device_unregister(&ofdev->dev); > + return rc; > + } > + rc = device_create_file(&ofdev->dev, &dev_attr_modalias); > if (rc) > device_unregister(&ofdev->dev); > > @@ -126,6 +144,7 @@ EXPORT_SYMBOL(of_device_register); > void of_device_unregister(struct of_device *ofdev) > { > device_remove_file(&ofdev->dev, &dev_attr_devspec); > + device_remove_file(&ofdev->dev, &dev_attr_modalias); > device_unregister(&ofdev->dev); > } > EXPORT_SYMBOL(of_device_unregister); -- Cheers, Stephen Rothwell sfr@canb.auug.org.au http://www.canb.auug.org.au/~sfr/ [-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --] ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v2] create modalias file in sysfs for bus of_platform @ 2008-01-22 14:58 ` Stephen Rothwell 0 siblings, 0 replies; 14+ messages in thread From: Stephen Rothwell @ 2008-01-22 14:58 UTC (permalink / raw) To: Olaf Hering; +Cc: sparclinux, linuxppc-dev [-- Attachment #1: Type: text/plain, Size: 2185 bytes --] Hi Olaf, Thanks for doing this. Patches to drivers/of should also be cc'd to the Sparc guys as they share this stuff with is, now. Also, drivers/macintosh/macio_sysfs.c does this for itself, so that should probably be removed. On Tue, 22 Jan 2008 15:40:53 +0100 Olaf Hering <olaf@aepfle.de> wrote: > > Create /sys/bus/of_platform/devices/*/modalias file to allow autoloading > of modules. modalias files are already present for many other bus types. > > Signed-off-by: Olaf Hering <olaf@aepfle.de> > > --- > drivers/of/device.c | 19 +++++++++++++++++++ > 1 file changed, 19 insertions(+) > > --- a/drivers/of/device.c > +++ b/drivers/of/device.c > @@ -86,7 +86,20 @@ static ssize_t dev_show_devspec(struct d > return sprintf(buf, "%s", ofdev->node->full_name); > } > > +static ssize_t dev_show_modalias(struct device *dev, > + struct device_attribute *attr, char *buf) > +{ > + struct of_device *ofdev = to_of_device(dev); > + ssize_t len = 0; > + > + len = of_device_get_modalias(ofdev, buf, PAGE_SIZE); Should you pass (PAGE_SIZE - 1 (or 2)) here? > + buf[len] = '\n'; > + buf[len+1] = 0; > + return len+1; > +} > + > static DEVICE_ATTR(devspec, S_IRUGO, dev_show_devspec, NULL); > +static DEVICE_ATTR(modalias, S_IRUGO, dev_show_modalias, NULL); > > /** > * of_release_dev - free an of device structure when all users of it are finished. > @@ -116,6 +129,11 @@ int of_device_register(struct of_device > return rc; > > rc = device_create_file(&ofdev->dev, &dev_attr_devspec); > + if (rc) { > + device_unregister(&ofdev->dev); > + return rc; > + } > + rc = device_create_file(&ofdev->dev, &dev_attr_modalias); > if (rc) > device_unregister(&ofdev->dev); > > @@ -126,6 +144,7 @@ EXPORT_SYMBOL(of_device_register); > void of_device_unregister(struct of_device *ofdev) > { > device_remove_file(&ofdev->dev, &dev_attr_devspec); > + device_remove_file(&ofdev->dev, &dev_attr_modalias); > device_unregister(&ofdev->dev); > } > EXPORT_SYMBOL(of_device_unregister); -- Cheers, Stephen Rothwell sfr@canb.auug.org.au http://www.canb.auug.org.au/~sfr/ [-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --] ^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v3] create modalias file in sysfs for bus of_platform 2008-01-22 14:40 ` [PATCH v2] " Olaf Hering 2008-01-22 14:58 ` Stephen Rothwell @ 2008-01-22 19:09 ` Olaf Hering 2008-01-22 23:03 ` Stephen Rothwell 2008-01-26 0:23 ` Paul Mackerras 1 sibling, 2 replies; 14+ messages in thread From: Olaf Hering @ 2008-01-22 19:09 UTC (permalink / raw) To: linuxppc-dev Create /sys/bus/of_platform/devices/*/modalias file to allow autoloading of modules. modalias files are already present for many other bus types. Signed-off-by: Olaf Hering <olaf@aepfle.de> --- drivers/of/device.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) --- a/drivers/of/device.c +++ b/drivers/of/device.c @@ -86,7 +86,20 @@ static ssize_t dev_show_devspec(struct d return sprintf(buf, "%s", ofdev->node->full_name); } +static ssize_t dev_show_modalias(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct of_device *ofdev = to_of_device(dev); + ssize_t len = 0; + + len = of_device_get_modalias(ofdev, buf, PAGE_SIZE - 2); + buf[len] = '\n'; + buf[len+1] = 0; + return len+1; +} + static DEVICE_ATTR(devspec, S_IRUGO, dev_show_devspec, NULL); +static DEVICE_ATTR(modalias, S_IRUGO, dev_show_modalias, NULL); /** * of_release_dev - free an of device structure when all users of it are finished. @@ -116,6 +129,11 @@ int of_device_register(struct of_device return rc; rc = device_create_file(&ofdev->dev, &dev_attr_devspec); + if (rc) { + device_unregister(&ofdev->dev); + return rc; + } + rc = device_create_file(&ofdev->dev, &dev_attr_modalias); if (rc) device_unregister(&ofdev->dev); @@ -126,6 +144,7 @@ EXPORT_SYMBOL(of_device_register); void of_device_unregister(struct of_device *ofdev) { device_remove_file(&ofdev->dev, &dev_attr_devspec); + device_remove_file(&ofdev->dev, &dev_attr_modalias); device_unregister(&ofdev->dev); } EXPORT_SYMBOL(of_device_unregister); ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v3] create modalias file in sysfs for bus of_platform 2008-01-22 19:09 ` [PATCH v3] " Olaf Hering @ 2008-01-22 23:03 ` Stephen Rothwell 2008-01-26 0:23 ` Paul Mackerras 1 sibling, 0 replies; 14+ messages in thread From: Stephen Rothwell @ 2008-01-22 23:03 UTC (permalink / raw) To: Olaf Hering; +Cc: sparclinux, linuxppc-dev [-- Attachment #1: Type: text/plain, Size: 2201 bytes --] [Adding sparclinux cc] I withdraw the comment about drivers/macintosh/macio_sysfs.c, I didn't realise that it was a whole other bus. On Tue, 22 Jan 2008 20:09:39 +0100 Olaf Hering <olaf@aepfle.de> wrote: > > Create /sys/bus/of_platform/devices/*/modalias file to allow autoloading > of modules. modalias files are already present for many other bus types. > > Signed-off-by: Olaf Hering <olaf@aepfle.de> > > --- > drivers/of/device.c | 19 +++++++++++++++++++ > 1 file changed, 19 insertions(+) > > --- a/drivers/of/device.c > +++ b/drivers/of/device.c > @@ -86,7 +86,20 @@ static ssize_t dev_show_devspec(struct d > return sprintf(buf, "%s", ofdev->node->full_name); > } > > +static ssize_t dev_show_modalias(struct device *dev, > + struct device_attribute *attr, char *buf) > +{ > + struct of_device *ofdev = to_of_device(dev); > + ssize_t len = 0; > + > + len = of_device_get_modalias(ofdev, buf, PAGE_SIZE - 2); > + buf[len] = '\n'; > + buf[len+1] = 0; > + return len+1; > +} > + > static DEVICE_ATTR(devspec, S_IRUGO, dev_show_devspec, NULL); > +static DEVICE_ATTR(modalias, S_IRUGO, dev_show_modalias, NULL); > > /** > * of_release_dev - free an of device structure when all users of it are finished. > @@ -116,6 +129,11 @@ int of_device_register(struct of_device > return rc; > > rc = device_create_file(&ofdev->dev, &dev_attr_devspec); > + if (rc) { > + device_unregister(&ofdev->dev); > + return rc; > + } > + rc = device_create_file(&ofdev->dev, &dev_attr_modalias); > if (rc) > device_unregister(&ofdev->dev); > > @@ -126,6 +144,7 @@ EXPORT_SYMBOL(of_device_register); > void of_device_unregister(struct of_device *ofdev) > { > device_remove_file(&ofdev->dev, &dev_attr_devspec); > + device_remove_file(&ofdev->dev, &dev_attr_modalias); > device_unregister(&ofdev->dev); > } > EXPORT_SYMBOL(of_device_unregister); > _______________________________________________ > Linuxppc-dev mailing list > Linuxppc-dev@ozlabs.org > https://ozlabs.org/mailman/listinfo/linuxppc-dev -- Cheers, Stephen Rothwell sfr@canb.auug.org.au http://www.canb.auug.org.au/~sfr/ [-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --] ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v3] create modalias file in sysfs for bus of_platform @ 2008-01-22 23:03 ` Stephen Rothwell 0 siblings, 0 replies; 14+ messages in thread From: Stephen Rothwell @ 2008-01-22 23:03 UTC (permalink / raw) To: Olaf Hering; +Cc: sparclinux, linuxppc-dev [-- Attachment #1: Type: text/plain, Size: 2201 bytes --] [Adding sparclinux cc] I withdraw the comment about drivers/macintosh/macio_sysfs.c, I didn't realise that it was a whole other bus. On Tue, 22 Jan 2008 20:09:39 +0100 Olaf Hering <olaf@aepfle.de> wrote: > > Create /sys/bus/of_platform/devices/*/modalias file to allow autoloading > of modules. modalias files are already present for many other bus types. > > Signed-off-by: Olaf Hering <olaf@aepfle.de> > > --- > drivers/of/device.c | 19 +++++++++++++++++++ > 1 file changed, 19 insertions(+) > > --- a/drivers/of/device.c > +++ b/drivers/of/device.c > @@ -86,7 +86,20 @@ static ssize_t dev_show_devspec(struct d > return sprintf(buf, "%s", ofdev->node->full_name); > } > > +static ssize_t dev_show_modalias(struct device *dev, > + struct device_attribute *attr, char *buf) > +{ > + struct of_device *ofdev = to_of_device(dev); > + ssize_t len = 0; > + > + len = of_device_get_modalias(ofdev, buf, PAGE_SIZE - 2); > + buf[len] = '\n'; > + buf[len+1] = 0; > + return len+1; > +} > + > static DEVICE_ATTR(devspec, S_IRUGO, dev_show_devspec, NULL); > +static DEVICE_ATTR(modalias, S_IRUGO, dev_show_modalias, NULL); > > /** > * of_release_dev - free an of device structure when all users of it are finished. > @@ -116,6 +129,11 @@ int of_device_register(struct of_device > return rc; > > rc = device_create_file(&ofdev->dev, &dev_attr_devspec); > + if (rc) { > + device_unregister(&ofdev->dev); > + return rc; > + } > + rc = device_create_file(&ofdev->dev, &dev_attr_modalias); > if (rc) > device_unregister(&ofdev->dev); > > @@ -126,6 +144,7 @@ EXPORT_SYMBOL(of_device_register); > void of_device_unregister(struct of_device *ofdev) > { > device_remove_file(&ofdev->dev, &dev_attr_devspec); > + device_remove_file(&ofdev->dev, &dev_attr_modalias); > device_unregister(&ofdev->dev); > } > EXPORT_SYMBOL(of_device_unregister); > _______________________________________________ > Linuxppc-dev mailing list > Linuxppc-dev@ozlabs.org > https://ozlabs.org/mailman/listinfo/linuxppc-dev -- Cheers, Stephen Rothwell sfr@canb.auug.org.au http://www.canb.auug.org.au/~sfr/ [-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --] ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v3] create modalias file in sysfs for bus of_platform 2008-01-22 19:09 ` [PATCH v3] " Olaf Hering 2008-01-22 23:03 ` Stephen Rothwell @ 2008-01-26 0:23 ` Paul Mackerras 2008-01-26 10:04 ` Olaf Hering 1 sibling, 1 reply; 14+ messages in thread From: Paul Mackerras @ 2008-01-26 0:23 UTC (permalink / raw) To: Olaf Hering; +Cc: linuxppc-dev Olaf Hering writes: > Create /sys/bus/of_platform/devices/*/modalias file to allow autoloading > of modules. modalias files are already present for many other bus types. This one causes various oopses on boot for me, both on a dual G5 and on a tibook. Paul. ^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v4] create modalias file in sysfs for bus of_platform 2008-01-26 0:23 ` Paul Mackerras @ 2008-01-26 10:04 ` Olaf Hering 0 siblings, 0 replies; 14+ messages in thread From: Olaf Hering @ 2008-01-26 10:04 UTC (permalink / raw) To: Paul Mackerras; +Cc: sparclinux, linuxppc-dev Create /sys/bus/of_platform/devices/*/modalias file to allow autoloading of modules. modalias files are already present for many other bus types. Signed-off-by: Olaf Hering <olaf@aepfle.de> --- drivers/of/device.c | 33 ++++++++++++++++++--------------- drivers/of/platform.c | 3 +++ 2 files changed, 21 insertions(+), 15 deletions(-) Index: linux-2.6/drivers/of/device.c =================================================================== --- linux-2.6.orig/drivers/of/device.c +++ linux-2.6/drivers/of/device.c @@ -77,7 +77,7 @@ void of_dev_put(struct of_device *dev) } EXPORT_SYMBOL(of_dev_put); -static ssize_t dev_show_devspec(struct device *dev, +static ssize_t devspec_show(struct device *dev, struct device_attribute *attr, char *buf) { struct of_device *ofdev; @@ -86,7 +86,22 @@ static ssize_t dev_show_devspec(struct d return sprintf(buf, "%s", ofdev->node->full_name); } -static DEVICE_ATTR(devspec, S_IRUGO, dev_show_devspec, NULL); +static ssize_t modalias_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + ssize_t len; + + len = of_device_get_modalias(to_of_device(dev), buf, PAGE_SIZE - 2); + buf[len] = '\n'; + buf[len+1] = 0; + return len+1; +} + +struct device_attribute of_platform_device_attrs[] = { + __ATTR_RO(devspec), + __ATTR_RO(modalias), + __ATTR_NULL +}; /** * of_release_dev - free an of device structure when all users of it are finished. @@ -107,25 +122,13 @@ EXPORT_SYMBOL(of_release_dev); int of_device_register(struct of_device *ofdev) { - int rc; - BUG_ON(ofdev->node == NULL); - - rc = device_register(&ofdev->dev); - if (rc) - return rc; - - rc = device_create_file(&ofdev->dev, &dev_attr_devspec); - if (rc) - device_unregister(&ofdev->dev); - - return rc; + return device_register(&ofdev->dev); } EXPORT_SYMBOL(of_device_register); void of_device_unregister(struct of_device *ofdev) { - device_remove_file(&ofdev->dev, &dev_attr_devspec); device_unregister(&ofdev->dev); } EXPORT_SYMBOL(of_device_unregister); Index: linux-2.6/drivers/of/platform.c =================================================================== --- linux-2.6.orig/drivers/of/platform.c +++ linux-2.6/drivers/of/platform.c @@ -17,6 +17,8 @@ #include <linux/of_device.h> #include <linux/of_platform.h> +extern struct device_attribute of_platform_device_attrs[]; + static int of_platform_bus_match(struct device *dev, struct device_driver *drv) { struct of_device *of_dev = to_of_device(dev); @@ -93,6 +95,7 @@ int of_bus_type_init(struct bus_type *bu bus->remove = of_platform_device_remove; bus->suspend = of_platform_device_suspend; bus->resume = of_platform_device_resume; + bus->dev_attrs = of_platform_device_attrs; return bus_register(bus); } ^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v4] create modalias file in sysfs for bus of_platform @ 2008-01-26 10:04 ` Olaf Hering 0 siblings, 0 replies; 14+ messages in thread From: Olaf Hering @ 2008-01-26 10:04 UTC (permalink / raw) To: Paul Mackerras; +Cc: sparclinux, linuxppc-dev Create /sys/bus/of_platform/devices/*/modalias file to allow autoloading of modules. modalias files are already present for many other bus types. Signed-off-by: Olaf Hering <olaf@aepfle.de> --- drivers/of/device.c | 33 ++++++++++++++++++--------------- drivers/of/platform.c | 3 +++ 2 files changed, 21 insertions(+), 15 deletions(-) Index: linux-2.6/drivers/of/device.c =================================--- linux-2.6.orig/drivers/of/device.c +++ linux-2.6/drivers/of/device.c @@ -77,7 +77,7 @@ void of_dev_put(struct of_device *dev) } EXPORT_SYMBOL(of_dev_put); -static ssize_t dev_show_devspec(struct device *dev, +static ssize_t devspec_show(struct device *dev, struct device_attribute *attr, char *buf) { struct of_device *ofdev; @@ -86,7 +86,22 @@ static ssize_t dev_show_devspec(struct d return sprintf(buf, "%s", ofdev->node->full_name); } -static DEVICE_ATTR(devspec, S_IRUGO, dev_show_devspec, NULL); +static ssize_t modalias_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + ssize_t len; + + len = of_device_get_modalias(to_of_device(dev), buf, PAGE_SIZE - 2); + buf[len] = '\n'; + buf[len+1] = 0; + return len+1; +} + +struct device_attribute of_platform_device_attrs[] = { + __ATTR_RO(devspec), + __ATTR_RO(modalias), + __ATTR_NULL +}; /** * of_release_dev - free an of device structure when all users of it are finished. @@ -107,25 +122,13 @@ EXPORT_SYMBOL(of_release_dev); int of_device_register(struct of_device *ofdev) { - int rc; - BUG_ON(ofdev->node = NULL); - - rc = device_register(&ofdev->dev); - if (rc) - return rc; - - rc = device_create_file(&ofdev->dev, &dev_attr_devspec); - if (rc) - device_unregister(&ofdev->dev); - - return rc; + return device_register(&ofdev->dev); } EXPORT_SYMBOL(of_device_register); void of_device_unregister(struct of_device *ofdev) { - device_remove_file(&ofdev->dev, &dev_attr_devspec); device_unregister(&ofdev->dev); } EXPORT_SYMBOL(of_device_unregister); Index: linux-2.6/drivers/of/platform.c =================================--- linux-2.6.orig/drivers/of/platform.c +++ linux-2.6/drivers/of/platform.c @@ -17,6 +17,8 @@ #include <linux/of_device.h> #include <linux/of_platform.h> +extern struct device_attribute of_platform_device_attrs[]; + static int of_platform_bus_match(struct device *dev, struct device_driver *drv) { struct of_device *of_dev = to_of_device(dev); @@ -93,6 +95,7 @@ int of_bus_type_init(struct bus_type *bu bus->remove = of_platform_device_remove; bus->suspend = of_platform_device_suspend; bus->resume = of_platform_device_resume; + bus->dev_attrs = of_platform_device_attrs; return bus_register(bus); } ^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v5] create modalias file in sysfs for bus of_platform 2008-01-26 10:04 ` Olaf Hering @ 2008-04-24 13:16 ` Olaf Hering -1 siblings, 0 replies; 14+ messages in thread From: Olaf Hering @ 2008-04-24 13:16 UTC (permalink / raw) To: Paul Mackerras; +Cc: sparclinux, linuxppc-dev Create /sys/bus/of_platform/devices/*/modalias file to allow autoloading of modules. modalias files are already present for many other bus types. This adds also a newline to the devspec files. Also create a devspec file for mac-io devices. They were created as a side effect. Use correct buffer size for mac-io modalias buffer. Tested on iBook1 and Efika. Signed-off-by: Olaf Hering <olaf@aepfle.de> --- drivers/macintosh/macio_sysfs.c | 12 +++++++++++- drivers/of/device.c | 36 ++++++++++++++++++++---------------- drivers/of/platform.c | 3 +++ 3 files changed, 34 insertions(+), 17 deletions(-) --- a/drivers/macintosh/macio_sysfs.c +++ b/drivers/macintosh/macio_sysfs.c @@ -44,7 +44,7 @@ static ssize_t modalias_show (struct dev struct of_device *ofdev = to_of_device(dev); int len; - len = of_device_get_modalias(ofdev, buf, PAGE_SIZE); + len = of_device_get_modalias(ofdev, buf, PAGE_SIZE - 2); buf[len] = '\n'; buf[len+1] = 0; @@ -52,6 +52,15 @@ static ssize_t modalias_show (struct dev return len+1; } +static ssize_t devspec_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct of_device *ofdev; + + ofdev = to_of_device(dev); + return sprintf(buf, "%s\n", ofdev->node->full_name); +} + macio_config_of_attr (name, "%s\n"); macio_config_of_attr (type, "%s\n"); @@ -60,5 +69,6 @@ struct device_attribute macio_dev_attrs[ __ATTR_RO(type), __ATTR_RO(compatible), __ATTR_RO(modalias), + __ATTR_RO(devspec), __ATTR_NULL }; --- a/drivers/of/device.c +++ b/drivers/of/device.c @@ -48,16 +48,32 @@ void of_dev_put(struct of_device *dev) } EXPORT_SYMBOL(of_dev_put); -static ssize_t dev_show_devspec(struct device *dev, +static ssize_t devspec_show(struct device *dev, struct device_attribute *attr, char *buf) { struct of_device *ofdev; ofdev = to_of_device(dev); - return sprintf(buf, "%s", ofdev->node->full_name); + return sprintf(buf, "%s\n", ofdev->node->full_name); } -static DEVICE_ATTR(devspec, S_IRUGO, dev_show_devspec, NULL); +static ssize_t modalias_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct of_device *ofdev = to_of_device(dev); + ssize_t len = 0; + + len = of_device_get_modalias(ofdev, buf, PAGE_SIZE - 2); + buf[len] = '\n'; + buf[len+1] = 0; + return len+1; +} + +struct device_attribute of_platform_device_attrs[] = { + __ATTR_RO(devspec), + __ATTR_RO(modalias), + __ATTR_NULL +}; /** * of_release_dev - free an of device structure when all users of it are finished. @@ -78,25 +94,13 @@ EXPORT_SYMBOL(of_release_dev); int of_device_register(struct of_device *ofdev) { - int rc; - BUG_ON(ofdev->node == NULL); - - rc = device_register(&ofdev->dev); - if (rc) - return rc; - - rc = device_create_file(&ofdev->dev, &dev_attr_devspec); - if (rc) - device_unregister(&ofdev->dev); - - return rc; + return device_register(&ofdev->dev); } EXPORT_SYMBOL(of_device_register); void of_device_unregister(struct of_device *ofdev) { - device_remove_file(&ofdev->dev, &dev_attr_devspec); device_unregister(&ofdev->dev); } EXPORT_SYMBOL(of_device_unregister); --- a/drivers/of/platform.c +++ b/drivers/of/platform.c @@ -17,6 +17,8 @@ #include <linux/of_device.h> #include <linux/of_platform.h> +extern struct device_attribute of_platform_device_attrs[]; + static int of_platform_bus_match(struct device *dev, struct device_driver *drv) { struct of_device *of_dev = to_of_device(dev); @@ -103,6 +105,7 @@ int of_bus_type_init(struct bus_type *bu bus->suspend = of_platform_device_suspend; bus->resume = of_platform_device_resume; bus->shutdown = of_platform_device_shutdown; + bus->dev_attrs = of_platform_device_attrs; return bus_register(bus); } ^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v5] create modalias file in sysfs for bus of_platform @ 2008-04-24 13:16 ` Olaf Hering 0 siblings, 0 replies; 14+ messages in thread From: Olaf Hering @ 2008-04-24 13:16 UTC (permalink / raw) To: Paul Mackerras; +Cc: sparclinux, linuxppc-dev Create /sys/bus/of_platform/devices/*/modalias file to allow autoloading of modules. modalias files are already present for many other bus types. This adds also a newline to the devspec files. Also create a devspec file for mac-io devices. They were created as a side effect. Use correct buffer size for mac-io modalias buffer. Tested on iBook1 and Efika. Signed-off-by: Olaf Hering <olaf@aepfle.de> --- drivers/macintosh/macio_sysfs.c | 12 +++++++++++- drivers/of/device.c | 36 ++++++++++++++++++++---------------- drivers/of/platform.c | 3 +++ 3 files changed, 34 insertions(+), 17 deletions(-) --- a/drivers/macintosh/macio_sysfs.c +++ b/drivers/macintosh/macio_sysfs.c @@ -44,7 +44,7 @@ static ssize_t modalias_show (struct dev struct of_device *ofdev = to_of_device(dev); int len; - len = of_device_get_modalias(ofdev, buf, PAGE_SIZE); + len = of_device_get_modalias(ofdev, buf, PAGE_SIZE - 2); buf[len] = '\n'; buf[len+1] = 0; @@ -52,6 +52,15 @@ static ssize_t modalias_show (struct dev return len+1; } +static ssize_t devspec_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct of_device *ofdev; + + ofdev = to_of_device(dev); + return sprintf(buf, "%s\n", ofdev->node->full_name); +} + macio_config_of_attr (name, "%s\n"); macio_config_of_attr (type, "%s\n"); @@ -60,5 +69,6 @@ struct device_attribute macio_dev_attrs[ __ATTR_RO(type), __ATTR_RO(compatible), __ATTR_RO(modalias), + __ATTR_RO(devspec), __ATTR_NULL }; --- a/drivers/of/device.c +++ b/drivers/of/device.c @@ -48,16 +48,32 @@ void of_dev_put(struct of_device *dev) } EXPORT_SYMBOL(of_dev_put); -static ssize_t dev_show_devspec(struct device *dev, +static ssize_t devspec_show(struct device *dev, struct device_attribute *attr, char *buf) { struct of_device *ofdev; ofdev = to_of_device(dev); - return sprintf(buf, "%s", ofdev->node->full_name); + return sprintf(buf, "%s\n", ofdev->node->full_name); } -static DEVICE_ATTR(devspec, S_IRUGO, dev_show_devspec, NULL); +static ssize_t modalias_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct of_device *ofdev = to_of_device(dev); + ssize_t len = 0; + + len = of_device_get_modalias(ofdev, buf, PAGE_SIZE - 2); + buf[len] = '\n'; + buf[len+1] = 0; + return len+1; +} + +struct device_attribute of_platform_device_attrs[] = { + __ATTR_RO(devspec), + __ATTR_RO(modalias), + __ATTR_NULL +}; /** * of_release_dev - free an of device structure when all users of it are finished. @@ -78,25 +94,13 @@ EXPORT_SYMBOL(of_release_dev); int of_device_register(struct of_device *ofdev) { - int rc; - BUG_ON(ofdev->node = NULL); - - rc = device_register(&ofdev->dev); - if (rc) - return rc; - - rc = device_create_file(&ofdev->dev, &dev_attr_devspec); - if (rc) - device_unregister(&ofdev->dev); - - return rc; + return device_register(&ofdev->dev); } EXPORT_SYMBOL(of_device_register); void of_device_unregister(struct of_device *ofdev) { - device_remove_file(&ofdev->dev, &dev_attr_devspec); device_unregister(&ofdev->dev); } EXPORT_SYMBOL(of_device_unregister); --- a/drivers/of/platform.c +++ b/drivers/of/platform.c @@ -17,6 +17,8 @@ #include <linux/of_device.h> #include <linux/of_platform.h> +extern struct device_attribute of_platform_device_attrs[]; + static int of_platform_bus_match(struct device *dev, struct device_driver *drv) { struct of_device *of_dev = to_of_device(dev); @@ -103,6 +105,7 @@ int of_bus_type_init(struct bus_type *bu bus->suspend = of_platform_device_suspend; bus->resume = of_platform_device_resume; bus->shutdown = of_platform_device_shutdown; + bus->dev_attrs = of_platform_device_attrs; return bus_register(bus); } ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v5] create modalias file in sysfs for bus of_platform 2008-04-24 13:16 ` Olaf Hering @ 2008-05-08 21:31 ` Olaf Hering -1 siblings, 0 replies; 14+ messages in thread From: Olaf Hering @ 2008-05-08 21:31 UTC (permalink / raw) To: Paul Mackerras; +Cc: sparclinux, linuxppc-dev On Thu, Apr 24, Olaf Hering wrote: > Create /sys/bus/of_platform/devices/*/modalias file to allow autoloading > of modules. modalias files are already present for many other bus types. > This adds also a newline to the devspec files. > > Also create a devspec file for mac-io devices. They were created as a side > effect. Use correct buffer size for mac-io modalias buffer. > > Tested on iBook1 and Efika. Did anyone test this on other systems, like sparc? ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v5] create modalias file in sysfs for bus of_platform @ 2008-05-08 21:31 ` Olaf Hering 0 siblings, 0 replies; 14+ messages in thread From: Olaf Hering @ 2008-05-08 21:31 UTC (permalink / raw) To: Paul Mackerras; +Cc: sparclinux, linuxppc-dev On Thu, Apr 24, Olaf Hering wrote: > Create /sys/bus/of_platform/devices/*/modalias file to allow autoloading > of modules. modalias files are already present for many other bus types. > This adds also a newline to the devspec files. > > Also create a devspec file for mac-io devices. They were created as a side > effect. Use correct buffer size for mac-io modalias buffer. > > Tested on iBook1 and Efika. Did anyone test this on other systems, like sparc? ^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2008-05-08 21:31 UTC | newest] Thread overview: 14+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2008-01-22 14:21 [PATCH] create modalias file in sysfs for bus of_platform Olaf Hering 2008-01-22 14:40 ` [PATCH v2] " Olaf Hering 2008-01-22 14:58 ` Stephen Rothwell 2008-01-22 14:58 ` Stephen Rothwell 2008-01-22 19:09 ` [PATCH v3] " Olaf Hering 2008-01-22 23:03 ` Stephen Rothwell 2008-01-22 23:03 ` Stephen Rothwell 2008-01-26 0:23 ` Paul Mackerras 2008-01-26 10:04 ` [PATCH v4] " Olaf Hering 2008-01-26 10:04 ` Olaf Hering 2008-04-24 13:16 ` [PATCH v5] " Olaf Hering 2008-04-24 13:16 ` Olaf Hering 2008-05-08 21:31 ` Olaf Hering 2008-05-08 21:31 ` Olaf Hering
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.