public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Maxwell Doose <m32285159@gmail.com>
Cc: songqiang1304521@gmail.com, jic23@kernel.org,
	dlechner@baylibre.com, nuno.sa@analog.com, andy@kernel.org,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3] iio: magnetometer: rm3100: Modernize locking and refactor control flow
Date: Wed, 29 Apr 2026 12:12:01 +0300	[thread overview]
Message-ID: <afHLYbjUjE-kQGer@ashevche-desk.local> (raw)
In-Reply-To: <20260428222600.91322-1-m32285159@gmail.com>

On Tue, Apr 28, 2026 at 05:26:00PM -0500, Maxwell Doose wrote:
> Replace mutex_lock() and mutex_unlock() calls in rm3100-core.c with
> the more modern guard(mutex)() family. This will help modernize the
> driver and bring it up-to-date with modern available macros/functions.
> 
> While replacing mutex_lock() and mutex_unlock(), the critical sections
> of rm3100_read_mag() and rm3100_get_samp_freq() have been extended to
> include negligible operations for cleaner logic.
> 
> Add new helper-wrapper function rm3100_guarded_regmap_bulk_read() to
> help keep rm3100_trigger_handler() switch-cases clean while maintaining
> mutex locking and avoiding re-entrancy risks from potential callbacks.
> 
> While at it, remove redundant gotos where applicable, and use direct
> returns instead.

...

> +/**
> + * rm3100_guarded_regmap_bulk_read() - Wrapper around regmap_bulk_read() with a mutex
> + *
> + * @lock: Mutex to lock while performing operations
> + * @map: Register map to read from, passed to regmap_bulk_read()
> + * @reg: First register to be read from, passed to regmap_bulk_read()
> + * @val: Pointer to store read value, in native register size for device,
> + * passed to regmap_bulk_read()
> + * @val_count: Number of registers to read, passed to regmap_bulk_read()
> + *
> + * Intended for use only in rm3100_trigger_handler().
> + *

I don't mind having kernel-doc for a static function, but if you do that,
validate. Here is "Return section is missing".

Needs to be

 * Return:

> + * A value of zero will be returned on success, a negative errno will
> + * be returned in error cases.

 * A value of zero on success, a negative errno in error cases.

> + */
> +static int rm3100_guarded_regmap_bulk_read(struct mutex *lock, struct regmap *map,

No, supply *data and not a *lock.

> +					   unsigned int reg, void *val, size_t val_count)

static int rm3100_guarded_regmap_bulk_read(struct rm3100_data *data, unsigned int reg,
					   void *val, size_t val_count)
> +{
> +	guard(mutex)(lock);
> +	return regmap_bulk_read(map, reg, val, val_count);

	guard(mutex)(&data->lock);
	return regmap_bulk_read(data->regmap, reg, val, val_count);

> +}

-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2026-04-29  9:12 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-28 22:26 [PATCH v3] iio: magnetometer: rm3100: Modernize locking and refactor control flow Maxwell Doose
2026-04-29  9:12 ` Andy Shevchenko [this message]
2026-04-29 14:26   ` Maxwell Doose
2026-04-29 18:22     ` Andy Shevchenko
2026-04-29 18:58       ` Maxwell Doose
2026-04-29 10:41 ` Jonathan Cameron
2026-04-29 15:19   ` Maxwell Doose
2026-04-29 18:26     ` Andy Shevchenko
2026-04-29 19:00       ` Maxwell Doose
2026-04-29 19:12         ` Andy Shevchenko
2026-04-29 20:38           ` Maxwell Doose

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=afHLYbjUjE-kQGer@ashevche-desk.local \
    --to=andriy.shevchenko@intel.com \
    --cc=andy@kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=jic23@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=m32285159@gmail.com \
    --cc=nuno.sa@analog.com \
    --cc=songqiang1304521@gmail.com \
    /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