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

gpio: clps711x: 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/20250702-gpio-mmio-rework-v2-4-6b77aab684d8@linaro.org
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

+16 -11
+16 -11
drivers/gpio/gpio-clps711x.c
··· 8 8 #include <linux/err.h> 9 9 #include <linux/module.h> 10 10 #include <linux/gpio/driver.h> 11 + #include <linux/gpio/generic.h> 11 12 #include <linux/platform_device.h> 12 13 13 14 static int clps711x_gpio_probe(struct platform_device *pdev) 14 15 { 16 + struct gpio_generic_chip_config config = { }; 15 17 struct device_node *np = pdev->dev.of_node; 18 + struct gpio_generic_chip *gen_gc; 16 19 void __iomem *dat, *dir; 17 - struct gpio_chip *gc; 18 20 int err, id; 19 21 20 22 if (!np) ··· 26 24 if ((id < 0) || (id > 4)) 27 25 return -ENODEV; 28 26 29 - gc = devm_kzalloc(&pdev->dev, sizeof(*gc), GFP_KERNEL); 30 - if (!gc) 27 + gen_gc = devm_kzalloc(&pdev->dev, sizeof(*gen_gc), GFP_KERNEL); 28 + if (!gen_gc) 31 29 return -ENOMEM; 32 30 33 31 dat = devm_platform_ioremap_resource(pdev, 0); ··· 38 36 if (IS_ERR(dir)) 39 37 return PTR_ERR(dir); 40 38 39 + config.dev = &pdev->dev; 40 + config.sz = 1; 41 + config.dat = dat; 42 + 41 43 switch (id) { 42 44 case 3: 43 45 /* PORTD is inverted logic for direction register */ 44 - err = bgpio_init(gc, &pdev->dev, 1, dat, NULL, NULL, 45 - NULL, dir, 0); 46 + config.dirin = dir; 46 47 break; 47 48 default: 48 - err = bgpio_init(gc, &pdev->dev, 1, dat, NULL, NULL, 49 - dir, NULL, 0); 49 + config.dirout = dir; 50 50 break; 51 51 } 52 52 53 + err = gpio_generic_chip_init(gen_gc, &config); 53 54 if (err) 54 55 return err; 55 56 56 57 switch (id) { 57 58 case 4: 58 59 /* PORTE is 3 lines only */ 59 - gc->ngpio = 3; 60 + gen_gc->gc.ngpio = 3; 60 61 break; 61 62 default: 62 63 break; 63 64 } 64 65 65 - gc->base = -1; 66 - gc->owner = THIS_MODULE; 66 + gen_gc->gc.base = -1; 67 + gen_gc->gc.owner = THIS_MODULE; 67 68 68 - return devm_gpiochip_add_data(&pdev->dev, gc, NULL); 69 + return devm_gpiochip_add_data(&pdev->dev, &gen_gc->gc, NULL); 69 70 } 70 71 71 72 static const struct of_device_id clps711x_gpio_ids[] = {