mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Hans de Goede <hdegoede@redhat.com>
To: Kai-Heng Feng <kai.heng.feng@canonical.com>,
	ktsai@capellamicro.com, jic23@kernel.org, lars@metafoo.de
Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] iio: light: cm32181: Unregister second I2C client if present
Date: Mon, 6 Feb 2023 10:51:55 +0100	[thread overview]
Message-ID: <2d5dc77a-4c57-cad5-3fb5-6dc999d3954d@redhat.com> (raw)
In-Reply-To: <20230206063616.981225-1-kai.heng.feng@canonical.com>

Hi,

On 2/6/23 07:36, Kai-Heng Feng wrote:
> If a second client that talks to the actual I2C address was created in
> probe(), there should be a corresponding cleanup in remove() to avoid
> leakage.
> 
> So if the "client" is not the same one used by I2C core, unregister it
> accordingly.
> 
> Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2152281
> Fixes: c1e62062ff54 ("iio: light: cm32181: Handle CM3218 ACPI devices with 2 I2C resources")
> Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>

Thank you for fixing this, patch looks good to me:

Reviewed-by: Hans de Goede <hdegoede@redhat.com>

Regards,

Hans




> ---
>  drivers/iio/light/cm32181.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/drivers/iio/light/cm32181.c b/drivers/iio/light/cm32181.c
> index b1674a5bfa368..37439e103d273 100644
> --- a/drivers/iio/light/cm32181.c
> +++ b/drivers/iio/light/cm32181.c
> @@ -488,6 +488,15 @@ static int cm32181_probe(struct i2c_client *client)
>  	return 0;
>  }
>  
> +static void cm32181_remove(struct i2c_client *client)
> +{
> +	struct cm32181_chip *cm32181 = iio_priv(i2c_get_clientdata(client));
> +
> +	/* Unregister the dummy client */
> +	if (cm32181->client != client)
> +		i2c_unregister_device(cm32181->client);
> +}
> +
>  static int cm32181_suspend(struct device *dev)
>  {
>  	struct cm32181_chip *cm32181 = iio_priv(dev_get_drvdata(dev));
> @@ -531,6 +540,7 @@ static struct i2c_driver cm32181_driver = {
>  		.pm = pm_sleep_ptr(&cm32181_pm_ops),
>  	},
>  	.probe_new	= cm32181_probe,
> +	.remove		= cm32181_remove,
>  };
>  
>  module_i2c_driver(cm32181_driver);


  reply	other threads:[~2023-02-06  9:53 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-06  6:36 Kai-Heng Feng
2023-02-06  9:51 ` Hans de Goede [this message]
2023-02-06 14:36 ` Jonathan Cameron
2023-02-06 14:41   ` Hans de Goede

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=2d5dc77a-4c57-cad5-3fb5-6dc999d3954d@redhat.com \
    --to=hdegoede@redhat.com \
    --cc=jic23@kernel.org \
    --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

all inboxes | Powered by JetHome®