public inbox for devicetree@vger.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andy.shevchenko@gmail.com>
To: "Uwe Kleine-König" <u.kleine-koenig@baylibre.com>
Cc: Jonathan Cameron <jic23@kernel.org>,
	Lars-Peter Clausen <lars@metafoo.de>,
	 Michael Hennerich <Michael.Hennerich@analog.com>,
	linux-iio@vger.kernel.org,  Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	 Alisa-Dariana Roman <alisa.roman@analog.com>,
	Renato Lui Geh <renatogeh@gmail.com>,
	 Ceclan Dumitru <dumitru.ceclan@analog.com>,
	devicetree@vger.kernel.org,  Nuno Sa <nuno.sa@analog.com>,
	David Lechner <dlechner@baylibre.com>,
	 Alexandru Ardelean <aardelean@baylibre.com>,
	Trevor Gamblin <tgamblin@baylibre.com>
Subject: Re: [PATCH v5 08/10] iio: adc: ad_sigma_delta: Check for previous ready signals
Date: Tue, 3 Dec 2024 15:10:30 +0200	[thread overview]
Message-ID: <CAHp75VfuTRDAjOD73re8tCWWJsAFUq_P6hPiPd4j_mOFM8oKGw@mail.gmail.com> (raw)
In-Reply-To: <20241203110019.1520071-20-u.kleine-koenig@baylibre.com>

On Tue, Dec 3, 2024 at 1:01 PM Uwe Kleine-König
<u.kleine-koenig@baylibre.com> wrote:
>
> It can happen if a previous conversion was aborted the ADC pulls down
> the ̅R̅D̅Y line but the event wasn't handled before. In that case enabling

Interesting use of Unicode, but I suggest to avoid it when it can be
avoided, i.e.
using the notation of #RDY_N might be appropriate as that is how
usually the HW people refer to the active low signals.

> the irq might immediately fire (depending on the irq controller's

controller

> capabilities) and even with a rdy-gpio isn't identified as an unrelated
> one.
>
> To cure that problem check for a pending event before the measurement is
> started and clear it if needed.

...

> +       data = kzalloc(data_read_len + 1, GFP_KERNEL);

Yes, I know that's not needed right now, but would make code robust
against changes. I'm talking about using __free() here.

> +       if (!data)
> +               return -ENOMEM;
> +
> +       spi_message_init(&m);
> +       if (sigma_delta->info->has_registers) {
> +               unsigned int data_reg = sigma_delta->info->data_reg ?: AD_SD_REG_DATA;
> +
> +               data[0] = data_reg << sigma_delta->info->addr_shift;
> +               data[0] |= sigma_delta->info->read_mask;
> +               data[0] |= sigma_delta->comm;
> +               t[0].tx_buf = data;
> +               spi_message_add_tail(&t[0], &m);
> +       }
> +
> +       /*
> +        * The first transferred byte is part of the real data register,
> +        * so this doesn't need to be 0xff. In the remaining
> +        * `data_read_len - 1` bytes are less than $num_resetclks ones.
> +        */
> +       t[1].tx_buf = data + 1;
> +       data[1] = 0x00;
> +       memset(data + 2, 0xff, data_read_len - 1);
> +       spi_message_add_tail(&t[1], &m);

> +       ret = spi_sync_locked(sigma_delta->spi, &m);
> +
> +       kfree(data);
> +
> +       return ret;

With the above this will become just as

  return spi_sync_locked(...);

-- 
With Best Regards,
Andy Shevchenko

  reply	other threads:[~2024-12-03 13:11 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-03 11:00 [PATCH v5 00/10] iio: adc: ad7124: Various fixes Uwe Kleine-König
2024-12-03 11:00 ` [PATCH v5 01/10] iio: adc: ad7124: Don't create more channels than the driver can handle Uwe Kleine-König
2024-12-03 11:00 ` [PATCH v5 02/10] iio: adc: ad7124: Refuse invalid input specifiers Uwe Kleine-König
2024-12-03 11:00 ` [PATCH v5 03/10] dt-bindings: iio: adc: adi,ad7{124,173,192,780}: Allow specifications of a gpio for irq line Uwe Kleine-König
2024-12-03 16:21   ` Conor Dooley
2024-12-03 11:00 ` [PATCH v5 04/10] iio: adc: ad_sigma_delta: Add support for reading irq status using a GPIO Uwe Kleine-König
2024-12-03 11:00 ` [PATCH v5 05/10] iio: adc: ad_sigma_delta: Handle CS assertion as intended in ad_sd_read_reg_raw() Uwe Kleine-König
2024-12-03 11:00 ` [PATCH v5 06/10] iio: adc: ad_sigma_delta: Fix a race condition Uwe Kleine-König
2024-12-03 11:00 ` [PATCH v5 07/10] iio: adc: ad_sigma_delta: Store information about reset sequence length Uwe Kleine-König
2024-12-03 11:00 ` [PATCH v5 08/10] iio: adc: ad_sigma_delta: Check for previous ready signals Uwe Kleine-König
2024-12-03 13:10   ` Andy Shevchenko [this message]
2024-12-03 16:15     ` Uwe Kleine-König
2024-12-03 17:47       ` Andy Shevchenko
2024-12-03 18:47         ` Uwe Kleine-König
2024-12-03 18:53           ` Andy Shevchenko
2024-12-03 11:00 ` [PATCH v5 09/10] iio: adc: ad7124: Add error reporting during probe Uwe Kleine-König
2024-12-03 11:00 ` [PATCH v5 10/10] iio: adc: ad7124: Implement temperature measurement Uwe Kleine-König
2024-12-05 18:31 ` [PATCH v5 00/10] iio: adc: ad7124: Various fixes Uwe Kleine-König

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=CAHp75VfuTRDAjOD73re8tCWWJsAFUq_P6hPiPd4j_mOFM8oKGw@mail.gmail.com \
    --to=andy.shevchenko@gmail.com \
    --cc=Michael.Hennerich@analog.com \
    --cc=aardelean@baylibre.com \
    --cc=alisa.roman@analog.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=dumitru.ceclan@analog.com \
    --cc=jic23@kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=nuno.sa@analog.com \
    --cc=renatogeh@gmail.com \
    --cc=robh@kernel.org \
    --cc=tgamblin@baylibre.com \
    --cc=u.kleine-koenig@baylibre.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