Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

iio: adis_buffer: check return value on page change

On the trigger handler, we might need to change the device page. Hence,
we should check the return value from 'spi_write()' and act accordingly.

Signed-off-by: Nuno Sa <nuno.sa@analog.com>
Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com>
Link: https://lore.kernel.org/r/20210422101911.135630-5-nuno.sa@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Nuno Sa and committed by
Jonathan Cameron
00f6742b ab3df797

+7 -1
+7 -1
drivers/iio/imu/adis_buffer.c
··· 134 134 if (adis->current_page != 0) { 135 135 adis->tx[0] = ADIS_WRITE_REG(ADIS_REG_PAGE_ID); 136 136 adis->tx[1] = 0; 137 - spi_write(adis->spi, adis->tx, 2); 137 + ret = spi_write(adis->spi, adis->tx, 2); 138 + if (ret) { 139 + dev_err(&adis->spi->dev, "Failed to change device page: %d\n", ret); 140 + mutex_unlock(&adis->state_lock); 141 + goto irq_done; 142 + } 138 143 } 139 144 } 140 145 ··· 156 151 iio_push_to_buffers_with_timestamp(indio_dev, adis->buffer, 157 152 pf->timestamp); 158 153 154 + irq_done: 159 155 iio_trigger_notify_done(indio_dev->trig); 160 156 161 157 return IRQ_HANDLED;