diff options
Diffstat (limited to 'drivers/base/platform.c')
-rw-r--r-- | drivers/base/platform.c | 68 |
1 files changed, 41 insertions, 27 deletions
diff --git a/drivers/base/platform.c b/drivers/base/platform.c index 8827dafba945..0f81731bdfa8 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c | |||
@@ -25,6 +25,7 @@ | |||
25 | struct device platform_bus = { | 25 | struct device platform_bus = { |
26 | .bus_id = "platform", | 26 | .bus_id = "platform", |
27 | }; | 27 | }; |
28 | EXPORT_SYMBOL_GPL(platform_bus); | ||
28 | 29 | ||
29 | /** | 30 | /** |
30 | * platform_get_resource - get a resource for a device | 31 | * platform_get_resource - get a resource for a device |
@@ -49,6 +50,7 @@ platform_get_resource(struct platform_device *dev, unsigned int type, | |||
49 | } | 50 | } |
50 | return NULL; | 51 | return NULL; |
51 | } | 52 | } |
53 | EXPORT_SYMBOL_GPL(platform_get_resource); | ||
52 | 54 | ||
53 | /** | 55 | /** |
54 | * platform_get_irq - get an IRQ for a device | 56 | * platform_get_irq - get an IRQ for a device |
@@ -61,6 +63,7 @@ int platform_get_irq(struct platform_device *dev, unsigned int num) | |||
61 | 63 | ||
62 | return r ? r->start : 0; | 64 | return r ? r->start : 0; |
63 | } | 65 | } |
66 | EXPORT_SYMBOL_GPL(platform_get_irq); | ||
64 | 67 | ||
65 | /** | 68 | /** |
66 | * platform_get_resource_byname - get a resource for a device by name | 69 | * platform_get_resource_byname - get a resource for a device by name |
@@ -84,6 +87,7 @@ platform_get_resource_byname(struct platform_device *dev, unsigned int type, | |||
84 | } | 87 | } |
85 | return NULL; | 88 | return NULL; |
86 | } | 89 | } |
90 | EXPORT_SYMBOL_GPL(platform_get_resource_byname); | ||
87 | 91 | ||
88 | /** | 92 | /** |
89 | * platform_get_irq - get an IRQ for a device | 93 | * platform_get_irq - get an IRQ for a device |
@@ -96,6 +100,7 @@ int platform_get_irq_byname(struct platform_device *dev, char *name) | |||
96 | 100 | ||
97 | return r ? r->start : 0; | 101 | return r ? r->start : 0; |
98 | } | 102 | } |
103 | EXPORT_SYMBOL_GPL(platform_get_irq_byname); | ||
99 | 104 | ||
100 | /** | 105 | /** |
101 | * platform_add_devices - add a numbers of platform devices | 106 | * platform_add_devices - add a numbers of platform devices |
@@ -117,6 +122,7 @@ int platform_add_devices(struct platform_device **devs, int num) | |||
117 | 122 | ||
118 | return ret; | 123 | return ret; |
119 | } | 124 | } |
125 | EXPORT_SYMBOL_GPL(platform_add_devices); | ||
120 | 126 | ||
121 | struct platform_object { | 127 | struct platform_object { |
122 | struct platform_device pdev; | 128 | struct platform_device pdev; |
@@ -168,7 +174,7 @@ struct platform_device *platform_device_alloc(const char *name, unsigned int id) | |||
168 | pa->pdev.dev.release = platform_device_release; | 174 | pa->pdev.dev.release = platform_device_release; |
169 | } | 175 | } |
170 | 176 | ||
171 | return pa ? &pa->pdev : NULL; | 177 | return pa ? &pa->pdev : NULL; |
172 | } | 178 | } |
173 | EXPORT_SYMBOL_GPL(platform_device_alloc); | 179 | EXPORT_SYMBOL_GPL(platform_device_alloc); |
174 | 180 | ||
@@ -257,7 +263,7 @@ int platform_device_add(struct platform_device *pdev) | |||
257 | p = &ioport_resource; | 263 | p = &ioport_resource; |
258 | } | 264 | } |
259 | 265 | ||
260 | if (p && request_resource(p, r)) { | 266 | if (p && insert_resource(p, r)) { |
261 | printk(KERN_ERR | 267 | printk(KERN_ERR |
262 | "%s: failed to claim resource %d\n", | 268 | "%s: failed to claim resource %d\n", |
263 | pdev->dev.bus_id, i); | 269 | pdev->dev.bus_id, i); |
@@ -282,24 +288,13 @@ int platform_device_add(struct platform_device *pdev) | |||
282 | EXPORT_SYMBOL_GPL(platform_device_add); | 288 | EXPORT_SYMBOL_GPL(platform_device_add); |
283 | 289 | ||
284 | /** | 290 | /** |
285 | * platform_device_register - add a platform-level device | 291 | * platform_device_del - remove a platform-level device |
286 | * @pdev: platform device we're adding | ||
287 | * | ||
288 | */ | ||
289 | int platform_device_register(struct platform_device * pdev) | ||
290 | { | ||
291 | device_initialize(&pdev->dev); | ||
292 | return platform_device_add(pdev); | ||
293 | } | ||
294 | |||
295 | /** | ||
296 | * platform_device_unregister - remove a platform-level device | ||
297 | * @pdev: platform device we're removing | 292 | * @pdev: platform device we're removing |
298 | * | 293 | * |
299 | * Note that this function will also release all memory- and port-based | 294 | * Note that this function will also release all memory- and port-based |
300 | * resources owned by the device (@dev->resource). | 295 | * resources owned by the device (@dev->resource). |
301 | */ | 296 | */ |
302 | void platform_device_unregister(struct platform_device * pdev) | 297 | void platform_device_del(struct platform_device *pdev) |
303 | { | 298 | { |
304 | int i; | 299 | int i; |
305 | 300 | ||
@@ -310,9 +305,37 @@ void platform_device_unregister(struct platform_device * pdev) | |||
310 | release_resource(r); | 305 | release_resource(r); |
311 | } | 306 | } |
312 | 307 | ||
313 | device_unregister(&pdev->dev); | 308 | device_del(&pdev->dev); |
314 | } | 309 | } |
315 | } | 310 | } |
311 | EXPORT_SYMBOL_GPL(platform_device_del); | ||
312 | |||
313 | /** | ||
314 | * platform_device_register - add a platform-level device | ||
315 | * @pdev: platform device we're adding | ||
316 | * | ||
317 | */ | ||
318 | int platform_device_register(struct platform_device * pdev) | ||
319 | { | ||
320 | device_initialize(&pdev->dev); | ||
321 | return platform_device_add(pdev); | ||
322 | } | ||
323 | EXPORT_SYMBOL_GPL(platform_device_register); | ||
324 | |||
325 | /** | ||
326 | * platform_device_unregister - unregister a platform-level device | ||
327 | * @pdev: platform device we're unregistering | ||
328 | * | ||
329 | * Unregistration is done in 2 steps. Fisrt we release all resources | ||
330 | * and remove it from the sybsystem, then we drop reference count by | ||
331 | * calling platform_device_put(). | ||
332 | */ | ||
333 | void platform_device_unregister(struct platform_device * pdev) | ||
334 | { | ||
335 | platform_device_del(pdev); | ||
336 | platform_device_put(pdev); | ||
337 | } | ||
338 | EXPORT_SYMBOL_GPL(platform_device_unregister); | ||
316 | 339 | ||
317 | /** | 340 | /** |
318 | * platform_device_register_simple | 341 | * platform_device_register_simple |
@@ -355,6 +378,7 @@ error: | |||
355 | platform_device_put(pdev); | 378 | platform_device_put(pdev); |
356 | return ERR_PTR(retval); | 379 | return ERR_PTR(retval); |
357 | } | 380 | } |
381 | EXPORT_SYMBOL_GPL(platform_device_register_simple); | ||
358 | 382 | ||
359 | static int platform_drv_probe(struct device *_dev) | 383 | static int platform_drv_probe(struct device *_dev) |
360 | { | 384 | { |
@@ -476,6 +500,7 @@ struct bus_type platform_bus_type = { | |||
476 | .suspend = platform_suspend, | 500 | .suspend = platform_suspend, |
477 | .resume = platform_resume, | 501 | .resume = platform_resume, |
478 | }; | 502 | }; |
503 | EXPORT_SYMBOL_GPL(platform_bus_type); | ||
479 | 504 | ||
480 | int __init platform_bus_init(void) | 505 | int __init platform_bus_init(void) |
481 | { | 506 | { |
@@ -504,14 +529,3 @@ u64 dma_get_required_mask(struct device *dev) | |||
504 | } | 529 | } |
505 | EXPORT_SYMBOL_GPL(dma_get_required_mask); | 530 | EXPORT_SYMBOL_GPL(dma_get_required_mask); |
506 | #endif | 531 | #endif |
507 | |||
508 | EXPORT_SYMBOL_GPL(platform_bus); | ||
509 | EXPORT_SYMBOL_GPL(platform_bus_type); | ||
510 | EXPORT_SYMBOL_GPL(platform_add_devices); | ||
511 | EXPORT_SYMBOL_GPL(platform_device_register); | ||
512 | EXPORT_SYMBOL_GPL(platform_device_register_simple); | ||
513 | EXPORT_SYMBOL_GPL(platform_device_unregister); | ||
514 | EXPORT_SYMBOL_GPL(platform_get_irq); | ||
515 | EXPORT_SYMBOL_GPL(platform_get_resource); | ||
516 | EXPORT_SYMBOL_GPL(platform_get_irq_byname); | ||
517 | EXPORT_SYMBOL_GPL(platform_get_resource_byname); | ||