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

mfd: hi655x-pmic: Replace legacy gpio interface for gpiod interface

Considering the current transition of the GPIO subsystem, remove all
dependencies of the legacy GPIO interface (linux/gpio.h and linux
/of_gpio.h) and replace it with the descriptor-based GPIO approach.

Signed-off-by: Maíra Canal <maira.canal@usp.br>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Link: https://lore.kernel.org/r/Yk2maZuf+5FGL+eg@fedora

authored by

Maíra Canal and committed by
Lee Jones
7f5aaa4a 54c861f9

+11 -20
+8 -19
drivers/mfd/hi655x-pmic.c
··· 9 9 * Fei Wang <w.f@huawei.com> 10 10 */ 11 11 12 - #include <linux/gpio.h> 13 12 #include <linux/io.h> 14 13 #include <linux/interrupt.h> 15 14 #include <linux/init.h> 16 15 #include <linux/mfd/core.h> 17 16 #include <linux/mfd/hi655x-pmic.h> 18 17 #include <linux/module.h> 19 - #include <linux/of_gpio.h> 18 + #include <linux/gpio/consumer.h> 20 19 #include <linux/of_platform.h> 21 20 #include <linux/platform_device.h> 22 21 #include <linux/regmap.h> ··· 93 94 int ret; 94 95 struct hi655x_pmic *pmic; 95 96 struct device *dev = &pdev->dev; 96 - struct device_node *np = dev->of_node; 97 97 void __iomem *base; 98 98 99 99 pmic = devm_kzalloc(dev, sizeof(*pmic), GFP_KERNEL); ··· 118 120 119 121 hi655x_local_irq_clear(pmic->regmap); 120 122 121 - pmic->gpio = of_get_named_gpio(np, "pmic-gpios", 0); 122 - if (!gpio_is_valid(pmic->gpio)) { 123 - dev_err(dev, "Failed to get the pmic-gpios\n"); 124 - return -ENODEV; 125 - } 123 + pmic->gpio = devm_gpiod_get_optional(dev, "pmic", GPIOD_IN); 124 + if (IS_ERR(pmic->gpio)) 125 + return dev_err_probe(dev, PTR_ERR(pmic->gpio), 126 + "Failed to request hi655x pmic-gpio"); 126 127 127 - ret = devm_gpio_request_one(dev, pmic->gpio, GPIOF_IN, 128 - "hi655x_pmic_irq"); 129 - if (ret < 0) { 130 - dev_err(dev, "Failed to request gpio %d ret = %d\n", 131 - pmic->gpio, ret); 132 - return ret; 133 - } 134 - 135 - ret = regmap_add_irq_chip(pmic->regmap, gpio_to_irq(pmic->gpio), 128 + ret = regmap_add_irq_chip(pmic->regmap, gpiod_to_irq(pmic->gpio), 136 129 IRQF_TRIGGER_LOW | IRQF_NO_SUSPEND, 0, 137 130 &hi655x_irq_chip, &pmic->irq_data); 138 131 if (ret) { ··· 138 149 regmap_irq_get_domain(pmic->irq_data)); 139 150 if (ret) { 140 151 dev_err(dev, "Failed to register device %d\n", ret); 141 - regmap_del_irq_chip(gpio_to_irq(pmic->gpio), pmic->irq_data); 152 + regmap_del_irq_chip(gpiod_to_irq(pmic->gpio), pmic->irq_data); 142 153 return ret; 143 154 } 144 155 ··· 149 160 { 150 161 struct hi655x_pmic *pmic = platform_get_drvdata(pdev); 151 162 152 - regmap_del_irq_chip(gpio_to_irq(pmic->gpio), pmic->irq_data); 163 + regmap_del_irq_chip(gpiod_to_irq(pmic->gpio), pmic->irq_data); 153 164 mfd_remove_devices(&pdev->dev); 154 165 return 0; 155 166 }
+3 -1
include/linux/mfd/hi655x-pmic.h
··· 12 12 #ifndef __HI655X_PMIC_H 13 13 #define __HI655X_PMIC_H 14 14 15 + #include <linux/gpio/consumer.h> 16 + 15 17 /* Hi655x registers are mapped to memory bus in 4 bytes stride */ 16 18 #define HI655X_STRIDE 4 17 19 #define HI655X_BUS_ADDR(x) ((x) << 2) ··· 55 53 struct resource *res; 56 54 struct device *dev; 57 55 struct regmap *regmap; 58 - int gpio; 56 + struct gpio_desc *gpio; 59 57 unsigned int ver; 60 58 struct regmap_irq_chip_data *irq_data; 61 59 };