* [PATCH] iio: adc: ad7949: use spi_is_bpw_supported()
@ 2025-06-11 15:04 David Lechner
2025-06-11 15:15 ` Andy Shevchenko
0 siblings, 1 reply; 6+ messages in thread
From: David Lechner @ 2025-06-11 15:04 UTC (permalink / raw)
To: Michael Hennerich, Jonathan Cameron, Nuno Sá,
Andy Shevchenko
Cc: Da Xue, linux-iio, linux-kernel, David Lechner
Use spi_is_bpw_supported() instead of directly accessing spi->controller
->bits_per_word_mask. bits_per_word_mask may be 0, which implies that
8-bits-per-word is supported. spi_is_bpw_supported() takes this into
account while spi_ctrl_mask == SPI_BPW_MASK(8) does not.
Closes: https://lore.kernel.org/linux-spi/c8b8a963-6cef-4c9b-bfef-dab2b7bd0b0f@sirena.org.uk/
Signed-off-by: David Lechner <dlechner@baylibre.com>
---
drivers/iio/adc/ad7949.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/iio/adc/ad7949.c b/drivers/iio/adc/ad7949.c
index edd0c3a35ab73cca5ff87632e4d588eb5d712b47..202561cad4012b67e23ad6d3623c913cfef35e68 100644
--- a/drivers/iio/adc/ad7949.c
+++ b/drivers/iio/adc/ad7949.c
@@ -308,7 +308,6 @@ static void ad7949_disable_reg(void *reg)
static int ad7949_spi_probe(struct spi_device *spi)
{
- u32 spi_ctrl_mask = spi->controller->bits_per_word_mask;
struct device *dev = &spi->dev;
const struct ad7949_adc_spec *spec;
struct ad7949_adc_chip *ad7949_adc;
@@ -337,11 +336,11 @@ static int ad7949_spi_probe(struct spi_device *spi)
ad7949_adc->resolution = spec->resolution;
/* Set SPI bits per word */
- if (spi_ctrl_mask & SPI_BPW_MASK(ad7949_adc->resolution)) {
+ if (spi_is_bpw_supported(spi, ad7949_adc->resolution)) {
spi->bits_per_word = ad7949_adc->resolution;
- } else if (spi_ctrl_mask == SPI_BPW_MASK(16)) {
+ } else if (spi_is_bpw_supported(spi, 16)) {
spi->bits_per_word = 16;
- } else if (spi_ctrl_mask == SPI_BPW_MASK(8)) {
+ } else if (spi_is_bpw_supported(spi, 8)) {
spi->bits_per_word = 8;
} else {
dev_err(dev, "unable to find common BPW with spi controller\n");
---
base-commit: 4c6073fec2fee4827fa0dd8a4ab4e6f7bbc05ee6
change-id: 20250611-iio-adc-ad7949-use-spi_is_bpw_supported-17f1293abf88
Best regards,
--
David Lechner <dlechner@baylibre.com>
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] iio: adc: ad7949: use spi_is_bpw_supported()
2025-06-11 15:04 [PATCH] iio: adc: ad7949: use spi_is_bpw_supported() David Lechner
@ 2025-06-11 15:15 ` Andy Shevchenko
2025-06-11 15:21 ` David Lechner
0 siblings, 1 reply; 6+ messages in thread
From: Andy Shevchenko @ 2025-06-11 15:15 UTC (permalink / raw)
To: David Lechner
Cc: Michael Hennerich, Jonathan Cameron, Nuno Sá, Da Xue,
linux-iio, linux-kernel
On Wed, Jun 11, 2025 at 10:04:58AM -0500, David Lechner wrote:
> Use spi_is_bpw_supported() instead of directly accessing spi->controller
> ->bits_per_word_mask. bits_per_word_mask may be 0, which implies that
> 8-bits-per-word is supported. spi_is_bpw_supported() takes this into
> account while spi_ctrl_mask == SPI_BPW_MASK(8) does not.
> Closes: https://lore.kernel.org/linux-spi/c8b8a963-6cef-4c9b-bfef-dab2b7bd0b0f@sirena.org.uk/
Reported-by yourself. I'm wondering if the Closes adds a value in this case.
Otherwise I can do the same to maybe 10% of my patches, for instance. But
I don't think I put Closes tag on whatever improvement potential bug fix
I do report (read: notice) myself.
> Signed-off-by: David Lechner <dlechner@baylibre.com>
Code wise LGTM,
Reviewed-by: Andy Shevchenko <andy@kernel.org>
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] iio: adc: ad7949: use spi_is_bpw_supported()
2025-06-11 15:15 ` Andy Shevchenko
@ 2025-06-11 15:21 ` David Lechner
2025-06-11 16:55 ` Jonathan Cameron
0 siblings, 1 reply; 6+ messages in thread
From: David Lechner @ 2025-06-11 15:21 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Michael Hennerich, Jonathan Cameron, Nuno Sá, Da Xue,
linux-iio, linux-kernel
On 6/11/25 10:15 AM, Andy Shevchenko wrote:
> On Wed, Jun 11, 2025 at 10:04:58AM -0500, David Lechner wrote:
>> Use spi_is_bpw_supported() instead of directly accessing spi->controller
>> ->bits_per_word_mask. bits_per_word_mask may be 0, which implies that
>> 8-bits-per-word is supported. spi_is_bpw_supported() takes this into
>> account while spi_ctrl_mask == SPI_BPW_MASK(8) does not.
>
>> Closes: https://lore.kernel.org/linux-spi/c8b8a963-6cef-4c9b-bfef-dab2b7bd0b0f@sirena.org.uk/
>
> Reported-by yourself. I'm wondering if the Closes adds a value in this case.
> Otherwise I can do the same to maybe 10% of my patches, for instance. But
> I don't think I put Closes tag on whatever improvement potential bug fix
> I do report (read: notice) myself.
I included it so that Da Xue will know that this has been resolved and
doesn't need to do anything more. Normally I would have not included
it though.
>
>> Signed-off-by: David Lechner <dlechner@baylibre.com>
>
> Code wise LGTM,
> Reviewed-by: Andy Shevchenko <andy@kernel.org>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] iio: adc: ad7949: use spi_is_bpw_supported()
2025-06-11 15:21 ` David Lechner
@ 2025-06-11 16:55 ` Jonathan Cameron
2025-06-11 17:00 ` David Lechner
0 siblings, 1 reply; 6+ messages in thread
From: Jonathan Cameron @ 2025-06-11 16:55 UTC (permalink / raw)
To: David Lechner
Cc: Andy Shevchenko, Michael Hennerich, Nuno Sá, Da Xue,
linux-iio, linux-kernel
On Wed, 11 Jun 2025 10:21:56 -0500
David Lechner <dlechner@baylibre.com> wrote:
> On 6/11/25 10:15 AM, Andy Shevchenko wrote:
> > On Wed, Jun 11, 2025 at 10:04:58AM -0500, David Lechner wrote:
> >> Use spi_is_bpw_supported() instead of directly accessing spi->controller
> >> ->bits_per_word_mask. bits_per_word_mask may be 0, which implies that
> >> 8-bits-per-word is supported. spi_is_bpw_supported() takes this into
> >> account while spi_ctrl_mask == SPI_BPW_MASK(8) does not.
> >
> >> Closes: https://lore.kernel.org/linux-spi/c8b8a963-6cef-4c9b-bfef-dab2b7bd0b0f@sirena.org.uk/
> >
> > Reported-by yourself. I'm wondering if the Closes adds a value in this case.
> > Otherwise I can do the same to maybe 10% of my patches, for instance. But
> > I don't think I put Closes tag on whatever improvement potential bug fix
> > I do report (read: notice) myself.
>
> I included it so that Da Xue will know that this has been resolved and
> doesn't need to do anything more. Normally I would have not included
> it though.
If I followed the discussion correctly does this need a fixes tag?
>
> >
> >> Signed-off-by: David Lechner <dlechner@baylibre.com>
> >
> > Code wise LGTM,
> > Reviewed-by: Andy Shevchenko <andy@kernel.org>
> >
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] iio: adc: ad7949: use spi_is_bpw_supported()
2025-06-11 16:55 ` Jonathan Cameron
@ 2025-06-11 17:00 ` David Lechner
2025-06-14 11:40 ` Jonathan Cameron
0 siblings, 1 reply; 6+ messages in thread
From: David Lechner @ 2025-06-11 17:00 UTC (permalink / raw)
To: Jonathan Cameron
Cc: Andy Shevchenko, Michael Hennerich, Nuno Sá, Da Xue,
linux-iio, linux-kernel
On 6/11/25 11:55 AM, Jonathan Cameron wrote:
> On Wed, 11 Jun 2025 10:21:56 -0500
> David Lechner <dlechner@baylibre.com> wrote:
>
>> On 6/11/25 10:15 AM, Andy Shevchenko wrote:
>>> On Wed, Jun 11, 2025 at 10:04:58AM -0500, David Lechner wrote:
>>>> Use spi_is_bpw_supported() instead of directly accessing spi->controller
>>>> ->bits_per_word_mask. bits_per_word_mask may be 0, which implies that
>>>> 8-bits-per-word is supported. spi_is_bpw_supported() takes this into
>>>> account while spi_ctrl_mask == SPI_BPW_MASK(8) does not.
>>>
>>>> Closes: https://lore.kernel.org/linux-spi/c8b8a963-6cef-4c9b-bfef-dab2b7bd0b0f@sirena.org.uk/
>>>
>>> Reported-by yourself. I'm wondering if the Closes adds a value in this case.
>>> Otherwise I can do the same to maybe 10% of my patches, for instance. But
>>> I don't think I put Closes tag on whatever improvement potential bug fix
>>> I do report (read: notice) myself.
>>
>> I included it so that Da Xue will know that this has been resolved and
>> doesn't need to do anything more. Normally I would have not included
>> it though.
>
> If I followed the discussion correctly does this need a fixes tag?
I supposed it doesn't hurt. It could be possible that someone tries to
use an older stable kernel with a SPI controller that didn't set the
flags, in which case there could be a problem.
Fixes: 0b2a740b424e ("iio: adc: ad7949: enable use with non 14/16-bit controllers")
>
>>
>>>
>>>> Signed-off-by: David Lechner <dlechner@baylibre.com>
>>>
>>> Code wise LGTM,
>>> Reviewed-by: Andy Shevchenko <andy@kernel.org>
>>>
>>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] iio: adc: ad7949: use spi_is_bpw_supported()
2025-06-11 17:00 ` David Lechner
@ 2025-06-14 11:40 ` Jonathan Cameron
0 siblings, 0 replies; 6+ messages in thread
From: Jonathan Cameron @ 2025-06-14 11:40 UTC (permalink / raw)
To: David Lechner
Cc: Andy Shevchenko, Michael Hennerich, Nuno Sá, Da Xue,
linux-iio, linux-kernel
On Wed, 11 Jun 2025 12:00:27 -0500
David Lechner <dlechner@baylibre.com> wrote:
> On 6/11/25 11:55 AM, Jonathan Cameron wrote:
> > On Wed, 11 Jun 2025 10:21:56 -0500
> > David Lechner <dlechner@baylibre.com> wrote:
> >
> >> On 6/11/25 10:15 AM, Andy Shevchenko wrote:
> >>> On Wed, Jun 11, 2025 at 10:04:58AM -0500, David Lechner wrote:
> >>>> Use spi_is_bpw_supported() instead of directly accessing spi->controller
> >>>> ->bits_per_word_mask. bits_per_word_mask may be 0, which implies that
> >>>> 8-bits-per-word is supported. spi_is_bpw_supported() takes this into
> >>>> account while spi_ctrl_mask == SPI_BPW_MASK(8) does not.
> >>>
> >>>> Closes: https://lore.kernel.org/linux-spi/c8b8a963-6cef-4c9b-bfef-dab2b7bd0b0f@sirena.org.uk/
> >>>
> >>> Reported-by yourself. I'm wondering if the Closes adds a value in this case.
> >>> Otherwise I can do the same to maybe 10% of my patches, for instance. But
> >>> I don't think I put Closes tag on whatever improvement potential bug fix
> >>> I do report (read: notice) myself.
> >>
> >> I included it so that Da Xue will know that this has been resolved and
> >> doesn't need to do anything more. Normally I would have not included
> >> it though.
> >
> > If I followed the discussion correctly does this need a fixes tag?
>
> I supposed it doesn't hurt. It could be possible that someone tries to
> use an older stable kernel with a SPI controller that didn't set the
> flags, in which case there could be a problem.
>
> Fixes: 0b2a740b424e ("iio: adc: ad7949: enable use with non 14/16-bit controllers")
Applied to the fixes-togreg branch of iio.git.
I didn't mark it for stable purely because it would have been obvious
I think if anyone actually hit this.
Jonathan
>
> >
> >>
> >>>
> >>>> Signed-off-by: David Lechner <dlechner@baylibre.com>
> >>>
> >>> Code wise LGTM,
> >>> Reviewed-by: Andy Shevchenko <andy@kernel.org>
> >>>
> >>
> >
>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-06-14 11:40 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-11 15:04 [PATCH] iio: adc: ad7949: use spi_is_bpw_supported() David Lechner
2025-06-11 15:15 ` Andy Shevchenko
2025-06-11 15:21 ` David Lechner
2025-06-11 16:55 ` Jonathan Cameron
2025-06-11 17:00 ` David Lechner
2025-06-14 11:40 ` Jonathan Cameron
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 NNTP newsgroup(s).