diff options
-rw-r--r-- | drivers/base/platform.c | 45 | ||||
-rw-r--r-- | include/linux/platform_device.h | 1 |
2 files changed, 31 insertions, 15 deletions
diff --git a/drivers/base/platform.c b/drivers/base/platform.c index 1091af1cbb58..95ecfc490d54 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c | |||
@@ -168,7 +168,7 @@ struct platform_device *platform_device_alloc(const char *name, unsigned int id) | |||
168 | pa->pdev.dev.release = platform_device_release; | 168 | pa->pdev.dev.release = platform_device_release; |
169 | } | 169 | } |
170 | 170 | ||
171 | return pa ? &pa->pdev : NULL; | 171 | return pa ? &pa->pdev : NULL; |
172 | } | 172 | } |
173 | EXPORT_SYMBOL_GPL(platform_device_alloc); | 173 | EXPORT_SYMBOL_GPL(platform_device_alloc); |
174 | 174 | ||
@@ -282,24 +282,13 @@ int platform_device_add(struct platform_device *pdev) | |||
282 | EXPORT_SYMBOL_GPL(platform_device_add); | 282 | EXPORT_SYMBOL_GPL(platform_device_add); |
283 | 283 | ||
284 | /** | 284 | /** |
285 | * platform_device_register - add a platform-level device | 285 | * 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 | 286 | * @pdev: platform device we're removing |
298 | * | 287 | * |
299 | * Note that this function will also release all memory- and port-based | 288 | * Note that this function will also release all memory- and port-based |
300 | * resources owned by the device (@dev->resource). | 289 | * resources owned by the device (@dev->resource). |
301 | */ | 290 | */ |
302 | void platform_device_unregister(struct platform_device * pdev) | 291 | void platform_device_del(struct platform_device *pdev) |
303 | { | 292 | { |
304 | int i; | 293 | int i; |
305 | 294 | ||
@@ -310,9 +299,35 @@ void platform_device_unregister(struct platform_device * pdev) | |||
310 | release_resource(r); | 299 | release_resource(r); |
311 | } | 300 | } |
312 | 301 | ||
313 | device_unregister(&pdev->dev); | 302 | device_del(&pdev->dev); |
314 | } | 303 | } |
315 | } | 304 | } |
305 | EXPORT_SYMBOL_GPL(platform_device_del); | ||
306 | |||
307 | /** | ||
308 | * platform_device_register - add a platform-level device | ||
309 | * @pdev: platform device we're adding | ||
310 | * | ||
311 | */ | ||
312 | int platform_device_register(struct platform_device * pdev) | ||
313 | { | ||
314 | device_initialize(&pdev->dev); | ||
315 | return platform_device_add(pdev); | ||
316 | } | ||
317 | |||
318 | /** | ||
319 | * platform_device_unregister - unregister a platform-level device | ||
320 | * @pdev: platform device we're unregistering | ||
321 | * | ||
322 | * Unregistration is done in 2 steps. Fisrt we release all resources | ||
323 | * and remove it from the sybsystem, then we drop reference count by | ||
324 | * calling platform_device_put(). | ||
325 | */ | ||
326 | void platform_device_unregister(struct platform_device * pdev) | ||
327 | { | ||
328 | platform_device_del(pdev); | ||
329 | platform_device_put(pdev); | ||
330 | } | ||
316 | 331 | ||
317 | /** | 332 | /** |
318 | * platform_device_register_simple | 333 | * platform_device_register_simple |
diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h index 17e336f40b47..782090c68932 100644 --- a/include/linux/platform_device.h +++ b/include/linux/platform_device.h | |||
@@ -41,6 +41,7 @@ extern struct platform_device *platform_device_alloc(const char *name, unsigned | |||
41 | extern int platform_device_add_resources(struct platform_device *pdev, struct resource *res, unsigned int num); | 41 | extern int platform_device_add_resources(struct platform_device *pdev, struct resource *res, unsigned int num); |
42 | extern int platform_device_add_data(struct platform_device *pdev, void *data, size_t size); | 42 | extern int platform_device_add_data(struct platform_device *pdev, void *data, size_t size); |
43 | extern int platform_device_add(struct platform_device *pdev); | 43 | extern int platform_device_add(struct platform_device *pdev); |
44 | extern void platform_device_del(struct platform_device *pdev); | ||
44 | extern void platform_device_put(struct platform_device *pdev); | 45 | extern void platform_device_put(struct platform_device *pdev); |
45 | 46 | ||
46 | struct platform_driver { | 47 | struct platform_driver { |