linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drivers/media/dvb/dvb-usb/dib0700: fix return values
@ 2010-05-19 10:26 Daniel Mack
  2010-05-19 10:34 ` Wolfram Sang
  0 siblings, 1 reply; 14+ messages in thread
From: Daniel Mack @ 2010-05-19 10:26 UTC (permalink / raw)
  To: linux-kernel
  Cc: Daniel Mack, Mauro Carvalho Chehab, Jiri Slaby, Dmitry Torokhov,
	Devin Heitmueller, linux-media

Propagte correct error values instead of returning -1 which just means
-EPERM ("Permission denied")

While at it, also fix some coding style violations.

Signed-off-by: Daniel Mack <daniel@caiaq.de>
Cc: Mauro Carvalho Chehab <mchehab@infradead.org>
Cc: Jiri Slaby <jslaby@suse.cz>
Cc: Dmitry Torokhov <dtor@mail.ru>
Cc: Devin Heitmueller <dheitmueller@kernellabs.com>
Cc: linux-media@vger.kernel.org
---
 drivers/media/dvb/dvb-usb/dib0700_core.c |   47 ++++++++++++++---------------
 1 files changed, 23 insertions(+), 24 deletions(-)

diff --git a/drivers/media/dvb/dvb-usb/dib0700_core.c b/drivers/media/dvb/dvb-usb/dib0700_core.c
index d5e2c23..c73da6b 100644
--- a/drivers/media/dvb/dvb-usb/dib0700_core.c
+++ b/drivers/media/dvb/dvb-usb/dib0700_core.c
@@ -111,23 +111,24 @@ int dib0700_set_gpio(struct dvb_usb_device *d, enum dib07x0_gpios gpio, u8 gpio_
 
 static int dib0700_set_usb_xfer_len(struct dvb_usb_device *d, u16 nb_ts_packets)
 {
-    struct dib0700_state *st = d->priv;
-    u8 b[3];
-    int ret;
-
-    if (st->fw_version >= 0x10201) {
-	b[0] = REQUEST_SET_USB_XFER_LEN;
-	b[1] = (nb_ts_packets >> 8)&0xff;
-	b[2] = nb_ts_packets & 0xff;
-
-	deb_info("set the USB xfer len to %i Ts packet\n", nb_ts_packets);
-
-	ret = dib0700_ctrl_wr(d, b, 3);
-    } else {
-	deb_info("this firmware does not allow to change the USB xfer len\n");
-	ret = -EIO;
-    }
-    return ret;
+	struct dib0700_state *st = d->priv;
+	u8 b[3];
+	int ret;
+
+	if (st->fw_version >= 0x10201) {
+		b[0] = REQUEST_SET_USB_XFER_LEN;
+		b[1] = (nb_ts_packets >> 8)&0xff;
+		b[2] = nb_ts_packets & 0xff;
+
+		deb_info("set the USB xfer len to %i Ts packet\n", nb_ts_packets);
+
+		ret = dib0700_ctrl_wr(d, b, 3);
+	} else {
+		deb_info("this firmware does not allow to change the USB xfer len\n");
+		ret = -EIO;
+	}
+
+	return ret;
 }
 
 /*
@@ -642,7 +643,7 @@ int dib0700_rc_setup(struct dvb_usb_device *d)
 	i = dib0700_ctrl_wr(d, rc_setup, 3);
 	if (i<0) {
 		err("ir protocol setup failed");
-		return -1;
+		return i;
 	}
 
 	if (st->fw_version < 0x10200)
@@ -652,7 +653,7 @@ int dib0700_rc_setup(struct dvb_usb_device *d)
 	purb = usb_alloc_urb(0, GFP_KERNEL);
 	if (purb == NULL) {
 		err("rc usb alloc urb failed\n");
-		return -1;
+		return -ENOMEM;
 	}
 
 	purb->transfer_buffer = usb_buffer_alloc(d->udev, RC_MSG_SIZE_V1_20,
@@ -661,7 +662,7 @@ int dib0700_rc_setup(struct dvb_usb_device *d)
 	if (purb->transfer_buffer == NULL) {
 		err("rc usb_buffer_alloc() failed\n");
 		usb_free_urb(purb);
-		return -1;
+		return -ENOMEM;
 	}
 
 	purb->status = -EINPROGRESS;
@@ -670,12 +671,10 @@ int dib0700_rc_setup(struct dvb_usb_device *d)
 			  dib0700_rc_urb_completion, d);
 
 	ret = usb_submit_urb(purb, GFP_ATOMIC);
-	if (ret != 0) {
+	if (ret != 0)
 		err("rc submit urb failed\n");
-		return -1;
-	}
 
-	return 0;
+	return ret;
 }
 
 static int dib0700_probe(struct usb_interface *intf,
-- 
1.7.1


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

* Re: [PATCH] drivers/media/dvb/dvb-usb/dib0700: fix return values
  2010-05-19 10:26 [PATCH] drivers/media/dvb/dvb-usb/dib0700: fix return values Daniel Mack
@ 2010-05-19 10:34 ` Wolfram Sang
  2010-05-19 10:46   ` Daniel Mack
  0 siblings, 1 reply; 14+ messages in thread
From: Wolfram Sang @ 2010-05-19 10:34 UTC (permalink / raw)
  To: Daniel Mack
  Cc: linux-kernel, Mauro Carvalho Chehab, Jiri Slaby, Dmitry Torokhov,
	Devin Heitmueller, linux-media

[-- Attachment #1: Type: text/plain, Size: 3833 bytes --]

On Wed, May 19, 2010 at 12:26:12PM +0200, Daniel Mack wrote:
> Propagte correct error values instead of returning -1 which just means
> -EPERM ("Permission denied")
> 
> While at it, also fix some coding style violations.
> 
> Signed-off-by: Daniel Mack <daniel@caiaq.de>

Just minor nits. You decide if it is worth a resend ;)

> Cc: Mauro Carvalho Chehab <mchehab@infradead.org>
> Cc: Jiri Slaby <jslaby@suse.cz>
> Cc: Dmitry Torokhov <dtor@mail.ru>
> Cc: Devin Heitmueller <dheitmueller@kernellabs.com>
> Cc: linux-media@vger.kernel.org
> ---
>  drivers/media/dvb/dvb-usb/dib0700_core.c |   47 ++++++++++++++---------------
>  1 files changed, 23 insertions(+), 24 deletions(-)
> 
> diff --git a/drivers/media/dvb/dvb-usb/dib0700_core.c b/drivers/media/dvb/dvb-usb/dib0700_core.c
> index d5e2c23..c73da6b 100644
> --- a/drivers/media/dvb/dvb-usb/dib0700_core.c
> +++ b/drivers/media/dvb/dvb-usb/dib0700_core.c
> @@ -111,23 +111,24 @@ int dib0700_set_gpio(struct dvb_usb_device *d, enum dib07x0_gpios gpio, u8 gpio_
>  
>  static int dib0700_set_usb_xfer_len(struct dvb_usb_device *d, u16 nb_ts_packets)
>  {
> -    struct dib0700_state *st = d->priv;
> -    u8 b[3];
> -    int ret;
> -
> -    if (st->fw_version >= 0x10201) {
> -	b[0] = REQUEST_SET_USB_XFER_LEN;
> -	b[1] = (nb_ts_packets >> 8)&0xff;
> -	b[2] = nb_ts_packets & 0xff;
> -
> -	deb_info("set the USB xfer len to %i Ts packet\n", nb_ts_packets);
> -
> -	ret = dib0700_ctrl_wr(d, b, 3);
> -    } else {
> -	deb_info("this firmware does not allow to change the USB xfer len\n");
> -	ret = -EIO;
> -    }
> -    return ret;
> +	struct dib0700_state *st = d->priv;
> +	u8 b[3];
> +	int ret;
> +
> +	if (st->fw_version >= 0x10201) {
> +		b[0] = REQUEST_SET_USB_XFER_LEN;
> +		b[1] = (nb_ts_packets >> 8)&0xff;

Spaces around operators?

> +		b[2] = nb_ts_packets & 0xff;
> +
> +		deb_info("set the USB xfer len to %i Ts packet\n", nb_ts_packets);
> +
> +		ret = dib0700_ctrl_wr(d, b, 3);
> +	} else {
> +		deb_info("this firmware does not allow to change the USB xfer len\n");
> +		ret = -EIO;
> +	}
> +
> +	return ret;
>  }
>  
>  /*
> @@ -642,7 +643,7 @@ int dib0700_rc_setup(struct dvb_usb_device *d)
>  	i = dib0700_ctrl_wr(d, rc_setup, 3);
>  	if (i<0) {

Spaces around operators?

>  		err("ir protocol setup failed");
> -		return -1;
> +		return i;
>  	}
>  
>  	if (st->fw_version < 0x10200)
> @@ -652,7 +653,7 @@ int dib0700_rc_setup(struct dvb_usb_device *d)
>  	purb = usb_alloc_urb(0, GFP_KERNEL);
>  	if (purb == NULL) {
>  		err("rc usb alloc urb failed\n");
> -		return -1;
> +		return -ENOMEM;
>  	}
>  
>  	purb->transfer_buffer = usb_buffer_alloc(d->udev, RC_MSG_SIZE_V1_20,
> @@ -661,7 +662,7 @@ int dib0700_rc_setup(struct dvb_usb_device *d)
>  	if (purb->transfer_buffer == NULL) {
>  		err("rc usb_buffer_alloc() failed\n");
>  		usb_free_urb(purb);
> -		return -1;
> +		return -ENOMEM;
>  	}
>  
>  	purb->status = -EINPROGRESS;
> @@ -670,12 +671,10 @@ int dib0700_rc_setup(struct dvb_usb_device *d)
>  			  dib0700_rc_urb_completion, d);
>  
>  	ret = usb_submit_urb(purb, GFP_ATOMIC);
> -	if (ret != 0) {
> +	if (ret != 0)

if (ret)

>  		err("rc submit urb failed\n");
> -		return -1;
> -	}
>  
> -	return 0;
> +	return ret;
>  }
>  
>  static int dib0700_probe(struct usb_interface *intf,
> -- 
> 1.7.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

-- 
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 197 bytes --]

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

* [PATCH] drivers/media/dvb/dvb-usb/dib0700: fix return values
  2010-05-19 10:34 ` Wolfram Sang
@ 2010-05-19 10:46   ` Daniel Mack
  2010-05-24  2:34     ` Devin Heitmueller
  0 siblings, 1 reply; 14+ messages in thread
From: Daniel Mack @ 2010-05-19 10:46 UTC (permalink / raw)
  To: linux-kernel
  Cc: Daniel Mack, Mauro Carvalho Chehab, Jiri Slaby, Dmitry Torokhov,
	Devin Heitmueller, linux-media

Propagte correct error values instead of returning -1 which just means
-EPERM ("Permission denied")

While at it, also fix some coding style violations.

Signed-off-by: Daniel Mack <daniel@caiaq.de>
Cc: Mauro Carvalho Chehab <mchehab@infradead.org>
Cc: Jiri Slaby <jslaby@suse.cz>
Cc: Dmitry Torokhov <dtor@mail.ru>
Cc: Devin Heitmueller <dheitmueller@kernellabs.com>
Cc: linux-media@vger.kernel.org
---
 drivers/media/dvb/dvb-usb/dib0700_core.c |   82 +++++++++++++++--------------
 1 files changed, 42 insertions(+), 40 deletions(-)

diff --git a/drivers/media/dvb/dvb-usb/dib0700_core.c b/drivers/media/dvb/dvb-usb/dib0700_core.c
index 4f961d2..45aec3a 100644
--- a/drivers/media/dvb/dvb-usb/dib0700_core.c
+++ b/drivers/media/dvb/dvb-usb/dib0700_core.c
@@ -53,7 +53,7 @@ static int dib0700_ctrl_wr(struct dvb_usb_device *d, u8 *tx, u8 txlen)
 	int status;
 
 	deb_data(">>> ");
-	debug_dump(tx,txlen,deb_data);
+	debug_dump(tx, txlen, deb_data);
 
 	status = usb_control_msg(d->udev, usb_sndctrlpipe(d->udev,0),
 		tx[0], USB_TYPE_VENDOR | USB_DIR_OUT, 0, 0, tx, txlen,
@@ -98,7 +98,7 @@ int dib0700_ctrl_rd(struct dvb_usb_device *d, u8 *tx, u8 txlen, u8 *rx, u8 rxlen
 		deb_info("ep 0 read error (status = %d)\n",status);
 
 	deb_data("<<< ");
-	debug_dump(rx,rxlen,deb_data);
+	debug_dump(rx, rxlen, deb_data);
 
 	return status; /* length in case of success */
 }
@@ -106,28 +106,29 @@ int dib0700_ctrl_rd(struct dvb_usb_device *d, u8 *tx, u8 txlen, u8 *rx, u8 rxlen
 int dib0700_set_gpio(struct dvb_usb_device *d, enum dib07x0_gpios gpio, u8 gpio_dir, u8 gpio_val)
 {
 	u8 buf[3] = { REQUEST_SET_GPIO, gpio, ((gpio_dir & 0x01) << 7) | ((gpio_val & 0x01) << 6) };
-	return dib0700_ctrl_wr(d,buf,3);
+	return dib0700_ctrl_wr(d, buf, sizeof(buf));
 }
 
 static int dib0700_set_usb_xfer_len(struct dvb_usb_device *d, u16 nb_ts_packets)
 {
-    struct dib0700_state *st = d->priv;
-    u8 b[3];
-    int ret;
-
-    if (st->fw_version >= 0x10201) {
-	b[0] = REQUEST_SET_USB_XFER_LEN;
-	b[1] = (nb_ts_packets >> 8)&0xff;
-	b[2] = nb_ts_packets & 0xff;
-
-	deb_info("set the USB xfer len to %i Ts packet\n", nb_ts_packets);
-
-	ret = dib0700_ctrl_wr(d, b, 3);
-    } else {
-	deb_info("this firmware does not allow to change the USB xfer len\n");
-	ret = -EIO;
-    }
-    return ret;
+	struct dib0700_state *st = d->priv;
+	u8 b[3];
+	int ret;
+
+	if (st->fw_version >= 0x10201) {
+		b[0] = REQUEST_SET_USB_XFER_LEN;
+		b[1] = (nb_ts_packets >> 8) & 0xff;
+		b[2] = nb_ts_packets & 0xff;
+
+		deb_info("set the USB xfer len to %i Ts packet\n", nb_ts_packets);
+
+		ret = dib0700_ctrl_wr(d, b, 3);
+	} else {
+		deb_info("this firmware does not allow to change the USB xfer len\n");
+		ret = -EIO;
+	}
+
+	return ret;
 }
 
 /*
@@ -178,7 +179,8 @@ static int dib0700_i2c_xfer_new(struct i2c_adapter *adap, struct i2c_msg *msg,
 			value = ((en_start << 7) | (en_stop << 6) |
 				 (msg[i].len & 0x3F)) << 8 | i2c_dest;
 			/* I2C ctrl + FE bus; */
-			index = ((gen_mode<<6)&0xC0) | ((bus_mode<<4)&0x30);
+			index = ((gen_mode << 6) & 0xC0) |
+				((bus_mode << 4) & 0x30);
 
 			result = usb_control_msg(d->udev,
 						 usb_rcvctrlpipe(d->udev, 0),
@@ -198,11 +200,12 @@ static int dib0700_i2c_xfer_new(struct i2c_adapter *adap, struct i2c_msg *msg,
 		} else {
 			/* Write request */
 			buf[0] = REQUEST_NEW_I2C_WRITE;
-			buf[1] = (msg[i].addr << 1);
+			buf[1] = msg[i].addr << 1;
 			buf[2] = (en_start << 7) | (en_stop << 6) |
 				(msg[i].len & 0x3F);
 			/* I2C ctrl + FE bus; */
-			buf[3] = ((gen_mode<<6)&0xC0) | ((bus_mode<<4)&0x30);
+			buf[3] = ((gen_mode << 6) & 0xC0) |
+				 ((bus_mode << 4) & 0x30);
 			/* The Actual i2c payload */
 			memcpy(&buf[4], msg[i].buf, msg[i].len);
 
@@ -240,7 +243,7 @@ static int dib0700_i2c_xfer_legacy(struct i2c_adapter *adap,
 
 	for (i = 0; i < num; i++) {
 		/* fill in the address */
-		buf[1] = (msg[i].addr << 1);
+		buf[1] = msg[i].addr << 1;
 		/* fill the buffer */
 		memcpy(&buf[2], msg[i].buf, msg[i].len);
 
@@ -368,7 +371,8 @@ int dib0700_download_firmware(struct usb_device *udev, const struct firmware *fw
 	u8 buf[260];
 
 	while ((ret = dvb_usb_get_hexline(fw, &hx, &pos)) > 0) {
-		deb_fwdata("writing to address 0x%08x (buffer: 0x%02x %02x)\n",hx.addr, hx.len, hx.chk);
+		deb_fwdata("writing to address 0x%08x (buffer: 0x%02x %02x)\n",
+				hx.addr, hx.len, hx.chk);
 
 		buf[0] = hx.len;
 		buf[1] = (hx.addr >> 8) & 0xff;
@@ -408,16 +412,16 @@ int dib0700_download_firmware(struct usb_device *udev, const struct firmware *fw
 				  REQUEST_GET_VERSION,
 				  USB_TYPE_VENDOR | USB_DIR_IN, 0, 0,
 				  b, sizeof(b), USB_CTRL_GET_TIMEOUT);
-	fw_version = (b[8] << 24)  | (b[9] << 16)  | (b[10] << 8) | b[11];
+	fw_version = (b[8] << 24) | (b[9] << 16) | (b[10] << 8) | b[11];
 
 	/* set the buffer size - DVB-USB is allocating URB buffers
 	 * only after the firwmare download was successful */
 	for (i = 0; i < dib0700_device_count; i++) {
 		for (adap_num = 0; adap_num < dib0700_devices[i].num_adapters;
 				adap_num++) {
-			if (fw_version >= 0x10201)
+			if (fw_version >= 0x10201) {
 				dib0700_devices[i].adapter[adap_num].stream.u.bulk.buffersize = 188*nb_packet_buffer_size;
-			else {
+			} else {
 				/* for fw version older than 1.20.1,
 				 * the buffersize has to be n times 512 */
 				dib0700_devices[i].adapter[adap_num].stream.u.bulk.buffersize = ((188*nb_packet_buffer_size+188/2)/512)*512;
@@ -453,7 +457,7 @@ int dib0700_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
 	if (st->disable_streaming_master_mode == 1)
 		b[2] = 0x00;
 	else
-		b[2] = (0x01 << 4); /* Master mode */
+		b[2] = 0x01 << 4; /* Master mode */
 
 	b[3] = 0x00;
 
@@ -466,7 +470,7 @@ int dib0700_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
 
 	b[2] |= st->channel_state;
 
-	deb_info("data for streaming: %x %x\n",b[1],b[2]);
+	deb_info("data for streaming: %x %x\n", b[1], b[2]);
 
 	return dib0700_ctrl_wr(adap->dev, b, 4);
 }
@@ -631,7 +635,7 @@ resubmit:
 int dib0700_rc_setup(struct dvb_usb_device *d)
 {
 	struct dib0700_state *st = d->priv;
-	u8 rc_setup[3] = {REQUEST_SET_RC, dvb_usb_dib0700_ir_proto, 0};
+	u8 rc_setup[3] = { REQUEST_SET_RC, dvb_usb_dib0700_ir_proto, 0 };
 	struct urb *purb;
 	int ret;
 	int i;
@@ -640,10 +644,10 @@ int dib0700_rc_setup(struct dvb_usb_device *d)
 		return 0;
 
 	/* Set the IR mode */
-	i = dib0700_ctrl_wr(d, rc_setup, 3);
-	if (i<0) {
+	i = dib0700_ctrl_wr(d, rc_setup, sizeof(rc_setup));
+	if (i < 0) {
 		err("ir protocol setup failed");
-		return -1;
+		return i;
 	}
 
 	if (st->fw_version < 0x10200)
@@ -653,14 +657,14 @@ int dib0700_rc_setup(struct dvb_usb_device *d)
 	purb = usb_alloc_urb(0, GFP_KERNEL);
 	if (purb == NULL) {
 		err("rc usb alloc urb failed\n");
-		return -1;
+		return -ENOMEM;
 	}
 
 	purb->transfer_buffer = kzalloc(RC_MSG_SIZE_V1_20, GFP_KERNEL);
 	if (purb->transfer_buffer == NULL) {
 		err("rc kzalloc failed\n");
 		usb_free_urb(purb);
-		return -1;
+		return -ENOMEM;
 	}
 
 	purb->status = -EINPROGRESS;
@@ -669,12 +673,10 @@ int dib0700_rc_setup(struct dvb_usb_device *d)
 			  dib0700_rc_urb_completion, d);
 
 	ret = usb_submit_urb(purb, GFP_ATOMIC);
-	if (ret != 0) {
+	if (ret)
 		err("rc submit urb failed\n");
-		return -1;
-	}
 
-	return 0;
+	return ret;
 }
 
 static int dib0700_probe(struct usb_interface *intf,
-- 
1.7.1


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

* Re: [PATCH] drivers/media/dvb/dvb-usb/dib0700: fix return values
  2010-05-19 10:46   ` Daniel Mack
@ 2010-05-24  2:34     ` Devin Heitmueller
  2010-05-24 10:57       ` [PATCH 1/2] " Daniel Mack
  2010-05-24 10:57       ` [PATCH 2/2] drivers/media/dvb/dvb-usb/dib0700: CodingStyle fixes Daniel Mack
  0 siblings, 2 replies; 14+ messages in thread
From: Devin Heitmueller @ 2010-05-24  2:34 UTC (permalink / raw)
  To: Daniel Mack
  Cc: linux-kernel, Mauro Carvalho Chehab, Jiri Slaby, Dmitry Torokhov,
	linux-media

On Wed, May 19, 2010 at 6:46 AM, Daniel Mack <daniel@caiaq.de> wrote:
> Propagte correct error values instead of returning -1 which just means
> -EPERM ("Permission denied")
>
> While at it, also fix some coding style violations.
>
> Signed-off-by: Daniel Mack <daniel@caiaq.de>
> Cc: Mauro Carvalho Chehab <mchehab@infradead.org>
> Cc: Jiri Slaby <jslaby@suse.cz>
> Cc: Dmitry Torokhov <dtor@mail.ru>
> Cc: Devin Heitmueller <dheitmueller@kernellabs.com>
> Cc: linux-media@vger.kernel.org
> ---
>  drivers/media/dvb/dvb-usb/dib0700_core.c |   82 +++++++++++++++--------------
>  1 files changed, 42 insertions(+), 40 deletions(-)
>
> diff --git a/drivers/media/dvb/dvb-usb/dib0700_core.c b/drivers/media/dvb/dvb-usb/dib0700_core.c
> index 4f961d2..45aec3a 100644
> --- a/drivers/media/dvb/dvb-usb/dib0700_core.c
> +++ b/drivers/media/dvb/dvb-usb/dib0700_core.c
> @@ -53,7 +53,7 @@ static int dib0700_ctrl_wr(struct dvb_usb_device *d, u8 *tx, u8 txlen)
>        int status;
>
>        deb_data(">>> ");
> -       debug_dump(tx,txlen,deb_data);
> +       debug_dump(tx, txlen, deb_data);
>
>        status = usb_control_msg(d->udev, usb_sndctrlpipe(d->udev,0),
>                tx[0], USB_TYPE_VENDOR | USB_DIR_OUT, 0, 0, tx, txlen,
> @@ -98,7 +98,7 @@ int dib0700_ctrl_rd(struct dvb_usb_device *d, u8 *tx, u8 txlen, u8 *rx, u8 rxlen
>                deb_info("ep 0 read error (status = %d)\n",status);
>
>        deb_data("<<< ");
> -       debug_dump(rx,rxlen,deb_data);
> +       debug_dump(rx, rxlen, deb_data);
>
>        return status; /* length in case of success */
>  }
> @@ -106,28 +106,29 @@ int dib0700_ctrl_rd(struct dvb_usb_device *d, u8 *tx, u8 txlen, u8 *rx, u8 rxlen
>  int dib0700_set_gpio(struct dvb_usb_device *d, enum dib07x0_gpios gpio, u8 gpio_dir, u8 gpio_val)
>  {
>        u8 buf[3] = { REQUEST_SET_GPIO, gpio, ((gpio_dir & 0x01) << 7) | ((gpio_val & 0x01) << 6) };
> -       return dib0700_ctrl_wr(d,buf,3);
> +       return dib0700_ctrl_wr(d, buf, sizeof(buf));
>  }
>
>  static int dib0700_set_usb_xfer_len(struct dvb_usb_device *d, u16 nb_ts_packets)
>  {
> -    struct dib0700_state *st = d->priv;
> -    u8 b[3];
> -    int ret;
> -
> -    if (st->fw_version >= 0x10201) {
> -       b[0] = REQUEST_SET_USB_XFER_LEN;
> -       b[1] = (nb_ts_packets >> 8)&0xff;
> -       b[2] = nb_ts_packets & 0xff;
> -
> -       deb_info("set the USB xfer len to %i Ts packet\n", nb_ts_packets);
> -
> -       ret = dib0700_ctrl_wr(d, b, 3);
> -    } else {
> -       deb_info("this firmware does not allow to change the USB xfer len\n");
> -       ret = -EIO;
> -    }
> -    return ret;
> +       struct dib0700_state *st = d->priv;
> +       u8 b[3];
> +       int ret;
> +
> +       if (st->fw_version >= 0x10201) {
> +               b[0] = REQUEST_SET_USB_XFER_LEN;
> +               b[1] = (nb_ts_packets >> 8) & 0xff;
> +               b[2] = nb_ts_packets & 0xff;
> +
> +               deb_info("set the USB xfer len to %i Ts packet\n", nb_ts_packets);
> +
> +               ret = dib0700_ctrl_wr(d, b, 3);
> +       } else {
> +               deb_info("this firmware does not allow to change the USB xfer len\n");
> +               ret = -EIO;
> +       }
> +
> +       return ret;
>  }
>
>  /*
> @@ -178,7 +179,8 @@ static int dib0700_i2c_xfer_new(struct i2c_adapter *adap, struct i2c_msg *msg,
>                        value = ((en_start << 7) | (en_stop << 6) |
>                                 (msg[i].len & 0x3F)) << 8 | i2c_dest;
>                        /* I2C ctrl + FE bus; */
> -                       index = ((gen_mode<<6)&0xC0) | ((bus_mode<<4)&0x30);
> +                       index = ((gen_mode << 6) & 0xC0) |
> +                               ((bus_mode << 4) & 0x30);
>
>                        result = usb_control_msg(d->udev,
>                                                 usb_rcvctrlpipe(d->udev, 0),
> @@ -198,11 +200,12 @@ static int dib0700_i2c_xfer_new(struct i2c_adapter *adap, struct i2c_msg *msg,
>                } else {
>                        /* Write request */
>                        buf[0] = REQUEST_NEW_I2C_WRITE;
> -                       buf[1] = (msg[i].addr << 1);
> +                       buf[1] = msg[i].addr << 1;
>                        buf[2] = (en_start << 7) | (en_stop << 6) |
>                                (msg[i].len & 0x3F);
>                        /* I2C ctrl + FE bus; */
> -                       buf[3] = ((gen_mode<<6)&0xC0) | ((bus_mode<<4)&0x30);
> +                       buf[3] = ((gen_mode << 6) & 0xC0) |
> +                                ((bus_mode << 4) & 0x30);
>                        /* The Actual i2c payload */
>                        memcpy(&buf[4], msg[i].buf, msg[i].len);
>
> @@ -240,7 +243,7 @@ static int dib0700_i2c_xfer_legacy(struct i2c_adapter *adap,
>
>        for (i = 0; i < num; i++) {
>                /* fill in the address */
> -               buf[1] = (msg[i].addr << 1);
> +               buf[1] = msg[i].addr << 1;
>                /* fill the buffer */
>                memcpy(&buf[2], msg[i].buf, msg[i].len);
>
> @@ -368,7 +371,8 @@ int dib0700_download_firmware(struct usb_device *udev, const struct firmware *fw
>        u8 buf[260];
>
>        while ((ret = dvb_usb_get_hexline(fw, &hx, &pos)) > 0) {
> -               deb_fwdata("writing to address 0x%08x (buffer: 0x%02x %02x)\n",hx.addr, hx.len, hx.chk);
> +               deb_fwdata("writing to address 0x%08x (buffer: 0x%02x %02x)\n",
> +                               hx.addr, hx.len, hx.chk);
>
>                buf[0] = hx.len;
>                buf[1] = (hx.addr >> 8) & 0xff;
> @@ -408,16 +412,16 @@ int dib0700_download_firmware(struct usb_device *udev, const struct firmware *fw
>                                  REQUEST_GET_VERSION,
>                                  USB_TYPE_VENDOR | USB_DIR_IN, 0, 0,
>                                  b, sizeof(b), USB_CTRL_GET_TIMEOUT);
> -       fw_version = (b[8] << 24)  | (b[9] << 16)  | (b[10] << 8) | b[11];
> +       fw_version = (b[8] << 24) | (b[9] << 16) | (b[10] << 8) | b[11];
>
>        /* set the buffer size - DVB-USB is allocating URB buffers
>         * only after the firwmare download was successful */
>        for (i = 0; i < dib0700_device_count; i++) {
>                for (adap_num = 0; adap_num < dib0700_devices[i].num_adapters;
>                                adap_num++) {
> -                       if (fw_version >= 0x10201)
> +                       if (fw_version >= 0x10201) {
>                                dib0700_devices[i].adapter[adap_num].stream.u.bulk.buffersize = 188*nb_packet_buffer_size;
> -                       else {
> +                       } else {
>                                /* for fw version older than 1.20.1,
>                                 * the buffersize has to be n times 512 */
>                                dib0700_devices[i].adapter[adap_num].stream.u.bulk.buffersize = ((188*nb_packet_buffer_size+188/2)/512)*512;
> @@ -453,7 +457,7 @@ int dib0700_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
>        if (st->disable_streaming_master_mode == 1)
>                b[2] = 0x00;
>        else
> -               b[2] = (0x01 << 4); /* Master mode */
> +               b[2] = 0x01 << 4; /* Master mode */
>
>        b[3] = 0x00;
>
> @@ -466,7 +470,7 @@ int dib0700_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
>
>        b[2] |= st->channel_state;
>
> -       deb_info("data for streaming: %x %x\n",b[1],b[2]);
> +       deb_info("data for streaming: %x %x\n", b[1], b[2]);
>
>        return dib0700_ctrl_wr(adap->dev, b, 4);
>  }
> @@ -631,7 +635,7 @@ resubmit:
>  int dib0700_rc_setup(struct dvb_usb_device *d)
>  {
>        struct dib0700_state *st = d->priv;
> -       u8 rc_setup[3] = {REQUEST_SET_RC, dvb_usb_dib0700_ir_proto, 0};
> +       u8 rc_setup[3] = { REQUEST_SET_RC, dvb_usb_dib0700_ir_proto, 0 };
>        struct urb *purb;
>        int ret;
>        int i;
> @@ -640,10 +644,10 @@ int dib0700_rc_setup(struct dvb_usb_device *d)
>                return 0;
>
>        /* Set the IR mode */
> -       i = dib0700_ctrl_wr(d, rc_setup, 3);
> -       if (i<0) {
> +       i = dib0700_ctrl_wr(d, rc_setup, sizeof(rc_setup));
> +       if (i < 0) {
>                err("ir protocol setup failed");
> -               return -1;
> +               return i;
>        }
>
>        if (st->fw_version < 0x10200)
> @@ -653,14 +657,14 @@ int dib0700_rc_setup(struct dvb_usb_device *d)
>        purb = usb_alloc_urb(0, GFP_KERNEL);
>        if (purb == NULL) {
>                err("rc usb alloc urb failed\n");
> -               return -1;
> +               return -ENOMEM;
>        }
>
>        purb->transfer_buffer = kzalloc(RC_MSG_SIZE_V1_20, GFP_KERNEL);
>        if (purb->transfer_buffer == NULL) {
>                err("rc kzalloc failed\n");
>                usb_free_urb(purb);
> -               return -1;
> +               return -ENOMEM;
>        }
>
>        purb->status = -EINPROGRESS;
> @@ -669,12 +673,10 @@ int dib0700_rc_setup(struct dvb_usb_device *d)
>                          dib0700_rc_urb_completion, d);
>
>        ret = usb_submit_urb(purb, GFP_ATOMIC);
> -       if (ret != 0) {
> +       if (ret)
>                err("rc submit urb failed\n");
> -               return -1;
> -       }
>
> -       return 0;
> +       return ret;
>  }
>
>  static int dib0700_probe(struct usb_interface *intf,
> --
> 1.7.1

Hello Daniel,

I am not against any of these changes in principle, but you should not
be mixing functional changes with codingstyle fixes.  It results in a
situation where as a reviewer I have to scrutinize every line *very*
closely to determine whether it's an actual change or just a
codingstyle fix.

In other words, split this into two patches.

Thanks,

Devin

-- 
Devin J. Heitmueller - Kernel Labs
http://www.kernellabs.com

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

* [PATCH 1/2] drivers/media/dvb/dvb-usb/dib0700: fix return values
  2010-05-24  2:34     ` Devin Heitmueller
@ 2010-05-24 10:57       ` Daniel Mack
  2010-05-24 11:14         ` Wolfram Sang
  2010-05-24 10:57       ` [PATCH 2/2] drivers/media/dvb/dvb-usb/dib0700: CodingStyle fixes Daniel Mack
  1 sibling, 1 reply; 14+ messages in thread
From: Daniel Mack @ 2010-05-24 10:57 UTC (permalink / raw)
  To: linux-kernel
  Cc: Daniel Mack, Wolfram Sang, Mauro Carvalho Chehab, Jiri Slaby,
	Dmitry Torokhov, Devin Heitmueller, linux-media

Propagte correct error values instead of returning -1 which just means
-EPERM ("Permission denied")

Signed-off-by: Daniel Mack <daniel@caiaq.de>
Cc: Wolfram Sang <w.sang@pengutronix.de>
Cc: Mauro Carvalho Chehab <mchehab@infradead.org>
Cc: Jiri Slaby <jslaby@suse.cz>
Cc: Dmitry Torokhov <dtor@mail.ru>
Cc: Devin Heitmueller <dheitmueller@kernellabs.com>
Cc: linux-media@vger.kernel.org
---
 drivers/media/dvb/dvb-usb/dib0700_core.c |   16 +++++++---------
 1 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/drivers/media/dvb/dvb-usb/dib0700_core.c b/drivers/media/dvb/dvb-usb/dib0700_core.c
index 4f961d2..d2dabac 100644
--- a/drivers/media/dvb/dvb-usb/dib0700_core.c
+++ b/drivers/media/dvb/dvb-usb/dib0700_core.c
@@ -640,10 +640,10 @@ int dib0700_rc_setup(struct dvb_usb_device *d)
 		return 0;
 
 	/* Set the IR mode */
-	i = dib0700_ctrl_wr(d, rc_setup, 3);
-	if (i<0) {
+	i = dib0700_ctrl_wr(d, rc_setup, sizeof(rc_setup));
+	if (i < 0) {
 		err("ir protocol setup failed");
-		return -1;
+		return i;
 	}
 
 	if (st->fw_version < 0x10200)
@@ -653,14 +653,14 @@ int dib0700_rc_setup(struct dvb_usb_device *d)
 	purb = usb_alloc_urb(0, GFP_KERNEL);
 	if (purb == NULL) {
 		err("rc usb alloc urb failed\n");
-		return -1;
+		return -ENOMEM;
 	}
 
 	purb->transfer_buffer = kzalloc(RC_MSG_SIZE_V1_20, GFP_KERNEL);
 	if (purb->transfer_buffer == NULL) {
 		err("rc kzalloc failed\n");
 		usb_free_urb(purb);
-		return -1;
+		return -ENOMEM;
 	}
 
 	purb->status = -EINPROGRESS;
@@ -669,12 +669,10 @@ int dib0700_rc_setup(struct dvb_usb_device *d)
 			  dib0700_rc_urb_completion, d);
 
 	ret = usb_submit_urb(purb, GFP_ATOMIC);
-	if (ret != 0) {
+	if (ret)
 		err("rc submit urb failed\n");
-		return -1;
-	}
 
-	return 0;
+	return ret;
 }
 
 static int dib0700_probe(struct usb_interface *intf,
-- 
1.7.1


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

* [PATCH 2/2] drivers/media/dvb/dvb-usb/dib0700: CodingStyle fixes
  2010-05-24  2:34     ` Devin Heitmueller
  2010-05-24 10:57       ` [PATCH 1/2] " Daniel Mack
@ 2010-05-24 10:57       ` Daniel Mack
  2010-05-24 11:12         ` Wolfram Sang
  2010-05-24 14:35         ` David Ellingsworth
  1 sibling, 2 replies; 14+ messages in thread
From: Daniel Mack @ 2010-05-24 10:57 UTC (permalink / raw)
  To: linux-kernel
  Cc: Daniel Mack, Wolfram Sang, Mauro Carvalho Chehab, Jiri Slaby,
	Dmitry Torokhov, Devin Heitmueller, linux-media

Signed-off-by: Daniel Mack <daniel@caiaq.de>
Cc: Wolfram Sang <w.sang@pengutronix.de>
Cc: Mauro Carvalho Chehab <mchehab@infradead.org>
Cc: Jiri Slaby <jslaby@suse.cz>
Cc: Dmitry Torokhov <dtor@mail.ru>
Cc: Devin Heitmueller <dheitmueller@kernellabs.com>
Cc: linux-media@vger.kernel.org
---
 drivers/media/dvb/dvb-usb/dib0700_core.c |   66 ++++++++++++++++--------------
 1 files changed, 35 insertions(+), 31 deletions(-)

diff --git a/drivers/media/dvb/dvb-usb/dib0700_core.c b/drivers/media/dvb/dvb-usb/dib0700_core.c
index d2dabac..45aec3a 100644
--- a/drivers/media/dvb/dvb-usb/dib0700_core.c
+++ b/drivers/media/dvb/dvb-usb/dib0700_core.c
@@ -53,7 +53,7 @@ static int dib0700_ctrl_wr(struct dvb_usb_device *d, u8 *tx, u8 txlen)
 	int status;
 
 	deb_data(">>> ");
-	debug_dump(tx,txlen,deb_data);
+	debug_dump(tx, txlen, deb_data);
 
 	status = usb_control_msg(d->udev, usb_sndctrlpipe(d->udev,0),
 		tx[0], USB_TYPE_VENDOR | USB_DIR_OUT, 0, 0, tx, txlen,
@@ -98,7 +98,7 @@ int dib0700_ctrl_rd(struct dvb_usb_device *d, u8 *tx, u8 txlen, u8 *rx, u8 rxlen
 		deb_info("ep 0 read error (status = %d)\n",status);
 
 	deb_data("<<< ");
-	debug_dump(rx,rxlen,deb_data);
+	debug_dump(rx, rxlen, deb_data);
 
 	return status; /* length in case of success */
 }
@@ -106,28 +106,29 @@ int dib0700_ctrl_rd(struct dvb_usb_device *d, u8 *tx, u8 txlen, u8 *rx, u8 rxlen
 int dib0700_set_gpio(struct dvb_usb_device *d, enum dib07x0_gpios gpio, u8 gpio_dir, u8 gpio_val)
 {
 	u8 buf[3] = { REQUEST_SET_GPIO, gpio, ((gpio_dir & 0x01) << 7) | ((gpio_val & 0x01) << 6) };
-	return dib0700_ctrl_wr(d,buf,3);
+	return dib0700_ctrl_wr(d, buf, sizeof(buf));
 }
 
 static int dib0700_set_usb_xfer_len(struct dvb_usb_device *d, u16 nb_ts_packets)
 {
-    struct dib0700_state *st = d->priv;
-    u8 b[3];
-    int ret;
-
-    if (st->fw_version >= 0x10201) {
-	b[0] = REQUEST_SET_USB_XFER_LEN;
-	b[1] = (nb_ts_packets >> 8)&0xff;
-	b[2] = nb_ts_packets & 0xff;
-
-	deb_info("set the USB xfer len to %i Ts packet\n", nb_ts_packets);
-
-	ret = dib0700_ctrl_wr(d, b, 3);
-    } else {
-	deb_info("this firmware does not allow to change the USB xfer len\n");
-	ret = -EIO;
-    }
-    return ret;
+	struct dib0700_state *st = d->priv;
+	u8 b[3];
+	int ret;
+
+	if (st->fw_version >= 0x10201) {
+		b[0] = REQUEST_SET_USB_XFER_LEN;
+		b[1] = (nb_ts_packets >> 8) & 0xff;
+		b[2] = nb_ts_packets & 0xff;
+
+		deb_info("set the USB xfer len to %i Ts packet\n", nb_ts_packets);
+
+		ret = dib0700_ctrl_wr(d, b, 3);
+	} else {
+		deb_info("this firmware does not allow to change the USB xfer len\n");
+		ret = -EIO;
+	}
+
+	return ret;
 }
 
 /*
@@ -178,7 +179,8 @@ static int dib0700_i2c_xfer_new(struct i2c_adapter *adap, struct i2c_msg *msg,
 			value = ((en_start << 7) | (en_stop << 6) |
 				 (msg[i].len & 0x3F)) << 8 | i2c_dest;
 			/* I2C ctrl + FE bus; */
-			index = ((gen_mode<<6)&0xC0) | ((bus_mode<<4)&0x30);
+			index = ((gen_mode << 6) & 0xC0) |
+				((bus_mode << 4) & 0x30);
 
 			result = usb_control_msg(d->udev,
 						 usb_rcvctrlpipe(d->udev, 0),
@@ -198,11 +200,12 @@ static int dib0700_i2c_xfer_new(struct i2c_adapter *adap, struct i2c_msg *msg,
 		} else {
 			/* Write request */
 			buf[0] = REQUEST_NEW_I2C_WRITE;
-			buf[1] = (msg[i].addr << 1);
+			buf[1] = msg[i].addr << 1;
 			buf[2] = (en_start << 7) | (en_stop << 6) |
 				(msg[i].len & 0x3F);
 			/* I2C ctrl + FE bus; */
-			buf[3] = ((gen_mode<<6)&0xC0) | ((bus_mode<<4)&0x30);
+			buf[3] = ((gen_mode << 6) & 0xC0) |
+				 ((bus_mode << 4) & 0x30);
 			/* The Actual i2c payload */
 			memcpy(&buf[4], msg[i].buf, msg[i].len);
 
@@ -240,7 +243,7 @@ static int dib0700_i2c_xfer_legacy(struct i2c_adapter *adap,
 
 	for (i = 0; i < num; i++) {
 		/* fill in the address */
-		buf[1] = (msg[i].addr << 1);
+		buf[1] = msg[i].addr << 1;
 		/* fill the buffer */
 		memcpy(&buf[2], msg[i].buf, msg[i].len);
 
@@ -368,7 +371,8 @@ int dib0700_download_firmware(struct usb_device *udev, const struct firmware *fw
 	u8 buf[260];
 
 	while ((ret = dvb_usb_get_hexline(fw, &hx, &pos)) > 0) {
-		deb_fwdata("writing to address 0x%08x (buffer: 0x%02x %02x)\n",hx.addr, hx.len, hx.chk);
+		deb_fwdata("writing to address 0x%08x (buffer: 0x%02x %02x)\n",
+				hx.addr, hx.len, hx.chk);
 
 		buf[0] = hx.len;
 		buf[1] = (hx.addr >> 8) & 0xff;
@@ -408,16 +412,16 @@ int dib0700_download_firmware(struct usb_device *udev, const struct firmware *fw
 				  REQUEST_GET_VERSION,
 				  USB_TYPE_VENDOR | USB_DIR_IN, 0, 0,
 				  b, sizeof(b), USB_CTRL_GET_TIMEOUT);
-	fw_version = (b[8] << 24)  | (b[9] << 16)  | (b[10] << 8) | b[11];
+	fw_version = (b[8] << 24) | (b[9] << 16) | (b[10] << 8) | b[11];
 
 	/* set the buffer size - DVB-USB is allocating URB buffers
 	 * only after the firwmare download was successful */
 	for (i = 0; i < dib0700_device_count; i++) {
 		for (adap_num = 0; adap_num < dib0700_devices[i].num_adapters;
 				adap_num++) {
-			if (fw_version >= 0x10201)
+			if (fw_version >= 0x10201) {
 				dib0700_devices[i].adapter[adap_num].stream.u.bulk.buffersize = 188*nb_packet_buffer_size;
-			else {
+			} else {
 				/* for fw version older than 1.20.1,
 				 * the buffersize has to be n times 512 */
 				dib0700_devices[i].adapter[adap_num].stream.u.bulk.buffersize = ((188*nb_packet_buffer_size+188/2)/512)*512;
@@ -453,7 +457,7 @@ int dib0700_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
 	if (st->disable_streaming_master_mode == 1)
 		b[2] = 0x00;
 	else
-		b[2] = (0x01 << 4); /* Master mode */
+		b[2] = 0x01 << 4; /* Master mode */
 
 	b[3] = 0x00;
 
@@ -466,7 +470,7 @@ int dib0700_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
 
 	b[2] |= st->channel_state;
 
-	deb_info("data for streaming: %x %x\n",b[1],b[2]);
+	deb_info("data for streaming: %x %x\n", b[1], b[2]);
 
 	return dib0700_ctrl_wr(adap->dev, b, 4);
 }
@@ -631,7 +635,7 @@ resubmit:
 int dib0700_rc_setup(struct dvb_usb_device *d)
 {
 	struct dib0700_state *st = d->priv;
-	u8 rc_setup[3] = {REQUEST_SET_RC, dvb_usb_dib0700_ir_proto, 0};
+	u8 rc_setup[3] = { REQUEST_SET_RC, dvb_usb_dib0700_ir_proto, 0 };
 	struct urb *purb;
 	int ret;
 	int i;
-- 
1.7.1


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

* Re: [PATCH 2/2] drivers/media/dvb/dvb-usb/dib0700: CodingStyle fixes
  2010-05-24 10:57       ` [PATCH 2/2] drivers/media/dvb/dvb-usb/dib0700: CodingStyle fixes Daniel Mack
@ 2010-05-24 11:12         ` Wolfram Sang
  2010-05-24 14:35         ` David Ellingsworth
  1 sibling, 0 replies; 14+ messages in thread
From: Wolfram Sang @ 2010-05-24 11:12 UTC (permalink / raw)
  To: Daniel Mack
  Cc: linux-kernel, Mauro Carvalho Chehab, Jiri Slaby, Dmitry Torokhov,
	Devin Heitmueller, linux-media

[-- Attachment #1: Type: text/plain, Size: 632 bytes --]

On Mon, May 24, 2010 at 12:57:15PM +0200, Daniel Mack wrote:
> Signed-off-by: Daniel Mack <daniel@caiaq.de>
> Cc: Wolfram Sang <w.sang@pengutronix.de>
> Cc: Mauro Carvalho Chehab <mchehab@infradead.org>
> Cc: Jiri Slaby <jslaby@suse.cz>
> Cc: Dmitry Torokhov <dtor@mail.ru>
> Cc: Devin Heitmueller <dheitmueller@kernellabs.com>
> Cc: linux-media@vger.kernel.org

Looks correct to me and definately more readable:

Acked-by: Wolfram Sang <w.sang@pengutronix.de>

-- 
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 197 bytes --]

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

* Re: [PATCH 1/2] drivers/media/dvb/dvb-usb/dib0700: fix return values
  2010-05-24 10:57       ` [PATCH 1/2] " Daniel Mack
@ 2010-05-24 11:14         ` Wolfram Sang
  0 siblings, 0 replies; 14+ messages in thread
From: Wolfram Sang @ 2010-05-24 11:14 UTC (permalink / raw)
  To: Daniel Mack
  Cc: linux-kernel, Mauro Carvalho Chehab, Jiri Slaby, Dmitry Torokhov,
	Devin Heitmueller, linux-media

[-- Attachment #1: Type: text/plain, Size: 800 bytes --]

On Mon, May 24, 2010 at 12:57:14PM +0200, Daniel Mack wrote:
> Propagte correct error values instead of returning -1 which just means
> -EPERM ("Permission denied")
> 
> Signed-off-by: Daniel Mack <daniel@caiaq.de>
> Cc: Wolfram Sang <w.sang@pengutronix.de>
> Cc: Mauro Carvalho Chehab <mchehab@infradead.org>
> Cc: Jiri Slaby <jslaby@suse.cz>
> Cc: Dmitry Torokhov <dtor@mail.ru>
> Cc: Devin Heitmueller <dheitmueller@kernellabs.com>
> Cc: linux-media@vger.kernel.org

I am no specialist for this driver, but as I am on cc and it looks good to me
(no big changes, after all):

Acked-by: Wolfram Sang <w.sang@pengutronix.de>

-- 
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 197 bytes --]

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

* Re: [PATCH 2/2] drivers/media/dvb/dvb-usb/dib0700: CodingStyle fixes
  2010-05-24 10:57       ` [PATCH 2/2] drivers/media/dvb/dvb-usb/dib0700: CodingStyle fixes Daniel Mack
  2010-05-24 11:12         ` Wolfram Sang
@ 2010-05-24 14:35         ` David Ellingsworth
  2010-05-24 15:23           ` [PATCH] " Daniel Mack
  1 sibling, 1 reply; 14+ messages in thread
From: David Ellingsworth @ 2010-05-24 14:35 UTC (permalink / raw)
  To: Daniel Mack
  Cc: linux-kernel, Wolfram Sang, Mauro Carvalho Chehab, Jiri Slaby,
	Dmitry Torokhov, Devin Heitmueller, linux-media

See comments below:

On Mon, May 24, 2010 at 6:57 AM, Daniel Mack <daniel@caiaq.de> wrote:

<snip />
> @@ -106,28 +106,29 @@ int dib0700_ctrl_rd(struct dvb_usb_device *d, u8 *tx, u8 txlen, u8 *rx, u8 rxlen
>  int dib0700_set_gpio(struct dvb_usb_device *d, enum dib07x0_gpios gpio, u8 gpio_dir, u8 gpio_val)
>  {
>        u8 buf[3] = { REQUEST_SET_GPIO, gpio, ((gpio_dir & 0x01) << 7) | ((gpio_val & 0x01) << 6) };
> -       return dib0700_ctrl_wr(d,buf,3);
> +       return dib0700_ctrl_wr(d, buf, sizeof(buf));
>  }
>
>  static int dib0700_set_usb_xfer_len(struct dvb_usb_device *d, u16 nb_ts_packets)
>  {
> -    struct dib0700_state *st = d->priv;
> -    u8 b[3];
> -    int ret;
> -
> -    if (st->fw_version >= 0x10201) {
> -       b[0] = REQUEST_SET_USB_XFER_LEN;
> -       b[1] = (nb_ts_packets >> 8)&0xff;
> -       b[2] = nb_ts_packets & 0xff;
> -
> -       deb_info("set the USB xfer len to %i Ts packet\n", nb_ts_packets);
> -
> -       ret = dib0700_ctrl_wr(d, b, 3);
> -    } else {
> -       deb_info("this firmware does not allow to change the USB xfer len\n");
> -       ret = -EIO;
> -    }
> -    return ret;
> +       struct dib0700_state *st = d->priv;
> +       u8 b[3];
> +       int ret;
> +
> +       if (st->fw_version >= 0x10201) {
> +               b[0] = REQUEST_SET_USB_XFER_LEN;
> +               b[1] = (nb_ts_packets >> 8) & 0xff;
> +               b[2] = nb_ts_packets & 0xff;
> +
> +               deb_info("set the USB xfer len to %i Ts packet\n", nb_ts_packets);
> +
> +               ret = dib0700_ctrl_wr(d, b, 3);

sizeof(b) would be better than the hard-coded value of 3 above.

> +       } else {
> +               deb_info("this firmware does not allow to change the USB xfer len\n");
> +               ret = -EIO;
> +       }
> +
> +       return ret;
>  }
>
>  /*
<snip />

Everything else looks good.

Regards,

David Ellingsworth

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

* [PATCH] drivers/media/dvb/dvb-usb/dib0700: CodingStyle fixes
  2010-05-24 14:35         ` David Ellingsworth
@ 2010-05-24 15:23           ` Daniel Mack
  2010-05-24 15:56             ` Dmitry Torokhov
  0 siblings, 1 reply; 14+ messages in thread
From: Daniel Mack @ 2010-05-24 15:23 UTC (permalink / raw)
  To: linux-kernel
  Cc: Daniel Mack, Wolfram Sang, Mauro Carvalho Chehab, Jiri Slaby,
	Dmitry Torokhov, Devin Heitmueller, linux-media

Signed-off-by: Daniel Mack <daniel@caiaq.de>
Cc: Wolfram Sang <w.sang@pengutronix.de>
Cc: Mauro Carvalho Chehab <mchehab@infradead.org>
Cc: Jiri Slaby <jslaby@suse.cz>
Cc: Dmitry Torokhov <dtor@mail.ru>
Cc: Devin Heitmueller <dheitmueller@kernellabs.com>
Cc: linux-media@vger.kernel.org
---
 drivers/media/dvb/dvb-usb/dib0700_core.c |   66 ++++++++++++++++--------------
 1 files changed, 35 insertions(+), 31 deletions(-)

diff --git a/drivers/media/dvb/dvb-usb/dib0700_core.c b/drivers/media/dvb/dvb-usb/dib0700_core.c
index d2dabac..7deade7 100644
--- a/drivers/media/dvb/dvb-usb/dib0700_core.c
+++ b/drivers/media/dvb/dvb-usb/dib0700_core.c
@@ -53,7 +53,7 @@ static int dib0700_ctrl_wr(struct dvb_usb_device *d, u8 *tx, u8 txlen)
 	int status;
 
 	deb_data(">>> ");
-	debug_dump(tx,txlen,deb_data);
+	debug_dump(tx, txlen, deb_data);
 
 	status = usb_control_msg(d->udev, usb_sndctrlpipe(d->udev,0),
 		tx[0], USB_TYPE_VENDOR | USB_DIR_OUT, 0, 0, tx, txlen,
@@ -98,7 +98,7 @@ int dib0700_ctrl_rd(struct dvb_usb_device *d, u8 *tx, u8 txlen, u8 *rx, u8 rxlen
 		deb_info("ep 0 read error (status = %d)\n",status);
 
 	deb_data("<<< ");
-	debug_dump(rx,rxlen,deb_data);
+	debug_dump(rx, rxlen, deb_data);
 
 	return status; /* length in case of success */
 }
@@ -106,28 +106,29 @@ int dib0700_ctrl_rd(struct dvb_usb_device *d, u8 *tx, u8 txlen, u8 *rx, u8 rxlen
 int dib0700_set_gpio(struct dvb_usb_device *d, enum dib07x0_gpios gpio, u8 gpio_dir, u8 gpio_val)
 {
 	u8 buf[3] = { REQUEST_SET_GPIO, gpio, ((gpio_dir & 0x01) << 7) | ((gpio_val & 0x01) << 6) };
-	return dib0700_ctrl_wr(d,buf,3);
+	return dib0700_ctrl_wr(d, buf, sizeof(buf));
 }
 
 static int dib0700_set_usb_xfer_len(struct dvb_usb_device *d, u16 nb_ts_packets)
 {
-    struct dib0700_state *st = d->priv;
-    u8 b[3];
-    int ret;
-
-    if (st->fw_version >= 0x10201) {
-	b[0] = REQUEST_SET_USB_XFER_LEN;
-	b[1] = (nb_ts_packets >> 8)&0xff;
-	b[2] = nb_ts_packets & 0xff;
-
-	deb_info("set the USB xfer len to %i Ts packet\n", nb_ts_packets);
-
-	ret = dib0700_ctrl_wr(d, b, 3);
-    } else {
-	deb_info("this firmware does not allow to change the USB xfer len\n");
-	ret = -EIO;
-    }
-    return ret;
+	struct dib0700_state *st = d->priv;
+	u8 b[3];
+	int ret;
+
+	if (st->fw_version >= 0x10201) {
+		b[0] = REQUEST_SET_USB_XFER_LEN;
+		b[1] = (nb_ts_packets >> 8) & 0xff;
+		b[2] = nb_ts_packets & 0xff;
+
+		deb_info("set the USB xfer len to %i Ts packet\n", nb_ts_packets);
+
+		ret = dib0700_ctrl_wr(d, b, sizeof(b));
+	} else {
+		deb_info("this firmware does not allow to change the USB xfer len\n");
+		ret = -EIO;
+	}
+
+	return ret;
 }
 
 /*
@@ -178,7 +179,8 @@ static int dib0700_i2c_xfer_new(struct i2c_adapter *adap, struct i2c_msg *msg,
 			value = ((en_start << 7) | (en_stop << 6) |
 				 (msg[i].len & 0x3F)) << 8 | i2c_dest;
 			/* I2C ctrl + FE bus; */
-			index = ((gen_mode<<6)&0xC0) | ((bus_mode<<4)&0x30);
+			index = ((gen_mode << 6) & 0xC0) |
+				((bus_mode << 4) & 0x30);
 
 			result = usb_control_msg(d->udev,
 						 usb_rcvctrlpipe(d->udev, 0),
@@ -198,11 +200,12 @@ static int dib0700_i2c_xfer_new(struct i2c_adapter *adap, struct i2c_msg *msg,
 		} else {
 			/* Write request */
 			buf[0] = REQUEST_NEW_I2C_WRITE;
-			buf[1] = (msg[i].addr << 1);
+			buf[1] = msg[i].addr << 1;
 			buf[2] = (en_start << 7) | (en_stop << 6) |
 				(msg[i].len & 0x3F);
 			/* I2C ctrl + FE bus; */
-			buf[3] = ((gen_mode<<6)&0xC0) | ((bus_mode<<4)&0x30);
+			buf[3] = ((gen_mode << 6) & 0xC0) |
+				 ((bus_mode << 4) & 0x30);
 			/* The Actual i2c payload */
 			memcpy(&buf[4], msg[i].buf, msg[i].len);
 
@@ -240,7 +243,7 @@ static int dib0700_i2c_xfer_legacy(struct i2c_adapter *adap,
 
 	for (i = 0; i < num; i++) {
 		/* fill in the address */
-		buf[1] = (msg[i].addr << 1);
+		buf[1] = msg[i].addr << 1;
 		/* fill the buffer */
 		memcpy(&buf[2], msg[i].buf, msg[i].len);
 
@@ -368,7 +371,8 @@ int dib0700_download_firmware(struct usb_device *udev, const struct firmware *fw
 	u8 buf[260];
 
 	while ((ret = dvb_usb_get_hexline(fw, &hx, &pos)) > 0) {
-		deb_fwdata("writing to address 0x%08x (buffer: 0x%02x %02x)\n",hx.addr, hx.len, hx.chk);
+		deb_fwdata("writing to address 0x%08x (buffer: 0x%02x %02x)\n",
+				hx.addr, hx.len, hx.chk);
 
 		buf[0] = hx.len;
 		buf[1] = (hx.addr >> 8) & 0xff;
@@ -408,16 +412,16 @@ int dib0700_download_firmware(struct usb_device *udev, const struct firmware *fw
 				  REQUEST_GET_VERSION,
 				  USB_TYPE_VENDOR | USB_DIR_IN, 0, 0,
 				  b, sizeof(b), USB_CTRL_GET_TIMEOUT);
-	fw_version = (b[8] << 24)  | (b[9] << 16)  | (b[10] << 8) | b[11];
+	fw_version = (b[8] << 24) | (b[9] << 16) | (b[10] << 8) | b[11];
 
 	/* set the buffer size - DVB-USB is allocating URB buffers
 	 * only after the firwmare download was successful */
 	for (i = 0; i < dib0700_device_count; i++) {
 		for (adap_num = 0; adap_num < dib0700_devices[i].num_adapters;
 				adap_num++) {
-			if (fw_version >= 0x10201)
+			if (fw_version >= 0x10201) {
 				dib0700_devices[i].adapter[adap_num].stream.u.bulk.buffersize = 188*nb_packet_buffer_size;
-			else {
+			} else {
 				/* for fw version older than 1.20.1,
 				 * the buffersize has to be n times 512 */
 				dib0700_devices[i].adapter[adap_num].stream.u.bulk.buffersize = ((188*nb_packet_buffer_size+188/2)/512)*512;
@@ -453,7 +457,7 @@ int dib0700_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
 	if (st->disable_streaming_master_mode == 1)
 		b[2] = 0x00;
 	else
-		b[2] = (0x01 << 4); /* Master mode */
+		b[2] = 0x01 << 4; /* Master mode */
 
 	b[3] = 0x00;
 
@@ -466,7 +470,7 @@ int dib0700_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
 
 	b[2] |= st->channel_state;
 
-	deb_info("data for streaming: %x %x\n",b[1],b[2]);
+	deb_info("data for streaming: %x %x\n", b[1], b[2]);
 
 	return dib0700_ctrl_wr(adap->dev, b, 4);
 }
@@ -631,7 +635,7 @@ resubmit:
 int dib0700_rc_setup(struct dvb_usb_device *d)
 {
 	struct dib0700_state *st = d->priv;
-	u8 rc_setup[3] = {REQUEST_SET_RC, dvb_usb_dib0700_ir_proto, 0};
+	u8 rc_setup[3] = { REQUEST_SET_RC, dvb_usb_dib0700_ir_proto, 0 };
 	struct urb *purb;
 	int ret;
 	int i;
-- 
1.7.1


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

* Re: [PATCH] drivers/media/dvb/dvb-usb/dib0700: CodingStyle fixes
  2010-05-24 15:23           ` [PATCH] " Daniel Mack
@ 2010-05-24 15:56             ` Dmitry Torokhov
  2010-05-24 16:02               ` Daniel Mack
  0 siblings, 1 reply; 14+ messages in thread
From: Dmitry Torokhov @ 2010-05-24 15:56 UTC (permalink / raw)
  To: Daniel Mack
  Cc: linux-kernel, Wolfram Sang, Mauro Carvalho Chehab, Jiri Slaby,
	Devin Heitmueller, linux-media

On Mon, May 24, 2010 at 05:23:05PM +0200, Daniel Mack wrote:
> Signed-off-by: Daniel Mack <daniel@caiaq.de>
> Cc: Wolfram Sang <w.sang@pengutronix.de>
> Cc: Mauro Carvalho Chehab <mchehab@infradead.org>
> Cc: Jiri Slaby <jslaby@suse.cz>
> Cc: Dmitry Torokhov <dtor@mail.ru>
> Cc: Devin Heitmueller <dheitmueller@kernellabs.com>
> Cc: linux-media@vger.kernel.org

Not sure how I got on the list but chnages look good to me.

Thanks.

-- 
Dmitry

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

* Re: [PATCH] drivers/media/dvb/dvb-usb/dib0700: CodingStyle fixes
  2010-05-24 15:56             ` Dmitry Torokhov
@ 2010-05-24 16:02               ` Daniel Mack
  2010-05-29  3:53                 ` Mauro Carvalho Chehab
  0 siblings, 1 reply; 14+ messages in thread
From: Daniel Mack @ 2010-05-24 16:02 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: linux-kernel, Wolfram Sang, Mauro Carvalho Chehab, Jiri Slaby,
	Devin Heitmueller, linux-media

On Mon, May 24, 2010 at 08:56:24AM -0700, Dmitry Torokhov wrote:
> On Mon, May 24, 2010 at 05:23:05PM +0200, Daniel Mack wrote:
> > Signed-off-by: Daniel Mack <daniel@caiaq.de>
> > Cc: Wolfram Sang <w.sang@pengutronix.de>
> > Cc: Mauro Carvalho Chehab <mchehab@infradead.org>
> > Cc: Jiri Slaby <jslaby@suse.cz>
> > Cc: Dmitry Torokhov <dtor@mail.ru>
> > Cc: Devin Heitmueller <dheitmueller@kernellabs.com>
> > Cc: linux-media@vger.kernel.org
> 
> Not sure how I got on the list but chnages look good to me.

get_maintainer.pl :)

Daniel

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

* Re: [PATCH] drivers/media/dvb/dvb-usb/dib0700: CodingStyle fixes
  2010-05-24 16:02               ` Daniel Mack
@ 2010-05-29  3:53                 ` Mauro Carvalho Chehab
  2010-05-29  3:58                   ` Mauro Carvalho Chehab
  0 siblings, 1 reply; 14+ messages in thread
From: Mauro Carvalho Chehab @ 2010-05-29  3:53 UTC (permalink / raw)
  To: Daniel Mack, Patrick Boettcher
  Cc: Dmitry Torokhov, linux-kernel, Wolfram Sang, Jiri Slaby,
	Devin Heitmueller, linux-media

Em Mon, 24 May 2010 18:02:15 +0200
Daniel Mack <daniel@caiaq.de> escreveu:

> On Mon, May 24, 2010 at 08:56:24AM -0700, Dmitry Torokhov wrote:
> > On Mon, May 24, 2010 at 05:23:05PM +0200, Daniel Mack wrote:
> > > Signed-off-by: Daniel Mack <daniel@caiaq.de>
> > > Cc: Wolfram Sang <w.sang@pengutronix.de>
> > > Cc: Mauro Carvalho Chehab <mchehab@infradead.org>
> > > Cc: Jiri Slaby <jslaby@suse.cz>
> > > Cc: Dmitry Torokhov <dtor@mail.ru>
> > > Cc: Devin Heitmueller <dheitmueller@kernellabs.com>
> > > Cc: linux-media@vger.kernel.org
> > 
> > Not sure how I got on the list but chnages look good to me.
> 
> get_maintainer.pl :)

It did a very bad work in this case... It selected a random set of people,
but it forgot to add the email of the low level driver... 
This driver is maintained by Patrick (c/c). My name is also ok (as I am the
subsystem maintainer), but instead of c/c me, you can just copy
linux-media@vger.kernel.org, since I work directly with the patchwork
queue associated with the public ML.

Patrick,

Could you please review this patch and another one sent by Daniel at the ML?

-- 

Cheers,
Mauro

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

* Re: [PATCH] drivers/media/dvb/dvb-usb/dib0700: CodingStyle fixes
  2010-05-29  3:53                 ` Mauro Carvalho Chehab
@ 2010-05-29  3:58                   ` Mauro Carvalho Chehab
  0 siblings, 0 replies; 14+ messages in thread
From: Mauro Carvalho Chehab @ 2010-05-29  3:58 UTC (permalink / raw)
  To: Patrick Boettcher; +Cc: Daniel Mack, linux-media

Patrick,

Em Sat, 29 May 2010 00:53:14 -0300
Mauro Carvalho Chehab <mchehab@redhat.com> escreveu:

> Patrick,
> 
> Could you please review this patch and another one sent by Daniel at the ML?

I think that those are the relevant changesets:

May,24 2010: [1/2] drivers/media/dvb/dvb-usb/dib0700: fix return values             http://patchwork.kernel.org/patch/101858
May,24 2010: [2/2] drivers/media/dvb/dvb-usb/dib0700: CodingStyle fixes             http://patchwork.kernel.org/patch/101859
May,24 2010: drivers/media/dvb/dvb-usb/dib0700: CodingStyle fixes                   http://patchwork.kernel.org/patch/101888

I haven't check if 101888 superseeds 101859.

-- 

Cheers,
Mauro

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

end of thread, other threads:[~2010-05-29  3:58 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-19 10:26 [PATCH] drivers/media/dvb/dvb-usb/dib0700: fix return values Daniel Mack
2010-05-19 10:34 ` Wolfram Sang
2010-05-19 10:46   ` Daniel Mack
2010-05-24  2:34     ` Devin Heitmueller
2010-05-24 10:57       ` [PATCH 1/2] " Daniel Mack
2010-05-24 11:14         ` Wolfram Sang
2010-05-24 10:57       ` [PATCH 2/2] drivers/media/dvb/dvb-usb/dib0700: CodingStyle fixes Daniel Mack
2010-05-24 11:12         ` Wolfram Sang
2010-05-24 14:35         ` David Ellingsworth
2010-05-24 15:23           ` [PATCH] " Daniel Mack
2010-05-24 15:56             ` Dmitry Torokhov
2010-05-24 16:02               ` Daniel Mack
2010-05-29  3:53                 ` Mauro Carvalho Chehab
2010-05-29  3:58                   ` Mauro Carvalho Chehab

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).