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.

powerpc/44x: Change GPIO driver to a proper platform driver

In order to drop legacy-of-mm-gpiochip dependency, first change the
44x GPIO driver to a proper platform driver.

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Madhavan Srinivasan <maddy@linux.ibm.com>
Link: https://patch.msgid.link/29d89aa43536714b193d9710301341f838fcb5b7.1755519343.git.christophe.leroy@csgroup.eu

authored by

Christophe Leroy and committed by
Madhavan Srinivasan
1044dbaf 7f9bcf13

+41 -32
+41 -32
arch/powerpc/platforms/44x/gpio.c
··· 18 18 #include <linux/gpio/driver.h> 19 19 #include <linux/types.h> 20 20 #include <linux/slab.h> 21 + #include <linux/platform_device.h> 21 22 22 23 #define GPIO_MASK(gpio) (0x80000000 >> (gpio)) 23 24 #define GPIO_MASK2(gpio) (0xc0000000 >> ((gpio) * 2)) ··· 156 155 return 0; 157 156 } 158 157 159 - static int __init ppc4xx_add_gpiochips(void) 158 + static int ppc4xx_gpio_probe(struct platform_device *ofdev) 160 159 { 161 - struct device_node *np; 160 + struct device *dev = &ofdev->dev; 161 + struct device_node *np = dev->of_node; 162 + struct ppc4xx_gpio_chip *chip; 163 + struct of_mm_gpio_chip *mm_gc; 164 + struct gpio_chip *gc; 162 165 163 - for_each_compatible_node(np, NULL, "ibm,ppc4xx-gpio") { 164 - int ret; 165 - struct ppc4xx_gpio_chip *ppc4xx_gc; 166 - struct of_mm_gpio_chip *mm_gc; 167 - struct gpio_chip *gc; 166 + chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL); 167 + if (!chip) 168 + return -ENOMEM; 168 169 169 - ppc4xx_gc = kzalloc(sizeof(*ppc4xx_gc), GFP_KERNEL); 170 - if (!ppc4xx_gc) { 171 - ret = -ENOMEM; 172 - goto err; 173 - } 170 + spin_lock_init(&chip->lock); 174 171 175 - spin_lock_init(&ppc4xx_gc->lock); 172 + mm_gc = &chip->mm_gc; 173 + gc = &mm_gc->gc; 176 174 177 - mm_gc = &ppc4xx_gc->mm_gc; 178 - gc = &mm_gc->gc; 175 + gc->ngpio = 32; 176 + gc->direction_input = ppc4xx_gpio_dir_in; 177 + gc->direction_output = ppc4xx_gpio_dir_out; 178 + gc->get = ppc4xx_gpio_get; 179 + gc->set = ppc4xx_gpio_set; 179 180 180 - gc->ngpio = 32; 181 - gc->direction_input = ppc4xx_gpio_dir_in; 182 - gc->direction_output = ppc4xx_gpio_dir_out; 183 - gc->get = ppc4xx_gpio_get; 184 - gc->set = ppc4xx_gpio_set; 185 - 186 - ret = of_mm_gpiochip_add_data(np, mm_gc, ppc4xx_gc); 187 - if (ret) 188 - goto err; 189 - continue; 190 - err: 191 - pr_err("%pOF: registration failed with status %d\n", np, ret); 192 - kfree(ppc4xx_gc); 193 - /* try others anyway */ 194 - } 195 - return 0; 181 + return of_mm_gpiochip_add_data(np, mm_gc, chip); 196 182 } 197 - arch_initcall(ppc4xx_add_gpiochips); 183 + 184 + static const struct of_device_id ppc4xx_gpio_match[] = { 185 + { 186 + .compatible = "ibm,ppc4xx-gpio", 187 + }, 188 + {}, 189 + }; 190 + MODULE_DEVICE_TABLE(of, ppc4xx_gpio_match); 191 + 192 + static struct platform_driver ppc4xx_gpio_driver = { 193 + .probe = ppc4xx_gpio_probe, 194 + .driver = { 195 + .name = "ppc4xx-gpio", 196 + .of_match_table = ppc4xx_gpio_match, 197 + }, 198 + }; 199 + 200 + static int __init ppc4xx_gpio_init(void) 201 + { 202 + return platform_driver_register(&ppc4xx_gpio_driver); 203 + } 204 + arch_initcall(ppc4xx_gpio_init);