mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2025-01-12 00:38:55 +00:00
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 <alexandru.ardelean@analog.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
This commit is contained in:
parent
33c53cbf8f
commit
1ecca8a9a4
@ -89,14 +89,14 @@ static irqreturn_t ping_handle_irq(int irq, void *dev_id)
|
|||||||
return IRQ_HANDLED;
|
return IRQ_HANDLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ping_read(struct ping_data *data)
|
static int ping_read(struct iio_dev *indio_dev)
|
||||||
{
|
{
|
||||||
|
struct ping_data *data = iio_priv(indio_dev);
|
||||||
int ret;
|
int ret;
|
||||||
ktime_t ktime_dt;
|
ktime_t ktime_dt;
|
||||||
s64 dt_ns;
|
s64 dt_ns;
|
||||||
u32 time_ns, distance_mm;
|
u32 time_ns, distance_mm;
|
||||||
struct platform_device *pdev = to_platform_device(data->dev);
|
struct platform_device *pdev = to_platform_device(data->dev);
|
||||||
struct iio_dev *indio_dev = iio_priv_to_dev(data);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* just one read-echo-cycle can take place at a time
|
* just one read-echo-cycle can take place at a time
|
||||||
@ -228,7 +228,6 @@ static int ping_read_raw(struct iio_dev *indio_dev,
|
|||||||
struct iio_chan_spec const *channel, int *val,
|
struct iio_chan_spec const *channel, int *val,
|
||||||
int *val2, long info)
|
int *val2, long info)
|
||||||
{
|
{
|
||||||
struct ping_data *data = iio_priv(indio_dev);
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (channel->type != IIO_DISTANCE)
|
if (channel->type != IIO_DISTANCE)
|
||||||
@ -236,7 +235,7 @@ static int ping_read_raw(struct iio_dev *indio_dev,
|
|||||||
|
|
||||||
switch (info) {
|
switch (info) {
|
||||||
case IIO_CHAN_INFO_RAW:
|
case IIO_CHAN_INFO_RAW:
|
||||||
ret = ping_read(data);
|
ret = ping_read(indio_dev);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
*val = ret;
|
*val = ret;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user