Skip to contentSkip to conversation

mfd: tps6586x - free allocated resources when unload the module

PATCH Axel Lin 2 participants 2 messages Aug 23, 2010 – Sep 10, 2010 Multifunction devices (MFD)

lore
Share & tools
lore

Axel Lin

author
#0 lore raw

For the resources allocated in tps6586x_i2c_probe(), we need to free it in tps6586x_i2c_remove().

---
 drivers/mfd/tps6586x.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)
drivers/mfd/tps6586x.c +15 -0
index 4cde31e..6eb2730 100644
@@ -338,6 +338,21 @@ err_add_devs:
 
 static int __devexit tps6586x_i2c_remove(struct i2c_client *client)
 {
+	struct tps6586x *tps6586x = i2c_get_clientdata(client);
+	struct tps6586x_platform_data *pdata = client->dev.platform_data;
+	int ret;
+
+	if (pdata->gpio_base) {
+		ret = gpiochip_remove(&tps6586x->gpio);
+		if (ret) {
+			dev_err(&client->dev, "Can't remove gpio chip: %d\n",
+				ret);
+			return ret;
+		}
+	}
+
+	tps6586x_remove_subdevs(tps6586x);
+	kfree(tps6586x);
 	return 0;
 }
 
Signature · 1 line
1.7.2
#1 lore raw

Hi Axel,

Quoted 2 lines · Axel Lin

For the resources allocated in tps6586x_i2c_probe(), we need to free it in tps6586x_i2c_remove().

Thanks, patch applied.

Cheers,
Samuel.

Signature · 2 lines
Intel Open Source Technology Centre
http://oss.intel.com/