diff mbox series

[08/15] iio: imu: bmi160: use irq_get_trigger_type()

Message ID 20240901135950.797396-9-jic23@kernel.org (mailing list archive)
State Accepted
Headers show
Series IIO: use irq_get_trigger_type() instead of opencoding. | expand

Commit Message

Jonathan Cameron Sept. 1, 2024, 1:59 p.m. UTC
From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

Use irq_get_trigger_type() to replace getting the irq data then the
type in two steps.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
 drivers/iio/imu/bmi160/bmi160_core.c | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)

Comments

Andy Shevchenko Sept. 2, 2024, 11:45 a.m. UTC | #1
On Sun, Sep 01, 2024 at 02:59:43PM +0100, Jonathan Cameron wrote:
> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> 
> Use irq_get_trigger_type() to replace getting the irq data then the
> type in two steps.

...

>  {
> -	struct irq_data *desc;
> -	u32 irq_type;
>  	int ret;
> -
> -	desc = irq_get_irq_data(irq);
> -	if (!desc) {
> -		dev_err(&indio_dev->dev, "Could not find IRQ %d\n", irq);
> -		return -EINVAL;
> -	}
> -
> -	irq_type = irqd_get_trigger_type(desc);
> +	u32 irq_type = irq_get_trigger_type(irq);

Hmm... You broke the reversed xmas tree ordering.
Anyway, can we actually

>  	ret = bmi160_config_device_irq(indio_dev, irq_type, pin);

	ret = bmi160_config_device_irq(indio_dev, irq_get_trigger_type(irq), pin);

instead?

>  	if (ret)
Jonathan Cameron Sept. 7, 2024, 2:26 p.m. UTC | #2
On Mon, 2 Sep 2024 14:45:52 +0300
Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:

> On Sun, Sep 01, 2024 at 02:59:43PM +0100, Jonathan Cameron wrote:
> > From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> > 
> > Use irq_get_trigger_type() to replace getting the irq data then the
> > type in two steps.  
> 
> ...
> 
> >  {
> > -	struct irq_data *desc;
> > -	u32 irq_type;
> >  	int ret;
> > -
> > -	desc = irq_get_irq_data(irq);
> > -	if (!desc) {
> > -		dev_err(&indio_dev->dev, "Could not find IRQ %d\n", irq);
> > -		return -EINVAL;
> > -	}
> > -
> > -	irq_type = irqd_get_trigger_type(desc);
> > +	u32 irq_type = irq_get_trigger_type(irq);  
> 
> Hmm... You broke the reversed xmas tree ordering.
> Anyway, can we actually
I put this back.
> 
> >  	ret = bmi160_config_device_irq(indio_dev, irq_type, pin);  
> 
> 	ret = bmi160_config_device_irq(indio_dev, irq_get_trigger_type(irq), pin);
> 
> instead?
Nope. irq_type is passed into the probe_trigger function outside the context
we can see in the patch.

Jonathan
> 
> >  	if (ret)  
>
diff mbox series

Patch

diff --git a/drivers/iio/imu/bmi160/bmi160_core.c b/drivers/iio/imu/bmi160/bmi160_core.c
index 495e8a74ac67..3665fcd5ff0d 100644
--- a/drivers/iio/imu/bmi160/bmi160_core.c
+++ b/drivers/iio/imu/bmi160/bmi160_core.c
@@ -690,17 +690,8 @@  static int bmi160_config_device_irq(struct iio_dev *indio_dev, int irq_type,
 static int bmi160_setup_irq(struct iio_dev *indio_dev, int irq,
 			    enum bmi160_int_pin pin)
 {
-	struct irq_data *desc;
-	u32 irq_type;
 	int ret;
-
-	desc = irq_get_irq_data(irq);
-	if (!desc) {
-		dev_err(&indio_dev->dev, "Could not find IRQ %d\n", irq);
-		return -EINVAL;
-	}
-
-	irq_type = irqd_get_trigger_type(desc);
+	u32 irq_type = irq_get_trigger_type(irq);
 
 	ret = bmi160_config_device_irq(indio_dev, irq_type, pin);
 	if (ret)