mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Martin Samuelsson <sam@home.se>
To: Adrian Bunk <bunk@stusta.de>
Cc: akpm@osdl.org, linux-kernel@vger.kernel.org,
	mchehab@infradead.org, js@linuxtv.org,
	v4l-dvb-maintainer@linuxtv.org
Subject: Re: [-mm patch] drivers/media/video/bt866.c: small fixes
Date: Tue, 4 Apr 2006 20:32:19 +0200	[thread overview]
Message-ID: <20060404203219.40fe6b4c.sam@home.se> (raw)
In-Reply-To: <20060404163001.GO6529@stusta.de>

An extension to Adrian's patch:
- Numerous coding style compliance fixes.
- Obscure defines moved to prominent places.
- sizeof(init) replaced by ARRAY_SIZE(init).
- schedule_timeout() replaced by schedule_timeout_interruptible().

Signed-off-by: Martin Samuelsson <sam@home.se>

---

 bt866.c |   67 +++++++++++++++++++++++++++-------------------------------------
 1 files changed, 29 insertions(+), 38 deletions(-)

This should fix all things Andrew pointed out when I first submitted the 
avs6eyes driver.

--- linux-2.6.17-rc1-mm1-ab-avs6eyes/drivers/media/video/bt866.c	2006-04-04 22:13:01.000000000 +0200
+++ linux-2.6.16-git15-avs6eyes/drivers/media/video/bt866.c	2006-04-04 22:00:32.000000000 +0200
@@ -51,9 +51,12 @@
 
 #include <linux/video_encoder.h>
 
+#define	BT866_DEVNAME	"bt866"
+#define I2C_BT866	0x88
+
 MODULE_LICENSE("GPL");
 
-#define DEBUG(x)   		/* Debug driver */
+#define DEBUG(x)		/* Debug driver */
 
 /* ----------------------------------------------------------------------- */
 
@@ -70,8 +73,6 @@ struct bt866 {
 	int sat;
 };
 
-#define   I2C_BT866	0x88
-
 static int bt866_write(struct bt866 *dev,
 			unsigned char subaddr, unsigned char data);
 
@@ -152,9 +153,8 @@ static int bt866_do_command(struct bt866
 		int i;
 		u8 val;
 
-		for (i = 0; i < sizeof(init) / 2; i += 2) {
+		for (i = 0; i < ARRAY_SIZE(init) / 2; i += 2)
 			bt866_write(encoder, init[i], init[i+1]);
-		}
 
 		val = encoder->reg[0xdc];
 
@@ -162,7 +162,6 @@ static int bt866_do_command(struct bt866
 			val |= 0x40; /* CBSWAP */
 		else
 			val &= ~0x40; /* !CBSWAP */
-		//debug printk("0xdc = 0x%02x\n", val);
 
 		bt866_write(encoder, 0xdc, val);
 
@@ -196,9 +195,8 @@ static int bt866_do_command(struct bt866
 			     encoder->i2c->name, *iarg));
 
 		/* not much choice of outputs */
-		if (*iarg != 0) {
+		if (*iarg != 0)
 			return -EINVAL;
-		}
 	}
 	break;
 
@@ -236,8 +234,6 @@ static int bt866_do_command(struct bt866
 	return 0;
 }
 
