linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] staging: greybus: use new GPIO line value setter callbacks
@ 2025-04-07  7:14 Bartosz Golaszewski
  2025-04-07 13:49 ` Alex Elder
  0 siblings, 1 reply; 3+ messages in thread
From: Bartosz Golaszewski @ 2025-04-07  7:14 UTC (permalink / raw)
  To: Rui Miguel Silva, Johan Hovold, Alex Elder, Greg Kroah-Hartman,
	Linus Walleij, Bartosz Golaszewski
  Cc: greybus-dev, linux-staging, linux-kernel, linux-gpio,
	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/staging/greybus/gpio.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/greybus/gpio.c b/drivers/staging/greybus/gpio.c
index 16bcf7fc8158..f81c34160f72 100644
--- a/drivers/staging/greybus/gpio.c
+++ b/drivers/staging/greybus/gpio.c
@@ -185,8 +185,8 @@ static int gb_gpio_get_value_operation(struct gb_gpio_controller *ggc,
 	return 0;
 }
 
-static void gb_gpio_set_value_operation(struct gb_gpio_controller *ggc,
-					u8 which, bool value_high)
+static int gb_gpio_set_value_operation(struct gb_gpio_controller *ggc,
+				       u8 which, bool value_high)
 {
 	struct device *dev = &ggc->gbphy_dev->dev;
 	struct gb_gpio_set_value_request request;
@@ -195,7 +195,7 @@ static void gb_gpio_set_value_operation(struct gb_gpio_controller *ggc,
 	if (ggc->lines[which].direction == 1) {
 		dev_warn(dev, "refusing to set value of input gpio %u\n",
 			 which);
-		return;
+		return -EPERM;
 	}
 
 	request.which = which;
@@ -204,10 +204,12 @@ static void gb_gpio_set_value_operation(struct gb_gpio_controller *ggc,
 				&request, sizeof(request), NULL, 0);
 	if (ret) {
 		dev_err(dev, "failed to set value of gpio %u\n", which);
-		return;
+		return ret;
 	}
 
 	ggc->lines[which].value = request.value;
+
+	return 0;
 }
 
 static int gb_gpio_set_debounce_operation(struct gb_gpio_controller *ggc,
@@ -457,11 +459,11 @@ static int gb_gpio_get(struct gpio_chip *chip, unsigned int offset)
 	return ggc->lines[which].value;
 }
 
-static void gb_gpio_set(struct gpio_chip *chip, unsigned int offset, int value)
+static int gb_gpio_set(struct gpio_chip *chip, unsigned int offset, int value)
 {
 	struct gb_gpio_controller *ggc = gpiochip_get_data(chip);
 
-	gb_gpio_set_value_operation(ggc, (u8)offset, !!value);
+	return gb_gpio_set_value_operation(ggc, (u8)offset, !!value);
 }
 
 static int gb_gpio_set_config(struct gpio_chip *chip, unsigned int offset,
@@ -555,7 +557,7 @@ static int gb_gpio_probe(struct gbphy_device *gbphy_dev,
 	gpio->direction_input = gb_gpio_direction_input;
 	gpio->direction_output = gb_gpio_direction_output;
 	gpio->get = gb_gpio_get;
-	gpio->set = gb_gpio_set;
+	gpio->set_rv = gb_gpio_set;
 	gpio->set_config = gb_gpio_set_config;
 	gpio->base = -1;		/* Allocate base dynamically */
 	gpio->ngpio = ggc->line_max + 1;

---
base-commit: 0af2f6be1b4281385b618cb86ad946eded089ac8
change-id: 20250331-gpiochip-set-rv-greybus-cd2365755186

Best regards,
-- 
Bartosz Golaszewski <bartosz.golaszewski@linaro.org>


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] staging: greybus: use new GPIO line value setter callbacks
  2025-04-07  7:14 [PATCH] staging: greybus: use new GPIO line value setter callbacks Bartosz Golaszewski
@ 2025-04-07 13:49 ` Alex Elder
  2025-04-07 14:03   ` Rui Miguel Silva
  0 siblings, 1 reply; 3+ messages in thread
From: Alex Elder @ 2025-04-07 13:49 UTC (permalink / raw)
  To: Bartosz Golaszewski, Rui Miguel Silva, Johan Hovold, Alex Elder,
	Greg Kroah-Hartman, Linus Walleij
  Cc: greybus-dev, linux-staging, linux-kernel, linux-gpio,
	Bartosz Golaszewski

On 4/7/25 2:14 AM, Bartosz Golaszewski wrote:
> 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>

Here is the commit that enabled these:
   98ce1eb1fd87e gpiolib: introduce gpio_chip setters that return values

This looks good.  Thank you.

Reviewed-by: Alex Elder <elder@riscstar.com>

> ---
>   drivers/staging/greybus/gpio.c | 16 +++++++++-------
>   1 file changed, 9 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/staging/greybus/gpio.c b/drivers/staging/greybus/gpio.c
> index 16bcf7fc8158..f81c34160f72 100644
> --- a/drivers/staging/greybus/gpio.c
> +++ b/drivers/staging/greybus/gpio.c
> @@ -185,8 +185,8 @@ static int gb_gpio_get_value_operation(struct gb_gpio_controller *ggc,
>   	return 0;
>   }
>   
> -static void gb_gpio_set_value_operation(struct gb_gpio_controller *ggc,
> -					u8 which, bool value_high)
> +static int gb_gpio_set_value_operation(struct gb_gpio_controller *ggc,
> +				       u8 which, bool value_high)
>   {
>   	struct device *dev = &ggc->gbphy_dev->dev;
>   	struct gb_gpio_set_value_request request;
> @@ -195,7 +195,7 @@ static void gb_gpio_set_value_operation(struct gb_gpio_controller *ggc,
>   	if (ggc->lines[which].direction == 1) {
>   		dev_warn(dev, "refusing to set value of input gpio %u\n",
>   			 which);
> -		return;
> +		return -EPERM;
>   	}
>   
>   	request.which = which;
> @@ -204,10 +204,12 @@ static void gb_gpio_set_value_operation(struct gb_gpio_controller *ggc,
>   				&request, sizeof(request), NULL, 0);
>   	if (ret) {
>   		dev_err(dev, "failed to set value of gpio %u\n", which);
> -		return;
> +		return ret;
>   	}
>   
>   	ggc->lines[which].value = request.value;
> +
> +	return 0;
>   }
>   
>   static int gb_gpio_set_debounce_operation(struct gb_gpio_controller *ggc,
> @@ -457,11 +459,11 @@ static int gb_gpio_get(struct gpio_chip *chip, unsigned int offset)
>   	return ggc->lines[which].value;
>   }
>   
> -static void gb_gpio_set(struct gpio_chip *chip, unsigned int offset, int value)
> +static int gb_gpio_set(struct gpio_chip *chip, unsigned int offset, int value)
>   {
>   	struct gb_gpio_controller *ggc = gpiochip_get_data(chip);
>   
> -	gb_gpio_set_value_operation(ggc, (u8)offset, !!value);
> +	return gb_gpio_set_value_operation(ggc, (u8)offset, !!value);
>   }
>   
>   static int gb_gpio_set_config(struct gpio_chip *chip, unsigned int offset,
> @@ -555,7 +557,7 @@ static int gb_gpio_probe(struct gbphy_device *gbphy_dev,
>   	gpio->direction_input = gb_gpio_direction_input;
>   	gpio->direction_output = gb_gpio_direction_output;
>   	gpio->get = gb_gpio_get;
> -	gpio->set = gb_gpio_set;
> +	gpio->set_rv = gb_gpio_set;
>   	gpio->set_config = gb_gpio_set_config;
>   	gpio->base = -1;		/* Allocate base dynamically */
>   	gpio->ngpio = ggc->line_max + 1;
> 
> ---
> base-commit: 0af2f6be1b4281385b618cb86ad946eded089ac8
> change-id: 20250331-gpiochip-set-rv-greybus-cd2365755186
> 
> Best regards,


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] staging: greybus: use new GPIO line value setter callbacks
  2025-04-07 13:49 ` Alex Elder
