Re: [PATCH v2 3/3] HID: cp2112: fix broken gpio_direction_input callback

2017-11-10 Thread Jiri Kosina
On Fri, 10 Nov 2017, Sébastien Szymanski wrote:

> When everything goes smoothly, ret is set to 0 which makes the function
> to return EIO error.
> 
> Fixes: 8e9faa15469e ("HID: cp2112: fix gpio-callback error handling")
> Signed-off-by: Sébastien Szymanski 
> ---
> Changes in v2:
>  - rework error handling to have only one exit path as suggested by
>Benjamin Tissoires 

Applied to for-4.15/upstream.

-- 
Jiri Kosina
SUSE Labs



Re: [PATCH v2 3/3] HID: cp2112: fix broken gpio_direction_input callback

2017-11-10 Thread Jiri Kosina
On Fri, 10 Nov 2017, Sébastien Szymanski wrote:

> When everything goes smoothly, ret is set to 0 which makes the function
> to return EIO error.
> 
> Fixes: 8e9faa15469e ("HID: cp2112: fix gpio-callback error handling")
> Signed-off-by: Sébastien Szymanski 
> ---
> Changes in v2:
>  - rework error handling to have only one exit path as suggested by
>Benjamin Tissoires 

Applied to for-4.15/upstream.

-- 
Jiri Kosina
SUSE Labs



[PATCH v2 3/3] HID: cp2112: fix broken gpio_direction_input callback

2017-11-10 Thread Sébastien Szymanski
When everything goes smoothly, ret is set to 0 which makes the function
to return EIO error.

Fixes: 8e9faa15469e ("HID: cp2112: fix gpio-callback error handling")
Signed-off-by: Sébastien Szymanski 
---
Changes in v2:
 - rework error handling to have only one exit path as suggested by
   Benjamin Tissoires 

 drivers/hid/hid-cp2112.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/hid/hid-cp2112.c b/drivers/hid/hid-cp2112.c
index 28e3c18..68cdc96 100644
--- a/drivers/hid/hid-cp2112.c
+++ b/drivers/hid/hid-cp2112.c
@@ -196,6 +196,8 @@ static int cp2112_gpio_direction_input(struct gpio_chip 
*chip, unsigned offset)
 HID_REQ_GET_REPORT);
if (ret != CP2112_GPIO_CONFIG_LENGTH) {
hid_err(hdev, "error requesting GPIO config: %d\n", ret);
+   if (ret >= 0)
+   ret = -EIO;
goto exit;
}
 
@@ -205,8 +207,10 @@ static int cp2112_gpio_direction_input(struct gpio_chip 
*chip, unsigned offset)
ret = hid_hw_raw_request(hdev, CP2112_GPIO_CONFIG, buf,
 CP2112_GPIO_CONFIG_LENGTH, HID_FEATURE_REPORT,
 HID_REQ_SET_REPORT);
-   if (ret < 0) {
+   if (ret != CP2112_GPIO_CONFIG_LENGTH) {
hid_err(hdev, "error setting GPIO config: %d\n", ret);
+   if (ret >= 0)
+   ret = -EIO;
goto exit;
}
 
@@ -214,7 +218,7 @@ static int cp2112_gpio_direction_input(struct gpio_chip 
*chip, unsigned offset)
 
 exit:
mutex_unlock(>lock);
-   return ret < 0 ? ret : -EIO;
+   return ret;
 }
 
 static void cp2112_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
-- 
2.7.3



[PATCH v2 3/3] HID: cp2112: fix broken gpio_direction_input callback

2017-11-10 Thread Sébastien Szymanski
When everything goes smoothly, ret is set to 0 which makes the function
to return EIO error.

Fixes: 8e9faa15469e ("HID: cp2112: fix gpio-callback error handling")
Signed-off-by: Sébastien Szymanski 
---
Changes in v2:
 - rework error handling to have only one exit path as suggested by
   Benjamin Tissoires 

 drivers/hid/hid-cp2112.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/hid/hid-cp2112.c b/drivers/hid/hid-cp2112.c
index 28e3c18..68cdc96 100644
--- a/drivers/hid/hid-cp2112.c
+++ b/drivers/hid/hid-cp2112.c
@@ -196,6 +196,8 @@ static int cp2112_gpio_direction_input(struct gpio_chip 
*chip, unsigned offset)
 HID_REQ_GET_REPORT);
if (ret != CP2112_GPIO_CONFIG_LENGTH) {
hid_err(hdev, "error requesting GPIO config: %d\n", ret);
+   if (ret >= 0)
+   ret = -EIO;
goto exit;
}
 
@@ -205,8 +207,10 @@ static int cp2112_gpio_direction_input(struct gpio_chip 
*chip, unsigned offset)
ret = hid_hw_raw_request(hdev, CP2112_GPIO_CONFIG, buf,
 CP2112_GPIO_CONFIG_LENGTH, HID_FEATURE_REPORT,
 HID_REQ_SET_REPORT);
-   if (ret < 0) {
+   if (ret != CP2112_GPIO_CONFIG_LENGTH) {
hid_err(hdev, "error setting GPIO config: %d\n", ret);
+   if (ret >= 0)
+   ret = -EIO;
goto exit;
}
 
@@ -214,7 +218,7 @@ static int cp2112_gpio_direction_input(struct gpio_chip 
*chip, unsigned offset)
 
 exit:
mutex_unlock(>lock);
-   return ret < 0 ? ret : -EIO;
+   return ret;
 }
 
 static void cp2112_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
