aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean Delvare <khali@linux-fr.org>2008-06-15 11:20:18 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2008-07-20 06:09:41 -0400
commitdf9b5d4cf636f992276b6b595620d9b2a63095db (patch)
tree9f9fcab4d67bae17609b01aece7df193cfe2a778
parent6275163e3ddbf0f0b34981bf6dc50b803e5a1c67 (diff)
V4L/DVB (8047): bt8xx: i2c structure templates clean-up
Clean up the use of structure templates in bttv-i2c. For one thing, a real template is supposed to be read-only. And in some cases it's more efficient to initialize the few fields we need individually. This clean-up shrinks bttv-i2c.o by 29% (x86_64). Signed-off-by: Jean Delvare <khali@linux-fr.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
-rw-r--r--drivers/media/video/bt8xx/bttv-i2c.c49
1 files changed, 14 insertions, 35 deletions
diff --git a/drivers/media/video/bt8xx/bttv-i2c.c b/drivers/media/video/bt8xx/bttv-i2c.c
index 4d5b8035e466..bcd2cd240a16 100644
--- a/drivers/media/video/bt8xx/bttv-i2c.c
+++ b/drivers/media/video/bt8xx/bttv-i2c.c
@@ -36,11 +36,6 @@
36#include <linux/jiffies.h> 36#include <linux/jiffies.h>
37#include <asm/io.h> 37#include <asm/io.h>
38 38
39static struct i2c_algo_bit_data bttv_i2c_algo_bit_template;
40static struct i2c_adapter bttv_i2c_adap_sw_template;
41static struct i2c_adapter bttv_i2c_adap_hw_template;
42static struct i2c_client bttv_i2c_client_template;
43
44static int attach_inform(struct i2c_client *client); 39static int attach_inform(struct i2c_client *client);
45 40
46static int i2c_debug; 41static int i2c_debug;
@@ -104,7 +99,7 @@ static int bttv_bit_getsda(void *data)
104 return state; 99 return state;
105} 100}
106 101
107static struct i2c_algo_bit_data bttv_i2c_algo_bit_template = { 102static struct i2c_algo_bit_data __devinitdata bttv_i2c_algo_bit_template = {
108 .setsda = bttv_bit_setsda, 103 .setsda = bttv_bit_setsda,
109 .setscl = bttv_bit_setscl, 104 .setscl = bttv_bit_setscl,
110 .getsda = bttv_bit_getsda, 105 .getsda = bttv_bit_getsda,
@@ -113,14 +108,6 @@ static struct i2c_algo_bit_data bttv_i2c_algo_bit_template = {
113 .timeout = 200, 108 .timeout = 200,
114}; 109};
115 110
116static struct i2c_adapter bttv_i2c_adap_sw_template = {
117 .owner = THIS_MODULE,
118 .class = I2C_CLASS_TV_ANALOG,
119 .name = "bttv",
120 .id = I2C_HW_B_BT848,
121 .client_register = attach_inform,
122};
123
124/* ----------------------------------------------------------------------- */ 111/* ----------------------------------------------------------------------- */
125/* I2C functions - hardware i2c */ 112/* I2C functions - hardware i2c */
126 113
@@ -270,20 +257,11 @@ static int bttv_i2c_xfer(struct i2c_adapter *i2c_adap, struct i2c_msg *msgs, int
270 return retval; 257 return retval;
271} 258}
272 259
273static struct i2c_algorithm bttv_algo = { 260static const struct i2c_algorithm bttv_algo = {
274 .master_xfer = bttv_i2c_xfer, 261 .master_xfer = bttv_i2c_xfer,
275 .functionality = functionality, 262 .functionality = functionality,
276}; 263};
277 264
278static struct i2c_adapter bttv_i2c_adap_hw_template = {
279 .owner = THIS_MODULE,
280 .class = I2C_CLASS_TV_ANALOG,
281 .name = "bt878",
282 .id = I2C_HW_B_BT848 /* FIXME */,
283 .algo = &bttv_algo,
284 .client_register = attach_inform,
285};
286
287/* ----------------------------------------------------------------------- */ 265/* ----------------------------------------------------------------------- */
288/* I2C functions - common stuff */ 266/* I2C functions - common stuff */
289 267
@@ -332,10 +310,6 @@ void bttv_call_i2c_clients(struct bttv *btv, unsigned int cmd, void *arg)
332 i2c_clients_command(&btv->c.i2c_adap, cmd, arg); 310 i2c_clients_command(&btv->c.i2c_adap, cmd, arg);
333} 311}
334 312
335static struct i2c_client bttv_i2c_client_template = {
336 .name = "bttv internal",
337};
338
339 313
340/* read I2C */ 314/* read I2C */
341int bttv_I2CRead(struct bttv *btv, unsigned char addr, char *probe_for) 315int bttv_I2CRead(struct bttv *btv, unsigned char addr, char *probe_for)
@@ -417,29 +391,34 @@ static void do_i2c_scan(char *name, struct i2c_client *c)
417/* init + register i2c algo-bit adapter */ 391/* init + register i2c algo-bit adapter */
418int __devinit init_bttv_i2c(struct bttv *btv) 392int __devinit init_bttv_i2c(struct bttv *btv)
419{ 393{
420 memcpy(&btv->i2c_client, &bttv_i2c_client_template, 394 strlcpy(btv->i2c_client.name, "bttv internal", I2C_NAME_SIZE);
421 sizeof(bttv_i2c_client_template));
422 395
423 if (i2c_hw) 396 if (i2c_hw)
424 btv->use_i2c_hw = 1; 397 btv->use_i2c_hw = 1;
425 if (btv->use_i2c_hw) { 398 if (btv->use_i2c_hw) {
426 /* bt878 */ 399 /* bt878 */
427 memcpy(&btv->c.i2c_adap, &bttv_i2c_adap_hw_template, 400 strlcpy(btv->c.i2c_adap.name, "bt878",
428 sizeof(bttv_i2c_adap_hw_template)); 401 sizeof(btv->c.i2c_adap.name));
402 btv->c.i2c_adap.id = I2C_HW_B_BT848; /* FIXME */
403 btv->c.i2c_adap.algo = &bttv_algo;
429 } else { 404 } else {
430 /* bt848 */ 405 /* bt848 */
431 /* Prevents usage of invalid delay values */ 406 /* Prevents usage of invalid delay values */
432 if (i2c_udelay<5) 407 if (i2c_udelay<5)
433 i2c_udelay=5; 408 i2c_udelay=5;
434 bttv_i2c_algo_bit_template.udelay=i2c_udelay;
435 409
436 memcpy(&btv->c.i2c_adap, &bttv_i2c_adap_sw_template, 410 strlcpy(btv->c.i2c_adap.name, "bttv",
437 sizeof(bttv_i2c_adap_sw_template)); 411 sizeof(btv->c.i2c_adap.name));
412 btv->c.i2c_adap.id = I2C_HW_B_BT848;
438 memcpy(&btv->i2c_algo, &bttv_i2c_algo_bit_template, 413 memcpy(&btv->i2c_algo, &bttv_i2c_algo_bit_template,
439 sizeof(bttv_i2c_algo_bit_template)); 414 sizeof(bttv_i2c_algo_bit_template));
415 btv->i2c_algo.udelay = i2c_udelay;
440 btv->i2c_algo.data = btv; 416 btv->i2c_algo.data = btv;
441 btv->c.i2c_adap.algo_data = &btv->i2c_algo; 417 btv->c.i2c_adap.algo_data = &btv->i2c_algo;
442 } 418 }
419 btv->c.i2c_adap.owner = THIS_MODULE;
420 btv->c.i2c_adap.class = I2C_CLASS_TV_ANALOG;
421 btv->c.i2c_adap.client_register = attach_inform;
443 422
444 btv->c.i2c_adap.dev.parent = &btv->c.pci->dev; 423 btv->c.i2c_adap.dev.parent = &btv->c.pci->dev;
445 snprintf(btv->c.i2c_adap.name, sizeof(btv->c.i2c_adap.name), 424 snprintf(btv->c.i2c_adap.name, sizeof(btv->c.i2c_adap.name),