public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: Douglas Schilling Landgraf <dougsland@gmail.com>
To: Alexey Klimov <klimov.linux@gmail.com>
Cc: video4linux-list@redhat.com
Subject: Re: [review patch 2/5] dsbr100: fix codinstyle, make ifs more clear
Date: Sat, 20 Dec 2008 13:27:30 -0200	[thread overview]
Message-ID: <20081220132730.45e9c365@gmail.com> (raw)
In-Reply-To: <1229742563.10297.114.camel@tux.localhost>

Hello Alexey,

On Sat, 20 Dec 2008 06:09:23 +0300
Alexey Klimov <klimov.linux@gmail.com> wrote:

> We should make if-constructions more clear. Introduce int variables in
> some functions to make it this way.
> 
> ---
> diff -r a302bfcb23f8 linux/drivers/media/radio/dsbr100.c
> --- a/linux/drivers/media/radio/dsbr100.c	Fri Dec 19 14:34:30
> 2008 +0300 +++ b/linux/drivers/media/radio/dsbr100.c	Sat Dec
> 20 02:31:26 2008 +0300 @@ -200,15 +200,24 @@
>  /* switch on radio */
>  static int dsbr100_start(struct dsbr100_device *radio)
>  {
> +	int first;
> +	int second;
> +
>  	mutex_lock(&radio->lock);
> -	if (usb_control_msg(radio->usbdev,
> usb_rcvctrlpipe(radio->usbdev, 0),
> -			USB_REQ_GET_STATUS,
> -			USB_TYPE_VENDOR | USB_RECIP_DEVICE |
> USB_DIR_IN,
> -			0x00, 0xC7, radio->transfer_buffer, 8, 300)
> < 0 ||
> -	usb_control_msg(radio->usbdev,
> usb_rcvctrlpipe(radio->usbdev, 0),
> -			DSB100_ONOFF,
> -			USB_TYPE_VENDOR | USB_RECIP_DEVICE |
> USB_DIR_IN,
> -			0x01, 0x00, radio->transfer_buffer, 8, 300)
> < 0) { +
> +	first = usb_control_msg(radio->usbdev,
> +		usb_rcvctrlpipe(radio->usbdev, 0),
> +		USB_REQ_GET_STATUS,
> +		USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN,
> +		0x00, 0xC7, radio->transfer_buffer, 8, 300);
> +
> +	second = usb_control_msg(radio->usbdev,
> +		usb_rcvctrlpipe(radio->usbdev, 0),
> +		DSB100_ONOFF,
> +		USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN,
> +		0x01, 0x00, radio->transfer_buffer, 8, 300);
> +
> +	if (first < 0 || second < 0) {
>  		mutex_unlock(&radio->lock);
>  		return -1;
>  	}

IMO, we could create a variable like "ret" or "retval" to validate each
usb_control_msg call instead of create 3 variables "first", "second" and "third".

> @@ -222,15 +231,24 @@
>  /* switch off radio */
>  static int dsbr100_stop(struct dsbr100_device *radio)
>  {
> +	int first;
> +	int second;
> +
>  	mutex_lock(&radio->lock);
> -	if (usb_control_msg(radio->usbdev,
> usb_rcvctrlpipe(radio->usbdev, 0),
> -			USB_REQ_GET_STATUS,
> -			USB_TYPE_VENDOR | USB_RECIP_DEVICE |
> USB_DIR_IN,
> -			0x16, 0x1C, radio->transfer_buffer, 8, 300)
> < 0 ||
> -	usb_control_msg(radio->usbdev,
> usb_rcvctrlpipe(radio->usbdev, 0),
> -			DSB100_ONOFF,
> -			USB_TYPE_VENDOR | USB_RECIP_DEVICE |
> USB_DIR_IN,
> -			0x00, 0x00, radio->transfer_buffer, 8, 300)
> < 0) { +
> +	first = usb_control_msg(radio->usbdev,
> +		usb_rcvctrlpipe(radio->usbdev, 0),
> +		USB_REQ_GET_STATUS,
> +		USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN,
> +		0x16, 0x1C, radio->transfer_buffer, 8, 300);
> +
> +	second = usb_control_msg(radio->usbdev,
> +		usb_rcvctrlpipe(radio->usbdev, 0),
> +		DSB100_ONOFF,
> +		USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN,
> +		0x00, 0x00, radio->transfer_buffer, 8, 300);
> +
> +	if (first < 0 || second < 0) {
>  		mutex_unlock(&radio->lock);
>  		return -1;
>  	}

The same here.

> @@ -243,21 +261,33 @@
>  /* set a frequency, freq is defined by v4l's TUNER_LOW, i.e. 1/16th
> kHz */ static int dsbr100_setfreq(struct dsbr100_device *radio, int
> freq) {
> +	int first;
> +	int second;
> +	int third;
> +
>  	freq = (freq / 16 * 80) / 1000 + 856;
>  	mutex_lock(&radio->lock);
> -	if (usb_control_msg(radio->usbdev,
> usb_rcvctrlpipe(radio->usbdev, 0),
> -			DSB100_TUNE,
> -			USB_TYPE_VENDOR | USB_RECIP_DEVICE |
> USB_DIR_IN,
> -			(freq >> 8) & 0x00ff, freq & 0xff,
> -			radio->transfer_buffer, 8, 300) < 0 ||
> -	   usb_control_msg(radio->usbdev,
> usb_rcvctrlpipe(radio->usbdev, 0),
> -			USB_REQ_GET_STATUS,
> -			USB_TYPE_VENDOR | USB_RECIP_DEVICE |
> USB_DIR_IN,
> -			0x96, 0xB7, radio->transfer_buffer, 8, 300)
> < 0 ||
> -	usb_control_msg(radio->usbdev,
> usb_rcvctrlpipe(radio->usbdev, 0),
> -			USB_REQ_GET_STATUS,
> -			USB_TYPE_VENDOR | USB_RECIP_DEVICE |
> USB_DIR_IN,
> -			0x00, 0x24, radio->transfer_buffer, 8, 300)
> < 0) { +
> +	first = usb_control_msg(radio->usbdev,
> +		usb_rcvctrlpipe(radio->usbdev, 0),
> +		DSB100_TUNE,
> +		USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN,
> +		(freq >> 8) & 0x00ff, freq & 0xff,
> +		radio->transfer_buffer, 8, 300);
> +
> +	second = usb_control_msg(radio->usbdev,
> +		usb_rcvctrlpipe(radio->usbdev, 0),
> +		USB_REQ_GET_STATUS,
> +		USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN,
> +		0x96, 0xB7, radio->transfer_buffer, 8, 300);
> +
> +	third = usb_control_msg(radio->usbdev,
> +		usb_rcvctrlpipe(radio->usbdev, 0),
> +		USB_REQ_GET_STATUS,
> +		USB_TYPE_VENDOR | USB_RECIP_DEVICE |  USB_DIR_IN,
> +		0x00, 0x24, radio->transfer_buffer, 8, 300);
> +
> +	if (first < 0 || second < 0 || third < 0) {
>  		radio->stereo = -1;
>  		mutex_unlock(&radio->lock);
>  		return -1;

The same here. What do you think?

Cheers,
Douglas

--
video4linux-list mailing list
Unsubscribe mailto:video4linux-list-request@redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list

  reply	other threads:[~2008-12-20 15:27 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-20  3:09 [review patch 2/5] dsbr100: fix codinstyle, make ifs more clear Alexey Klimov
2008-12-20 15:27 ` Douglas Schilling Landgraf [this message]
2008-12-20 17:59   ` David Ellingsworth
2008-12-21 18:46     ` Alexey Klimov
2008-12-21 20:13       ` Thierry Merle
2008-12-21 20:51         ` Alexey Klimov
2008-12-21 21:00           ` Alexey Klimov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20081220132730.45e9c365@gmail.com \
    --to=dougsland@gmail.com \
    --cc=klimov.linux@gmail.com \
    --cc=video4linux-list@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox