[PATCH v2] create modalias file in sysfs for bus of_platform
Stephen Rothwell
sfr at canb.auug.org.au
Wed Jan 23 01:58:21 EST 2008
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 at 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 at 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 at canb.auug.org.au
http://www.canb.auug.org.au/~sfr/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.ozlabs.org/pipermail/linuxppc-dev/attachments/20080123/c6aafa35/attachment.pgp>
More information about the Linuxppc-dev
mailing list