Skip to contentSkip to conversation

power_supply: da9052-battery: Add missing platform_set_drvdata

PATCH In review Axel Lin 2 participants 4 messages Jan 11, 2012 – Mar 15, 2012

lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH 1/3 power_supply: 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.

---
 drivers/power/da9052-battery.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
drivers/power/da9052-battery.c +1 -0
index e8ea47a..07d5b36 100644
@@ -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:
Signature · 1 line
1.7.5.4
author
#1 lore raw

PATCH 2/3 power_supply: da9052-battery: Fix a memory leak when unload the module

---
 drivers/power/da9052-battery.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
drivers/power/da9052-battery.c +1 -0
index 07d5b36..daf52a4 100644
@@ -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;
 }
Signature · 1 line
1.7.5.4
author
#2 lore raw

PATCH 3/3 power_supply: da9052-battery: Convert to use module_platform_driver

In reply to Axel Lin

Use the module_platform_driver() macro which makes the code smaller and a bit simpler.

---
 drivers/power/da9052-battery.c |   12 +-----------
 1 files changed, 1 insertions(+), 11 deletions(-)
drivers/power/da9052-battery.c +1 -11
index daf52a4..d648ba9 100644
@@ -648,17 +648,7 @@ static struct platform_driver da9052_bat_driver = {
 	},
 };
 
-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 <[email protected]>");
Signature · 1 line
1.7.5.4