[PATCH v2 3/6] gpio: pca953x: Add helper function to check if chip has interrupts

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add pca953x_has_interrupt() function to improve code readability.

Signed-off-by: Levente Révész <levente.revesz@xxxxxxxxxx>
---
Changes in v2:

    This is a new patch.

 drivers/gpio/gpio-pca953x.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c
index dcd508368520..1725c1000445 100644
--- a/drivers/gpio/gpio-pca953x.c
+++ b/drivers/gpio/gpio-pca953x.c
@@ -230,6 +230,11 @@ static inline bool pca953x_is_pcal_type(const struct pca953x_chip *chip)
 	return chip_type == PCAL953X_TYPE || chip_type == PCAL653X_TYPE;
 }
 
+static inline bool pca953x_has_interrupt(const struct pca953x_chip *chip)
+{
+	return chip->driver_data & PCA_INT;
+}
+
 #define PCA953x_BANK_INPUT	BIT(0)
 #define PCA953x_BANK_OUTPUT	BIT(1)
 #define PCA953x_BANK_POLARITY	BIT(2)
@@ -965,7 +970,7 @@ static int pca953x_irq_setup(struct pca953x_chip *chip, int irq_base)
 	if (irq_base == -1)
 		return 0;
 
-	if (!(chip->driver_data & PCA_INT))
+	if (!pca953x_has_interrupt(chip))
 		return 0;
 
 	ret = pca953x_read_regs(chip, chip->regs->input, irq_stat);
@@ -1011,7 +1016,7 @@ static int pca953x_irq_setup(struct pca953x_chip *chip,
 {
 	struct i2c_client *client = chip->client;
 
-	if (client->irq && irq_base != -1 && (chip->driver_data & PCA_INT))
+	if (client->irq && irq_base != -1 && pca953x_has_interrupt(chip))
 		dev_warn(&client->dev, "interrupt support not compiled in\n");
 
 	return 0;
-- 
2.37.3





[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux