Skip to content

Commit 7341fa7

Browse files
tpetazzonilinusw
authored andcommitted
gpio: pca953x: reduce indentation level in pca953x_irq_setup()
The current design of pca953x_irq_setup() is: if (all conditions to support IRQ are met) { lots of code to support IRQs, which goes to a serious indentation level. } return 0; It makes more sense to handle this like this: if (!all conditions to support IRQ are met) return 0; handle IRQ support This commit does just this change, reducing by one tab the indentation level of the IRQ setup code. Thanks to this reduced indentation level, we are less restricted by the 80-column limit, and we can have more function arguments on the same line. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
1 parent a3f1cae commit 7341fa7

File tree

1 file changed

+42
-42
lines changed

1 file changed

+42
-42
lines changed

drivers/gpio/gpio-pca953x.c

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -702,53 +702,53 @@ static int pca953x_irq_setup(struct pca953x_chip *chip,
702702
int reg_direction[MAX_BANK];
703703
int ret, i;
704704

705-
if (client->irq && irq_base != -1
706-
&& (chip->driver_data & PCA_INT)) {
707-
ret = pca953x_read_regs(chip,
708-
chip->regs->input, chip->irq_stat);
709-
if (ret)
710-
return ret;
705+
if (!client->irq)
706+
return 0;
711707

712-
/*
713-
* There is no way to know which GPIO line generated the
714-
* interrupt. We have to rely on the previous read for
715-
* this purpose.
716-
*/
717-
regmap_bulk_read(chip->regmap, chip->regs->direction,
718-
reg_direction, NBANK(chip));
719-
for (i = 0; i < NBANK(chip); i++)
720-
chip->irq_stat[i] &= reg_direction[i];
721-
mutex_init(&chip->irq_lock);
722-
723-
ret = devm_request_threaded_irq(&client->dev,
724-
client->irq,
725-
NULL,
726-
pca953x_irq_handler,
727-
IRQF_TRIGGER_LOW | IRQF_ONESHOT |
728-
IRQF_SHARED,
729-
dev_name(&client->dev), chip);
730-
if (ret) {
731-
dev_err(&client->dev, "failed to request irq %d\n",
732-
client->irq);
733-
return ret;
734-
}
708+
if (irq_base == -1)
709+
return 0;
735710

736-
ret = gpiochip_irqchip_add_nested(&chip->gpio_chip,
737-
&pca953x_irq_chip,
738-
irq_base,
739-
handle_simple_irq,
740-
IRQ_TYPE_NONE);
741-
if (ret) {
742-
dev_err(&client->dev,
743-
"could not connect irqchip to gpiochip\n");
744-
return ret;
745-
}
711+
if (!(chip->driver_data & PCA_INT))
712+
return 0;
746713

747-
gpiochip_set_nested_irqchip(&chip->gpio_chip,
748-
&pca953x_irq_chip,
749-
client->irq);
714+
ret = pca953x_read_regs(chip, chip->regs->input, chip->irq_stat);
715+
if (ret)
716+
return ret;
717+
718+
/*
719+
* There is no way to know which GPIO line generated the
720+
* interrupt. We have to rely on the previous read for
721+
* this purpose.
722+
*/
723+
regmap_bulk_read(chip->regmap, chip->regs->direction, reg_direction,
724+
NBANK(chip));
725+
for (i = 0; i < NBANK(chip); i++)
726+
chip->irq_stat[i] &= reg_direction[i];
727+
mutex_init(&chip->irq_lock);
728+
729+
ret = devm_request_threaded_irq(&client->dev, client->irq,
730+
NULL, pca953x_irq_handler,
731+
IRQF_TRIGGER_LOW | IRQF_ONESHOT |
732+
IRQF_SHARED,
733+
dev_name(&client->dev), chip);
734+
if (ret) {
735+
dev_err(&client->dev, "failed to request irq %d\n",
736+
client->irq);
737+
return ret;
738+
}
739+
740+
ret = gpiochip_irqchip_add_nested(&chip->gpio_chip, &pca953x_irq_chip,
741+
irq_base, handle_simple_irq,
742+
IRQ_TYPE_NONE);
743+
if (ret) {
744+
dev_err(&client->dev,
745+
"could not connect irqchip to gpiochip\n");
746+
return ret;
750747
}
751748

749+
gpiochip_set_nested_irqchip(&chip->gpio_chip, &pca953x_irq_chip,
750+
client->irq);
751+
752752
return 0;
753753
}
754754

0 commit comments

Comments
 (0)