mirror of
https://github.com/torvalds/linux.git
synced 2026-06-01 19:13:47 +02:00
gpio: ts4800: 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/20250825-gpio-mmio-gpio-conv-v1-7-356b4b1d5110@linaro.org Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
This commit is contained in:
parent
ac1eca3ab9
commit
9215a4fb59
|
|
@ -6,6 +6,7 @@
|
|||
*/
|
||||
|
||||
#include <linux/gpio/driver.h>
|
||||
#include <linux/gpio/generic.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/property.h>
|
||||
|
|
@ -17,13 +18,14 @@
|
|||
|
||||
static int ts4800_gpio_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct gpio_generic_chip_config config;
|
||||
struct device *dev = &pdev->dev;
|
||||
struct gpio_chip *chip;
|
||||
struct gpio_generic_chip *chip;
|
||||
void __iomem *base_addr;
|
||||
int retval;
|
||||
u32 ngpios;
|
||||
|
||||
chip = devm_kzalloc(&pdev->dev, sizeof(struct gpio_chip), GFP_KERNEL);
|
||||
chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL);
|
||||
if (!chip)
|
||||
return -ENOMEM;
|
||||
|
||||
|
|
@ -37,15 +39,22 @@ static int ts4800_gpio_probe(struct platform_device *pdev)
|
|||
else if (retval)
|
||||
return retval;
|
||||
|
||||
retval = bgpio_init(chip, &pdev->dev, 2, base_addr + INPUT_REG_OFFSET,
|
||||
base_addr + OUTPUT_REG_OFFSET, NULL,
|
||||
base_addr + DIRECTION_REG_OFFSET, NULL, 0);
|
||||
config = (typeof(config)){
|
||||
.dev = dev,
|
||||
.sz = 2,
|
||||
.dat = base_addr + INPUT_REG_OFFSET,
|
||||
.set = base_addr + OUTPUT_REG_OFFSET,
|
||||
.dirout = base_addr + DIRECTION_REG_OFFSET,
|
||||
};
|
||||
|
||||
retval = gpio_generic_chip_init(chip, &config);
|
||||
if (retval)
|
||||
return dev_err_probe(dev, retval, "bgpio_init failed\n");
|
||||
return dev_err_probe(dev, retval,
|
||||
"failed to initialize the generic GPIO chip\n");
|
||||
|
||||
chip->ngpio = ngpios;
|
||||
chip->gc.ngpio = ngpios;
|
||||
|
||||
return devm_gpiochip_add_data(&pdev->dev, chip, NULL);
|
||||
return devm_gpiochip_add_data(dev, &chip->gc, NULL);
|
||||
}
|
||||
|
||||
static const struct of_device_id ts4800_gpio_of_match[] = {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user