From: Jonathan Cameron <jic23@kernel.org>
To: Beomho Seo <beomho.seo@samsung.com>,
linux-iio@vger.kernel.org, j.anaszewski@samsung.com,
sachin.kamat@linaro.org, ch.naveen@samsung.com,
ktsai@capellamicro.com, srinivas.pandruvada@linux.intel.com,
t.figa@samsung.com
Cc: myungjoo.ham@samsung.com, jh80.chung@samsung.com, cw00.choi@samsung.com
Subject: Re: [PATCH 5/5] iio: magnetometer: ak8975: Use devm_* APIs
Date: Sat, 21 Jun 2014 12:43:41 +0100 [thread overview]
Message-ID: <53A56FED.8090406@kernel.org> (raw)
In-Reply-To: <1403072503-29246-6-git-send-email-beomho.seo@samsung.com>
On 18/06/14 07:21, Beomho Seo wrote:
> This patch use devm_* APIs and make driver simpler.
>
> Signed-off-by: Beomho Seo <beomho.seo@samsung.com>
Hi,
Comments in line.
J
> ---
> drivers/iio/magnetometer/ak8975.c | 48 ++++++++-----------------------------
> 1 file changed, 10 insertions(+), 38 deletions(-)
>
> diff --git a/drivers/iio/magnetometer/ak8975.c b/drivers/iio/magnetometer/ak8975.c
> index 09ea5c4..ad71160 100644
> --- a/drivers/iio/magnetometer/ak8975.c
> +++ b/drivers/iio/magnetometer/ak8975.c
> @@ -165,7 +165,7 @@ static int ak8975_setup_irq(struct ak8975_data *data)
> else
> irq = gpio_to_irq(data->eoc_gpio);
>
> - rc = request_irq(irq, ak8975_irq_handler,
> + rc = devm_request_irq(&client->dev, irq, ak8975_irq_handler,
> IRQF_TRIGGER_RISING | IRQF_ONESHOT,
> dev_name(&client->dev), data);
> if (rc < 0) {
> @@ -520,20 +520,21 @@ static int ak8975_probe(struct i2c_client *client,
> /* We may not have a GPIO based IRQ to scan, that is fine, we will
> poll if so */
> if (gpio_is_valid(eoc_gpio)) {
> - err = gpio_request_one(eoc_gpio, GPIOF_IN, "ak_8975");
> + err = devm_gpio_request_one(&client->dev, eoc_gpio,
> + GPIOF_IN, "ak_8975");
> if (err < 0) {
> dev_err(&client->dev,
> "failed to request GPIO %d, error %d\n",
> eoc_gpio, err);
> - goto exit;
> + return err;
> }
> }
>
> /* Register with IIO */
> - indio_dev = iio_device_alloc(sizeof(*data));
> + indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data));
> if (indio_dev == NULL) {
> err = -ENOMEM;
> - goto exit_gpio;
> + return err;
return -ENOMEM;
> }
> data = iio_priv(indio_dev);
> i2c_set_clientdata(client, indio_dev);
> @@ -551,7 +552,7 @@ static int ak8975_probe(struct i2c_client *client,
> name = ak8975_match_acpi_device(&client->dev, &data->chipset);
> else {
> err = -ENOSYS;
> - goto exit_free_iio;
> + return err;
If you are going to do this, please just return -ENOSYS directly rather than
leaving the intermediate step.
> }
> dev_dbg(&client->dev, "Asahi compass chip %s\n", name);
>
> @@ -559,7 +560,7 @@ static int ak8975_probe(struct i2c_client *client,
> err = ak8975_setup(client);
> if (err < 0) {
> dev_err(&client->dev, "AK8975 initialization fails\n");
> - goto exit_free_iio;
> + return err;
> }
>
> data->client = client;
> @@ -571,37 +572,9 @@ static int ak8975_probe(struct i2c_client *client,
> indio_dev->info = &ak8975_info;
> indio_dev->modes = INDIO_DIRECT_MODE;
> indio_dev->name = name;
> - err = iio_device_register(indio_dev);
> + err = devm_iio_device_register(&client->dev, indio_dev);
> if (err < 0)
> - goto exit_free_iio;
> -
> - return 0;
> -
> -exit_free_iio:
> - iio_device_free(indio_dev);
> - if (data->eoc_irq)
> - free_irq(data->eoc_irq, data);
> -exit_gpio:
> - if (gpio_is_valid(eoc_gpio))
> - gpio_free(eoc_gpio);
> -exit:
> - return err;
> -}
> -
> -static int ak8975_remove(struct i2c_client *client)
> -{
> - struct iio_dev *indio_dev = i2c_get_clientdata(client);
> - struct ak8975_data *data = iio_priv(indio_dev);
> -
> - iio_device_unregister(indio_dev);
> -
> - if (data->eoc_irq)
> - free_irq(data->eoc_irq, data);
> -
> - if (gpio_is_valid(data->eoc_gpio))
> - gpio_free(data->eoc_gpio);
> -
> - iio_device_free(indio_dev);
> + return err;
>
> return 0;
> }
> @@ -628,7 +601,6 @@ static struct i2c_driver ak8975_driver = {
> .acpi_match_table = ACPI_PTR(ak_acpi_match),
> },
> .probe = ak8975_probe,
> - .remove = ak8975_remove,
> .id_table = ak8975_id,
> };
> module_i2c_driver(ak8975_driver);
>
prev parent reply other threads:[~2014-06-21 11:41 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-18 6:21 [PATCH 0/5] iio: Using devm_* APIs in some sensor drivers Beomho Seo
2014-06-18 6:21 ` [PATCH 1/5] iio: adc: exynos_adc: Use devm_* APIs Beomho Seo
2014-06-18 6:35 ` Sachin Kamat
2014-06-18 14:53 ` Srinivas Pandruvada
2014-06-18 19:50 ` Jonathan Cameron
2014-06-18 6:21 ` [PATCH 2/5] iio: light: cm32181: " Beomho Seo
2014-06-18 8:20 ` Sachin Kamat
2014-06-21 11:44 ` Jonathan Cameron
2014-06-18 6:21 ` [PATCH 3/5] iio: light: cm36651: " Beomho Seo
2014-06-18 14:50 ` Srinivas Pandruvada
2014-06-18 6:21 ` [PATCH 4/5] iio: light: gp2ap020a00f: " Beomho Seo
2014-06-18 8:17 ` Sachin Kamat
2014-06-18 14:51 ` Srinivas Pandruvada
2014-06-18 6:21 ` [PATCH 5/5] iio: magnetometer: ak8975: " Beomho Seo
2014-06-21 11:43 ` 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=53A56FED.8090406@kernel.org \
--to=jic23@kernel.org \
--cc=beomho.seo@samsung.com \
--cc=ch.naveen@samsung.com \
--cc=cw00.choi@samsung.com \
--cc=j.anaszewski@samsung.com \
--cc=jh80.chung@samsung.com \
--cc=ktsai@capellamicro.com \
--cc=linux-iio@vger.kernel.org \
--cc=myungjoo.ham@samsung.com \
--cc=sachin.kamat@linaro.org \
--cc=srinivas.pandruvada@linux.intel.com \
--cc=t.figa@samsung.com \
/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.