From: Jonathan Cameron <jic23@kernel.org>
To: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: Hartmut Knaack <knaack.h@gmx.de>,
Lars-Peter Clausen <lars@metafoo.de>,
Peter Meerwald-Stadler <pmeerw@pmeerw.net>,
linux-iio@vger.kernel.org, kernel@pengutronix.de
Subject: Re: [PATCH] iio: ssp_sensors: don't manually free devm managed resources
Date: Sun, 7 Oct 2018 20:05:19 +0100 [thread overview]
Message-ID: <20181007200519.5e731736@archlinux> (raw)
In-Reply-To: <20181005194830.9332-1-u.kleine-koenig@pengutronix.de>
On Fri, 5 Oct 2018 21:48:30 +0200
Uwe Kleine-K=C3=B6nig <u.kleine-koenig@pengutronix.de> wrote:
> The charme of devm_* functions is that you don't need to care about them
> in the error path. In this case it is valid to just return NULL which mak=
es
> the device fail to probe and then the two gpios and the allocated memory
> are freed automatically by the driver core.
>=20
> Signed-off-by: Uwe Kleine-K=C3=B6nig <u.kleine-koenig@pengutronix.de>
Applied to the togreg branch of iio.git and pushed out as testing
for the autobuilders to play with it.
Thanks,
Jonathan
> ---
> drivers/iio/common/ssp_sensors/ssp_dev.c | 20 ++++++--------------
> 1 file changed, 6 insertions(+), 14 deletions(-)
>=20
> diff --git a/drivers/iio/common/ssp_sensors/ssp_dev.c b/drivers/iio/commo=
n/ssp_sensors/ssp_dev.c
> index af3aa38f67cd..9e13be2c0cb9 100644
> --- a/drivers/iio/common/ssp_sensors/ssp_dev.c
> +++ b/drivers/iio/common/ssp_sensors/ssp_dev.c
> @@ -462,43 +462,35 @@ static struct ssp_data *ssp_parse_dt(struct device =
*dev)
> =20
> data->mcu_ap_gpio =3D of_get_named_gpio(node, "mcu-ap-gpios", 0);
> if (data->mcu_ap_gpio < 0)
> - goto err_free_pd;
> + return NULL;
> =20
> data->ap_mcu_gpio =3D of_get_named_gpio(node, "ap-mcu-gpios", 0);
> if (data->ap_mcu_gpio < 0)
> - goto err_free_pd;
> + return NULL;
> =20
> data->mcu_reset_gpio =3D of_get_named_gpio(node, "mcu-reset-gpios", 0);
> if (data->mcu_reset_gpio < 0)
> - goto err_free_pd;
> + return NULL;
> =20
> ret =3D devm_gpio_request_one(dev, data->ap_mcu_gpio, GPIOF_OUT_INIT_HI=
GH,
> "ap-mcu-gpios");
> if (ret)
> - goto err_free_pd;
> + return NULL;
> =20
> ret =3D devm_gpio_request_one(dev, data->mcu_reset_gpio,
> GPIOF_OUT_INIT_HIGH, "mcu-reset-gpios");
> if (ret)
> - goto err_ap_mcu;
> + return NULL;
> =20
> match =3D of_match_node(ssp_of_match, node);
> if (!match)
> - goto err_mcu_reset_gpio;
> + return NULL;
> =20
> data->sensorhub_info =3D match->data;
> =20
> dev_set_drvdata(dev, data);
> =20
> return data;
> -
> -err_mcu_reset_gpio:
> - devm_gpio_free(dev, data->mcu_reset_gpio);
> -err_ap_mcu:
> - devm_gpio_free(dev, data->ap_mcu_gpio);
> -err_free_pd:
> - devm_kfree(dev, data);
> - return NULL;
> }
> #else
> static struct ssp_data *ssp_parse_dt(struct device *pdev)
prev parent reply other threads:[~2018-10-08 2:13 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-05 19:48 [PATCH] iio: ssp_sensors: don't manually free devm managed resources Uwe Kleine-König
2018-10-07 19:05 ` Jonathan Cameron [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181007200519.5e731736@archlinux \
--to=jic23@kernel.org \
--cc=kernel@pengutronix.de \
--cc=knaack.h@gmx.de \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=pmeerw@pmeerw.net \
--cc=u.kleine-koenig@pengutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.