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

gpio: mm-lantiq: Drop legacy-of-mm-gpiochip.h header from GPIO driver

Remove legacy-of-mm-gpiochip.h header file. The above mentioned
file provides an OF API that's deprecated. There is no agnostic
alternatives to it and we have to open code the logic which was
hidden behind of_mm_gpiochip_add_data(). Note, most of the GPIO
drivers are using their own labeling schemas and resource retrieval
that only a few may gain of the code deduplication, so whenever
alternative is appear we can move drivers again to use that one.

[Text copied from commit 34064c8267a6 ("powerpc/8xx: Drop
legacy-of-mm-gpiochip.h header")]

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

authored by

Christophe Leroy and committed by
Bartosz Golaszewski
8d0d46da 9631a100

+25 -23
-1
drivers/gpio/Kconfig
··· 476 476 config GPIO_MM_LANTIQ 477 477 bool "Lantiq Memory mapped GPIOs" 478 478 depends on LANTIQ && SOC_XWAY 479 - select OF_GPIO_MM_GPIOCHIP 480 479 help 481 480 This enables support for memory mapped GPIOs on the External Bus Unit 482 481 (EBU) found on Lantiq SoCs. The GPIOs are output only as they are
+25 -22
drivers/gpio/gpio-mm-lantiq.c
··· 10 10 #include <linux/platform_device.h> 11 11 #include <linux/mutex.h> 12 12 #include <linux/gpio/driver.h> 13 - #include <linux/gpio/legacy-of-mm-gpiochip.h> 14 13 #include <linux/of.h> 15 14 #include <linux/io.h> 16 15 #include <linux/slab.h> ··· 26 27 #define LTQ_EBU_WP 0x80000000 /* write protect bit */ 27 28 28 29 struct ltq_mm { 29 - struct of_mm_gpio_chip mmchip; 30 + struct gpio_chip gc; 31 + void __iomem *regs; 30 32 u16 shadow; /* shadow the latches state */ 31 33 }; 32 34 ··· 44 44 45 45 spin_lock_irqsave(&ebu_lock, flags); 46 46 ltq_ebu_w32(LTQ_EBU_BUSCON, LTQ_EBU_BUSCON1); 47 - __raw_writew(chip->shadow, chip->mmchip.regs); 47 + __raw_writew(chip->shadow, chip->regs); 48 48 ltq_ebu_w32(LTQ_EBU_BUSCON | LTQ_EBU_WP, LTQ_EBU_BUSCON1); 49 49 spin_unlock_irqrestore(&ebu_lock, flags); 50 50 } ··· 87 87 * ltq_mm_save_regs() - Set initial values of GPIO pins 88 88 * @mm_gc: pointer to memory mapped GPIO chip structure 89 89 */ 90 - static void ltq_mm_save_regs(struct of_mm_gpio_chip *mm_gc) 90 + static void ltq_mm_save_regs(struct ltq_mm *chip) 91 91 { 92 - struct ltq_mm *chip = 93 - container_of(mm_gc, struct ltq_mm, mmchip); 94 - 95 92 /* tell the ebu controller which memory address we will be using */ 96 - ltq_ebu_w32(CPHYSADDR(chip->mmchip.regs) | 0x1, LTQ_EBU_ADDRSEL1); 93 + ltq_ebu_w32(CPHYSADDR((__force void *)chip->regs) | 0x1, LTQ_EBU_ADDRSEL1); 97 94 98 95 ltq_mm_apply(chip); 99 96 } 100 97 101 98 static int ltq_mm_probe(struct platform_device *pdev) 102 99 { 100 + struct device *dev = &pdev->dev; 101 + struct device_node *np = dev->of_node; 102 + struct gpio_chip *gc; 103 103 struct ltq_mm *chip; 104 104 u32 shadow; 105 105 ··· 107 107 if (!chip) 108 108 return -ENOMEM; 109 109 110 - platform_set_drvdata(pdev, chip); 110 + gc = &chip->gc; 111 111 112 - chip->mmchip.gc.ngpio = 16; 113 - chip->mmchip.gc.direction_output = ltq_mm_dir_out; 114 - chip->mmchip.gc.set = ltq_mm_set; 115 - chip->mmchip.save_regs = ltq_mm_save_regs; 112 + gc->base = -1; 113 + gc->ngpio = 16; 114 + gc->direction_output = ltq_mm_dir_out; 115 + gc->set = ltq_mm_set; 116 + gc->parent = dev; 117 + gc->owner = THIS_MODULE; 118 + gc->label = devm_kasprintf(dev, GFP_KERNEL, "%pOF", np); 119 + if (!gc->label) 120 + return -ENOMEM; 121 + 122 + chip->regs = devm_of_iomap(dev, np, 0, NULL); 123 + if (IS_ERR(chip->regs)) 124 + return PTR_ERR(chip->regs); 125 + 126 + ltq_mm_save_regs(chip); 116 127 117 128 /* store the shadow value if one was passed by the devicetree */ 118 129 if (!of_property_read_u32(pdev->dev.of_node, "lantiq,shadow", &shadow)) 119 130 chip->shadow = shadow; 120 131 121 - return of_mm_gpiochip_add_data(pdev->dev.of_node, &chip->mmchip, chip); 122 - } 123 - 124 - static void ltq_mm_remove(struct platform_device *pdev) 125 - { 126 - struct ltq_mm *chip = platform_get_drvdata(pdev); 127 - 128 - of_mm_gpiochip_remove(&chip->mmchip); 132 + return devm_gpiochip_add_data(dev, gc, chip); 129 133 } 130 134 131 135 static const struct of_device_id ltq_mm_match[] = { ··· 140 136 141 137 static struct platform_driver ltq_mm_driver = { 142 138 .probe = ltq_mm_probe, 143 - .remove = ltq_mm_remove, 144 139 .driver = { 145 140 .name = "gpio-mm-ltq", 146 141 .of_match_table = ltq_mm_match,