From: Jonathan Cameron <jic23@kernel.org>
To: Hans de Goede <hdegoede@redhat.com>
Cc: Kai-Heng Feng <kai.heng.feng@canonical.com>,
lars@metafoo.de, Kevin Tsai <ktsai@capellamicro.com>,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4] iio: light: cm32181: Unregister second I2C client if present
Date: Sun, 26 Feb 2023 12:55:55 +0000 [thread overview]
Message-ID: <20230226125555.32fe6a96@jic23-huawei> (raw)
In-Reply-To: <031354f0-be2f-fe59-4ca9-b8196e5e87fa@redhat.com>
On Thu, 23 Feb 2023 09:41:29 +0100
Hans de Goede <hdegoede@redhat.com> wrote:
> Hi,
>
> On 2/23/23 03:00, Kai-Heng Feng wrote:
> > If a second dummy client that talks to the actual I2C address was
> > created in probe(), there should be a proper cleanup on driver and
> > device removal to avoid leakage.
> >
> > So unregister the dummy client via another callback.
> >
> > Reviewed-by: Hans de Goede <hdegoede@redhat.com>
> > Suggested-by: Hans de Goede <hdegoede@redhat.com>
> > Fixes: c1e62062ff54 ("iio: light: cm32181: Handle CM3218 ACPI devices with 2 I2C resources")
> > Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2152281
> > Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
>
> Thanks this patch looks good to me now, and you
> already added my Reviewed-by, so from my POV this
> is ready for merging now.
>
Applied to the fixes-togreg branch of iio.git and marked for stable inclusion.
Thanks,
Jonathan
> Regards,
>
> Hans
>
> > ---
> > v4:
> > - Remove logging kmalloc failures.
> >
> > v3:
> > - Use devm_add_action_or_reset() in a correct place.
> > - Wording.
> >
> > v2:
> > - Use devm_add_action_or_reset() instead of remove() callback to avoid
> > race.
> >
> > drivers/iio/light/cm32181.c | 12 ++++++++++++
> > 1 file changed, 12 insertions(+)
> >
> > diff --git a/drivers/iio/light/cm32181.c b/drivers/iio/light/cm32181.c
> > index b1674a5bfa368..d4a34a3bf00d9 100644
> > --- a/drivers/iio/light/cm32181.c
> > +++ b/drivers/iio/light/cm32181.c
> > @@ -429,6 +429,14 @@ static const struct iio_info cm32181_info = {
> > .attrs = &cm32181_attribute_group,
> > };
> >
> > +static void cm32181_unregister_dummy_client(void *data)
> > +{
> > + struct i2c_client *client = data;
> > +
> > + /* Unregister the dummy client */
> > + i2c_unregister_device(client);
> > +}
> > +
> > static int cm32181_probe(struct i2c_client *client)
> > {
> > struct device *dev = &client->dev;
> > @@ -460,6 +468,10 @@ static int cm32181_probe(struct i2c_client *client)
> > client = i2c_acpi_new_device(dev, 1, &board_info);
> > if (IS_ERR(client))
> > return PTR_ERR(client);
> > +
> > + ret = devm_add_action_or_reset(dev, cm32181_unregister_dummy_client, client);
> > + if (ret)
> > + return ret;
> > }
> >
> > cm32181 = iio_priv(indio_dev);
>
prev parent reply other threads:[~2023-02-26 12:41 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-23 2:00 [PATCH v4] iio: light: cm32181: Unregister second I2C client if present Kai-Heng Feng
2023-02-23 8:41 ` Hans de Goede
2023-02-26 12:55 ` 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=20230226125555.32fe6a96@jic23-huawei \
--to=jic23@kernel.org \
--cc=hdegoede@redhat.com \
--cc=kai.heng.feng@canonical.com \
--cc=ktsai@capellamicro.com \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/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