Re: [PATCH v2] mfd: tps6586x - free allocated resources when unloadthe module

From: Eric Miao
Date: Tue Aug 24 2010 - 05:01:06 EST


On Tue, Aug 24, 2010 at 3:18 PM, Axel Lin <axel.lin@xxxxxxxxx> wrote:
> For the resources allocated in tps6586x_i2c_probe(),
> we need to free it in tps6586x_i2c_remove().
>
> Signed-off-by: Axel Lin <axel.lin@xxxxxxxxx>
> ---
> Changes since V1:
> Current implementation allows gpiochip_add() fail in probe,
> thus just show a wraning if gpiochip_remove() fail.
>
> I don't have this hardware handy,
> I am not sure that does it make sense to allow gpiochip_add() fail in probe.

That's fully possible.

>
> Âdrivers/mfd/tps6586x.c | Â 13 +++++++++++++
> Â1 files changed, 13 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/mfd/tps6586x.c b/drivers/mfd/tps6586x.c
> index 1c91936..2f9336c 100644
> --- a/drivers/mfd/tps6586x.c
> +++ b/drivers/mfd/tps6586x.c
> @@ -344,6 +344,19 @@ 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);
> + Â Â Â }
> +
> + Â Â Â tps6586x_remove_subdevs(tps6586x);
> + Â Â Â kfree(tps6586x);
> Â Â Â Âreturn 0;
> Â}
>
> --
> 1.7.2
>
>
>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/