aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base/platform.c
diff options
context:
space:
mode:
authorJeff Garzik <jeff@garzik.org>2006-06-22 22:51:46 -0400
committerJeff Garzik <jeff@garzik.org>2006-06-22 22:51:46 -0400
commitdbe1ab9514c231c9b062140a107d9dea0eabefcc (patch)
tree0001c7143cf923fc704215f0a0e54221e9e5cbb9 /drivers/base/platform.c
parent612eff0e3715a6faff5ba1b74873b99e036c59fe (diff)
parentd588fcbe5a7ba8bba2cebf7799ab2d573717a806 (diff)
Merge branch 'master' into upstream
Diffstat (limited to 'drivers/base/platform.c')
-rw-r--r--drivers/base/platform.c35
1 files changed, 34 insertions, 1 deletions
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 83f5c5984d1a..2b8755db76c6 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -275,7 +275,7 @@ int platform_device_add(struct platform_device *pdev)
275 pr_debug("Registering platform device '%s'. Parent at %s\n", 275 pr_debug("Registering platform device '%s'. Parent at %s\n",
276 pdev->dev.bus_id, pdev->dev.parent->bus_id); 276 pdev->dev.bus_id, pdev->dev.parent->bus_id);
277 277
278 ret = device_register(&pdev->dev); 278 ret = device_add(&pdev->dev);
279 if (ret == 0) 279 if (ret == 0)
280 return ret; 280 return ret;
281 281
@@ -452,6 +452,37 @@ void platform_driver_unregister(struct platform_driver *drv)
452EXPORT_SYMBOL_GPL(platform_driver_unregister); 452EXPORT_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 */
461static ssize_t
462modalias_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
470static struct device_attribute platform_dev_attrs[] = {
471 __ATTR_RO(modalias),
472 __ATTR_NULL,
473};
474
475static 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
497struct bus_type platform_bus_type = { 528struct 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};