Linux-IIO Archive mirror
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Nuno Sa <nuno.sa@analog.com>
Cc: <linux-iio@vger.kernel.org>, Lars-Peter Clausen <lars@metafoo.de>
Subject: Re: [PATCH v3 4/4] iio: inkern: move to the cleanup.h magic
Date: Sun, 3 Mar 2024 14:24:31 +0000	[thread overview]
Message-ID: <20240303142431.506c05a2@jic23-huawei> (raw)
In-Reply-To: <20240229-iio-use-cleanup-magic-v3-4-c3d34889ae3c@analog.com>

On Thu, 29 Feb 2024 16:10:28 +0100
Nuno Sa <nuno.sa@analog.com> wrote:

> Use the new cleanup magic for handling mutexes in IIO. This allows us to
> greatly simplify some code paths.
> 
> While at it, also use __free(kfree) where allocations are done and drop
> obvious comment in iio_channel_read_min().
> 
> Signed-off-by: Nuno Sa <nuno.sa@analog.com>

Hi Nuno

Series looks very nice. One trivial thing inline - I can tidy that up whilst
applying if nothing else comes up.

Given this obviously touches a lot of core code, so even though simple it's
high risk for queuing up late. I also have a complex mess already queued up
for the coming merge window. Hence I'm going to hold off on applying this
series until the start of the next cycle.

Nothing outside IIO is going to depend on it, so it's rather simpler decision
to hold it than for the ones that add new general purpose infrastructure.

Jonathan




>  EXPORT_SYMBOL_GPL(iio_read_channel_attribute);
>  
> @@ -757,29 +711,24 @@ int iio_read_channel_processed_scale(struct iio_channel *chan, int *val,
>  	struct iio_dev_opaque *iio_dev_opaque = to_iio_dev_opaque(chan->indio_dev);
>  	int ret;
>  
> -	mutex_lock(&iio_dev_opaque->info_exist_lock);
> -	if (!chan->indio_dev->info) {
> -		ret = -ENODEV;
> -		goto err_unlock;
> -	}
> +	guard(mutex)(&iio_dev_opaque->info_exist_lock);
> +	if (!chan->indio_dev->info)
> +		return -ENODEV;
>  
>  	if (iio_channel_has_info(chan->channel, IIO_CHAN_INFO_PROCESSED)) {
>  		ret = iio_channel_read(chan, val, NULL,
>  				       IIO_CHAN_INFO_PROCESSED);
>  		if (ret < 0)
> -			goto err_unlock;
> +			return ret;
>  		*val *= scale;

		return 0;

>  	} else {
could drop the else.

>  		ret = iio_channel_read(chan, val, NULL, IIO_CHAN_INFO_RAW);
>  		if (ret < 0)
> -			goto err_unlock;
> +			return ret;
>  		ret = iio_convert_raw_to_processed_unlocked(chan, *val, val,
>  							    scale);
		return iio_convert_raw_to_proc...

>  	}
>  
> -err_unlock:
> -	mutex_unlock(&iio_dev_opaque->info_exist_lock);
> -
>  	return ret;
Drop this.
>  }


  reply	other threads:[~2024-03-03 14:24 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-29 15:10 [PATCH v3 0/4] iio: move IIO to the cleanup.h magic Nuno Sa
2024-02-29 15:10 ` [PATCH v3 1/4] iio: core: move to " Nuno Sa
2024-02-29 15:10 ` [PATCH v3 2/4] iio: trigger: move to the " Nuno Sa
2024-03-16 19:32   ` Andy Shevchenko
2024-03-18 12:33     ` Jonathan Cameron
2024-03-18 13:12       ` Andy Shevchenko
2024-03-18 14:15         ` Jonathan Cameron
2024-03-16 19:39   ` Andy Shevchenko
2024-03-18  9:22     ` Nuno Sá
2024-02-29 15:10 ` [PATCH v3 3/4] iio: buffer: iio: core: " Nuno Sa
2024-03-16 19:38   ` Andy Shevchenko
2024-03-18  9:23     ` Nuno Sá
2024-03-18 12:35     ` Jonathan Cameron
2024-03-16 19:49   ` Andy Shevchenko
2024-02-29 15:10 ` [PATCH v3 4/4] iio: inkern: " Nuno Sa
2024-03-03 14:24   ` Jonathan Cameron [this message]
2024-03-04  8:04     ` Nuno Sá
2024-03-09 17:41       ` Jonathan Cameron
2024-03-16 13:26         ` Jonathan Cameron
2024-03-16 19:48   ` Andy Shevchenko
2024-03-18  9:20     ` Nuno Sá
2024-03-23 18:09     ` Jonathan Cameron

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=20240303142431.506c05a2@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).