@ 2025-04-07 14:03   ` Rui Miguel Silva
  0 siblings, 0 replies; 3+ messages in thread
From: Rui Miguel Silva @ 2025-04-07 14:03 UTC (permalink / raw)
  To: Alex Elder, Bartosz Golaszewski, Rui Miguel Silva, Johan Hovold,
	Alex Elder, Greg Kroah-Hartman, Linus Walleij
  Cc: greybus-dev, linux-staging, linux-kernel, linux-gpio,
	Bartosz Golaszewski

Hi Bartosz,
Thanks for the patch.

On Mon Apr 7, 2025 at 2:49 PM WEST, Alex Elder wrote:

> On 4/7/25 2:14 AM, Bartosz Golaszewski wrote:
>> 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>
>
> Here is the commit that enabled these:
>    98ce1eb1fd87e gpiolib: introduce gpio_chip setters that return values
>
> This looks good.  Thank you.
>
> Reviewed-by: Alex Elder <elder@riscstar.com>

Agree with Alex.
LGTM.

Reviewed-by: Rui Miguel Silva <rui.silva@linaro.org>

Cheers,
   Rui
>
>> ---
>>   drivers/staging/greybus/gpio.c | 16 +++++++++-------
>>   1 file changed, 9 insertions(+), 7 deletions(-)
>> 
>> diff --git a/drivers/staging/greybus/gpio.c b/drivers/staging/greybus/gpio.c
>> index 16bcf7fc8158..f81c34160f72 100644
>> --- a/drivers/staging/greybus/gpio.c
>> +++ b/drivers/staging/greybus/gpio.c
>> @@ -185,8 +185,8 @@ static int gb_gpio_get_value_operation(struct gb_gpio_controller *ggc,
>>   	return 0;
>>   }
>>   
>> -static void gb_gpio_set_value_operation(struct gb_gpio_controller *ggc,
>> -					u8 which, bool value_high)
>> +static int gb_gpio_set_value_operation(struct gb_gpio_controller *ggc,
>> +				       u8 which, bool value_high)
>>   {
>>   	struct device *dev = &ggc->gbphy_dev->dev;
>>   	struct gb_gpio_set_value_request request;
>> @@ -195,7 +195,7 @@ static void gb_gpio_set_value_operation(struct gb_gpio_controller *ggc,
>>   	if (ggc->lines[which].direction == 1) {
>>   		dev_warn(dev, "refusing to set value of input gpio %u\n",
>>   			 which);
>> -		return;
>> +		return -EPERM;
>>   	}
>>   
>>   	request.which = which;
>> @@ -204,10 +204,12 @@ static void gb_gpio_set_value_operation(struct gb_gpio_controller *ggc,
>>   				&request, sizeof(request), NULL, 0);
>>   	if (ret) {
>>   		dev_err(dev, "failed to set value of gpio %u\n", which);
>> -		return;
>> +		return ret;
>>   	}
>>   
>>   	ggc->lines[which].value = request.value;
>> +
>> +	return 0;
>>   }
>>   
>>   static int gb_gpio_set_debounce_operation(struct gb_gpio_controller *ggc,
>> @@ -457,11 +459,11 @@ static int gb_gpio_get(struct gpio_chip *chip, unsigned int offset)
>>   	return ggc->lines[which].value;
>>   }
>>   
>> -static void gb_gpio_set(struct gpio_chip *chip, unsigned int offset, int value)
>> +static int gb_gpio_set(struct gpio_chip *chip, unsigned int offset, int value)
>>   {
>>   	struct gb_gpio_controller *ggc = gpiochip_get_data(chip);
>>   
>> -	gb_gpio_set_value_operation(ggc, (u8)offset, !!value);
>> +	return gb_gpio_set_value_operation(ggc, (u8)offset, !!value);
>>   }
>>   
>>   static int gb_gpio_set_config(struct gpio_chip *chip, unsigned int offset,
>> @@ -555,7 +557,7 @@ static int gb_gpio_probe(struct gbphy_device *gbphy_dev,
>>   	gpio->direction_input = gb_gpio_direction_input;
>>   	gpio->direction_output = gb_gpio_direction_output;
>>   	gpio->get = gb_gpio_get;
>> -	gpio->set = gb_gpio_set;
>> +	gpio->set_rv = gb_gpio_set;
>>   	gpio->set_config = gb_gpio_set_config;
>>   	gpio->base = -1;		/* Allocate base dynamically */
>>   	gpio->ngpio = ggc->line_max + 1;
>> 
>> ---
>> base-commit: 0af2f6be1b4281385b618cb86ad946eded089ac8
>> change-id: 20250331-gpiochip-set-rv-greybus-cd2365755186
>> 
>> Best regards,




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-04-07 14:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-07  7:14 [PATCH] staging: greybus: use new GPIO line value setter callbacks Bartosz Golaszewski
2025-04-07 13:49 ` Alex Elder
2025-04-07 14:03   ` Rui Miguel Silva

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).