gpio: altera: User gc helper variable

Make the code easier to read by adding a local gpio_chip *gc
variable.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://patch.msgid.link/20260427-gpio-mmio-more-v3-2-fe1882351424@kernel.org
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
This commit is contained in:
Linus Walleij 2026-04-27 10:47:58 +02:00 committed by Bartosz Golaszewski
parent 575d985581
commit 9278928e0f

View File

@ -234,6 +234,7 @@ static int altera_gpio_probe(struct platform_device *pdev)
struct device *dev = &pdev->dev;
int reg, ret;
struct altera_gpio_chip *altera_gc;
struct gpio_chip *gc;
struct gpio_irq_chip *girq;
int mapped_irq;
@ -243,29 +244,31 @@ static int altera_gpio_probe(struct platform_device *pdev)
raw_spin_lock_init(&altera_gc->gpio_lock);
gc = &altera_gc->gc;
if (device_property_read_u32(dev, "altr,ngpio", &reg))
/* By default assume maximum ngpio */
altera_gc->gc.ngpio = ALTERA_GPIO_MAX_NGPIO;
gc->ngpio = ALTERA_GPIO_MAX_NGPIO;
else
altera_gc->gc.ngpio = reg;
gc->ngpio = reg;
if (altera_gc->gc.ngpio > ALTERA_GPIO_MAX_NGPIO) {
if (gc->ngpio > ALTERA_GPIO_MAX_NGPIO) {
dev_warn(&pdev->dev,
"ngpio is greater than %d, defaulting to %d\n",
ALTERA_GPIO_MAX_NGPIO, ALTERA_GPIO_MAX_NGPIO);
altera_gc->gc.ngpio = ALTERA_GPIO_MAX_NGPIO;
gc->ngpio = ALTERA_GPIO_MAX_NGPIO;
}
altera_gc->gc.direction_input = altera_gpio_direction_input;
altera_gc->gc.direction_output = altera_gpio_direction_output;
altera_gc->gc.get = altera_gpio_get;
altera_gc->gc.set = altera_gpio_set;
altera_gc->gc.owner = THIS_MODULE;
altera_gc->gc.parent = &pdev->dev;
altera_gc->gc.base = -1;
gc->direction_input = altera_gpio_direction_input;
gc->direction_output = altera_gpio_direction_output;
gc->get = altera_gpio_get;
gc->set = altera_gpio_set;
gc->owner = THIS_MODULE;
gc->parent = &pdev->dev;
gc->base = -1;
altera_gc->gc.label = devm_kasprintf(dev, GFP_KERNEL, "%pfw", dev_fwnode(dev));
if (!altera_gc->gc.label)
gc->label = devm_kasprintf(dev, GFP_KERNEL, "%pfw", dev_fwnode(dev));
if (!gc->label)
return -ENOMEM;
altera_gc->regs = devm_platform_ioremap_resource(pdev, 0);
@ -283,7 +286,7 @@ static int altera_gpio_probe(struct platform_device *pdev)
}
altera_gc->interrupt_trigger = reg;
girq = &altera_gc->gc.irq;
girq = &gc->irq;
gpio_irq_chip_set_chip(girq, &altera_gpio_irq_chip);
if (altera_gc->interrupt_trigger == IRQ_TYPE_LEVEL_HIGH)