From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Aldo Conte <aldocontelk@gmail.com>
Cc: jic23@kernel.org, dlechner@baylibre.com, nuno.sa@analog.com,
andy@kernel.org, shuah@kernel.org, linux-iio@vger.kernel.org,
linux-kernel@vger.kernel.org,
linux-kernel-mentees@lists.linux.dev
Subject: Re: [PATCH 3/3] iio: light: tcs3472: Use guard(mutex)() family over manual locking
Date: Wed, 6 May 2026 13:04:48 +0300 [thread overview]
Message-ID: <afsSQN04yWVSLM2y@ashevche-desk.local> (raw)
In-Reply-To: <20260506094311.222500-4-aldocontelk@gmail.com>
On Wed, May 06, 2026 at 11:43:11AM +0200, Aldo Conte wrote:
> Convert tcs3472_read_event_config, tcs3472_write_event_config,
> tcs3472_write_event, tcs3472_powerdown and tcs3472_resume to use
> automatico cleanup with guard(mutex)() instead of the old manual
> locking method.
> Found by code inspection.
Huh?! Is it a bug? What is the inspection assumed here?
> Tested on a Raspberry Pi 3B with a TCS34725 at 0x29 address.
> The following fields were read and written without any issues:
> sampling_frequency, integration_time, calibscale and the
> threshold event interface.
> The unload of the driver works cleanly.
The comments should be in the cover letter and not in each of the commit
message, we do not want that noise here!
> Signed-off-by: Aldo Conte <aldocontelk@gmail.com>
So, do not do ping-pong programming: when the code introduced in the series is
immediately being changed by another patch in the same series. As explained
this patch should be first in the series to solve that.
...
> {
> struct tcs3472_data *data = iio_priv(indio_dev);
> - int ret;
>
> - mutex_lock(&data->lock);
> - ret = !!(data->enable & TCS3472_ENABLE_AIEN);
> - mutex_unlock(&data->lock);
> -
> - return ret;
> + guard(mutex)(&data->lock);
Leave a blank line here.
> + return !!(data->enable & TCS3472_ENABLE_AIEN);
> }
...
> static int tcs3472_resume(struct device *dev)
> u8 enable_mask = TCS3472_ENABLE_AEN | TCS3472_ENABLE_PON |
> TCS3472_ENABLE_WEN;
Taking into account the comment against patch 1, add a new patch to make this
follow the patter suggested there.
> - 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;
>
> - mutex_unlock(&data->lock);
> -
> return ret;
> }
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2026-05-06 10:04 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-06 9:43 [PATCH 0/3] iio: light: tcs3472: devm conversion, wait time, locking cleanup Aldo Conte
2026-05-06 9:43 ` [PATCH 1/3] iio: light: tcs3472: use devm for resource management Aldo Conte
2026-05-06 10:00 ` Andy Shevchenko
2026-05-06 9:43 ` [PATCH 2/3] iio: light: tcs3472: implement wait time and sampling frequency Aldo Conte
2026-05-06 10:19 ` Andy Shevchenko
2026-05-06 18:17 ` Jonathan Cameron
2026-05-06 9:43 ` [PATCH 3/3] iio: light: tcs3472: Use guard(mutex)() family over manual locking Aldo Conte
2026-05-06 10:04 ` Andy Shevchenko [this message]
2026-05-06 10:21 ` [PATCH 0/3] iio: light: tcs3472: devm conversion, wait time, locking cleanup Andy Shevchenko
2026-05-06 12:19 ` Aldo Conte
2026-05-06 15:35 ` Aldo Conte
2026-05-06 15:45 ` Andy Shevchenko
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=afsSQN04yWVSLM2y@ashevche-desk.local \
--to=andriy.shevchenko@intel.com \
--cc=aldocontelk@gmail.com \
--cc=andy@kernel.org \
--cc=dlechner@baylibre.com \
--cc=jic23@kernel.org \
--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