diff options
author | Dmitry Torokhov <dtor_core@ameritech.net> | 2005-12-10 01:36:27 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2006-01-04 19:18:09 -0500 |
commit | 93ce3061be212f6280e7ccafa9a7f698a95c6d75 (patch) | |
tree | a451566360fea86ef597fcd2fe693dce65626f93 /drivers/base | |
parent | e39b84337b8aed3044683a57741a19e5002225b9 (diff) |
[PATCH] Driver Core: Add platform_device_del()
Driver core: add platform_device_del function
Having platform_device_del90 allows more straightforward error
handling code in drivers registering platform devices.
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/base')
-rw-r--r-- | drivers/base/platform.c | 45 |
1 files changed, 30 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 |