Skip to content

Commit 7b86482

Browse files
dlechjic23
authored andcommitted
iio: adc: ad7949: use spi_is_bpw_supported()
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. Fixes: 0b2a740 ("iio: adc: ad7949: enable use with non 14/16-bit controllers") Closes: https://lore.kernel.org/linux-spi/c8b8a963-6cef-4c9b-bfef-dab2b7bd0b0f@sirena.org.uk/ Signed-off-by: David Lechner <dlechner@baylibre.com> Reviewed-by: Andy Shevchenko <andy@kernel.org> Link: https://patch.msgid.link/20250611-iio-adc-ad7949-use-spi_is_bpw_supported-v1-1-c4e15bfd326e@baylibre.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
1 parent 1fe16dc commit 7b86482

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

drivers/iio/adc/ad7949.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,6 @@ static void ad7949_disable_reg(void *reg)
308308

309309
static int ad7949_spi_probe(struct spi_device *spi)
310310
{
311-
u32 spi_ctrl_mask = spi->controller->bits_per_word_mask;
312311
struct device *dev = &spi->dev;
313312
const struct ad7949_adc_spec *spec;
314313
struct ad7949_adc_chip *ad7949_adc;
@@ -337,11 +336,11 @@ static int ad7949_spi_probe(struct spi_device *spi)
337336
ad7949_adc->resolution = spec->resolution;
338337

339338
/* Set SPI bits per word */
340-
if (spi_ctrl_mask & SPI_BPW_MASK(ad7949_adc->resolution)) {
339+
if (spi_is_bpw_supported(spi, ad7949_adc->resolution)) {
341340
spi->bits_per_word = ad7949_adc->resolution;
342-
} else if (spi_ctrl_mask == SPI_BPW_MASK(16)) {
341+
} else if (spi_is_bpw_supported(spi, 16)) {
343342
spi->bits_per_word = 16;
344-
} else if (spi_ctrl_mask == SPI_BPW_MASK(8)) {
343+
} else if (spi_is_bpw_supported(spi, 8)) {
345344
spi->bits_per_word = 8;
346345
} else {
347346
dev_err(dev, "unable to find common BPW with spi controller\n");

0 commit comments

Comments
 (0)