From: Jonathan Cameron <jic23@kernel.org>
To: Chuhong Yuan <hslester96@gmail.com>
Cc: Hartmut Knaack <knaack.h@gmx.de>,
Lars-Peter Clausen <lars@metafoo.de>,
Peter Meerwald-Stadler <pmeerw@pmeerw.net>,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] iio: light: si1145: Use device-managed APIs
Date: Mon, 5 Aug 2019 15:54:20 +0100 [thread overview]
Message-ID: <20190805155403.3d45b0b5@archlinux> (raw)
In-Reply-To: <20190729014301.13402-1-hslester96@gmail.com>
On Mon, 29 Jul 2019 09:43:01 +0800
Chuhong Yuan <hslester96@gmail.com> wrote:
> Use device-managed APIs to simplify the code.
> The remove functions are redundant now and can
> be deleted.
>
> Signed-off-by: Chuhong Yuan <hslester96@gmail.com>
Nice little patch, thanks!
Applied to the togreg branch of iio.git and pushed out as testing for
the autobuilders to play with it.
Thanks,
Jonathan
> ---
> Changes in v2:
> - Split v1 into two patches.
> - Use devm_iio_trigger_register in probe_trigger,
> delete redundant remove_trigger.
> - Return devm_iio_device_register directly as a
> minor optimization.
>
> drivers/iio/light/si1145.c | 42 +++++---------------------------------
> 1 file changed, 5 insertions(+), 37 deletions(-)
>
> diff --git a/drivers/iio/light/si1145.c b/drivers/iio/light/si1145.c
> index 6579d2418814..982bba0c54e7 100644
> --- a/drivers/iio/light/si1145.c
> +++ b/drivers/iio/light/si1145.c
> @@ -1261,7 +1261,7 @@ static int si1145_probe_trigger(struct iio_dev *indio_dev)
> return ret;
> }
>
> - ret = iio_trigger_register(trig);
> + ret = devm_iio_trigger_register(&client->dev, trig);
> if (ret)
> return ret;
>
> @@ -1271,16 +1271,6 @@ static int si1145_probe_trigger(struct iio_dev *indio_dev)
> return 0;
> }
>
> -static void si1145_remove_trigger(struct iio_dev *indio_dev)
> -{
> - struct si1145_data *data = iio_priv(indio_dev);
> -
> - if (data->trig) {
> - iio_trigger_unregister(data->trig);
> - data->trig = NULL;
> - }
> -}
> -
> static int si1145_probe(struct i2c_client *client,
> const struct i2c_device_id *id)
> {
> @@ -1332,7 +1322,8 @@ static int si1145_probe(struct i2c_client *client,
> if (ret < 0)
> return ret;
>
> - ret = iio_triggered_buffer_setup(indio_dev, NULL,
> + ret = devm_iio_triggered_buffer_setup(&client->dev,
> + indio_dev, NULL,
> si1145_trigger_handler, &si1145_buffer_setup_ops);
> if (ret < 0)
> return ret;
> @@ -1340,23 +1331,12 @@ static int si1145_probe(struct i2c_client *client,
> if (client->irq) {
> ret = si1145_probe_trigger(indio_dev);
> if (ret < 0)
> - goto error_free_buffer;
> + return ret;
> } else {
> dev_info(&client->dev, "no irq, using polling\n");
> }
>
> - ret = iio_device_register(indio_dev);
> - if (ret < 0)
> - goto error_free_trigger;
> -
> - return 0;
> -
> -error_free_trigger:
> - si1145_remove_trigger(indio_dev);
> -error_free_buffer:
> - iio_triggered_buffer_cleanup(indio_dev);
> -
> - return ret;
> + return devm_iio_device_register(&client->dev, indio_dev);
> }
>
> static const struct i2c_device_id si1145_ids[] = {
> @@ -1371,23 +1351,11 @@ static const struct i2c_device_id si1145_ids[] = {
> };
> MODULE_DEVICE_TABLE(i2c, si1145_ids);
>
> -static int si1145_remove(struct i2c_client *client)
> -{
> - struct iio_dev *indio_dev = i2c_get_clientdata(client);
> -
> - iio_device_unregister(indio_dev);
> - si1145_remove_trigger(indio_dev);
> - iio_triggered_buffer_cleanup(indio_dev);
> -
> - return 0;
> -}
> -
> static struct i2c_driver si1145_driver = {
> .driver = {
> .name = "si1145",
> },
> .probe = si1145_probe,
> - .remove = si1145_remove,
> .id_table = si1145_ids,
> };
>
prev parent reply other threads:[~2019-08-05 14:54 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-29 1:43 [PATCH v2] iio: light: si1145: Use device-managed APIs Chuhong Yuan
2019-08-05 14:54 ` 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=20190805155403.3d45b0b5@archlinux \
--to=jic23@kernel.org \
--cc=hslester96@gmail.com \
--cc=knaack.h@gmx.de \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pmeerw@pmeerw.net \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).