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: mmio: 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-14-f3d1a4c57124@linaro.org
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

+21 -8
+21 -8
drivers/gpio/gpio-mmio.c
··· 57 57 #include <linux/types.h> 58 58 59 59 #include <linux/gpio/driver.h> 60 + #include <linux/gpio/generic.h> 60 61 61 62 #include "gpiolib.h" 62 63 ··· 738 737 739 738 static int bgpio_pdev_probe(struct platform_device *pdev) 740 739 { 740 + struct gpio_generic_chip_config config; 741 + struct gpio_generic_chip *gen_gc; 741 742 struct device *dev = &pdev->dev; 742 743 struct resource *r; 743 744 void __iomem *dat; ··· 751 748 unsigned long flags = 0; 752 749 unsigned int base; 753 750 int err; 754 - struct gpio_chip *gc; 755 751 const char *label; 756 752 757 753 r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "dat"); ··· 779 777 if (IS_ERR(dirin)) 780 778 return PTR_ERR(dirin); 781 779 782 - gc = devm_kzalloc(&pdev->dev, sizeof(*gc), GFP_KERNEL); 783 - if (!gc) 780 + gen_gc = devm_kzalloc(&pdev->dev, sizeof(*gen_gc), GFP_KERNEL); 781 + if (!gen_gc) 784 782 return -ENOMEM; 785 783 786 784 if (device_is_big_endian(dev)) ··· 789 787 if (device_property_read_bool(dev, "no-output")) 790 788 flags |= BGPIOF_NO_OUTPUT; 791 789 792 - err = bgpio_init(gc, dev, sz, dat, set, clr, dirout, dirin, flags); 790 + config = (struct gpio_generic_chip_config) { 791 + .dev = dev, 792 + .sz = sz, 793 + .dat = dat, 794 + .set = set, 795 + .clr = clr, 796 + .dirout = dirout, 797 + .dirin = dirin, 798 + .flags = flags, 799 + }; 800 + 801 + err = gpio_generic_chip_init(gen_gc, &config); 793 802 if (err) 794 803 return err; 795 804 796 805 err = device_property_read_string(dev, "label", &label); 797 806 if (!err) 798 - gc->label = label; 807 + gen_gc->gc.label = label; 799 808 800 809 /* 801 810 * This property *must not* be used in device-tree sources, it's only ··· 814 801 */ 815 802 err = device_property_read_u32(dev, "gpio-mmio,base", &base); 816 803 if (!err && base <= INT_MAX) 817 - gc->base = base; 804 + gen_gc->gc.base = base; 818 805 819 - platform_set_drvdata(pdev, gc); 806 + platform_set_drvdata(pdev, &gen_gc->gc); 820 807 821 - return devm_gpiochip_add_data(&pdev->dev, gc, NULL); 808 + return devm_gpiochip_add_data(&pdev->dev, &gen_gc->gc, NULL); 822 809 } 823 810 824 811 static const struct platform_device_id bgpio_id_table[] = {