platform_bus learns about modalias
PATCH 1/1 platform_bus learns about modalias
This is one of the most significant busses not to support the $MODALIAS and /sys/devices/.../modalias conventions.
This patch adds modalias support to platform devices, for simpler hotplug/coldplug driven driver setup.
drivers/base/platform.c +36 -0
@@ -452,6 +452,40 @@ void platform_driver_unregister(struct pEXPORT_SYMBOL_GPL (platform_driver_unregister); +/* modalias support enables more hands-off userspace setup: +* (a) environment variable lets new-style hotplug events work once system is +* fully running: "modprobe $MODALIAS" +* (b) sysfs attribute lets new-style coldplug recover from hotplug events +* mishandled before system is fully running: "modprobe $(cat modalias)" +*/ +static ssize_t +modalias_show (struct device *dev,struct device_attribute *a,char *buf) +{ +struct platform_device *pdev =to_platform_device (dev); +unsigned len =strlen (pdev->name); + + len =min (len, (size_t )(PAGE_SIZE -1 )); +memcpy (buf, pdev->name, len); + buf[PAGE_SIZE -1 ] =0 ; +return len; +} + +static struct device_attribute platform_dev_attrs[] = { +__ATTR_RO (modalias), + __ATTR_NULL, +}; + +static int platform_uevent (struct device *dev,char **envp,int num_envp, +char *buffer,int buffer_size) +{ +struct platform_device *pdev =to_platform_device (dev); + + envp[0 ] = buffer; +snprintf (buffer, buffer_size,"MODALIAS=%s" , pdev->name); +return 0 ; +} + +/** * platform_match - bind platform device to platform driver. * @dev: device.
@@ -496,7 +530,9 @@ static int platform_resume(struct devicestruct bus_type platform_bus_type = { .name ="platform" , + .dev_attrs = platform_dev_attrs, .match = platform_match, + .uevent = platform_uevent, .suspend = platform_suspend, .resume = platform_resume, };
[email protected]
Appliedpatch platform_bus-learns-about-modalias.patch added to gregkh-2.6 tree
This is a note to let you know that I've just added the patch titled
Subject: platform_bus learns about modalias
to my gregkh-2.6 tree. Its filename is
platform_bus-learns-about-modalias.patch
This tree can be found at
http://www.kernel.org/pub/linux/kernel/people/gregkh/gregkh-2.6/patches/
Quoted 1 line
From [email protected] Mon May 1 14:05:05 2006
From: David Brownell <[email protected]>
To: Greg KH <[email protected]>
Subject: platform_bus learns about modalias
Date: Mon, 1 May 2006 11:16:01 -0700
Cc: Russell King <[email protected]>,
Linux Kernel list <[email protected]>
Message-Id: <[email protected]>
This patch adds modalias support to platform devices, for simpler hotplug/coldplug driven driver setup.
--- drivers/base/platform.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+)
drivers/base/platform.c +36 -0
@@ -452,6 +452,40 @@ void platform_driver_unregister(struct pEXPORT_SYMBOL_GPL (platform_driver_unregister); +/* modalias support enables more hands-off userspace setup: +* (a) environment variable lets new-style hotplug events work once system is +* fully running: "modprobe $MODALIAS" +* (b) sysfs attribute lets new-style coldplug recover from hotplug events +* mishandled before system is fully running: "modprobe $(cat modalias)" +*/ +static ssize_t +modalias_show (struct device *dev,struct device_attribute *a,char *buf) +{ +struct platform_device *pdev =to_platform_device (dev); +unsigned len =strlen (pdev->name); + + len =min (len, (size_t )(PAGE_SIZE -1 )); +memcpy (buf, pdev->name, len); + buf[PAGE_SIZE -1 ] =0 ; +return len; +} + +static struct device_attribute platform_dev_attrs[] = { +__ATTR_RO (modalias), + __ATTR_NULL, +}; + +static int platform_uevent (struct device *dev,char **envp,int num_envp, +char *buffer,int buffer_size) +{ +struct platform_device *pdev =to_platform_device (dev); + + envp[0 ] = buffer; +snprintf (buffer, buffer_size,"MODALIAS=%s" , pdev->name); +return 0 ; +} + +/** * platform_match - bind platform device to platform driver. * @dev: device.
@@ -496,7 +530,9 @@ static int platform_resume(struct devicestruct bus_type platform_bus_type = { .name ="platform" , + .dev_attrs = platform_dev_attrs, .match = platform_match, + .uevent = platform_uevent, .suspend = platform_suspend, .resume = platform_resume, };
Patches currently in gregkh-2.6 which might be from [email protected] are
driver/spi-add-david-as-the-spi-subsystem-maintainer.patch driver/platform_bus-learns-about-modalias.patch driver/spi-spi_bitbang-clocking-fixes.patch driver/driver-core-config_debug_pm-covers-drivers-base-power-too.patch driver/spi-busnum-0-needs-to-work.patch driver/spi-devices-can-require-lsb-first-encodings.patch driver/spi-renamed-bitbang_transfer_setup-to-spi_bitbang_setup_transfer-and-export-it.patch driver/spi-spi-bounce-buffer-has-a-minimum-length.patch driver/spi-spi-whitespace-fixes.patch driver/spi-add-pxa2xx-ssp-spi-driver.patch driver/spi-per-transfer-overrides-for-wordsize-and-clocking.patch usb/usb-pegasus-fixes.patch usb/usb-allow-multiple-types-of-ehci-controllers-to-be-built-as-modules.patch usb/usb-fix-bug-in-ohci-hcd.c-ohci_restart.patch usb/usb-usbcore-always-turn-on-hub-port-power.patch
Quoted 2 lines · David Brownell
This is one of the most significant busses not to support the $MODALIAS and
/sys/devices/.../modaliasconventions.
Here's a replacement patch, against RC5. The modalias file itself should have a newline termination, and on some platforms the min() invocation caused compiler trouble (hence a build patch found in the MM tree).
- Dave
This patch adds modalias support to platform devices, for simpler hotplug/coldplug driven driver setup.
drivers/base/platform.c +33 -0
@@ -452,6 +452,37 @@ void platform_driver_unregister(struct pEXPORT_SYMBOL_GPL (platform_driver_unregister); +/* modalias support enables more hands-off userspace setup: +* (a) environment variable lets new-style hotplug events work once system is +* fully running: "modprobe $MODALIAS" +* (b) sysfs attribute lets new-style coldplug recover from hotplug events +* mishandled before system is fully running: "modprobe $(cat modalias)" +*/ +static ssize_t +modalias_show (struct device *dev,struct device_attribute *a,char *buf) +{ +struct platform_device *pdev =to_platform_device (dev); +int len =snprintf (buf,PAGE_SIZE ,"%s\n" , pdev->name); + +return (len >=PAGE_SIZE ) ? (PAGE_SIZE -1 ) : len; +} + +static struct device_attribute platform_dev_attrs[] = { +__ATTR_RO (modalias), + __ATTR_NULL, +}; + +static int platform_uevent (struct device *dev,char **envp,int num_envp, +char *buffer,int buffer_size) +{ +struct platform_device *pdev =to_platform_device (dev); + + envp[0 ] = buffer; +snprintf (buffer, buffer_size,"MODALIAS=%s" , pdev->name); +return 0 ; +} + +/** * platform_match - bind platform device to platform driver. * @dev: device.
@@ -496,7 +527,9 @@ static int platform_resume(struct devicestruct bus_type platform_bus_type = { .name ="platform" , + .dev_attrs = platform_dev_attrs, .match = platform_match, + .uevent = platform_uevent, .suspend = platform_suspend, .resume = platform_resume, };