Commit 720ce8b5 authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Jonathan Cameron

iio: gyro: mpu3050: Make use of device properties

Convert the module to be property provider agnostic and allow
it to be used on non-OF platforms.

While at it, reuse temporary device pointer in the same function.
Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20220413163004.84789-1-andriy.shevchenko@linux.intel.comSigned-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent 81366556
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/pm_runtime.h> #include <linux/pm_runtime.h>
#include <linux/property.h>
#include <linux/random.h> #include <linux/random.h>
#include <linux/slab.h> #include <linux/slab.h>
...@@ -1050,6 +1051,7 @@ static const struct iio_trigger_ops mpu3050_trigger_ops = { ...@@ -1050,6 +1051,7 @@ static const struct iio_trigger_ops mpu3050_trigger_ops = {
static int mpu3050_trigger_probe(struct iio_dev *indio_dev, int irq) static int mpu3050_trigger_probe(struct iio_dev *indio_dev, int irq)
{ {
struct mpu3050 *mpu3050 = iio_priv(indio_dev); struct mpu3050 *mpu3050 = iio_priv(indio_dev);
struct device *dev = mpu3050->dev;
unsigned long irq_trig; unsigned long irq_trig;
int ret; int ret;
...@@ -1061,8 +1063,7 @@ static int mpu3050_trigger_probe(struct iio_dev *indio_dev, int irq) ...@@ -1061,8 +1063,7 @@ static int mpu3050_trigger_probe(struct iio_dev *indio_dev, int irq)
return -ENOMEM; return -ENOMEM;
/* Check if IRQ is open drain */ /* Check if IRQ is open drain */
if (of_property_read_bool(mpu3050->dev->of_node, "drive-open-drain")) mpu3050->irq_opendrain = device_property_read_bool(dev, "drive-open-drain");
mpu3050->irq_opendrain = true;
irq_trig = irqd_get_trigger_type(irq_get_irq_data(irq)); irq_trig = irqd_get_trigger_type(irq_get_irq_data(irq));
/* /*
...@@ -1118,13 +1119,12 @@ static int mpu3050_trigger_probe(struct iio_dev *indio_dev, int irq) ...@@ -1118,13 +1119,12 @@ static int mpu3050_trigger_probe(struct iio_dev *indio_dev, int irq)
mpu3050->trig->name, mpu3050->trig->name,
mpu3050->trig); mpu3050->trig);
if (ret) { if (ret) {
dev_err(mpu3050->dev, dev_err(dev, "can't get IRQ %d, error %d\n", irq, ret);
"can't get IRQ %d, error %d\n", irq, ret);
return ret; return ret;
} }
mpu3050->irq = irq; mpu3050->irq = irq;
mpu3050->trig->dev.parent = mpu3050->dev; mpu3050->trig->dev.parent = dev;
mpu3050->trig->ops = &mpu3050_trigger_ops; mpu3050->trig->ops = &mpu3050_trigger_ops;
iio_trigger_set_drvdata(mpu3050->trig, indio_dev); iio_trigger_set_drvdata(mpu3050->trig, indio_dev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment