diff mbox series

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

Message ID a0b1d922-0bb6-91ec-9b86-b9dc46afe244@eilabs.com
State New
Headers show
Series gpio: pca953x: Add interrupt mask support for pca953x chips | expand

Commit Message

Levente Révész Oct. 26, 2022, 11:22 a.m. UTC
Add pca953x_has_interrupt() function to improve code readability.

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

    This is a new patch.

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

Patch

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;