The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Aldo Conte <aldocontelk@gmail.com>
Cc: dlechner@baylibre.com, nuno.sa@analog.com, andy@kernel.org,
	shuah@kernel.org, joshua.crofts1@gmail.com,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-kernel-mentees@lists.linux.dev
Subject: Re: [PATCH v3 3/8] iio: tcs3472: convert remaining locking to guard(mutex)
Date: Tue, 26 May 2026 13:57:47 +0100	[thread overview]
Message-ID: <20260526135747.230b7a6d@jic23-huawei> (raw)
In-Reply-To: <20260522123420.45495-4-aldocontelk@gmail.com>


>  
>  static irqreturn_t tcs3472_event_handler(int irq, void *priv)
> @@ -445,16 +433,16 @@ static int tcs3472_powerdown(struct tcs3472_data *data)
>  	int ret;
>  	u8 enable_mask = TCS3472_ENABLE_AEN | TCS3472_ENABLE_PON;
>  
> -	mutex_lock(&data->lock);
> +	guard(mutex)(&data->lock);
>  
>  	ret = i2c_smbus_write_byte_data(data->client, TCS3472_ENABLE,
>  					data->enable & ~enable_mask);
> -	if (!ret)
> -		data->enable &= ~enable_mask;
> +	if (ret)
> +		return ret;
>  
> -	mutex_unlock(&data->lock);
> +	data->enable &= ~enable_mask;

Hi Aldo,

I'm going to comment on a similar (but worse) case in review of patch 8.
If you do rework that to avoid falsely setting cached state that we can't
rely on being right, you could switch to using a local variable here.

	u8 enable = data->enable & ~(TCS3472_ENABLE_AEN | TCS3472_ENABLE_PON);

	ret = i2c_smbus_write_byte_data(data->client, TCS3472_ENABLE, enable);
  	if (ret)
		return ret;

	data->enable = enable;

	return 0;

(similar for other cases).  Given it's unrelated to what you are doing here
that doesn't stop me picking up this patch as is.

I'm working through the series, but so far 1-3 applied to the testing branch
of iio.git.

Thanks,

Jonathan


> -	return ret;
> +	return 0;
>  }
>  
>  static int tcs3472_probe(struct i2c_client *client)
> @@ -583,16 +571,16 @@ static int tcs3472_resume(struct device *dev)
>  	int ret;
>  	u8 enable_mask = TCS3472_ENABLE_AEN | TCS3472_ENABLE_PON;
>  
> -	mutex_lock(&data->lock);
> +	guard(mutex)(&data->lock);
>  
>  	ret = i2c_smbus_write_byte_data(data->client, TCS3472_ENABLE,
>  		data->enable | enable_mask);
> -	if (!ret)
> -		data->enable |= enable_mask;
> +	if (ret)
> +		return ret;
>  
> -	mutex_unlock(&data->lock);
> +	data->enable |= enable_mask;
>  
> -	return ret;
> +	return 0;
>  }
>  
>  static DEFINE_SIMPLE_DEV_PM_OPS(tcs3472_pm_ops, tcs3472_suspend,


  reply	other threads:[~2026-05-26 12:57 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-22 12:34 [PATCH v3 0/8] iio: tcs3472: cleanups, devm conversion and wait time Aldo Conte
2026-05-22 12:34 ` [PATCH v3 1/8] iio: tcs3472: power down chip on probe failure Aldo Conte
2026-05-22 12:34 ` [PATCH v3 2/8] iio: tcs3472: sort headers alphabetically Aldo Conte
2026-05-22 12:34 ` [PATCH v3 3/8] iio: tcs3472: convert remaining locking to guard(mutex) Aldo Conte
2026-05-26 12:57   ` Jonathan Cameron [this message]
2026-05-22 12:34 ` [PATCH v3 4/8] iio: tcs3472: use ! instead of explicit NULL check Aldo Conte
2026-05-26 12:58   ` Jonathan Cameron
2026-06-04  8:31   ` Andy Shevchenko
2026-06-04  8:38     ` Joshua Crofts
2026-06-04 10:37       ` Jonathan Cameron
2026-05-22 12:34 ` [PATCH v3 5/8] iio: tcs3472: use devm for resource management Aldo Conte
2026-05-26 13:00   ` Jonathan Cameron
2026-05-22 12:34 ` [PATCH v3 6/8] iio: tcs3472: use local struct device * for remaining cases Aldo Conte
2026-05-26 13:04   ` Jonathan Cameron
2026-05-22 12:34 ` [PATCH v3 7/8] iio: tcs3472: move standalone return to default case Aldo Conte
2026-05-22 12:34 ` [PATCH v3 8/8] iio: tcs3472: implement wait time and sampling frequency Aldo Conte
2026-05-26 13:11   ` Jonathan Cameron
2026-05-26 15:10     ` Aldo Conte
2026-05-26 16:52       ` Jonathan Cameron
2026-06-04  8:10   ` Aldo Conte
2026-06-04 10:42     ` Jonathan Cameron
2026-06-04  9:23   ` Aldo Conte
2026-06-06  9:27     ` Aldo Conte
2026-06-06 14:09       ` Jonathan Cameron
2026-06-07  9:44         ` Aldo Conte

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=20260526135747.230b7a6d@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=aldocontelk@gmail.com \
    --cc=andy@kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=joshua.crofts1@gmail.com \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel-mentees@lists.linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nuno.sa@analog.com \
    --cc=shuah@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