From e1be8329991b708adbb4e767bcfd6ad1f92bae65 Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Wed, 11 Jan 2012 15:43:44 +0800 Subject: da9052-battery: Add missing platform_set_drvdata Add missing platform_set_drvdata in da9052_bat_probe. Otherwise, calling platform_get_drvdata in da9052_bat_remove returns NULL. Signed-off-by: Axel Lin Signed-off-by: Anton Vorontsov --- drivers/power/da9052-battery.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/power/da9052-battery.c') diff --git a/drivers/power/da9052-battery.c b/drivers/power/da9052-battery.c index e8ea47a53dee..07d5b36535d5 100644 --- a/drivers/power/da9052-battery.c +++ b/drivers/power/da9052-battery.c @@ -612,6 +612,7 @@ static s32 __devinit da9052_bat_probe(struct platform_device *pdev) if (ret) goto err; + platform_set_drvdata(pdev, bat); return 0; err: -- cgit v1.2.3 From 61bb5a780dd4f50aa4dc859c28f1e8820d763b42 Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Wed, 11 Jan 2012 15:44:37 +0800 Subject: da9052-battery: Fix a memory leak when unload the module Signed-off-by: Axel Lin Signed-off-by: Anton Vorontsov --- drivers/power/da9052-battery.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/power/da9052-battery.c') diff --git a/drivers/power/da9052-battery.c b/drivers/power/da9052-battery.c index 07d5b36535d5..daf52a4b17bb 100644 --- a/drivers/power/da9052-battery.c +++ b/drivers/power/da9052-battery.c @@ -634,6 +634,7 @@ static int __devexit da9052_bat_remove(struct platform_device *pdev) free_irq(bat->da9052->irq_base + irq, bat); } power_supply_unregister(&bat->psy); + kfree(bat); return 0; } -- cgit v1.2.3 From 534f5306d701e2717b039898888bfbb8584186bd Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Wed, 11 Jan 2012 15:45:56 +0800 Subject: da9052-battery: Convert to use module_platform_driver Use the module_platform_driver() macro which makes the code smaller and a bit simpler. Signed-off-by: Axel Lin Signed-off-by: Anton Vorontsov --- drivers/power/da9052-battery.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) (limited to 'drivers/power/da9052-battery.c') diff --git a/drivers/power/da9052-battery.c b/drivers/power/da9052-battery.c index daf52a4b17bb..a5f6a0ec1572 100644 --- a/drivers/power/da9052-battery.c +++ b/drivers/power/da9052-battery.c @@ -647,18 +647,7 @@ static struct platform_driver da9052_bat_driver = { .owner = THIS_MODULE, }, }; - -static int __init da9052_bat_init(void) -{ - return platform_driver_register(&da9052_bat_driver); -} -module_init(da9052_bat_init); - -static void __exit da9052_bat_exit(void) -{ - platform_driver_unregister(&da9052_bat_driver); -} -module_exit(da9052_bat_exit); +module_platform_driver(da9052_bat_driver); MODULE_DESCRIPTION("DA9052 BAT Device Driver"); MODULE_AUTHOR("David Dajun Chen "); -- cgit v1.2.3