* [PATCH 01/12] gpio: tegra186: don't call the set() callback directly
2025-07-02 9:14 [PATCH 00/12] gpio: use new GPIO line value setter callbacks Bartosz Golaszewski
@ 2025-07-02 9:14 ` Bartosz Golaszewski
2025-07-02 9:14 ` [PATCH 02/12] gpio: tegra186: use new GPIO line value setter callbacks Bartosz Golaszewski
` (11 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: Bartosz Golaszewski @ 2025-07-02 9:14 UTC (permalink / raw)
To: Linus Walleij, Bartosz Golaszewski, Thierry Reding,
Jonathan Hunter, Robert Richter, Aaro Koskinen, Andreas Kemnade,
Kevin Hilman, Roger Quadros, Tony Lindgren
Cc: linux-gpio, linux-tegra, linux-kernel, linux-omap,
Bartosz Golaszewski
From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Drivers should not dereference GPIO chip callbacks directly. Move the
module's set() function higher to make it available to the
direction_output() callback and call it instead.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
drivers/gpio/gpio-tegra186.c | 42 +++++++++++++++++++++---------------------
1 file changed, 21 insertions(+), 21 deletions(-)
diff --git a/drivers/gpio/gpio-tegra186.c b/drivers/gpio/gpio-tegra186.c
index d27bfac6c9f53d23806725f5fc89fd0331f4afb0..04effccf9ecdf0828bc50455dace3ba8e8bdbbef 100644
--- a/drivers/gpio/gpio-tegra186.c
+++ b/drivers/gpio/gpio-tegra186.c
@@ -202,6 +202,26 @@ static int tegra186_init_valid_mask(struct gpio_chip *chip,
return 0;
}
+static void tegra186_gpio_set(struct gpio_chip *chip, unsigned int offset,
+ int level)
+{
+ struct tegra_gpio *gpio = gpiochip_get_data(chip);
+ void __iomem *base;
+ u32 value;
+
+ base = tegra186_gpio_get_base(gpio, offset);
+ if (WARN_ON(base == NULL))
+ return;
+
+ value = readl(base + TEGRA186_GPIO_OUTPUT_VALUE);
+ if (level == 0)
+ value &= ~TEGRA186_GPIO_OUTPUT_VALUE_HIGH;
+ else
+ value |= TEGRA186_GPIO_OUTPUT_VALUE_HIGH;
+
+ writel(value, base + TEGRA186_GPIO_OUTPUT_VALUE);
+}
+
static int tegra186_gpio_get_direction(struct gpio_chip *chip,
unsigned int offset)
{
@@ -251,7 +271,7 @@ static int tegra186_gpio_direction_output(struct gpio_chip *chip,
u32 value;
/* configure output level first */
- chip->set(chip, offset, level);
+ tegra186_gpio_set(chip, offset, level);
base = tegra186_gpio_get_base(gpio, offset);
if (WARN_ON(base == NULL))
@@ -359,26 +379,6 @@ static int tegra186_gpio_get(struct gpio_chip *chip, unsigned int offset)
return value & BIT(0);
}
-static void tegra186_gpio_set(struct gpio_chip *chip, unsigned int offset,
- int level)
-{
- struct tegra_gpio *gpio = gpiochip_get_data(chip);
- void __iomem *base;
- u32 value;
-
- base = tegra186_gpio_get_base(gpio, offset);
- if (WARN_ON(base == NULL))
- return;
-
- value = readl(base + TEGRA186_GPIO_OUTPUT_VALUE);
- if (level == 0)
- value &= ~TEGRA186_GPIO_OUTPUT_VALUE_HIGH;
- else
- value |= TEGRA186_GPIO_OUTPUT_VALUE_HIGH;
-
- writel(value, base + TEGRA186_GPIO_OUTPUT_VALUE);
-}
-
static int tegra186_gpio_set_config(struct gpio_chip *chip,
unsigned int offset,
unsigned long config)
--
2.48.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 02/12] gpio: tegra186: use new GPIO line value setter callbacks
2025-07-02 9:14 [PATCH 00/12] gpio: use new GPIO line value setter callbacks Bartosz Golaszewski
2025-07-02 9:14 ` [PATCH 01/12] gpio: tegra186: don't call the set() callback directly Bartosz Golaszewski
@ 2025-07-02 9:14 ` Bartosz Golaszewski
2025-07-02 9:14 ` [PATCH 03/12] gpio: tegra: " Bartosz Golaszewski
` (10 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: Bartosz Golaszewski @ 2025-07-02 9:14 UTC (permalink / raw)
To: Linus Walleij, Bartosz Golaszewski, Thierry Reding,
Jonathan Hunter, Robert Richter, Aaro Koskinen, Andreas Kemnade,
Kevin Hilman, Roger Quadros, Tony Lindgren
Cc: linux-gpio, linux-tegra, linux-kernel, linux-omap,
Bartosz Golaszewski
From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
struct gpio_chip now has callbacks for setting line values that return
an integer, allowing to indicate failures. Convert the driver to using
them.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
drivers/gpio/gpio-tegra186.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/drivers/gpio/gpio-tegra186.c b/drivers/gpio/gpio-tegra186.c
index 04effccf9ecdf0828bc50455dace3ba8e8bdbbef..f902da15c419588a2716a3fbae25d5c7637cdfc2 100644
--- a/drivers/gpio/gpio-tegra186.c
+++ b/drivers/gpio/gpio-tegra186.c
@@ -202,8 +202,8 @@ static int tegra186_init_valid_mask(struct gpio_chip *chip,
return 0;
}
-static void tegra186_gpio_set(struct gpio_chip *chip, unsigned int offset,
- int level)
+static int tegra186_gpio_set(struct gpio_chip *chip, unsigned int offset,
+ int level)
{
struct tegra_gpio *gpio = gpiochip_get_data(chip);
void __iomem *base;
@@ -211,7 +211,7 @@ static void tegra186_gpio_set(struct gpio_chip *chip, unsigned int offset,
base = tegra186_gpio_get_base(gpio, offset);
if (WARN_ON(base == NULL))
- return;
+ return -ENODEV;
value = readl(base + TEGRA186_GPIO_OUTPUT_VALUE);
if (level == 0)
@@ -220,6 +220,8 @@ static void tegra186_gpio_set(struct gpio_chip *chip, unsigned int offset,
value |= TEGRA186_GPIO_OUTPUT_VALUE_HIGH;
writel(value, base + TEGRA186_GPIO_OUTPUT_VALUE);
+
+ return 0;
}
static int tegra186_gpio_get_direction(struct gpio_chip *chip,
@@ -269,9 +271,12 @@ static int tegra186_gpio_direction_output(struct gpio_chip *chip,
struct tegra_gpio *gpio = gpiochip_get_data(chip);
void __iomem *base;
u32 value;
+ int ret;
/* configure output level first */
- tegra186_gpio_set(chip, offset, level);
+ ret = tegra186_gpio_set(chip, offset, level);
+ if (ret)
+ return ret;
base = tegra186_gpio_get_base(gpio, offset);
if (WARN_ON(base == NULL))
@@ -886,7 +891,7 @@ static int tegra186_gpio_probe(struct platform_device *pdev)
gpio->gpio.direction_input = tegra186_gpio_direction_input;
gpio->gpio.direction_output = tegra186_gpio_direction_output;
gpio->gpio.get = tegra186_gpio_get;
- gpio->gpio.set = tegra186_gpio_set;
+ gpio->gpio.set_rv = tegra186_gpio_set;
gpio->gpio.set_config = tegra186_gpio_set_config;
gpio->gpio.add_pin_ranges = tegra186_gpio_add_pin_ranges;
gpio->gpio.init_valid_mask = tegra186_init_valid_mask;
--
2.48.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 03/12] gpio: tegra: use new GPIO line value setter callbacks
2025-07-02 9:14 [PATCH 00/12] gpio: use new GPIO line value setter callbacks Bartosz Golaszewski
2025-07-02 9:14 ` [PATCH 01/12] gpio: tegra186: don't call the set() callback directly Bartosz Golaszewski
2025-07-02 9:14 ` [PATCH 02/12] gpio: tegra186: use new GPIO line value setter callbacks Bartosz Golaszewski
@ 2025-07-02 9:14 ` Bartosz Golaszewski
2025-07-02 9:14 ` [PATCH 04/12] gpio: thunderx: " Bartosz Golaszewski
` (9 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: Bartosz Golaszewski @ 2025-07-02 9:14 UTC (permalink / raw)
To: Linus Walleij, Bartosz Golaszewski, Thierry Reding,
Jonathan Hunter, Robert Richter, Aaro Koskinen, Andreas Kemnade,
Kevin Hilman, Roger Quadros, Tony Lindgren
Cc: linux-gpio, linux-tegra, linux-kernel, linux-omap,
Bartosz Golaszewski
From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
struct gpio_chip now has callbacks for setting line values that return
an integer, allowing to indicate failures. Convert the driver to using
them.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
drivers/gpio/gpio-tegra.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/gpio/gpio-tegra.c b/drivers/gpio/gpio-tegra.c
index 9ad286adf2632f300ee981185ea32d79ca012df5..126fd12550aa8e6bb812bb38a56d37c38114cd15 100644
--- a/drivers/gpio/gpio-tegra.c
+++ b/drivers/gpio/gpio-tegra.c
@@ -146,12 +146,14 @@ static void tegra_gpio_free(struct gpio_chip *chip, unsigned int offset)
tegra_gpio_disable(tgi, offset);
}
-static void tegra_gpio_set(struct gpio_chip *chip, unsigned int offset,
- int value)
+static int tegra_gpio_set(struct gpio_chip *chip, unsigned int offset,
+ int value)
{
struct tegra_gpio_info *tgi = gpiochip_get_data(chip);
tegra_gpio_mask_write(tgi, GPIO_MSK_OUT(tgi, offset), offset, value);
+
+ return 0;
}
static int tegra_gpio_get(struct gpio_chip *chip, unsigned int offset)
@@ -718,7 +720,7 @@ static int tegra_gpio_probe(struct platform_device *pdev)
tgi->gc.direction_input = tegra_gpio_direction_input;
tgi->gc.get = tegra_gpio_get;
tgi->gc.direction_output = tegra_gpio_direction_output;
- tgi->gc.set = tegra_gpio_set;
+ tgi->gc.set_rv = tegra_gpio_set;
tgi->gc.get_direction = tegra_gpio_get_direction;
tgi->gc.base = 0;
tgi->gc.ngpio = tgi->bank_count * 32;
--
2.48.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 04/12] gpio: thunderx: use new GPIO line value setter callbacks
2025-07-02 9:14 [PATCH 00/12] gpio: use new GPIO line value setter callbacks Bartosz Golaszewski
` (2 preceding siblings ...)
2025-07-02 9:14 ` [PATCH 03/12] gpio: tegra: " Bartosz Golaszewski
@ 2025-07-02 9:14 ` Bartosz Golaszewski
2025-07-02 9:14 ` [PATCH 05/12] gpio: timberdale: " Bartosz Golaszewski
` (8 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: Bartosz Golaszewski @ 2025-07-02 9:14 UTC (permalink / raw)
To: Linus Walleij, Bartosz Golaszewski, Thierry Reding,
Jonathan Hunter, Robert Richter, Aaro Koskinen, Andreas Kemnade,
Kevin Hilman, Roger Quadros, Tony Lindgren
Cc: linux-gpio, linux-tegra, linux-kernel, linux-omap,
Bartosz Golaszewski
From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
struct gpio_chip now has callbacks for setting line values that return
an integer, allowing to indicate failures. Convert the driver to using
them.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
drivers/gpio/gpio-thunderx.c | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
diff --git a/drivers/gpio/gpio-thunderx.c b/drivers/gpio/gpio-thunderx.c
index 5b851e904c11f5381cd4890828ecd956b78e2f00..eb6a1f0279c09a832ac71d76de8f696d9c28dd17 100644
--- a/drivers/gpio/gpio-thunderx.c
+++ b/drivers/gpio/gpio-thunderx.c
@@ -116,8 +116,8 @@ static int thunderx_gpio_dir_in(struct gpio_chip *chip, unsigned int line)
return 0;
}
-static void thunderx_gpio_set(struct gpio_chip *chip, unsigned int line,
- int value)
+static int thunderx_gpio_set(struct gpio_chip *chip, unsigned int line,
+ int value)
{
struct thunderx_gpio *txgpio = gpiochip_get_data(chip);
int bank = line / 64;
@@ -127,6 +127,8 @@ static void thunderx_gpio_set(struct gpio_chip *chip, unsigned int line,
(bank * GPIO_2ND_BANK) + (value ? GPIO_TX_SET : GPIO_TX_CLR);
writeq(BIT_ULL(bank_bit), reg);
+
+ return 0;
}
static int thunderx_gpio_dir_out(struct gpio_chip *chip, unsigned int line,
@@ -269,9 +271,9 @@ static int thunderx_gpio_get(struct gpio_chip *chip, unsigned int line)
return masked_bits != 0;
}
-static void thunderx_gpio_set_multiple(struct gpio_chip *chip,
- unsigned long *mask,
- unsigned long *bits)
+static int thunderx_gpio_set_multiple(struct gpio_chip *chip,
+ unsigned long *mask,
+ unsigned long *bits)
{
int bank;
u64 set_bits, clear_bits;
@@ -283,6 +285,8 @@ static void thunderx_gpio_set_multiple(struct gpio_chip *chip,
writeq(set_bits, txgpio->register_base + (bank * GPIO_2ND_BANK) + GPIO_TX_SET);
writeq(clear_bits, txgpio->register_base + (bank * GPIO_2ND_BANK) + GPIO_TX_CLR);
}
+
+ return 0;
}
static void thunderx_gpio_irq_ack(struct irq_data *d)
@@ -529,8 +533,8 @@ static int thunderx_gpio_probe(struct pci_dev *pdev,
chip->direction_input = thunderx_gpio_dir_in;
chip->get = thunderx_gpio_get;
chip->direction_output = thunderx_gpio_dir_out;
- chip->set = thunderx_gpio_set;
- chip->set_multiple = thunderx_gpio_set_multiple;
+ chip->set_rv = thunderx_gpio_set;
+ chip->set_multiple_rv = thunderx_gpio_set_multiple;
chip->set_config = thunderx_gpio_set_config;
girq = &chip->irq;
gpio_irq_chip_set_chip(girq, &thunderx_gpio_irq_chip);
--
2.48.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 05/12] gpio: timberdale: use new GPIO line value setter callbacks
2025-07-02 9:14 [PATCH 00/12] gpio: use new GPIO line value setter callbacks Bartosz Golaszewski
` (3 preceding siblings ...)
2025-07-02 9:14 ` [PATCH 04/12] gpio: thunderx: " Bartosz Golaszewski
@ 2025-07-02 9:14 ` Bartosz Golaszewski
2025-07-02 9:14 ` [PATCH 06/12] gpio: tpic2810: remove unneeded callbacks Bartosz Golaszewski
` (7 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: Bartosz Golaszewski @ 2025-07-02 9:14 UTC (permalink / raw)
To: Linus Walleij, Bartosz Golaszewski, Thierry Reding,
Jonathan Hunter, Robert Richter, Aaro Koskinen, Andreas Kemnade,
Kevin Hilman, Roger Quadros, Tony Lindgren
Cc: linux-gpio, linux-tegra, linux-kernel, linux-omap,
Bartosz Golaszewski
From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
struct gpio_chip now has callbacks for setting line values that return
an integer, allowing to indicate failures. Convert the driver to using
them.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
drivers/gpio/gpio-timberdale.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/gpio/gpio-timberdale.c b/drivers/gpio/gpio-timberdale.c
index cb303a26f4d3cd77368b5bdac42aa42821b39345..fbb883089189095cdc0101d864ab90dd042c73a3 100644
--- a/drivers/gpio/gpio-timberdale.c
+++ b/drivers/gpio/gpio-timberdale.c
@@ -80,10 +80,9 @@ static int timbgpio_gpio_direction_output(struct gpio_chip *gpio,
return timbgpio_update_bit(gpio, nr, TGPIODIR, false);
}
-static void timbgpio_gpio_set(struct gpio_chip *gpio,
- unsigned nr, int val)
+static int timbgpio_gpio_set(struct gpio_chip *gpio, unsigned int nr, int val)
{
- timbgpio_update_bit(gpio, nr, TGPIOVAL, val != 0);
+ return timbgpio_update_bit(gpio, nr, TGPIOVAL, val != 0);
}
static int timbgpio_to_irq(struct gpio_chip *gpio, unsigned offset)
@@ -254,7 +253,7 @@ static int timbgpio_probe(struct platform_device *pdev)
gc->direction_input = timbgpio_gpio_direction_input;
gc->get = timbgpio_gpio_get;
gc->direction_output = timbgpio_gpio_direction_output;
- gc->set = timbgpio_gpio_set;
+ gc->set_rv = timbgpio_gpio_set;
gc->to_irq = (irq >= 0 && tgpio->irq_base > 0) ? timbgpio_to_irq : NULL;
gc->dbg_show = NULL;
gc->base = pdata->gpio_base;
--
2.48.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 06/12] gpio: tpic2810: remove unneeded callbacks
2025-07-02 9:14 [PATCH 00/12] gpio: use new GPIO line value setter callbacks Bartosz Golaszewski
` (4 preceding siblings ...)
2025-07-02 9:14 ` [PATCH 05/12] gpio: timberdale: " Bartosz Golaszewski
@ 2025-07-02 9:14 ` Bartosz Golaszewski
2025-07-02 9:14 ` [PATCH 07/12] gpio: tpic2810: use new GPIO line value setter callbacks Bartosz Golaszewski
` (6 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: Bartosz Golaszewski @ 2025-07-02 9:14 UTC (permalink / raw)
To: Linus Walleij, Bartosz Golaszewski, Thierry Reding,
Jonathan Hunter, Robert Richter, Aaro Koskinen, Andreas Kemnade,
Kevin Hilman, Roger Quadros, Tony Lindgren
Cc: linux-gpio, linux-tegra, linux-kernel, linux-omap,
Bartosz Golaszewski
From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
GPIO core can handle output-only chips that don't implement the get()
and direction_input() callbacks. There's no need to provide dummy
implementation of the latter in the driver so drop it.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
drivers/gpio/gpio-tpic2810.c | 8 --------
1 file changed, 8 deletions(-)
diff --git a/drivers/gpio/gpio-tpic2810.c b/drivers/gpio/gpio-tpic2810.c
index effb7b8ff81fd51664b7f51a124aaafbf3504feb..e99725bd3d63d47ed6dbb800aacac14b1ee96b9c 100644
--- a/drivers/gpio/gpio-tpic2810.c
+++ b/drivers/gpio/gpio-tpic2810.c
@@ -34,13 +34,6 @@ static int tpic2810_get_direction(struct gpio_chip *chip,
return GPIO_LINE_DIRECTION_OUT;
}
-static int tpic2810_direction_input(struct gpio_chip *chip,
- unsigned offset)
-{
- /* This device is output only */
- return -EINVAL;
-}
-
static int tpic2810_direction_output(struct gpio_chip *chip,
unsigned offset, int value)
{
@@ -83,7 +76,6 @@ static const struct gpio_chip template_chip = {
.label = "tpic2810",
.owner = THIS_MODULE,
.get_direction = tpic2810_get_direction,
- .direction_input = tpic2810_direction_input,
.direction_output = tpic2810_direction_output,
.set = tpic2810_set,
.set_multiple = tpic2810_set_multiple,
--
2.48.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 07/12] gpio: tpic2810: use new GPIO line value setter callbacks
2025-07-02 9:14 [PATCH 00/12] gpio: use new GPIO line value setter callbacks Bartosz Golaszewski
` (5 preceding siblings ...)
2025-07-02 9:14 ` [PATCH 06/12] gpio: tpic2810: remove unneeded callbacks Bartosz Golaszewski
@ 2025-07-02 9:14 ` Bartosz Golaszewski
2025-07-02 9:14 ` [PATCH 08/12] gpio: tps65086: " Bartosz Golaszewski
` (5 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: Bartosz Golaszewski @ 2025-07-02 9:14 UTC (permalink / raw)
To: Linus Walleij, Bartosz Golaszewski, Thierry Reding,
Jonathan Hunter, Robert Richter, Aaro Koskinen, Andreas Kemnade,
Kevin Hilman, Roger Quadros, Tony Lindgren
Cc: linux-gpio, linux-tegra, linux-kernel, linux-omap,
Bartosz Golaszewski
From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
struct gpio_chip now has callbacks for setting line values that return
an integer, allowing to indicate failures. Convert the driver to using
them.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
drivers/gpio/gpio-tpic2810.c | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)
diff --git a/drivers/gpio/gpio-tpic2810.c b/drivers/gpio/gpio-tpic2810.c
index e99725bd3d63d47ed6dbb800aacac14b1ee96b9c..d5b8568ab0613be56965448277704336fd520090 100644
--- a/drivers/gpio/gpio-tpic2810.c
+++ b/drivers/gpio/gpio-tpic2810.c
@@ -25,7 +25,7 @@ struct tpic2810 {
struct mutex lock;
};
-static void tpic2810_set(struct gpio_chip *chip, unsigned offset, int value);
+static int tpic2810_set(struct gpio_chip *chip, unsigned int offset, int value);
static int tpic2810_get_direction(struct gpio_chip *chip,
unsigned offset)
@@ -38,8 +38,7 @@ static int tpic2810_direction_output(struct gpio_chip *chip,
unsigned offset, int value)
{
/* This device always output */
- tpic2810_set(chip, offset, value);
- return 0;
+ return tpic2810_set(chip, offset, value);
}
static void tpic2810_set_mask_bits(struct gpio_chip *chip, u8 mask, u8 bits)
@@ -61,15 +60,19 @@ static void tpic2810_set_mask_bits(struct gpio_chip *chip, u8 mask, u8 bits)
mutex_unlock(&gpio->lock);
}
-static void tpic2810_set(struct gpio_chip *chip, unsigned offset, int value)
+static int tpic2810_set(struct gpio_chip *chip, unsigned int offset, int value)
{
tpic2810_set_mask_bits(chip, BIT(offset), value ? BIT(offset) : 0);
+
+ return 0;
}
-static void tpic2810_set_multiple(struct gpio_chip *chip, unsigned long *mask,
- unsigned long *bits)
+static int tpic2810_set_multiple(struct gpio_chip *chip, unsigned long *mask,
+ unsigned long *bits)
{
tpic2810_set_mask_bits(chip, *mask, *bits);
+
+ return 0;
}
static const struct gpio_chip template_chip = {
@@ -77,8 +80,8 @@ static const struct gpio_chip template_chip = {
.owner = THIS_MODULE,
.get_direction = tpic2810_get_direction,
.direction_output = tpic2810_direction_output,
- .set = tpic2810_set,
- .set_multiple = tpic2810_set_multiple,
+ .set_rv = tpic2810_set,
+ .set_multiple_rv = tpic2810_set_multiple,
.base = -1,
.ngpio = 8,
.can_sleep = true,
--
2.48.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 08/12] gpio: tps65086: use new GPIO line value setter callbacks
2025-07-02 9:14 [PATCH 00/12] gpio: use new GPIO line value setter callbacks Bartosz Golaszewski
` (6 preceding siblings ...)
2025-07-02 9:14 ` [PATCH 07/12] gpio: tpic2810: use new GPIO line value setter callbacks Bartosz Golaszewski
@ 2025-07-02 9:14 ` Bartosz Golaszewski
2025-07-02 9:14 ` [PATCH 09/12] gpio: tps65218: remove unneeded callbacks Bartosz Golaszewski
` (4 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: Bartosz Golaszewski @ 2025-07-02 9:14 UTC (permalink / raw)
To: Linus Walleij, Bartosz Golaszewski, Thierry Reding,
Jonathan Hunter, Robert Richter, Aaro Koskinen, Andreas Kemnade,
Kevin Hilman, Roger Quadros, Tony Lindgren
Cc: linux-gpio, linux-tegra, linux-kernel, linux-omap,
Bartosz Golaszewski
From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
struct gpio_chip now has callbacks for setting line values that return
an integer, allowing to indicate failures. Convert the driver to using
them.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
drivers/gpio/gpio-tps65086.c | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)
diff --git a/drivers/gpio/gpio-tps65086.c b/drivers/gpio/gpio-tps65086.c
index 8f5827554e1e89b2cc2cac0e43521246fc986408..08fa061b73efcffd5f68724ae3fdc54515d45adb 100644
--- a/drivers/gpio/gpio-tps65086.c
+++ b/drivers/gpio/gpio-tps65086.c
@@ -37,10 +37,8 @@ static int tps65086_gpio_direction_output(struct gpio_chip *chip,
struct tps65086_gpio *gpio = gpiochip_get_data(chip);
/* Set the initial value */
- regmap_update_bits(gpio->tps->regmap, TPS65086_GPOCTRL,
- BIT(4 + offset), value ? BIT(4 + offset) : 0);
-
- return 0;
+ return regmap_update_bits(gpio->tps->regmap, TPS65086_GPOCTRL,
+ BIT(4 + offset), value ? BIT(4 + offset) : 0);
}
static int tps65086_gpio_get(struct gpio_chip *chip, unsigned offset)
@@ -55,13 +53,13 @@ static int tps65086_gpio_get(struct gpio_chip *chip, unsigned offset)
return val & BIT(4 + offset);
}
-static void tps65086_gpio_set(struct gpio_chip *chip, unsigned offset,
- int value)
+static int tps65086_gpio_set(struct gpio_chip *chip, unsigned int offset,
+ int value)
{
struct tps65086_gpio *gpio = gpiochip_get_data(chip);
- regmap_update_bits(gpio->tps->regmap, TPS65086_GPOCTRL,
- BIT(4 + offset), value ? BIT(4 + offset) : 0);
+ return regmap_update_bits(gpio->tps->regmap, TPS65086_GPOCTRL,
+ BIT(4 + offset), value ? BIT(4 + offset) : 0);
}
static const struct gpio_chip template_chip = {
@@ -71,7 +69,7 @@ static const struct gpio_chip template_chip = {
.direction_input = tps65086_gpio_direction_input,
.direction_output = tps65086_gpio_direction_output,
.get = tps65086_gpio_get,
- .set = tps65086_gpio_set,
+ .set_rv = tps65086_gpio_set,
.base = -1,
.ngpio = 4,
.can_sleep = true,
--
2.48.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 09/12] gpio: tps65218: remove unneeded callbacks
2025-07-02 9:14 [PATCH 00/12] gpio: use new GPIO line value setter callbacks Bartosz Golaszewski
` (7 preceding siblings ...)
2025-07-02 9:14 ` [PATCH 08/12] gpio: tps65086: " Bartosz Golaszewski
@ 2025-07-02 9:14 ` Bartosz Golaszewski
2025-07-02 9:14 ` [PATCH 10/12] gpio: tps65218: use new GPIO line value setter callbacks Bartosz Golaszewski
` (3 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: Bartosz Golaszewski @ 2025-07-02 9:14 UTC (permalink / raw)
To: Linus Walleij, Bartosz Golaszewski, Thierry Reding,
Jonathan Hunter, Robert Richter, Aaro Koskinen, Andreas Kemnade,
Kevin Hilman, Roger Quadros, Tony Lindgren
Cc: linux-gpio, linux-tegra, linux-kernel, linux-omap,
Bartosz Golaszewski
From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
GPIO core can handle output-only chips that don't implement the get()
and direction_input() callbacks. There's no need to provide dummy
implementation of the latter in the driver so drop it.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
drivers/gpio/gpio-tps65218.c | 6 ------
1 file changed, 6 deletions(-)
diff --git a/drivers/gpio/gpio-tps65218.c b/drivers/gpio/gpio-tps65218.c
index d7d9d50dcddf432c0825246d8ff54a5c980b0ae4..68e4f0a19f4eb945b33e5992fdf30a29a40bfc1e 100644
--- a/drivers/gpio/gpio-tps65218.c
+++ b/drivers/gpio/gpio-tps65218.c
@@ -59,11 +59,6 @@ static int tps65218_gpio_output(struct gpio_chip *gc, unsigned offset,
return 0;
}
-static int tps65218_gpio_input(struct gpio_chip *gc, unsigned offset)
-{
- return -EPERM;
-}
-
static int tps65218_gpio_request(struct gpio_chip *gc, unsigned offset)
{
struct tps65218_gpio *tps65218_gpio = gpiochip_get_data(gc);
@@ -174,7 +169,6 @@ static const struct gpio_chip template_chip = {
.owner = THIS_MODULE,
.request = tps65218_gpio_request,
.direction_output = tps65218_gpio_output,
- .direction_input = tps65218_gpio_input,
.get = tps65218_gpio_get,
.set = tps65218_gpio_set,
.set_config = tps65218_gpio_set_config,
--
2.48.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 10/12] gpio: tps65218: use new GPIO line value setter callbacks
2025-07-02 9:14 [PATCH 00/12] gpio: use new GPIO line value setter callbacks Bartosz Golaszewski
` (8 preceding siblings ...)
2025-07-02 9:14 ` [PATCH 09/12] gpio: tps65218: remove unneeded callbacks Bartosz Golaszewski
@ 2025-07-02 9:14 ` Bartosz Golaszewski
2025-07-02 9:14 ` [PATCH 11/12] gpio: tps65219: " Bartosz Golaszewski
` (2 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: Bartosz Golaszewski @ 2025-07-02 9:14 UTC (permalink / raw)
To: Linus Walleij, Bartosz Golaszewski, Thierry Reding,
Jonathan Hunter, Robert Richter, Aaro Koskinen, Andreas Kemnade,
Kevin Hilman, Roger Quadros, Tony Lindgren
Cc: linux-gpio, linux-tegra, linux-kernel, linux-omap,
Bartosz Golaszewski
From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
struct gpio_chip now has callbacks for setting line values that return
an integer, allowing to indicate failures. Convert the driver to using
them.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
drivers/gpio/gpio-tps65218.c | 25 ++++++++++++-------------
1 file changed, 12 insertions(+), 13 deletions(-)
diff --git a/drivers/gpio/gpio-tps65218.c b/drivers/gpio/gpio-tps65218.c
index 68e4f0a19f4eb945b33e5992fdf30a29a40bfc1e..49cd7754ed053bcdbf25a4e51e227287257a5f03 100644
--- a/drivers/gpio/gpio-tps65218.c
+++ b/drivers/gpio/gpio-tps65218.c
@@ -34,29 +34,28 @@ static int tps65218_gpio_get(struct gpio_chip *gc, unsigned offset)
return !!(val & (TPS65218_ENABLE2_GPIO1 << offset));
}
-static void tps65218_gpio_set(struct gpio_chip *gc, unsigned offset,
- int value)
+static int tps65218_gpio_set(struct gpio_chip *gc, unsigned int offset,
+ int value)
{
struct tps65218_gpio *tps65218_gpio = gpiochip_get_data(gc);
struct tps65218 *tps65218 = tps65218_gpio->tps65218;
if (value)
- tps65218_set_bits(tps65218, TPS65218_REG_ENABLE2,
- TPS65218_ENABLE2_GPIO1 << offset,
- TPS65218_ENABLE2_GPIO1 << offset,
- TPS65218_PROTECT_L1);
- else
- tps65218_clear_bits(tps65218, TPS65218_REG_ENABLE2,
- TPS65218_ENABLE2_GPIO1 << offset,
- TPS65218_PROTECT_L1);
+ return tps65218_set_bits(tps65218, TPS65218_REG_ENABLE2,
+ TPS65218_ENABLE2_GPIO1 << offset,
+ TPS65218_ENABLE2_GPIO1 << offset,
+ TPS65218_PROTECT_L1);
+
+ return tps65218_clear_bits(tps65218, TPS65218_REG_ENABLE2,
+ TPS65218_ENABLE2_GPIO1 << offset,
+ TPS65218_PROTECT_L1);
}
static int tps65218_gpio_output(struct gpio_chip *gc, unsigned offset,
int value)
{
/* Only drives GPOs */
- tps65218_gpio_set(gc, offset, value);
- return 0;
+ return tps65218_gpio_set(gc, offset, value);
}
static int tps65218_gpio_request(struct gpio_chip *gc, unsigned offset)
@@ -170,7 +169,7 @@ static const struct gpio_chip template_chip = {
.request = tps65218_gpio_request,
.direction_output = tps65218_gpio_output,
.get = tps65218_gpio_get,
- .set = tps65218_gpio_set,
+ .set_rv = tps65218_gpio_set,
.set_config = tps65218_gpio_set_config,
.can_sleep = true,
.ngpio = 3,
--
2.48.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 11/12] gpio: tps65219: use new GPIO line value setter callbacks
2025-07-02 9:14 [PATCH 00/12] gpio: use new GPIO line value setter callbacks Bartosz Golaszewski
` (9 preceding siblings ...)
2025-07-02 9:14 ` [PATCH 10/12] gpio: tps65218: use new GPIO line value setter callbacks Bartosz Golaszewski
@ 2025-07-02 9:14 ` Bartosz Golaszewski
2025-07-02 9:14 ` [PATCH 12/12] gpio: tps6586x: " Bartosz Golaszewski
2025-07-07 7:46 ` [PATCH 00/12] gpio: " Bartosz Golaszewski
12 siblings, 0 replies; 14+ messages in thread
From: Bartosz Golaszewski @ 2025-07-02 9:14 UTC (permalink / raw)
To: Linus Walleij, Bartosz Golaszewski, Thierry Reding,
Jonathan Hunter, Robert Richter, Aaro Koskinen, Andreas Kemnade,
Kevin Hilman, Roger Quadros, Tony Lindgren
Cc: linux-gpio, linux-tegra, linux-kernel, linux-omap,
Bartosz Golaszewski
From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
struct gpio_chip now has callbacks for setting line values that return
an integer, allowing to indicate failures. Convert the driver to using
them.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
drivers/gpio/gpio-tps65219.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/drivers/gpio/gpio-tps65219.c b/drivers/gpio/gpio-tps65219.c
index 526640c39a11faf7837847d7eccf0aa33d482ffb..630cb41e77a4ef212305e710e988999c98cfbe66 100644
--- a/drivers/gpio/gpio-tps65219.c
+++ b/drivers/gpio/gpio-tps65219.c
@@ -65,10 +65,9 @@ static int tps65219_gpio_get(struct gpio_chip *gc, unsigned int offset)
return ret;
}
-static void tps65219_gpio_set(struct gpio_chip *gc, unsigned int offset, int value)
+static int tps65219_gpio_set(struct gpio_chip *gc, unsigned int offset, int value)
{
struct tps65219_gpio *gpio = gpiochip_get_data(gc);
- struct device *dev = gpio->tps->dev;
int v, mask, bit;
bit = (offset == TPS65219_GPIO0_IDX) ? TPS65219_GPIO0_OFFSET : offset - 1;
@@ -76,8 +75,8 @@ static void tps65219_gpio_set(struct gpio_chip *gc, unsigned int offset, int val
mask = BIT(bit);
v = value ? mask : 0;
- if (regmap_update_bits(gpio->tps->regmap, TPS65219_REG_GENERAL_CONFIG, mask, v))
- dev_err(dev, "GPIO%d, set to value %d failed.\n", offset, value);
+ return regmap_update_bits(gpio->tps->regmap,
+ TPS65219_REG_GENERAL_CONFIG, mask, v);
}
static int tps65219_gpio_change_direction(struct gpio_chip *gc, unsigned int offset,
@@ -147,7 +146,7 @@ static const struct gpio_chip tps65219_template_chip = {
.direction_input = tps65219_gpio_direction_input,
.direction_output = tps65219_gpio_direction_output,
.get = tps65219_gpio_get,
- .set = tps65219_gpio_set,
+ .set_rv = tps65219_gpio_set,
.base = -1,
.ngpio = 3,
.can_sleep = true,
--
2.48.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 12/12] gpio: tps6586x: use new GPIO line value setter callbacks
2025-07-02 9:14 [PATCH 00/12] gpio: use new GPIO line value setter callbacks Bartosz Golaszewski
` (10 preceding siblings ...)
2025-07-02 9:14 ` [PATCH 11/12] gpio: tps65219: " Bartosz Golaszewski
@ 2025-07-02 9:14 ` Bartosz Golaszewski
2025-07-07 7:46 ` [PATCH 00/12] gpio: " Bartosz Golaszewski
12 siblings, 0 replies; 14+ messages in thread
From: Bartosz Golaszewski @ 2025-07-02 9:14 UTC (permalink / raw)
To: Linus Walleij, Bartosz Golaszewski, Thierry Reding,
Jonathan Hunter, Robert Richter, Aaro Koskinen, Andreas Kemnade,
Kevin Hilman, Roger Quadros, Tony Lindgren
Cc: linux-gpio, linux-tegra, linux-kernel, linux-omap,
Bartosz Golaszewski
From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
struct gpio_chip now has callbacks for setting line values that return
an integer, allowing to indicate failures. Convert the driver to using
them.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
drivers/gpio/gpio-tps6586x.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/drivers/gpio/gpio-tps6586x.c b/drivers/gpio/gpio-tps6586x.c
index d277aa951143ccf9560bd77d461786f120e46a52..f1ced092f38a5e491378fec2d80dcc1eb1182cbd 100644
--- a/drivers/gpio/gpio-tps6586x.c
+++ b/drivers/gpio/gpio-tps6586x.c
@@ -40,13 +40,13 @@ static int tps6586x_gpio_get(struct gpio_chip *gc, unsigned offset)
return !!(val & (1 << offset));
}
-static void tps6586x_gpio_set(struct gpio_chip *gc, unsigned offset,
- int value)
+static int tps6586x_gpio_set(struct gpio_chip *gc, unsigned int offset,
+ int value)
{
struct tps6586x_gpio *tps6586x_gpio = gpiochip_get_data(gc);
- tps6586x_update(tps6586x_gpio->parent, TPS6586X_GPIOSET2,
- value << offset, 1 << offset);
+ return tps6586x_update(tps6586x_gpio->parent, TPS6586X_GPIOSET2,
+ value << offset, 1 << offset);
}
static int tps6586x_gpio_output(struct gpio_chip *gc, unsigned offset,
@@ -54,8 +54,11 @@ static int tps6586x_gpio_output(struct gpio_chip *gc, unsigned offset,
{
struct tps6586x_gpio *tps6586x_gpio = gpiochip_get_data(gc);
uint8_t val, mask;
+ int ret;
- tps6586x_gpio_set(gc, offset, value);
+ ret = tps6586x_gpio_set(gc, offset, value);
+ if (ret)
+ return ret;
val = 0x1 << (offset * 2);
mask = 0x3 << (offset * 2);
@@ -95,7 +98,7 @@ static int tps6586x_gpio_probe(struct platform_device *pdev)
/* FIXME: add handling of GPIOs as dedicated inputs */
tps6586x_gpio->gpio_chip.direction_output = tps6586x_gpio_output;
- tps6586x_gpio->gpio_chip.set = tps6586x_gpio_set;
+ tps6586x_gpio->gpio_chip.set_rv = tps6586x_gpio_set;
tps6586x_gpio->gpio_chip.get = tps6586x_gpio_get;
tps6586x_gpio->gpio_chip.to_irq = tps6586x_gpio_to_irq;
--
2.48.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH 00/12] gpio: use new GPIO line value setter callbacks
2025-07-02 9:14 [PATCH 00/12] gpio: use new GPIO line value setter callbacks Bartosz Golaszewski
` (11 preceding siblings ...)
2025-07-02 9:14 ` [PATCH 12/12] gpio: tps6586x: " Bartosz Golaszewski
@ 2025-07-07 7:46 ` Bartosz Golaszewski
12 siblings, 0 replies; 14+ messages in thread
From: Bartosz Golaszewski @ 2025-07-07 7:46 UTC (permalink / raw)
To: Linus Walleij, Thierry Reding, Jonathan Hunter, Robert Richter,
Aaro Koskinen, Andreas Kemnade, Kevin Hilman, Roger Quadros,
Tony Lindgren, Bartosz Golaszewski
Cc: Bartosz Golaszewski, linux-gpio, linux-tegra, linux-kernel,
linux-omap
From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
On Wed, 02 Jul 2025 11:14:01 +0200, Bartosz Golaszewski wrote:
> Commit 98ce1eb1fd87e ("gpiolib: introduce gpio_chip setters that return
> values") added new line setter callbacks to struct gpio_chip. They allow
> to indicate failures to callers. We're in the process of converting all
> GPIO controllers to using them before removing the old ones. This series
> converts another round of GPIO drivers.
>
>
> [...]
Applied, thanks!
[01/12] gpio: tegra186: don't call the set() callback directly
https://git.kernel.org/brgl/linux/c/47c228d9fc9fe7e3b6f0e7f88f40779f0bb96469
[02/12] gpio: tegra186: use new GPIO line value setter callbacks
https://git.kernel.org/brgl/linux/c/871e1aee00298fccbda04eacd9e3bb5f46f446b9
[03/12] gpio: tegra: use new GPIO line value setter callbacks
https://git.kernel.org/brgl/linux/c/8a81d128e1377a7662d0913bc5013eb8a90c3e33
[04/12] gpio: thunderx: use new GPIO line value setter callbacks
https://git.kernel.org/brgl/linux/c/ecf0c0278f4799f6af245131f02dbb8587f87d29
[05/12] gpio: timberdale: use new GPIO line value setter callbacks
https://git.kernel.org/brgl/linux/c/dd66f8862f8418d989a8e342ff7af26bf4a0ae8f
[06/12] gpio: tpic2810: remove unneeded callbacks
https://git.kernel.org/brgl/linux/c/00c337cc68c34302fc0af2d9ac47be5c638d4a78
[07/12] gpio: tpic2810: use new GPIO line value setter callbacks
https://git.kernel.org/brgl/linux/c/4ffdd9d8a37eaf4e25855e1038b9e1091401c252
[08/12] gpio: tps65086: use new GPIO line value setter callbacks
https://git.kernel.org/brgl/linux/c/2a5be7a80b3b1036fba5dae13dd55c97fb7eabaa
[09/12] gpio: tps65218: remove unneeded callbacks
https://git.kernel.org/brgl/linux/c/913cbf8a0d4b0554d66cdc608b231cdf2401a496
[10/12] gpio: tps65218: use new GPIO line value setter callbacks
https://git.kernel.org/brgl/linux/c/4ca81a1f3a46603986cbdd11348433b0746ce483
[11/12] gpio: tps65219: use new GPIO line value setter callbacks
https://git.kernel.org/brgl/linux/c/fc0e4091afa9b6c02f1cc2ddec75b248c25cefe6
[12/12] gpio: tps6586x: use new GPIO line value setter callbacks
https://git.kernel.org/brgl/linux/c/e3ec7ad5ab139ad9e0ed8931ba562f95698c3b2f
Best regards,
--
Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
^ permalink raw reply [flat|nested] 14+ messages in thread