-#define	BT866_DEVNAME "bt866"
-
 static int bt866_write(struct bt866 *encoder,
 			unsigned char subaddr, unsigned char data)
 {
@@ -250,19 +246,20 @@ static int bt866_write(struct bt866 *enc
 	encoder->reg[subaddr] = data;
 
 	DEBUG(printk
-	      ( "%s: write 0x%02X = 0x%02X\n",
+	      ("%s: write 0x%02X = 0x%02X\n",
 	       encoder->i2c->name, subaddr, data));
 
 	for (err = 0; err < 3;) {
-		if (2 == i2c_master_send(encoder->i2c, buffer, 2))
+		if (i2c_master_send(encoder->i2c, buffer, 2) == 2)
 			break;
 		err++;
-		printk(KERN_WARNING "%s: I/O error #%d (write 0x%02x/0x%02x)\n",
+		printk(KERN_WARNING "%s: I/O error #%d "
+		       "(write 0x%02x/0x%02x)\n",
 		       encoder->i2c->name, err, encoder->addr, subaddr);
 		current->state = TASK_INTERRUPTIBLE;
-		schedule_timeout(HZ/10);
+		schedule_timeout_interruptible(HZ/10);
 	}
-	if (3 == err) {
+	if (err == 3) {
 		printk(KERN_WARNING "%s: giving up\n",
 		       encoder->i2c->name);
 		return -1;
@@ -273,13 +270,14 @@ static int bt866_write(struct bt866 *enc
 
 static int bt866_attach(struct i2c_adapter *adapter);
 static int bt866_detach(struct i2c_client *client);
-static int bt866_command(struct i2c_client *client, unsigned int cmd, void *arg );
+static int bt866_command(struct i2c_client *client,
+			 unsigned int cmd, void *arg);
 
 
 /* Addresses to scan */
-static unsigned short normal_i2c[]	=	{ I2C_BT866>>1, I2C_CLIENT_END };
-static unsigned short probe[2]		= 	{ I2C_CLIENT_END, I2C_CLIENT_END };
-static unsigned short ignore[2]		=	{ I2C_CLIENT_END, I2C_CLIENT_END };
+static unsigned short normal_i2c[]	= {I2C_BT866>>1, I2C_CLIENT_END};
+static unsigned short probe[2]		= {I2C_CLIENT_END, I2C_CLIENT_END};
+static unsigned short ignore[2]		= {I2C_CLIENT_END, I2C_CLIENT_END};
 
 static struct i2c_client_address_data addr_data = {
 	normal_i2c,
@@ -288,12 +286,8 @@ static struct i2c_client_address_data ad
 };
 
 static struct i2c_driver i2c_driver_bt866 = {
-	.driver = {
-		.name = BT866_DEVNAME,
-	},
-
+	.driver.name = BT866_DEVNAME,
 	.id = I2C_DRIVERID_BT866,
-
 	.attach_adapter = bt866_attach,
 	.detach_client = bt866_detach,
 	.command = bt866_command
@@ -302,11 +296,11 @@ static struct i2c_driver i2c_driver_bt86
 
 static struct i2c_client bt866_client_tmpl =
 {
-	name:		"(nil)",
-	addr:		0,
-	adapter:	NULL,
-	driver:		&i2c_driver_bt866,
-	usage_count:	0
+	.name = "(nil)",
+	.addr = 0,
+	.adapter = NULL,
+	.driver = &i2c_driver_bt866,
+	.usage_count = 0
 };
 
 static int bt866_found_proc(struct i2c_adapter *adapter,
@@ -316,13 +310,13 @@ static int bt866_found_proc(struct i2c_a
 	struct i2c_client *client;
 
 	client = kzalloc(sizeof(*client), GFP_KERNEL);
-	if(client == NULL)
+	if (client == NULL)
 		return -ENOMEM;
-	memcpy( client, &bt866_client_tmpl, sizeof(*client) );
+	memcpy(client, &bt866_client_tmpl, sizeof(*client));
 
-	encoder = kzalloc( sizeof(*encoder), GFP_KERNEL );
-	if( encoder == NULL ) {
-		kfree( client );
+	encoder = kzalloc(sizeof(*encoder), GFP_KERNEL);
+	if (encoder == NULL) {
+		kfree(client);
 		return -ENOMEM;
 	}
 
@@ -344,7 +338,7 @@ static int bt866_found_proc(struct i2c_a
 
 static int bt866_attach(struct i2c_adapter *adapter)
 {
-	if ( adapter->id == I2C_HW_B_ZR36067 )
+	if (adapter->id == I2C_HW_B_ZR36067)
 		return i2c_probe(adapter, &addr_data, bt866_found_proc);
 	return 0;
 }
@@ -367,9 +361,6 @@ static int bt866_command(struct i2c_clie
 	return bt866_do_command(encoder, cmd, arg);
 }
 
-/****************************************************************************
-* linux kernel module api
-****************************************************************************/
 static int __devinit bt866_init(void)
 {
 	i2c_add_driver(&i2c_driver_bt866);

  reply	other threads:[~2006-04-04 18:36 UTC|newest]

Thread overview: 64+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-04-04  8:45 2.6.17-rc1-mm1 Andrew Morton
2006-04-04 14:31 ` 2.6.17-rc1-mm1 Kumar Gala
2006-04-04 16:02 ` 2.6.17-mm1: drivers/w1/: patch undoes reasonable cleanups Adrian Bunk
2006-04-04 16:35   ` Evgeniy Polyakov
2006-04-04 16:29 ` 2.6.17-rc1-mm1: KEXEC became SMP-only Adrian Bunk
2006-04-04 17:22   ` Zachary Amsden
2006-04-04 17:50     ` Eric W. Biederman
2006-04-06 22:37     ` Adrian Bunk
2006-04-04 17:43   ` Eric W. Biederman
2006-04-04 17:51     ` Zachary Amsden
2006-04-04 18:43       ` Eric W. Biederman
2006-04-04 19:23         ` Zachary Amsden
2006-04-04 19:38           ` Muli Ben-Yehuda
2006-04-04 20:25           ` Andrew Morton
2006-04-04 22:02             ` Zachary Amsden
2006-04-04 22:19               ` Andrew Morton
2006-04-04 22:34                 ` Zachary Amsden
2006-04-04 22:38                   ` Andrew Morton
2006-04-05  0:21                 ` Martin Bligh
2006-04-05  2:45                   ` Eric W. Biederman
2006-04-04 16:29 ` [-mm patch] i386: pre_intr_init_hook optimization Adrian Bunk
2006-04-04 17:16   ` Zachary Amsden
2006-04-04 16:29 ` 2.6.17-rc1-mm1: why did acpi_ns_build_external_path() become global? Adrian Bunk
2006-04-04 16:30 ` [-mm patch] drivers/media/video/bt866.c: small fixes Adrian Bunk
2006-04-04 18:32   ` Martin Samuelsson [this message]
2006-04-05  7:42     ` Andrew Morton
2006-04-05  9:02       ` Adrian Bunk
2006-04-05 13:44       ` Martin Samuelsson
2006-04-05  8:32     ` Johannes Stezenbach
2006-04-05 13:54       ` Martin Samuelsson
2006-04-04 16:30 ` [-mm patch] fs/nfsd/nfs4state.c: make a struct static Adrian Bunk
2006-04-04 16:50   ` [NFS] " J. Bruce Fields
2006-04-04 17:29     ` Adrian Bunk
2006-04-04 20:53 ` 2.6.17-rc1-mm1: mlockall() regression on x86_64 Rafael J. Wysocki
2006-04-04 22:24   ` Andrew Morton
2006-04-04 21:53 ` 2.6.17-rc1-mm1 Zan Lynx
2006-04-04 22:09   ` 2.6.17-rc1-mm1 Andrew Morton
2006-04-05  7:01     ` 2.6.17-rc1-mm1 Roger Luethi
2006-04-05  7:29       ` 2.6.17-rc1-mm1 Andrew Morton
2006-04-05 22:01         ` 2.6.17-rc1-mm1 Roger Luethi
2006-04-04 23:38 ` 2.6.17-rc1-mm1 Luck, Tony
2006-04-05  2:05   ` 2.6.17-rc1-mm1 Zou Nan hai
2006-04-05 16:15     ` 2.6.17-rc1-mm1 Bjorn Helgaas
2006-04-05 21:17       ` 2.6.17-rc1-mm1 Luck, Tony
2006-04-05 21:37         ` 2.6.17-rc1-mm1 Andrew Morton
2006-04-05 21:39         ` 2.6.17-rc1-mm1 Andreas Schwab
2006-04-05 22:01         ` 2.6.17-rc1-mm1 Bjorn Helgaas
2006-04-06  1:49           ` 2.6.17-rc1-mm1 Antonino A. Daplas
2006-04-06 10:21           ` 2.6.17-rc1-mm1 Russell King
2006-04-06 10:34             ` 2.6.17-rc1-mm1 Russell King
2006-04-06 14:55               ` 2.6.17-rc1-mm1 Bjorn Helgaas
2006-04-06 10:16         ` 2.6.17-rc1-mm1 Russell King
2006-04-05  2:27 ` 2.6.17-rc1-mm1, nfsd/reiser4 BUG Zan Lynx
2006-04-07 12:27 ` 2.6.17-rc1-mm1: drivers/acpi/numa.c compile error Adrian Bunk
2006-04-07 20:59   ` Andrew Morton
2006-04-09 15:44     ` Adrian Bunk
2006-04-09 15:57       ` Randy.Dunlap
2006-04-07 20:58 ` 2.6.17-rc1-mm1 - detects buggy TSC on GEODE Jim Cromie
2006-04-08  0:07   ` Andrew Morton
2006-04-08  0:25     ` john stultz
2006-04-08  1:15     ` Jim Cromie
2006-04-13  7:39 ` 2.6.17-rc1-mm1 Heiko Carstens
2006-04-13  8:13   ` 2.6.17-rc1-mm1 Andrew Morton
2006-04-14 16:07     ` 2.6.17-rc1-mm1 Alasdair G Kergon

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=20060404203219.40fe6b4c.sam@home.se \
    --to=sam@home.se \
    --cc=akpm@osdl.org \
    --cc=bunk@stusta.de \
    --cc=js@linuxtv.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mchehab@infradead.org \
    --cc=v4l-dvb-maintainer@linuxtv.org \
    /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

Powered by JetHome