Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

gpio: ath79: use new generic GPIO chip API

Convert the driver to using the new generic GPIO chip interfaces from
linux/gpio/generic.h.

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20250910-gpio-mmio-gpio-conv-part4-v2-4-f3d1a4c57124@linaro.org
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

+24 -15
+24 -15
drivers/gpio/gpio-ath79.c
··· 10 10 11 11 #include <linux/device.h> 12 12 #include <linux/gpio/driver.h> 13 + #include <linux/gpio/generic.h> 13 14 #include <linux/interrupt.h> 14 15 #include <linux/irq.h> 15 16 #include <linux/mod_devicetable.h> ··· 29 28 #define AR71XX_GPIO_REG_INT_MASK 0x24 30 29 31 30 struct ath79_gpio_ctrl { 32 - struct gpio_chip gc; 31 + struct gpio_generic_chip chip; 33 32 void __iomem *base; 34 33 raw_spinlock_t lock; 35 34 unsigned long both_edges; ··· 38 37 static struct ath79_gpio_ctrl *irq_data_to_ath79_gpio(struct irq_data *data) 39 38 { 40 39 struct gpio_chip *gc = irq_data_get_irq_chip_data(data); 40 + struct gpio_generic_chip *gen_gc = to_gpio_generic_chip(gc); 41 41 42 - return container_of(gc, struct ath79_gpio_ctrl, gc); 42 + return container_of(gen_gc, struct ath79_gpio_ctrl, chip); 43 43 } 44 44 45 45 static u32 ath79_gpio_read(struct ath79_gpio_ctrl *ctrl, unsigned reg) ··· 74 72 u32 mask = BIT(irqd_to_hwirq(data)); 75 73 unsigned long flags; 76 74 77 - gpiochip_enable_irq(&ctrl->gc, irqd_to_hwirq(data)); 75 + gpiochip_enable_irq(&ctrl->chip.gc, irqd_to_hwirq(data)); 78 76 raw_spin_lock_irqsave(&ctrl->lock, flags); 79 77 ath79_gpio_update_bits(ctrl, AR71XX_GPIO_REG_INT_MASK, mask, mask); 80 78 raw_spin_unlock_irqrestore(&ctrl->lock, flags); ··· 89 87 raw_spin_lock_irqsave(&ctrl->lock, flags); 90 88 ath79_gpio_update_bits(ctrl, AR71XX_GPIO_REG_INT_MASK, mask, 0); 91 89 raw_spin_unlock_irqrestore(&ctrl->lock, flags); 92 - gpiochip_disable_irq(&ctrl->gc, irqd_to_hwirq(data)); 90 + gpiochip_disable_irq(&ctrl->chip.gc, irqd_to_hwirq(data)); 93 91 } 94 92 95 93 static void ath79_gpio_irq_enable(struct irq_data *data) ··· 189 187 { 190 188 struct gpio_chip *gc = irq_desc_get_handler_data(desc); 191 189 struct irq_chip *irqchip = irq_desc_get_chip(desc); 190 + struct gpio_generic_chip *gen_gc = to_gpio_generic_chip(gc); 192 191 struct ath79_gpio_ctrl *ctrl = 193 - container_of(gc, struct ath79_gpio_ctrl, gc); 192 + container_of(gen_gc, struct ath79_gpio_ctrl, chip); 194 193 unsigned long flags, pending; 195 194 u32 both_edges, state; 196 195 int irq; ··· 227 224 228 225 static int ath79_gpio_probe(struct platform_device *pdev) 229 226 { 227 + struct gpio_generic_chip_config config; 230 228 struct device *dev = &pdev->dev; 231 229 struct ath79_gpio_ctrl *ctrl; 232 230 struct gpio_irq_chip *girq; ··· 257 253 return PTR_ERR(ctrl->base); 258 254 259 255 raw_spin_lock_init(&ctrl->lock); 260 - err = bgpio_init(&ctrl->gc, dev, 4, 261 - ctrl->base + AR71XX_GPIO_REG_IN, 262 - ctrl->base + AR71XX_GPIO_REG_SET, 263 - ctrl->base + AR71XX_GPIO_REG_CLEAR, 264 - oe_inverted ? NULL : ctrl->base + AR71XX_GPIO_REG_OE, 265 - oe_inverted ? ctrl->base + AR71XX_GPIO_REG_OE : NULL, 266 - 0); 256 + 257 + config = (struct gpio_generic_chip_config) { 258 + .dev = dev, 259 + .sz = 4, 260 + .dat = ctrl->base + AR71XX_GPIO_REG_IN, 261 + .set = ctrl->base + AR71XX_GPIO_REG_SET, 262 + .clr = ctrl->base + AR71XX_GPIO_REG_CLEAR, 263 + .dirout = oe_inverted ? NULL : ctrl->base + AR71XX_GPIO_REG_OE, 264 + .dirin = oe_inverted ? ctrl->base + AR71XX_GPIO_REG_OE : NULL, 265 + }; 266 + 267 + err = gpio_generic_chip_init(&ctrl->chip, &config); 267 268 if (err) { 268 - dev_err(dev, "bgpio_init failed\n"); 269 + dev_err(dev, "failed to initialize generic GPIO chip\n"); 269 270 return err; 270 271 } 271 272 272 273 /* Optional interrupt setup */ 273 274 if (device_property_read_bool(dev, "interrupt-controller")) { 274 - girq = &ctrl->gc.irq; 275 + girq = &ctrl->chip.gc.irq; 275 276 gpio_irq_chip_set_chip(girq, &ath79_gpio_irqchip); 276 277 girq->parent_handler = ath79_gpio_irq_handler; 277 278 girq->num_parents = 1; ··· 289 280 girq->handler = handle_simple_irq; 290 281 } 291 282 292 - return devm_gpiochip_add_data(dev, &ctrl->gc, ctrl); 283 + return devm_gpiochip_add_data(dev, &ctrl->chip.gc, ctrl); 293 284 } 294 285 295 286 static struct platform_driver ath79_gpio_driver = {