From: Bartosz Golaszewski bartosz.golaszewski@linaro.org
[ Upstream commit df1540f8f311a8b2ef0e450e7e40710784acc8c7 ]
This is already done by the gpio-regmap abstraction by calling gpiochip_get_ngpios(). We don't need to do this at the driver level.
Signed-off-by: Bartosz Golaszewski bartosz.golaszewski@linaro.org Link: https://lore.kernel.org/r/20250408-gpio-regmap-ngpios-v2-1-26f254014f57@lina... Signed-off-by: Bartosz Golaszewski brgl@bgdev.pl Signed-off-by: Sasha Levin sashal@kernel.org ---
NO This commit should NOT be backported to stable kernel trees. **Analysis:** This commit removes driver-level handling of the 'ngpios' property in the ds4520 GPIO driver, relying instead on the gpio-regmap abstraction layer to handle this automatically via `gpiochip_get_ngpios()`. **Reasons this should NOT be backported:** 1. **Code cleanup, not a bugfix**: The commit message explicitly states "This is already done by the gpio-regmap abstraction by calling gpiochip_get_ngpios(). We don't need to do this at the driver level." This indicates the change removes redundant code rather than fixing a functional issue. 2. **No user-visible impact**: Both the before and after code achieve the same functionality - reading the 'ngpios' property and configuring the GPIO count. The driver worked correctly before this change. 3. **Architectural cleanup**: The change moves responsibility from the driver level to the abstraction layer, which is a code organization improvement rather than a critical fix. 4. **Missing infrastructure dependencies**: Looking at the code in `/home/sasha/linux/drivers/gpio/gpio-regmap.c:274-278`, the automatic ngpios handling was added in commit db305161880a "gpio: regmap: Allow ngpio to be read from the property". Without this infrastructure change being backported first, this commit would break the ds4520 driver in stable trees. 5. **Similar commits marked NO**: The reference commits show that code organization changes (#1, #4, #5) are marked as NO for backporting, while actual bugfixes (#2, #3) are marked as YES. 6. **No stable tree indicators**: The commit message contains no "Fixes:" tag, "Cc: stable" notation, or indication that this addresses a user- impacting issue. 7. **Risk vs benefit**: The change removes 6 lines of working code (lines 28, 36-38, 47 in the original) without fixing any reported issues. The risk of regression outweighs any benefit for stable trees. The ds4520 driver was relatively new (first commit 659ad5f7efec) and this cleanup came shortly after, making it an optimization rather than a critical fix requiring backport.
drivers/gpio/gpio-ds4520.c | 6 ------ 1 file changed, 6 deletions(-)
diff --git a/drivers/gpio/gpio-ds4520.c b/drivers/gpio/gpio-ds4520.c index 1903deaef3e9b..f52ecae382a45 100644 --- a/drivers/gpio/gpio-ds4520.c +++ b/drivers/gpio/gpio-ds4520.c @@ -25,7 +25,6 @@ static int ds4520_gpio_probe(struct i2c_client *client) struct gpio_regmap_config config = { }; struct device *dev = &client->dev; struct regmap *regmap; - u32 ngpio; u32 base; int ret;
@@ -33,10 +32,6 @@ static int ds4520_gpio_probe(struct i2c_client *client) if (ret) return dev_err_probe(dev, ret, "Missing 'reg' property.\n");
- ret = device_property_read_u32(dev, "ngpios", &ngpio); - if (ret) - return dev_err_probe(dev, ret, "Missing 'ngpios' property.\n"); - regmap = devm_regmap_init_i2c(client, &ds4520_regmap_config); if (IS_ERR(regmap)) return dev_err_probe(dev, PTR_ERR(regmap), @@ -44,7 +39,6 @@ static int ds4520_gpio_probe(struct i2c_client *client)
config.regmap = regmap; config.parent = dev; - config.ngpio = ngpio;
config.reg_dat_base = base + DS4520_IO_STATUS0; config.reg_set_base = base + DS4520_PULLUP0;