Add platform_device_del()
cover Add platform_device_del()
Hi,
OK, so here is the patch adding platform_device_del() that we were discussing. The second patch just moves exports around so we do not mix two styles in one source file.
Greg, if you are OK with it - are you going to push it or maybe I should put it in my tree so I can publish pieces depending on this as they are getting ready?
--
Dmitry
PATCH 1/2 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.
---
drivers/base/platform.c | 45 ++++++++++++++++++++++++++-------------- include/linux/platform_device.h | 1 2 files changed, 31 insertions(+), 15 deletions(-)
drivers/base/platform.c +30 -15
@@ -168,7 +168,7 @@ struct platform_device *platform_device_ pa->pdev.dev.release = platform_device_release; } -return pa ? &pa->pdev :NULL ; +return pa ? &pa->pdev :NULL ; }EXPORT_SYMBOL_GPL (platform_device_alloc);
@@ -282,24 +282,13 @@ int platform_device_add(struct platform_EXPORT_SYMBOL_GPL (platform_device_add);/** -* platform_device_register - add a platform-level device -* @pdev: platform device we're adding -* -*/ -int platform_device_register (struct platform_device * pdev) -{ -device_initialize (&pdev->dev); -return platform_device_add (pdev); -} - -/** -* platform_device_unregister - remove a platform-level device +* platform_device_del - remove a platform-level device * @pdev: platform device we're removing * * Note that this function will also release all memory- and port-based * resources owned by the device (@dev->resource). */ -void platform_device_unregister (struct platform_device * pdev) +void platform_device_del (struct platform_device *pdev) {int i;
@@ -310,9 +299,35 @@ void platform_device_unregister(struct prelease_resource (r); } -device_unregister (&pdev->dev); +device_del (&pdev->dev); } } +EXPORT_SYMBOL_GPL (platform_device_del); + +/** +* platform_device_register - add a platform-level device +* @pdev: platform device we're adding +* +*/ +int platform_device_register (struct platform_device * pdev) +{ +device_initialize (&pdev->dev); +return platform_device_add (pdev); +} + +/** +* platform_device_unregister - unregister a platform-level device +* @pdev: platform device we're unregistering +* +* Unregistration is done in 2 steps. Fisrt we release all resources +* and remove it from the sybsystem, then we drop reference count by +* calling platform_device_put(). +*/ +void platform_device_unregister (struct platform_device * pdev) +{ +platform_device_del (pdev); +platform_device_put (pdev); +}/** * platform_device_register_simple
include/linux/platform_device.h +1 -0
@@ -41,6 +41,7 @@ extern struct platform_device *platform_extern int platform_device_add_resources (struct platform_device *pdev,struct resource *res,unsigned int num);extern int platform_device_add_data (struct platform_device *pdev,void *data,size_t size);extern int platform_device_add (struct platform_device *pdev); +extern void platform_device_del (struct platform_device *pdev);extern void platform_device_put (struct platform_device *pdev);struct platform_driver {
Hi Dmirty,
Quoted 11 lines
Driver core: add
platform_device_delfunctionHaving
platform_device_del90allows more straightforward error handling code in drivers registering platform devices. (...)
+/**
+ *platform_device_unregister- unregister a platform-level device
+ * @pdev: platform device we're unregistering
+ *
+ * Unregistration is done in 2 steps. Fisrt we release all resources
+ * and remove it from the sybsystem, then we drop reference count by
Typo: subsystem.
Quoted 2 lines
+ * calling
platform_device_put().
+ */
Other than that, and let alone the fact that I prefer code cleanups as separate patches, and the fact that I don't think moving platform_device_register() around adds much value, this patch looks good to me.
Thanks,
Signature · 1 line
Jean Delvare
Hi Jean,
Quoted 14 lines · Jean Delvare
Hi Dmirty,
Quoted 11 lines
Driver core: add
platform_device_delfunctionHaving
platform_device_del90allows more straightforward error handling code in drivers registering platform devices. (...)
+/**
+ *platform_device_unregister- unregister a platform-level device
+ * @pdev: platform device we're unregistering
+ *
+ * Unregistration is done in 2 steps. Fisrt we release all resources
+ * and remove it from the sybsystem, then we drop reference count by
Quoted 1 line
Typo: subsystem.
Will fix, thank you for noticing.
Quoted 9 lines
Quoted 3 lines
+ * calling
platform_device_put().
+ */Other than that, and let alone the fact that I prefer code cleanups as separate patches, and the fact that I don't think moving
platform_device_register()around adds much value, this patch looks good to me.
It was not moved ;) platform_device_register() is and was in front of platform_device_unregister. But because the new platform_device_del() reused most of the platform_device_unregister() body patch plays a trick on you making you believe that some code was moved around.
Signature · 1 line
Dmitry
PATCH 2/2 Rearrange exports in platform.c
In reply to Dmitry TorokhovDriver core: rearrange exports in platform.c
The new way is to specify export right after symbol definition. Rearrange exports to follow new style to avoid mixing two styles in one file.
---
drivers/base/platform.c | 21 ++++++++++----------- 1 files changed, 10 insertions(+), 11 deletions(-)
drivers/base/platform.c +10 -11
@@ -25,6 +25,7 @@struct device platform_bus = { .bus_id ="platform" , }; +EXPORT_SYMBOL_GPL (platform_bus);/** * platform_get_resource - get a resource for a device
@@ -49,6 +50,7 @@ platform_get_resource(struct platform_de }return NULL ; } +EXPORT_SYMBOL_GPL (platform_get_resource);/** * platform_get_irq - get an IRQ for a device
@@ -61,6 +63,7 @@ int platform_get_irq(struct platform_devreturn r ? r->start :0 ; } +EXPORT_SYMBOL_GPL (platform_get_irq);/** * platform_get_resource_byname - get a resource for a device by name
@@ -84,6 +87,7 @@ platform_get_resource_byname(struct plat }return NULL ; } +EXPORT_SYMBOL_GPL (platform_get_resource_byname);/** * platform_get_irq - get an IRQ for a device
@@ -96,6 +100,7 @@ int platform_get_irq_byname(struct platfreturn r ? r->start :0 ; } +EXPORT_SYMBOL_GPL (platform_get_irq_byname);/** * platform_add_devices - add a numbers of platform devices
@@ -117,6 +122,7 @@ int platform_add_devices(struct platformreturn ret; } +EXPORT_SYMBOL_GPL (platform_add_devices);struct platform_object {struct platform_device pdev;
@@ -314,6 +320,7 @@ int platform_device_register(struct platdevice_initialize (&pdev->dev);return platform_device_add (pdev); } +EXPORT_SYMBOL_GPL (platform_device_register);/** * platform_device_unregister - unregister a platform-level device
@@ -328,6 +335,7 @@ void platform_device_unregister(struct pplatform_device_del (pdev);platform_device_put (pdev); } +EXPORT_SYMBOL_GPL (platform_device_unregister);/** * platform_device_register_simple
@@ -370,6 +378,7 @@ error:platform_device_put (pdev);return ERR_PTR (retval); } +EXPORT_SYMBOL_GPL (platform_device_register_simple);static int platform_drv_probe (struct device *_dev) {
@@ -491,6 +500,7 @@ struct bus_type platform_bus_type = { .suspend = platform_suspend, .resume = platform_resume, }; +EXPORT_SYMBOL_GPL (platform_bus_type);int __init platform_bus_init (void ) {
@@ -519,14 +529,3 @@ u64 dma_get_required_mask(struct device }EXPORT_SYMBOL_GPL (dma_get_required_mask);#endif - -EXPORT_SYMBOL_GPL (platform_bus); -EXPORT_SYMBOL_GPL (platform_bus_type); -EXPORT_SYMBOL_GPL (platform_add_devices); -EXPORT_SYMBOL_GPL (platform_device_register); -EXPORT_SYMBOL_GPL (platform_device_register_simple); -EXPORT_SYMBOL_GPL (platform_device_unregister); -EXPORT_SYMBOL_GPL (platform_get_irq); -EXPORT_SYMBOL_GPL (platform_get_resource); -EXPORT_SYMBOL_GPL (platform_get_irq_byname); -EXPORT_SYMBOL_GPL (platform_get_resource_byname);