diff options
author | David Brownell <david-b@pacbell.net> | 2006-05-29 13:37:33 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2006-06-21 15:40:48 -0400 |
commit | a0245f7ad5214cb00131d7cd176446e067c913dc (patch) | |
tree | 78f138afefa3114cb587561e464ddc6a8b6a7805 /drivers/base | |
parent | 05967118a6c354eaa5950429c70ad4c8daca94bf (diff) |
[PATCH] platform_bus learns about modalias
This patch adds modalias support to platform devices, for simpler
hotplug/coldplug driven driver setup.
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/base')
-rw-r--r-- | drivers/base/platform.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/drivers/base/platform.c b/drivers/base/platform.c index 83f5c5984d1a..f8071976fe07 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c | |||
@@ -452,6 +452,37 @@ void platform_driver_unregister(struct platform_driver *drv) | |||
452 | EXPORT_SYMBOL_GPL(platform_driver_unregister); | 452 | EXPORT_SYMBOL_GPL(platform_driver_unregister); |
453 | 453 | ||
454 | 454 | ||
455 | /* modalias support enables more hands-off userspace setup: | ||
456 | * (a) environment variable lets new-style hotplug events work once system is | ||
457 | * fully running: "modprobe $MODALIAS" | ||
458 | * (b) sysfs attribute lets new-style coldplug recover from hotplug events | ||
459 | * mishandled before system is fully running: "modprobe $(cat modalias)" | ||
460 | */ | ||
461 | static ssize_t | ||
462 | modalias_show(struct device *dev, struct device_attribute *a, char *buf) | ||
463 | { | ||
464 | struct platform_device *pdev = to_platform_device(dev); | ||
465 | int len = snprintf(buf, PAGE_SIZE, "%s\n", pdev->name); | ||
466 | |||
467 | return (len >= PAGE_SIZE) ? (PAGE_SIZE - 1) : len; | ||
468 | } | ||
469 | |||
470 | static struct device_attribute platform_dev_attrs[] = { | ||
471 | __ATTR_RO(modalias), | ||
472 | __ATTR_NULL, | ||
473 | }; | ||
474 | |||
475 | static int platform_uevent(struct device *dev, char **envp, int num_envp, | ||
476 | char *buffer, int buffer_size) | ||
477 | { | ||
478 | struct platform_device *pdev = to_platform_device(dev); | ||
479 | |||
480 | envp[0] = buffer; | ||
481 | snprintf(buffer, buffer_size, "MODALIAS=%s", pdev->name); | ||
482 | return 0; | ||
483 | } | ||
484 | |||
485 | |||
455 | /** | 486 | /** |
456 | * platform_match - bind platform device to platform driver. | 487 | * platform_match - bind platform device to platform driver. |
457 | * @dev: device. | 488 | * @dev: device. |
@@ -496,7 +527,9 @@ static int platform_resume(struct device * dev) | |||
496 | 527 | ||
497 | struct bus_type platform_bus_type = { | 528 | struct bus_type platform_bus_type = { |
498 | .name = "platform", | 529 | .name = "platform", |
530 | .dev_attrs = platform_dev_attrs, | ||
499 | .match = platform_match, | 531 | .match = platform_match, |
532 | .uevent = platform_uevent, | ||
500 | .suspend = platform_suspend, | 533 | .suspend = platform_suspend, |
501 | .resume = platform_resume, | 534 | .resume = platform_resume, |
502 | }; | 535 | }; |