Re: [PATCH][RFC] drivers/firmware/dcdbas: rework to get uevents

Frank Seidel
2007-11-16T10:54:12Z

On Mittwoch 14 November 2007 19:32:01, you (Frank Seidel) wrote:
> Hi,
>
> this is a small trivial rework of the dcdbas driver so
> HAL can get uevents when platform devices are added or removed.

Sorry for the noise! In the meantime i realized (thanks to a nice
colleague) this isn't really necessary anymore since patch
43cc71eed1250755986da4c0f9898f9a635cb3bf is in mainline.

If you'd anyway to add this patch i gues this is a better version
of it.

Thanks,
Frank
---
Trivial little change to use new platform platform_register_device to
also get uevents on loading and unloading the driver (e.g. needed for HAL).

Signed-off-by: Frank Seidel <fseidel@suse.de>
---
drivers/firmware/dcdbas.c | 38 +++++++++++++++++++++++++-------------
1 files changed, 25 insertions(+), 13 deletions(-)

--- a/drivers/firmware/dcdbas.c
+++ b/drivers/firmware/dcdbas.c
@@ -40,7 +40,7 @@
#include "dcdbas.h"

#define DRIVER_NAME "dcdbas"
-#define DRIVER_VERSION "5.6.0-3.2"
+#define DRIVER_VERSION "5.6.0-3.3"
#define DRIVER_DESCRIPTION "Dell Systems Management Base Driver"

static struct platform_device *dcdbas_pdev;
@@ -50,6 +50,7 @@ static dma_addr_t smi_data_buf_handle;
static unsigned long smi_data_buf_size;
static u32 smi_data_buf_phys_addr;
static DEFINE_MUTEX(smi_data_lock);
+static char driver_name[] = DRIVER_NAME;

static unsigned int host_control_action;
static unsigned int host_control_smi_type;
@@ -596,6 +597,15 @@ static struct platform_driver dcdbas_dri
.remove = __devexit_p(dcdbas_remove),
};

+static void __devexit dcdbas_release(struct device *dev)
+{
+ struct platform_device *pd =
+ container_of(dev, struct platform_device, dev);
+
+ kfree(dev->platform_data);
+ kfree(pd->resource);
+}
+
/**
* dcdbas_init: initialize driver
*/
@@ -603,26 +613,27 @@ static int __init dcdbas_init(void)
{
int error;

+ dcdbas_pdev = kmalloc(sizeof(*dcdbas_pdev), GFP_KERNEL);
+ if (!dcdbas_pdev)
+ return -ENOMEM;
+
error = platform_driver_register(&dcdbas_driver);
if (error)
- return error;
+ goto err_malloc;

- dcdbas_pdev = platform_device_alloc(DRIVER_NAME, -1);
- if (!dcdbas_pdev) {
- error = -ENOMEM;
- goto err_unregister_driver;
- }
-
- error = platform_device_add(dcdbas_pdev);
+ dcdbas_pdev->name = driver_name;
+ dcdbas_pdev->id = -1;
+ dcdbas_pdev->dev.release = dcdbas_release;
+ error = platform_device_register(dcdbas_pdev);
if (error)
- goto err_free_device;
+ goto err_unregister_driver;

return 0;

- err_free_device:
- platform_device_put(dcdbas_pdev);
- err_unregister_driver:
+err_unregister_driver:
platform_driver_unregister(&dcdbas_driver);
+err_malloc:
+ kfree(dcdbas_pdev);
return error;
}

@@ -647,6 +658,7 @@ static void __exit dcdbas_exit(void)
* released.
*/
smi_data_buf_free();
+ kfree(dcdbas_pdev);
}

module_init(dcdbas_init);