mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: berringtoni36@gmail.com
Cc: "Jonathan Cameron" <jic23@kernel.org>,
	"Nuno Sá" <nuno.sa@analog.com>,
	"Michael Hennerich" <Michael.Hennerich@analog.com>,
	"David Lechner" <dlechner@baylibre.com>,
	"Andy Shevchenko" <andy@kernel.org>,
	"Lothar Rubusch" <l.rubusch@gmail.com>,
	"Joshua Crofts" <joshua.crofts1@gmail.com>,
	linux@analog.com, linux-iio@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3] iio: accel: adxl345: separate event state from query errors
Date: Mon, 19 Oct 2026 13:20:42 +0300	[thread overview]
Message-ID: <atXu-v1i-xfbEpr8@ashevche-desk.local> (raw)
In-Reply-To: <20261018-adxl345-event-state-v3-1@gmail.com>

On Sun, Oct 18, 2026 at 09:42:00PM +0800, Wenqiang Zhao via B4 Relay wrote:
> From: Wenqiang Zhao <berringtoni36@gmail.com>
> 
> The activity/inactivity query helpers return either a boolean result or a
> negative regmap error. adxl345_read_mag_config() converts the latter to 1
> with !!, reporting a failed read as an enabled event. The disable path
> also turns a coupling query error into a successful write.
> 
> Return query status separately from the boolean result by passing bool
> output parameters to both helpers. Rename them from is_* to get_* and
> update the event read, disable and link-bit callers to check the status
> before using the result. Preserve the successful coupling-mismatch
> no-op when disabling an event.

...

>  	switch (type) {
>  	case ADXL345_ACTIVITY:
>  	case ADXL345_INACTIVITY:
> -		return coupling == ADXL345_COUPLING_DC;
> +		*matches = coupling == ADXL345_COUPLING_DC;
> +		break;
>  	case ADXL345_ACTIVITY_AC:
>  	case ADXL345_INACTIVITY_AC:
> -		return coupling == ADXL345_COUPLING_AC;
> +		*matches = coupling == ADXL345_COUPLING_AC;
> +		break;
>  	default:
>  		return -EINVAL;
>  	}
> +
> +	return 0;

Replace 'break;':s with the direct 'return 0;':s.

...

>  static int adxl345_read_mag_config(struct adxl345_state *st,
>  				   enum adxl345_activity_type type_act,
>  				   enum adxl345_activity_type type_inact)
>  {
> +	bool enabled;
> +	int ret;
> +
>  	switch (dir) {
>  	case IIO_EV_DIR_RISING:
> -		ret = adxl345_get_act_inact_en(st, type_act, &enabled);
> +		ret = adxl345_get_act_inact_en(st, type_act, &enabled);
>  		break;

It's better to spread

		if (ret)
			return ret;

here...

>  	case IIO_EV_DIR_FALLING:
> -		ret = adxl345_get_act_inact_en(st, type_inact, &enabled);
> +		ret = adxl345_get_act_inact_en(st, type_inact, &enabled);
>  		break;

...and here...

>  	default:
>  		return -EINVAL;
>  	}

> +	if (ret)
> +		return ret;
> +

...and avoid adding this one.

>  	return enabled;
>  }

-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2026-10-19 10:20 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-18 13:42 Wenqiang Zhao via B4 Relay
2026-10-19 10:20 ` Andy Shevchenko [this message]
2026-10-19 12:53   ` Iron Berrington
2026-10-19 13:05 ` [PATCH v4] " Wenqiang Zhao via B4 Relay

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=atXu-v1i-xfbEpr8@ashevche-desk.local \
    --to=andriy.shevchenko@intel.com \
    --cc=Michael.Hennerich@analog.com \
    --cc=andy@kernel.org \
    --cc=berringtoni36@gmail.com \
    --cc=dlechner@baylibre.com \
    --cc=jic23@kernel.org \
    --cc=joshua.crofts1@gmail.com \
    --cc=l.rubusch@gmail.com \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@analog.com \
    --cc=nuno.sa@analog.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

all inboxes | Powered by JetHome®