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

gpio: ge: Make driver OF-independent

There is nothing in the driver that requires OF APIs,
make the driver OF independent.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Randy Dunlap <rdunlap@infradead.org>
Tested-by: Randy Dunlap <rdunlap@infradead.org> # build-tested
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

authored by

Andy Shevchenko and committed by
Bartosz Golaszewski
0cf2b4f5 94484a79

+13 -20
+13 -20
drivers/gpio/gpio-ge.c
··· 21 21 #include <linux/gpio/driver.h> 22 22 #include <linux/io.h> 23 23 #include <linux/kernel.h> 24 + #include <linux/mod_devicetable.h> 24 25 #include <linux/module.h> 25 - #include <linux/of_address.h> 26 - #include <linux/of.h> 27 26 #include <linux/platform_device.h> 27 + #include <linux/property.h> 28 28 #include <linux/slab.h> 29 29 30 30 #define GEF_GPIO_DIRECT 0x00 ··· 54 54 55 55 static int __init gef_gpio_probe(struct platform_device *pdev) 56 56 { 57 + struct device *dev = &pdev->dev; 57 58 struct gpio_chip *gc; 58 59 void __iomem *regs; 59 60 int ret; ··· 63 62 if (!gc) 64 63 return -ENOMEM; 65 64 66 - regs = of_iomap(pdev->dev.of_node, 0); 67 - if (!regs) 68 - return -ENOMEM; 65 + regs = devm_platform_ioremap_resource(pdev, 0); 66 + if (IS_ERR(regs)) 67 + return PTR_ERR(regs); 69 68 70 69 ret = bgpio_init(gc, &pdev->dev, 4, regs + GEF_GPIO_IN, 71 70 regs + GEF_GPIO_OUT, NULL, NULL, 72 71 regs + GEF_GPIO_DIRECT, BGPIOF_BIG_ENDIAN_BYTE_ORDER); 73 - if (ret) { 74 - dev_err(&pdev->dev, "bgpio_init failed\n"); 75 - goto err0; 76 - } 72 + if (ret) 73 + return dev_err_probe(dev, ret, "bgpio_init failed\n"); 77 74 78 75 /* Setup pointers to chip functions */ 79 - gc->label = devm_kasprintf(&pdev->dev, GFP_KERNEL, "%pOF", pdev->dev.of_node); 80 - if (!gc->label) { 81 - ret = -ENOMEM; 82 - goto err0; 83 - } 76 + gc->label = devm_kasprintf(dev, GFP_KERNEL, "%pfw", dev_fwnode(dev)); 77 + if (!gc->label) 78 + return -ENOMEM; 84 79 85 80 gc->base = -1; 86 - gc->ngpio = (u16)(uintptr_t)of_device_get_match_data(&pdev->dev); 81 + gc->ngpio = (uintptr_t)device_get_match_data(dev); 87 82 88 83 /* This function adds a memory mapped GPIO chip */ 89 84 ret = devm_gpiochip_add_data(&pdev->dev, gc, NULL); 90 85 if (ret) 91 - goto err0; 86 + return dev_err_probe(dev, ret, "GPIO chip registration failed\n"); 92 87 93 88 return 0; 94 - err0: 95 - iounmap(regs); 96 - pr_err("%pOF: GPIO chip registration failed\n", pdev->dev.of_node); 97 - return ret; 98 89 }; 99 90 100 91 static struct platform_driver gef_gpio_driver = {