iio: proximity: srf08: use stack allocated scan buffer
Use a stack allocated scan struct in srf08_trigger_handler(). Since the scan buffer isn't used outside of this function and doesn't need to be DMA-safe, it doesn't need to be in struct srf08_data. We can also eliminate an extra local variable for the return value of srf08_read_ranging() by using scan.chan directly. Reviewed-by: Andreas Klinger <ak@it-klinger.de> Signed-off-by: David Lechner <dlechner@baylibre.com> Reviewed-by: Nuno Sá <nuno.sa@analog.com> Link: https://patch.msgid.link/20250721-iio-use-more-iio_declare_buffer_with_ts-6-v2-1-8b66e5b4e75a@baylibre.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>pull/1354/merge
parent
5335f93d28
commit
c9100ef6db
|
|
@ -63,12 +63,6 @@ struct srf08_data {
|
|||
int range_mm;
|
||||
struct mutex lock;
|
||||
|
||||
/* Ensure timestamp is naturally aligned */
|
||||
struct {
|
||||
s16 chan;
|
||||
aligned_s64 timestamp;
|
||||
} scan;
|
||||
|
||||
/* Sensor-Type */
|
||||
enum srf08_sensor_type sensor_type;
|
||||
|
||||
|
|
@ -182,16 +176,18 @@ static irqreturn_t srf08_trigger_handler(int irq, void *p)
|
|||
struct iio_poll_func *pf = p;
|
||||
struct iio_dev *indio_dev = pf->indio_dev;
|
||||
struct srf08_data *data = iio_priv(indio_dev);
|
||||
s16 sensor_data;
|
||||
struct {
|
||||
s16 chan;
|
||||
aligned_s64 timestamp;
|
||||
} scan = { };
|
||||
|
||||
sensor_data = srf08_read_ranging(data);
|
||||
if (sensor_data < 0)
|
||||
scan.chan = srf08_read_ranging(data);
|
||||
if (scan.chan < 0)
|
||||
goto err;
|
||||
|
||||
mutex_lock(&data->lock);
|
||||
|
||||
data->scan.chan = sensor_data;
|
||||
iio_push_to_buffers_with_ts(indio_dev, &data->scan, sizeof(data->scan),
|
||||
iio_push_to_buffers_with_ts(indio_dev, &scan, sizeof(scan),
|
||||
pf->timestamp);
|
||||
|
||||
mutex_unlock(&data->lock);
|
||||
|
|
|
|||
Loading…
Reference in New Issue