public inbox for linux-i2c@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 1/5] i2c: mux: pca954x: Refactor pca954x_irq_handler()
@ 2020-03-05 15:53 Andy Shevchenko
  2020-03-05 15:53 ` [PATCH v1 2/5] i2c: mux: pca954x: Make use of device properties Andy Shevchenko
                   ` (4 more replies)
  0 siblings, 5 replies; 17+ messages in thread
From: Andy Shevchenko @ 2020-03-05 15:53 UTC (permalink / raw)
  To: Peter Rosin, linux-i2c, Wolfram Sang; +Cc: Andy Shevchenko

Refactor pca954x_irq_handler() to:
  - use for_each_set_bit() macro
  - use IRQ_RETVAL() macro

Above change makes code easy to read and understand.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/i2c/muxes/i2c-mux-pca954x.c | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/drivers/i2c/muxes/i2c-mux-pca954x.c b/drivers/i2c/muxes/i2c-mux-pca954x.c
index a0d926ae3f86..819ff95e64ba 100644
--- a/drivers/i2c/muxes/i2c-mux-pca954x.c
+++ b/drivers/i2c/muxes/i2c-mux-pca954x.c
@@ -327,21 +327,18 @@ static DEVICE_ATTR_RW(idle_state);
 static irqreturn_t pca954x_irq_handler(int irq, void *dev_id)
 {
 	struct pca954x *data = dev_id;
-	unsigned int child_irq;
-	int ret, i, handled = 0;
+	unsigned long pending;
+	int ret, i;
 
 	ret = i2c_smbus_read_byte(data->client);
 	if (ret < 0)
 		return IRQ_NONE;
 
-	for (i = 0; i < data->chip->nchans; i++) {
-		if (ret & BIT(PCA954X_IRQ_OFFSET + i)) {
-			child_irq = irq_linear_revmap(data->irq, i);
-			handle_nested_irq(child_irq);
-			handled++;
-		}
-	}
-	return handled ? IRQ_HANDLED : IRQ_NONE;
+	pending = ret >> PCA954X_IRQ_OFFSET;
+	for_each_set_bit(i, &pending, data->chip->nchans)
+		handle_nested_irq(irq_linear_revmap(data->irq, i));
+
+	return IRQ_RETVAL(pending);
 }
 
 static int pca954x_irq_set_type(struct irq_data *idata, unsigned int type)
-- 
2.25.1

^ permalink raw reply related	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2020-03-16 16:08 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-03-05 15:53 [PATCH v1 1/5] i2c: mux: pca954x: Refactor pca954x_irq_handler() Andy Shevchenko
2020-03-05 15:53 ` [PATCH v1 2/5] i2c: mux: pca954x: Make use of device properties Andy Shevchenko
2020-03-05 21:05   ` Peter Rosin
2020-03-06  9:54     ` Andy Shevchenko
2020-03-06 11:48       ` Peter Rosin
2020-03-06 13:58         ` Andy Shevchenko
2020-03-06 14:57           ` Peter Rosin
2020-03-06 15:07             ` Andy Shevchenko
2020-03-05 15:53 ` [PATCH v1 3/5] i2c: mux: pca954x: Drop useless validation for optional GPIO descriptor Andy Shevchenko
2020-03-05 21:19   ` Peter Rosin
2020-03-06  9:56     ` Andy Shevchenko
2020-03-05 15:53 ` [PATCH v1 4/5] i2c: mux: pca954x: Move device_remove_file() out of pca954x_cleanup() Andy Shevchenko
2020-03-05 15:53 ` [PATCH v1 5/5] i2c: mux: pca954x: Convert license to SPDX identifier Andy Shevchenko
2020-03-05 21:34 ` [PATCH v1 1/5] i2c: mux: pca954x: Refactor pca954x_irq_handler() Peter Rosin
2020-03-06 10:02   ` Andy Shevchenko
2020-03-06 10:58     ` Peter Rosin
2020-03-16 16:08       ` Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox