Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1736749 > unrolled thread

[PATCH 2/4] [media] usbvision-core: Use common error handling code in usbvision_set_compress_params()

Started bySF Markus Elfring <elfring@users.sourceforge.net>
First post2017-09-21 17:10 +0200
Last post2017-09-22 17:00 +0200
Articles 3 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 2/4] [media] usbvision-core: Use common error handling code in  usbvision_set_compress_params() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-09-21 17:10 +0200
    Re: [PATCH 2/4] [media] usbvision-core: Use common error handling  code in usbvision_set_compress_params() Dan Carpenter <dan.carpenter@oracle.com> - 2017-09-22 13:50 +0200
      Re: [PATCH 2/4] [media] usbvision-core: Use common error handling  code in usbvision_set_compress_params() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-09-22 17:00 +0200

#1736749 — [PATCH 2/4] [media] usbvision-core: Use common error handling code in usbvision_set_compress_params()

FromSF Markus Elfring <elfring@users.sourceforge.net>
Date2017-09-21 17:10 +0200
Subject[PATCH 2/4] [media] usbvision-core: Use common error handling code in usbvision_set_compress_params()
Message-ID<usbgZ-2CM-3@gated-at.bofh.it>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 21 Sep 2017 12:45:49 +0200

* Add a jump target so that a bit of exception handling can be better
  reused at the end of this function.

* Replace the local variable "proc" by the identifier "__func__".

* Use the interface "dev_err" instead of "printk".

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/media/usb/usbvision/usbvision-core.c | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)

diff --git a/drivers/media/usb/usbvision/usbvision-core.c b/drivers/media/usb/usbvision/usbvision-core.c
index 16b76c85eeec..bb6f4f69165f 100644
--- a/drivers/media/usb/usbvision/usbvision-core.c
+++ b/drivers/media/usb/usbvision/usbvision-core.c
@@ -1857,7 +1857,6 @@ int usbvision_stream_interrupt(struct usb_usbvision *usbvision)
 
 static int usbvision_set_compress_params(struct usb_usbvision *usbvision)
 {
-	static const char proc[] = "usbvision_set_compresion_params: ";
 	int rc;
 	unsigned char *value = usbvision->ctrl_urb_buffer;
 
@@ -1882,12 +1881,8 @@ static int usbvision_set_compress_params(struct usb_usbvision *usbvision)
 			     USB_DIR_OUT | USB_TYPE_VENDOR |
 			     USB_RECIP_ENDPOINT, 0,
 			     (__u16) USBVISION_INTRA_CYC, value, 5, HZ);
-
-	if (rc < 0) {
-		printk(KERN_ERR "%sERROR=%d. USBVISION stopped - reconnect or reload driver.\n",
-		       proc, rc);
-		return rc;
-	}
+	if (rc < 0)
+		goto report_failure;
 
 	if (usbvision->bridge_type == BRIDGE_NT1004) {
 		value[0] =  20; /* PCM Threshold 1 */
@@ -1913,11 +1908,12 @@ static int usbvision_set_compress_params(struct usb_usbvision *usbvision)
 			     USB_DIR_OUT | USB_TYPE_VENDOR |
 			     USB_RECIP_ENDPOINT, 0,
 			     (__u16) USBVISION_PCM_THR1, value, 6, HZ);
+	if (rc < 0)
+report_failure:
+		dev_err(&usbvision->dev->dev,
+			"%s: ERROR=%d. USBVISION stopped - reconnect or reload driver.\n",
+			__func__, rc);
 
-	if (rc < 0) {
-		printk(KERN_ERR "%sERROR=%d. USBVISION stopped - reconnect or reload driver.\n",
-		       proc, rc);
-	}
 	return rc;
 }
 
-- 
2.14.1

[toc] | [next] | [standalone]


#1737429 — Re: [PATCH 2/4] [media] usbvision-core: Use common error handling code in usbvision_set_compress_params()

FromDan Carpenter <dan.carpenter@oracle.com>
Date2017-09-22 13:50 +0200
SubjectRe: [PATCH 2/4] [media] usbvision-core: Use common error handling code in usbvision_set_compress_params()
Message-ID<usuD0-5Be-5@gated-at.bofh.it>
In reply to#1736749
On Thu, Sep 21, 2017 at 05:07:06PM +0200, SF Markus Elfring wrote:
> @@ -1913,11 +1908,12 @@ static int usbvision_set_compress_params(struct usb_usbvision *usbvision)
>  			     USB_DIR_OUT | USB_TYPE_VENDOR |
>  			     USB_RECIP_ENDPOINT, 0,
>  			     (__u16) USBVISION_PCM_THR1, value, 6, HZ);
> +	if (rc < 0)
> +report_failure:
> +		dev_err(&usbvision->dev->dev,
> +			"%s: ERROR=%d. USBVISION stopped - reconnect or reload driver.\n",
> +			__func__, rc);

You've been asked several times not to write code like this.  You do
it later in the patch series as well.

regards,
dan carpenter

[toc] | [prev] | [next] | [standalone]


#1737566 — Re: [PATCH 2/4] [media] usbvision-core: Use common error handling code in usbvision_set_compress_params()

FromSF Markus Elfring <elfring@users.sourceforge.net>
Date2017-09-22 17:00 +0200
SubjectRe: [PATCH 2/4] [media] usbvision-core: Use common error handling code in usbvision_set_compress_params()
Message-ID<usxAR-7iO-5@gated-at.bofh.it>
In reply to#1737429
>> @@ -1913,11 +1908,12 @@ static int usbvision_set_compress_params(struct usb_usbvision *usbvision)
>>  			     USB_DIR_OUT | USB_TYPE_VENDOR |
>>  			     USB_RECIP_ENDPOINT, 0,
>>  			     (__u16) USBVISION_PCM_THR1, value, 6, HZ);
>> +	if (rc < 0)
>> +report_failure:
>> +		dev_err(&usbvision->dev->dev,
>> +			"%s: ERROR=%d. USBVISION stopped - reconnect or reload driver.\n",
>> +			__func__, rc);
> 
> You've been asked several times not to write code like this.

This suggestion occurred a few times.

Do you prefer to move this place to the end together with a duplicated statement “return rc;”?


> You do it later in the patch series as well.

To which update step do you refer here?

Regards,
Markus

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web