-- 
2.7.3



Re: [PATCH v2 3/3] HID: cp2112: fix broken gpio_direction_input callback

2017-11-10 Thread Benjamin Tissoires
On Nov 10 2017 or thereabouts, Sébastien Szymanski wrote:
> When everything goes smoothly, ret is set to 0 which makes the function
> to return EIO error.
> 
> Fixes: 8e9faa15469e ("HID: cp2112: fix gpio-callback error handling")
> Signed-off-by: Sébastien Szymanski 
> ---
> Changes in v2:
>  - rework error handling to have only one exit path as suggested by
>Benjamin Tissoires 

Looks good to me now. Thanks for the respin:
Reviewed-by: Benjamin Tissoires 

Cheers,
Benjamin

> 
>  drivers/hid/hid-cp2112.c | 8 ++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/hid/hid-cp2112.c b/drivers/hid/hid-cp2112.c
> index 28e3c18..68cdc96 100644
> --- a/drivers/hid/hid-cp2112.c
> +++ b/drivers/hid/hid-cp2112.c
> @@ -196,6 +196,8 @@ static int cp2112_gpio_direction_input(struct gpio_chip 
> *chip, unsigned offset)
>HID_REQ_GET_REPORT);
>   if (ret != CP2112_GPIO_CONFIG_LENGTH) {
>   hid_err(hdev, "error requesting GPIO config: %d\n", ret);
> + if (ret >= 0)
> + ret = -EIO;
>   goto exit;
>   }
>  
> @@ -205,8 +207,10 @@ static int cp2112_gpio_direction_input(struct gpio_chip 
> *chip, unsigned offset)
>   ret = hid_hw_raw_request(hdev, CP2112_GPIO_CONFIG, buf,
>CP2112_GPIO_CONFIG_LENGTH, HID_FEATURE_REPORT,
>HID_REQ_SET_REPORT);
> - if (ret < 0) {
> + if (ret != CP2112_GPIO_CONFIG_LENGTH) {
>   hid_err(hdev, "error setting GPIO config: %d\n", ret);
> + if (ret >= 0)
> + ret = -EIO;
>   goto exit;
>   }
>  
> @@ -214,7 +218,7 @@ static int cp2112_gpio_direction_input(struct gpio_chip 
> *chip, unsigned offset)
>  
>  exit:
>   mutex_unlock(>lock);
> - return ret < 0 ? ret : -EIO;
> + return ret;
>  }
>  
>  static void cp2112_gpio_set(struct gpio_chip *chip, unsigned offset, int 
> value)
> -- 
> 2.7.3
> 


Re: [PATCH v2 3/3] HID: cp2112: fix broken gpio_direction_input callback

2017-11-10 Thread Benjamin Tissoires
On Nov 10 2017 or thereabouts, Sébastien Szymanski wrote:
> When everything goes smoothly, ret is set to 0 which makes the function
> to return EIO error.
> 
> Fixes: 8e9faa15469e ("HID: cp2112: fix gpio-callback error handling")
> Signed-off-by: Sébastien Szymanski 
> ---
> Changes in v2:
>  - rework error handling to have only one exit path as suggested by
>Benjamin Tissoires 

Looks good to me now. Thanks for the respin:
Reviewed-by: Benjamin Tissoires 

Cheers,
Benjamin

> 
>  drivers/hid/hid-cp2112.c | 8 ++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/hid/hid-cp2112.c b/drivers/hid/hid-cp2112.c
> index 28e3c18..68cdc96 100644
> --- a/drivers/hid/hid-cp2112.c
> +++ b/drivers/hid/hid-cp2112.c
> @@ -196,6 +196,8 @@ static int cp2112_gpio_direction_input(struct gpio_chip 
> *chip, unsigned offset)
>HID_REQ_GET_REPORT);
>   if (ret != CP2112_GPIO_CONFIG_LENGTH) {
>   hid_err(hdev, "error requesting GPIO config: %d\n", ret);
> + if (ret >= 0)
> + ret = -EIO;
>   goto exit;
>   }
>  
> @@ -205,8 +207,10 @@ static int cp2112_gpio_direction_input(struct gpio_chip 
> *chip, unsigned offset)
>   ret = hid_hw_raw_request(hdev, CP2112_GPIO_CONFIG, buf,
>CP2112_GPIO_CONFIG_LENGTH, HID_FEATURE_REPORT,
>HID_REQ_SET_REPORT);
> - if (ret < 0) {
> + if (ret != CP2112_GPIO_CONFIG_LENGTH) {
>   hid_err(hdev, "error setting GPIO config: %d\n", ret);
> + if (ret >= 0)
> + ret = -EIO;
>   goto exit;
>   }
>  
> @@ -214,7 +218,7 @@ static int cp2112_gpio_direction_input(struct gpio_chip 
> *chip, unsigned offset)
>  
>  exit:
>   mutex_unlock(>lock);
> - return ret < 0 ? ret : -EIO;
> + return ret;
>  }
>  
>  static void cp2112_gpio_set(struct gpio_chip *chip, unsigned offset, int 
> value)
> -- 
> 2.7.3
>