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

gpio: ts4800: Remove duplicate code to handle 'ngpios' property

The gpio_generic_chip_init() handles the 'ngpios' property and
assigns the respective field in struct gpio_chip either with
the value of it, or, if not found, with the default based on
the register size. There is no need to repeat this in the driver.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Linus Walleij <linusw@kernel.org>
Link: https://patch.msgid.link/20260219134647.2258593-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>

authored by

Andy Shevchenko and committed by
Bartosz Golaszewski
0acbe817 c08381ad

-10
-10
drivers/gpio/gpio-ts4800.c
··· 11 11 #include <linux/platform_device.h> 12 12 #include <linux/property.h> 13 13 14 - #define DEFAULT_PIN_NUMBER 16 15 14 #define INPUT_REG_OFFSET 0x00 16 15 #define OUTPUT_REG_OFFSET 0x02 17 16 #define DIRECTION_REG_OFFSET 0x04 ··· 22 23 struct gpio_generic_chip *chip; 23 24 void __iomem *base_addr; 24 25 int retval; 25 - u32 ngpios; 26 26 27 27 chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL); 28 28 if (!chip) ··· 30 32 base_addr = devm_platform_ioremap_resource(pdev, 0); 31 33 if (IS_ERR(base_addr)) 32 34 return PTR_ERR(base_addr); 33 - 34 - retval = device_property_read_u32(dev, "ngpios", &ngpios); 35 - if (retval == -EINVAL) 36 - ngpios = DEFAULT_PIN_NUMBER; 37 - else if (retval) 38 - return retval; 39 35 40 36 config = (struct gpio_generic_chip_config) { 41 37 .dev = dev, ··· 43 51 if (retval) 44 52 return dev_err_probe(dev, retval, 45 53 "failed to initialize the generic GPIO chip\n"); 46 - 47 - chip->gc.ngpio = ngpios; 48 54 49 55 return devm_gpiochip_add_data(dev, &chip->gc, NULL); 50 56 }