arch/powerpc/platforms/8xx/cpm1.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)
The lack of get_direction() callbacks in this driver causes GPIOLIB to
emit a warning. Implement them for 16- and 32-bit variants.
Reported-by: Christophe Leroy <chleroy@kernel.org>
Closes: https://lore.kernel.org/all/63487206f6e5a93eaf9f41784317fe99d394312f.1780399750.git.chleroy@kernel.org/
Fixes: ec2cceadfae7 ("gpiolib: normalize the return value of gc->get() on behalf of buggy drivers")
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
Hi Christophe, please test if this works for you to silence the warning
from GPIO core.
---
arch/powerpc/platforms/8xx/cpm1.c | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/arch/powerpc/platforms/8xx/cpm1.c b/arch/powerpc/platforms/8xx/cpm1.c
index f00734f0590cf7c7382f808dce27373d9ff3d8bc..b31376bf6778802a7f6b6b499066846b6b1f61e9 100644
--- a/arch/powerpc/platforms/8xx/cpm1.c
+++ b/arch/powerpc/platforms/8xx/cpm1.c
@@ -472,6 +472,18 @@ static int cpm1_gpio16_dir_in(struct gpio_chip *gc, unsigned int gpio)
return 0;
}
+static int cpm1_gpio16_get_direction(struct gpio_chip *gc, unsigned int gpio)
+{
+ struct cpm1_gpio16_chip *cpm1_gc = gpiochip_get_data(gc);
+ struct cpm_ioport16 __iomem *iop = cpm1_gc->regs;
+ u16 pin_mask = 1 << (15 - gpio);
+
+ if (in_be16(&iop->dir) & pin_mask)
+ return GPIO_LINE_DIRECTION_OUT;
+
+ return GPIO_LINE_DIRECTION_IN;
+}
+
int cpm1_gpiochip_add16(struct device *dev)
{
struct device_node *np = dev->of_node;
@@ -498,6 +510,7 @@ int cpm1_gpiochip_add16(struct device *dev)
gc->ngpio = 16;
gc->direction_input = cpm1_gpio16_dir_in;
gc->direction_output = cpm1_gpio16_dir_out;
+ gc->get_direction = cpm1_gpio16_get_direction;
gc->get = cpm1_gpio16_get;
gc->set = cpm1_gpio16_set;
gc->to_irq = cpm1_gpio16_to_irq;
@@ -604,6 +617,18 @@ static int cpm1_gpio32_dir_in(struct gpio_chip *gc, unsigned int gpio)
return 0;
}
+static int cpm1_gpio32_get_direction(struct gpio_chip *gc, unsigned int gpio)
+{
+ struct cpm1_gpio32_chip *cpm1_gc = gpiochip_get_data(gc);
+ struct cpm_ioport32b __iomem *iop = cpm1_gc->regs;
+ u32 pin_mask = 1 << (31 - gpio);
+
+ if (in_be32(&iop->dir) & pin_mask)
+ return GPIO_LINE_DIRECTION_OUT;
+
+ return GPIO_LINE_DIRECTION_IN;
+}
+
int cpm1_gpiochip_add32(struct device *dev)
{
struct device_node *np = dev->of_node;
@@ -621,6 +646,7 @@ int cpm1_gpiochip_add32(struct device *dev)
gc->ngpio = 32;
gc->direction_input = cpm1_gpio32_dir_in;
gc->direction_output = cpm1_gpio32_dir_out;
+ gc->get_direction = cpm1_gpio32_get_direction;
gc->get = cpm1_gpio32_get;
gc->set = cpm1_gpio32_set;
gc->parent = dev;
---
base-commit: b7bee4ca5688e30ca50fbc87b1b8f7eed7006c17
change-id: 20260603-powerpc-8xx-cpm1-get-dir-698cefe92647
Best regards,
--
Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Le 03/06/2026 à 10:26, Bartosz Golaszewski a écrit :
> The lack of get_direction() callbacks in this driver causes GPIOLIB to
> emit a warning. Implement them for 16- and 32-bit variants.
>
> Reported-by: Christophe Leroy <chleroy@kernel.org>
> Closes: https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore.kernel.org%2Fall%2F63487206f6e5a93eaf9f41784317fe99d394312f.1780399750.git.chleroy%40kernel.org%2F&data=05%7C02%7Cchristophe.leroy%40csgroup.eu%7C67d2207e02454f2ecf0008dec149d67c%7C8b87af7d86474dc78df45f69a2011bb5%7C0%7C0%7C639160720043016747%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=k6%2FENNl94WS7QvRdhhmx8VvDyZKMNW8sAlKEq3AtQe4%3D&reserved=0
> Fixes: ec2cceadfae7 ("gpiolib: normalize the return value of gc->get() on behalf of buggy drivers")
Isn't it e623c4303ed1 ("gpiolib: sanitize the return value of
gpio_chip::get_direction()") ?
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
> ---
> Hi Christophe, please test if this works for you to silence the warning
> from GPIO core.
> ---
> arch/powerpc/platforms/8xx/cpm1.c | 26 ++++++++++++++++++++++++++
> 1 file changed, 26 insertions(+)
>
> diff --git a/arch/powerpc/platforms/8xx/cpm1.c b/arch/powerpc/platforms/8xx/cpm1.c
> index f00734f0590cf7c7382f808dce27373d9ff3d8bc..b31376bf6778802a7f6b6b499066846b6b1f61e9 100644
> --- a/arch/powerpc/platforms/8xx/cpm1.c
> +++ b/arch/powerpc/platforms/8xx/cpm1.c
> @@ -472,6 +472,18 @@ static int cpm1_gpio16_dir_in(struct gpio_chip *gc, unsigned int gpio)
> return 0;
> }
>
> +static int cpm1_gpio16_get_direction(struct gpio_chip *gc, unsigned int gpio)
> +{
> + struct cpm1_gpio16_chip *cpm1_gc = gpiochip_get_data(gc);
> + struct cpm_ioport16 __iomem *iop = cpm1_gc->regs;
> + u16 pin_mask = 1 << (15 - gpio);
> +
> + if (in_be16(&iop->dir) & pin_mask)
> + return GPIO_LINE_DIRECTION_OUT;
> +
> + return GPIO_LINE_DIRECTION_IN;
> +}
> +
> int cpm1_gpiochip_add16(struct device *dev)
> {
> struct device_node *np = dev->of_node;
> @@ -498,6 +510,7 @@ int cpm1_gpiochip_add16(struct device *dev)
> gc->ngpio = 16;
> gc->direction_input = cpm1_gpio16_dir_in;
> gc->direction_output = cpm1_gpio16_dir_out;
> + gc->get_direction = cpm1_gpio16_get_direction;
> gc->get = cpm1_gpio16_get;
> gc->set = cpm1_gpio16_set;
> gc->to_irq = cpm1_gpio16_to_irq;
> @@ -604,6 +617,18 @@ static int cpm1_gpio32_dir_in(struct gpio_chip *gc, unsigned int gpio)
> return 0;
> }
>
> +static int cpm1_gpio32_get_direction(struct gpio_chip *gc, unsigned int gpio)
> +{
> + struct cpm1_gpio32_chip *cpm1_gc = gpiochip_get_data(gc);
> + struct cpm_ioport32b __iomem *iop = cpm1_gc->regs;
> + u32 pin_mask = 1 << (31 - gpio);
> +
> + if (in_be32(&iop->dir) & pin_mask)
> + return GPIO_LINE_DIRECTION_OUT;
> +
> + return GPIO_LINE_DIRECTION_IN;
> +}
> +
> int cpm1_gpiochip_add32(struct device *dev)
> {
> struct device_node *np = dev->of_node;
> @@ -621,6 +646,7 @@ int cpm1_gpiochip_add32(struct device *dev)
> gc->ngpio = 32;
> gc->direction_input = cpm1_gpio32_dir_in;
> gc->direction_output = cpm1_gpio32_dir_out;
> + gc->get_direction = cpm1_gpio32_get_direction;
> gc->get = cpm1_gpio32_get;
> gc->set = cpm1_gpio32_set;
> gc->parent = dev;
>
> ---
> base-commit: b7bee4ca5688e30ca50fbc87b1b8f7eed7006c17
> change-id: 20260603-powerpc-8xx-cpm1-get-dir-698cefe92647
>
> Best regards,
On Thu, 4 Jun 2026 10:24:27 +0200, "Christophe Leroy (CS GROUP)"
<chleroy@kernel.org> said:
>
>
> Le 03/06/2026 à 10:26, Bartosz Golaszewski a écrit :
>> The lack of get_direction() callbacks in this driver causes GPIOLIB to
>> emit a warning. Implement them for 16- and 32-bit variants.
>>
>> Reported-by: Christophe Leroy <chleroy@kernel.org>
>> Closes: https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore.kernel.org%2Fall%2F63487206f6e5a93eaf9f41784317fe99d394312f.1780399750.git.chleroy%40kernel.org%2F&data=05%7C02%7Cchristophe.leroy%40csgroup.eu%7C67d2207e02454f2ecf0008dec149d67c%7C8b87af7d86474dc78df45f69a2011bb5%7C0%7C0%7C639160720043016747%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=k6%2FENNl94WS7QvRdhhmx8VvDyZKMNW8sAlKEq3AtQe4%3D&reserved=0
What happened here??
>> Fixes: ec2cceadfae7 ("gpiolib: normalize the return value of gc->get() on behalf of buggy drivers")
>
> Isn't it e623c4303ed1 ("gpiolib: sanitize the return value of
> gpio_chip::get_direction()") ?
>
Sure, can be:
Fixes: e623c4303ed1 ("gpiolib: sanitize the return value of
gpio_chip::get_direction()")
Bart
Le 04/06/2026 à 11:53, Bartosz Golaszewski a écrit :
> On Thu, 4 Jun 2026 10:24:27 +0200, "Christophe Leroy (CS GROUP)"
> <chleroy@kernel.org> said:
>>
>>
>> Le 03/06/2026 à 10:26, Bartosz Golaszewski a écrit :
>>> The lack of get_direction() callbacks in this driver causes GPIOLIB to
>>> emit a warning. Implement them for 16- and 32-bit variants.
>>>
>>> Reported-by: Christophe Leroy <chleroy@kernel.org>
>>> Closes: https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore.kernel.org%2Fall%2F63487206f6e5a93eaf9f41784317fe99d394312f.1780399750.git.chleroy%40kernel.org%2F&data=05%7C02%7Cchristophe.leroy%40csgroup.eu%7C94897fc3d78242b6193308dec21f300e%7C8b87af7d86474dc78df45f69a2011bb5%7C0%7C0%7C639161636389791222%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=an4ji%2Bk24tiNfOASUmnvOyp6kLJzRlH8qhihSkGp%2BVc%3D&reserved=0
>
> What happened here??
Ask Bill Gates.
My company uses Microsoft 365 outlook, it mangles all links included in
emails for security reasons they say, to minimise phishing.
>
>>> Fixes: ec2cceadfae7 ("gpiolib: normalize the return value of gc->get() on behalf of buggy drivers")
>>
>> Isn't it e623c4303ed1 ("gpiolib: sanitize the return value of
>> gpio_chip::get_direction()") ?
>>
>
> Sure, can be:
>
> Fixes: e623c4303ed1 ("gpiolib: sanitize the return value of
> gpio_chip::get_direction()")
>
> Bart
On Wed, Jun 3, 2026 at 10:26 AM Bartosz Golaszewski
<bartosz.golaszewski@oss.qualcomm.com> wrote:
> The lack of get_direction() callbacks in this driver causes GPIOLIB to
> emit a warning. Implement them for 16- and 32-bit variants.
>
> Reported-by: Christophe Leroy <chleroy@kernel.org>
> Closes: https://lore.kernel.org/all/63487206f6e5a93eaf9f41784317fe99d394312f.1780399750.git.chleroy@kernel.org/
> Fixes: ec2cceadfae7 ("gpiolib: normalize the return value of gc->get() on behalf of buggy drivers")
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
On Wed, Jun 3, 2026 at 10:26 AM Bartosz Golaszewski
<bartosz.golaszewski@oss.qualcomm.com> wrote:
> The lack of get_direction() callbacks in this driver causes GPIOLIB to
> emit a warning. Implement them for 16- and 32-bit variants.
>
> Reported-by: Christophe Leroy <chleroy@kernel.org>
> Closes: https://lore.kernel.org/all/63487206f6e5a93eaf9f41784317fe99d394312f.1780399750.git.chleroy@kernel.org/
> Fixes: ec2cceadfae7 ("gpiolib: normalize the return value of gc->get() on behalf of buggy drivers")
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Reviewed-by: Linus Walleij <linusw@kernel.org>
Yours,
Linus Walleij
Le 03/06/2026 à 10:26, Bartosz Golaszewski a écrit :
> The lack of get_direction() callbacks in this driver causes GPIOLIB to
> emit a warning. Implement them for 16- and 32-bit variants.
>
> Reported-by: Christophe Leroy <chleroy@kernel.org>
> Closes: https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore.kernel.org%2Fall%2F63487206f6e5a93eaf9f41784317fe99d394312f.1780399750.git.chleroy%40kernel.org%2F&data=05%7C02%7Cchristophe.leroy%40csgroup.eu%7C67d2207e02454f2ecf0008dec149d67c%7C8b87af7d86474dc78df45f69a2011bb5%7C0%7C0%7C639160720043016747%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=k6%2FENNl94WS7QvRdhhmx8VvDyZKMNW8sAlKEq3AtQe4%3D&reserved=0
> Fixes: ec2cceadfae7 ("gpiolib: normalize the return value of gc->get() on behalf of buggy drivers")
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Reviewed-by: Christophe Leroy (CS GROUP) <chleroy@kernel.org>
Tested-by: Christophe Leroy (CS GROUP) <chleroy@kernel.org>
> ---
> Hi Christophe, please test if this works for you to silence the warning
> from GPIO core.
Hi Bartosz, yes it does, many thanks for the fix.
By the way, wouldn't it also make sense to update the following comment
in include/linux/gpio/driver.h to change from 'recommended' to 'mandatory' ?
* @get_direction: returns direction for signal "offset", 0=out, 1=in,
* (same as GPIO_LINE_DIRECTION_OUT / GPIO_LINE_DIRECTION_IN),
* or negative error. It is recommended to always implement this
* function, even on input-only or output-only gpio chips.
> ---
> arch/powerpc/platforms/8xx/cpm1.c | 26 ++++++++++++++++++++++++++
> 1 file changed, 26 insertions(+)
>
> diff --git a/arch/powerpc/platforms/8xx/cpm1.c b/arch/powerpc/platforms/8xx/cpm1.c
> index f00734f0590cf7c7382f808dce27373d9ff3d8bc..b31376bf6778802a7f6b6b499066846b6b1f61e9 100644
> --- a/arch/powerpc/platforms/8xx/cpm1.c
> +++ b/arch/powerpc/platforms/8xx/cpm1.c
> @@ -472,6 +472,18 @@ static int cpm1_gpio16_dir_in(struct gpio_chip *gc, unsigned int gpio)
> return 0;
> }
>
> +static int cpm1_gpio16_get_direction(struct gpio_chip *gc, unsigned int gpio)
> +{
> + struct cpm1_gpio16_chip *cpm1_gc = gpiochip_get_data(gc);
> + struct cpm_ioport16 __iomem *iop = cpm1_gc->regs;
> + u16 pin_mask = 1 << (15 - gpio);
> +
> + if (in_be16(&iop->dir) & pin_mask)
> + return GPIO_LINE_DIRECTION_OUT;
> +
> + return GPIO_LINE_DIRECTION_IN;
> +}
> +
> int cpm1_gpiochip_add16(struct device *dev)
> {
> struct device_node *np = dev->of_node;
> @@ -498,6 +510,7 @@ int cpm1_gpiochip_add16(struct device *dev)
> gc->ngpio = 16;
> gc->direction_input = cpm1_gpio16_dir_in;
> gc->direction_output = cpm1_gpio16_dir_out;
> + gc->get_direction = cpm1_gpio16_get_direction;
> gc->get = cpm1_gpio16_get;
> gc->set = cpm1_gpio16_set;
> gc->to_irq = cpm1_gpio16_to_irq;
> @@ -604,6 +617,18 @@ static int cpm1_gpio32_dir_in(struct gpio_chip *gc, unsigned int gpio)
> return 0;
> }
>
> +static int cpm1_gpio32_get_direction(struct gpio_chip *gc, unsigned int gpio)
> +{
> + struct cpm1_gpio32_chip *cpm1_gc = gpiochip_get_data(gc);
> + struct cpm_ioport32b __iomem *iop = cpm1_gc->regs;
> + u32 pin_mask = 1 << (31 - gpio);
> +
> + if (in_be32(&iop->dir) & pin_mask)
> + return GPIO_LINE_DIRECTION_OUT;
> +
> + return GPIO_LINE_DIRECTION_IN;
> +}
> +
> int cpm1_gpiochip_add32(struct device *dev)
> {
> struct device_node *np = dev->of_node;
> @@ -621,6 +646,7 @@ int cpm1_gpiochip_add32(struct device *dev)
> gc->ngpio = 32;
> gc->direction_input = cpm1_gpio32_dir_in;
> gc->direction_output = cpm1_gpio32_dir_out;
> + gc->get_direction = cpm1_gpio32_get_direction;
> gc->get = cpm1_gpio32_get;
> gc->set = cpm1_gpio32_set;
> gc->parent = dev;
>
> ---
> base-commit: b7bee4ca5688e30ca50fbc87b1b8f7eed7006c17
> change-id: 20260603-powerpc-8xx-cpm1-get-dir-698cefe92647
>
> Best regards,
© 2016 - 2026 Red Hat, Inc.