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

Configure Feed

Select the types of activity you want to include in your feed.

iio: pressure: mprls0025pa: move memset to core

Move memset() from the bus specific code into core.

Zeroing out the buffer is performed because the sensor has noticeable
latch-up sensitivity and in some cases it clamps the MISO signal to GND
in sync with SCLK [1]. A raw conversion of zero is out of bounds since
valid values have to be between output_min and output_max (and the
smallest output_min is 2.5% of 2^24 = 419430).

The user is expected to discard out of bounds pressure values.

Given the fact that we can't follow the behaviour of all SPI controllers
when faced to this clamping of an output signal, a raw conversion of zero
is used as an early warning in case the low level SPI API reacts
unexpectedly.

Link: https://e2e.ti.com/support/processors-group/processors/f/processors-forum/1588325/am3358-spi-tx-data-corruption [1]
Signed-off-by: Petre Rodan <petre.rodan@subdimension.ro>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Petre Rodan and committed by
Jonathan Cameron
4edab7b0 cf322f80

+2 -1
+2
drivers/iio/pressure/mprls0025pa.c
··· 22 22 #include <linux/mod_devicetable.h> 23 23 #include <linux/module.h> 24 24 #include <linux/property.h> 25 + #include <linux/string.h> 25 26 #include <linux/units.h> 26 27 27 28 #include <linux/gpio/consumer.h> ··· 248 247 } 249 248 } 250 249 250 + memset(data->rx_buf, 0, sizeof(data->rx_buf)); 251 251 ret = data->ops->read(data, MPR_CMD_NOP, MPR_PKT_NOP_LEN); 252 252 if (ret < 0) 253 253 return ret;
-1
drivers/iio/pressure/mprls0025pa_i2c.c
··· 25 25 if (cnt > MPR_MEASUREMENT_RD_SIZE) 26 26 return -EOVERFLOW; 27 27 28 - memset(data->rx_buf, 0, MPR_MEASUREMENT_RD_SIZE); 29 28 ret = i2c_master_recv(client, data->rx_buf, cnt); 30 29 if (ret < 0) 31 30 return ret;