diff options
Diffstat (limited to 'drivers/base/platform.c')
| -rw-r--r-- | drivers/base/platform.c | 35 |
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) | |||
| 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 | }; |
