Skip to content

Commit 1ecca8a

Browse files
commodojic23
authored andcommitted
iio: proximity: ping: pass reference to IIO device as param to ping_read()
Since there will be some changes to how iio_priv_to_dev() is implemented, it could be that the helper becomes a bit slower, as it will be hidden away in the IIO core. But even without that rework, this looks like it can pass the 'indio_dev' object to ping_read() and obtain the state struct via iio_priv() which is a preferred practice than going back-n-forth (getting the state-struct, then using iio_priv_to_dev() to get the indio_dev object back). Signed-off-by: Alexandru Ardelean <[email protected]> Signed-off-by: Jonathan Cameron <[email protected]>
1 parent 33c53cb commit 1ecca8a

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

drivers/iio/proximity/ping.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,14 @@ static irqreturn_t ping_handle_irq(int irq, void *dev_id)
8989
return IRQ_HANDLED;
9090
}
9191

92-
static int ping_read(struct ping_data *data)
92+
static int ping_read(struct iio_dev *indio_dev)
9393
{
94+
struct ping_data *data = iio_priv(indio_dev);
9495
int ret;
9596
ktime_t ktime_dt;
9697
s64 dt_ns;
9798
u32 time_ns, distance_mm;
9899
struct platform_device *pdev = to_platform_device(data->dev);
99-
struct iio_dev *indio_dev = iio_priv_to_dev(data);
100100

101101
/*
102102
* just one read-echo-cycle can take place at a time
@@ -228,15 +228,14 @@ static int ping_read_raw(struct iio_dev *indio_dev,
228228
struct iio_chan_spec const *channel, int *val,
229229
int *val2, long info)
230230
{
231-
struct ping_data *data = iio_priv(indio_dev);
232231
int ret;
233232

234233
if (channel->type != IIO_DISTANCE)
235234
return -EINVAL;
236235

237236
switch (info) {
238237
case IIO_CHAN_INFO_RAW:
239-
ret = ping_read(data);
238+
ret = ping_read(indio_dev);
240239
if (ret < 0)
241240
return ret;
242241
*val = ret;

0 commit comments

Comments
 (0)