aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/base/platform.c21
-rw-r--r--include/linux/platform_device.h1
2 files changed, 22 insertions, 0 deletions
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 6040717b62bb..0cad9c7f6bb5 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -32,6 +32,25 @@ struct device platform_bus = {
32EXPORT_SYMBOL_GPL(platform_bus); 32EXPORT_SYMBOL_GPL(platform_bus);
33 33
34/** 34/**
35 * arch_setup_pdev_archdata - Allow manipulation of archdata before its used
36 * @dev: platform device
37 *
38 * This is called before platform_device_add() such that any pdev_archdata may
39 * be setup before the platform_notifier is called. So if a user needs to
40 * manipulate any relevant information in the pdev_archdata they can do:
41 *
42 * platform_devic_alloc()
43 * ... manipulate ...
44 * platform_device_add()
45 *
46 * And if they don't care they can just call platform_device_register() and
47 * everything will just work out.
48 */
49void __weak arch_setup_pdev_archdata(struct platform_device *pdev)
50{
51}
52
53/**
35 * platform_get_resource - get a resource for a device 54 * platform_get_resource - get a resource for a device
36 * @dev: platform device 55 * @dev: platform device
37 * @type: resource type 56 * @type: resource type
@@ -173,6 +192,7 @@ struct platform_device *platform_device_alloc(const char *name, int id)
173 pa->pdev.id = id; 192 pa->pdev.id = id;
174 device_initialize(&pa->pdev.dev); 193 device_initialize(&pa->pdev.dev);
175 pa->pdev.dev.release = platform_device_release; 194 pa->pdev.dev.release = platform_device_release;
195 arch_setup_pdev_archdata(&pa->pdev);
176 } 196 }
177 197
178 return pa ? &pa->pdev : NULL; 198 return pa ? &pa->pdev : NULL;
@@ -334,6 +354,7 @@ EXPORT_SYMBOL_GPL(platform_device_del);
334int platform_device_register(struct platform_device *pdev) 354int platform_device_register(struct platform_device *pdev)
335{ 355{
336 device_initialize(&pdev->dev); 356 device_initialize(&pdev->dev);
357 arch_setup_pdev_archdata(pdev);
337 return platform_device_add(pdev); 358 return platform_device_add(pdev);
338} 359}
339EXPORT_SYMBOL_GPL(platform_device_register); 360EXPORT_SYMBOL_GPL(platform_device_register);
diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h
index ede1a80e3358..27bb05aae70d 100644
--- a/include/linux/platform_device.h
+++ b/include/linux/platform_device.h
@@ -42,6 +42,7 @@ extern void platform_device_unregister(struct platform_device *);
42extern struct bus_type platform_bus_type; 42extern struct bus_type platform_bus_type;
43extern struct device platform_bus; 43extern struct device platform_bus;
44 44
45extern void arch_setup_pdev_archdata(struct platform_device *);
45extern struct resource *platform_get_resource(struct platform_device *, unsigned int, unsigned int); 46extern struct resource *platform_get_resource(struct platform_device *, unsigned int, unsigned int);
46extern int platform_get_irq(struct platform_device *, unsigned int); 47extern int platform_get_irq(struct platform_device *, unsigned int);
47extern struct resource *platform_get_resource_byname(struct platform_device *, unsigned int, const char *); 48extern struct resource *platform_get_resource_byname(struct platform_device *, unsigned int, const char *);