From: Martin Samuelsson 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(). This should fix all things Andrew pointed out when I first submitted the avs6eyes driver. Signed-off-by: Martin Samuelsson Cc: Mauro Carvalho Chehab Cc: Johannes Stezenbach Signed-off-by: Andrew Morton --- drivers/media/video/bt866.c | 70 +++++++++++++++------------------- 1 files changed, 31 insertions(+), 39 deletions(-) diff -puN drivers/media/video/bt866.c~drivers-media-video-bt866c-small-fixes drivers/media/video/bt866.c --- devel/drivers/media/video/bt866.c~drivers-media-video-bt866c-small-fixes 2006-04-05 01:09:45.000000000 -0700 +++ devel-akpm/drivers/media/video/bt866.c 2006-04-05 02:20:19.000000000 -0700 @@ -56,7 +56,12 @@ MODULE_LICENSE("GPL"); #endif -#define DEBUG(x) /* Debug driver */ +#define BT866_DEVNAME "bt866" +#define I2C_BT866 0x88 + +MODULE_LICENSE("GPL"); + +#define DEBUG(x) /* Debug driver */ /* ----------------------------------------------------------------------- */ @@ -73,8 +78,6 @@ struct bt866 { int sat; }; -#define I2C_BT866 0x88 - static int bt866_write(struct bt866 *dev, unsigned char subaddr, unsigned char data); @@ -155,9 +158,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]; @@ -165,7 +167,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); @@ -199,9 +200,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; @@ -239,8 +239,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) { @@ -253,19 +251,19 @@ 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; @@ -276,13 +274,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, @@ -291,12 +290,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 @@ -305,11 +300,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, @@ -319,13 +314,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; } @@ -347,7 +342,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; } @@ -370,9 +365,6 @@ static int bt866_command(struct i2c_clie return bt866_do_command(encoder, cmd, arg); } -/**************************************************************************** -* linux kernel module api -****************************************************************************/ #ifdef MODULE int init_module(void) #else _