linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexandru Ardelean <ardeleanalex@gmail.com>
To: Mugilraj Dhavachelvan <dmugil2000@gmail.com>
Cc: Jonathan Cameron <jic23@kernel.org>,
	Hartmut Knaack <knaack.h@gmx.de>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Peter Meerwald-Stadler <pmeerw@pmeerw.net>,
	linux-iio <linux-iio@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] iio:dac:max517: Use devm_iio_device_register()
Date: Sun, 14 Mar 2021 13:07:52 +0200	[thread overview]
Message-ID: <CA+U=DspBephozOheNQYBX9jG6bdwm4FeOTF_9tEggOWNvTQ32Q@mail.gmail.com> (raw)
In-Reply-To: <20210314093356.10609-1-dmugil2000@gmail.com>

On Sun, Mar 14, 2021 at 11:34 AM Mugilraj Dhavachelvan
<dmugil2000@gmail.com> wrote:
>
> Use devm_iio_device_register() to avoid remove function and
> drop explicit call to iio_device_unregister().
>
> Signed-off-by: Mugilraj Dhavachelvan <dmugil2000@gmail.com>
> ---
>  drivers/iio/dac/max517.c | 9 +--------
>  1 file changed, 1 insertion(+), 8 deletions(-)
>
> diff --git a/drivers/iio/dac/max517.c b/drivers/iio/dac/max517.c
> index 7e01838ef4d0..5f72f126162d 100644
> --- a/drivers/iio/dac/max517.c
> +++ b/drivers/iio/dac/max517.c
> @@ -189,13 +189,7 @@ static int max517_probe(struct i2c_client *client,
>                         data->vref_mv[chan] = platform_data->vref_mv[chan];
>         }
>
> -       return iio_device_register(indio_dev);
> -}
> -

In this case you can also remove the line with
     i2c_set_clientdata(client, indio_dev);

A lot of times, when functions like i2c_get_clientdata() get removed,
the i2c_set_clientdata() function becomes useless.
i.e. it stores some data that will never be used in the lifetime of the driver.

It isn't always the case that you can do that; so, some care must be
taken to avoid special cases.
But in this case, you can remove the i2c_set_clientdata() call.


> -static int max517_remove(struct i2c_client *client)
> -{
> -       iio_device_unregister(i2c_get_clientdata(client));
> -       return 0;
> +       return devm_iio_device_register(&client->dev, indio_dev);
>  }
>
>  static const struct i2c_device_id max517_id[] = {
> @@ -214,7 +208,6 @@ static struct i2c_driver max517_driver = {
>                 .pm     = &max517_pm_ops,
>         },
>         .probe          = max517_probe,
> -       .remove         = max517_remove,
>         .id_table       = max517_id,
>  };
>  module_i2c_driver(max517_driver);
> --
> 2.25.1
>

  reply	other threads:[~2021-03-14 11:08 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-14  9:33 [PATCH] iio:dac:max517: Use devm_iio_device_register() Mugilraj Dhavachelvan
2021-03-14 11:07 ` Alexandru Ardelean [this message]
2021-03-14 13:31   ` Mugilraj D
2021-03-14 17:57 ` [PATCH v2] iio:dac:max517.c: " Mugilraj Dhavachelvan
2021-03-15  5:55   ` Lars-Peter Clausen
2021-03-20 14:39     ` Jonathan Cameron

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='CA+U=DspBephozOheNQYBX9jG6bdwm4FeOTF_9tEggOWNvTQ32Q@mail.gmail.com' \
    --to=ardeleanalex@gmail.com \
    --cc=dmugil2000@gmail.com \
    --cc=jic23@kernel.org \
    --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).