diff options
author | Mauro Carvalho Chehab <mchehab@infradead.org> | 2006-12-11 15:18:15 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2006-12-27 07:23:25 -0500 |
commit | c6268461473e1c62e31afde657069c050ee8dea7 (patch) | |
tree | ec21fc0abb8307789b9c479afa0d4266da715ad1 /drivers/media | |
parent | 0a0ceadebd4551c26110f5daf0b38d9054674c9e (diff) |
V4L/DVB (4960): Removal of unused code from usbvision-i2c.c
i2c_adap is almost not used. This patch removes it, cleaning the i2c support,
and improving driver understanding.
Thanks to Thierry Merle for testing it.
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media')
-rw-r--r-- | drivers/media/video/usbvision/usbvision-i2c.c | 27 | ||||
-rw-r--r-- | drivers/media/video/usbvision/usbvision.h | 23 |
2 files changed, 4 insertions, 46 deletions
diff --git a/drivers/media/video/usbvision/usbvision-i2c.c b/drivers/media/video/usbvision/usbvision-i2c.c index 9540bd048345..efcd25bc1615 100644 --- a/drivers/media/video/usbvision/usbvision-i2c.c +++ b/drivers/media/video/usbvision/usbvision-i2c.c | |||
@@ -58,7 +58,6 @@ static int usbvision_i2c_read(void *data, unsigned char addr, char *buf, | |||
58 | static inline int try_write_address(struct i2c_adapter *i2c_adap, | 58 | static inline int try_write_address(struct i2c_adapter *i2c_adap, |
59 | unsigned char addr, int retries) | 59 | unsigned char addr, int retries) |
60 | { | 60 | { |
61 | struct i2c_algo_usb_data *adap = i2c_adap->algo_data; | ||
62 | void *data; | 61 | void *data; |
63 | int i, ret = -1; | 62 | int i, ret = -1; |
64 | char buf[4]; | 63 | char buf[4]; |
@@ -69,10 +68,10 @@ static inline int try_write_address(struct i2c_adapter *i2c_adap, | |||
69 | ret = (usbvision_i2c_write(data, addr, buf, 1)); | 68 | ret = (usbvision_i2c_write(data, addr, buf, 1)); |
70 | if (ret == 1) | 69 | if (ret == 1) |
71 | break; /* success! */ | 70 | break; /* success! */ |
72 | udelay(5 /*adap->udelay */ ); | 71 | udelay(5); |
73 | if (i == retries) /* no success */ | 72 | if (i == retries) /* no success */ |
74 | break; | 73 | break; |
75 | udelay(adap->udelay); | 74 | udelay(10); |
76 | } | 75 | } |
77 | if (i) { | 76 | if (i) { |
78 | PDEBUG(DBG_ALGO,"Needed %d retries for address %#2x", i, addr); | 77 | PDEBUG(DBG_ALGO,"Needed %d retries for address %#2x", i, addr); |
@@ -84,7 +83,6 @@ static inline int try_write_address(struct i2c_adapter *i2c_adap, | |||
84 | static inline int try_read_address(struct i2c_adapter *i2c_adap, | 83 | static inline int try_read_address(struct i2c_adapter *i2c_adap, |
85 | unsigned char addr, int retries) | 84 | unsigned char addr, int retries) |
86 | { | 85 | { |
87 | struct i2c_algo_usb_data *adap = i2c_adap->algo_data; | ||
88 | void *data; | 86 | void *data; |
89 | int i, ret = -1; | 87 | int i, ret = -1; |
90 | char buf[4]; | 88 | char buf[4]; |
@@ -94,10 +92,10 @@ static inline int try_read_address(struct i2c_adapter *i2c_adap, | |||
94 | ret = (usbvision_i2c_read(data, addr, buf, 1)); | 92 | ret = (usbvision_i2c_read(data, addr, buf, 1)); |
95 | if (ret == 1) | 93 | if (ret == 1) |
96 | break; /* success! */ | 94 | break; /* success! */ |
97 | udelay(5 /*adap->udelay */ ); | 95 | udelay(5); |
98 | if (i == retries) /* no success */ | 96 | if (i == retries) /* no success */ |
99 | break; | 97 | break; |
100 | udelay(adap->udelay); | 98 | udelay(10); |
101 | } | 99 | } |
102 | if (i) { | 100 | if (i) { |
103 | PDEBUG(DBG_ALGO,"Needed %d retries for address %#2x", i, addr); | 101 | PDEBUG(DBG_ALGO,"Needed %d retries for address %#2x", i, addr); |
@@ -248,15 +246,12 @@ int usbvision_i2c_usb_del_bus(struct i2c_adapter *adap) | |||
248 | /* usbvision specific I2C functions */ | 246 | /* usbvision specific I2C functions */ |
249 | /* ----------------------------------------------------------------------- */ | 247 | /* ----------------------------------------------------------------------- */ |
250 | static struct i2c_adapter i2c_adap_template; | 248 | static struct i2c_adapter i2c_adap_template; |
251 | static struct i2c_algo_usb_data i2c_algo_template; | ||
252 | static struct i2c_client i2c_client_template; | 249 | static struct i2c_client i2c_client_template; |
253 | 250 | ||
254 | int usbvision_init_i2c(struct usb_usbvision *usbvision) | 251 | int usbvision_init_i2c(struct usb_usbvision *usbvision) |
255 | { | 252 | { |
256 | memcpy(&usbvision->i2c_adap, &i2c_adap_template, | 253 | memcpy(&usbvision->i2c_adap, &i2c_adap_template, |
257 | sizeof(struct i2c_adapter)); | 254 | sizeof(struct i2c_adapter)); |
258 | memcpy(&usbvision->i2c_algo, &i2c_algo_template, | ||
259 | sizeof(struct i2c_algo_usb_data)); | ||
260 | memcpy(&usbvision->i2c_client, &i2c_client_template, | 255 | memcpy(&usbvision->i2c_client, &i2c_client_template, |
261 | sizeof(struct i2c_client)); | 256 | sizeof(struct i2c_client)); |
262 | 257 | ||
@@ -266,9 +261,7 @@ int usbvision_init_i2c(struct usb_usbvision *usbvision) | |||
266 | 261 | ||
267 | i2c_set_adapdata(&usbvision->i2c_adap, usbvision); | 262 | i2c_set_adapdata(&usbvision->i2c_adap, usbvision); |
268 | i2c_set_clientdata(&usbvision->i2c_client, usbvision); | 263 | i2c_set_clientdata(&usbvision->i2c_client, usbvision); |
269 | i2c_set_algo_usb_data(&usbvision->i2c_algo, usbvision); | ||
270 | 264 | ||
271 | usbvision->i2c_adap.algo_data = &usbvision->i2c_algo; | ||
272 | usbvision->i2c_client.adapter = &usbvision->i2c_adap; | 265 | usbvision->i2c_client.adapter = &usbvision->i2c_adap; |
273 | 266 | ||
274 | if (usbvision_write_reg(usbvision, USBVISION_SER_MODE, USBVISION_IIC_LRNACK) < 0) { | 267 | if (usbvision_write_reg(usbvision, USBVISION_SER_MODE, USBVISION_IIC_LRNACK) < 0) { |
@@ -297,7 +290,6 @@ int usbvision_init_i2c(struct usb_usbvision *usbvision) | |||
297 | void call_i2c_clients(struct usb_usbvision *usbvision, unsigned int cmd, | 290 | void call_i2c_clients(struct usb_usbvision *usbvision, unsigned int cmd, |
298 | void *arg) | 291 | void *arg) |
299 | { | 292 | { |
300 | BUG_ON(NULL == usbvision->i2c_adap.algo_data); | ||
301 | i2c_clients_command(&usbvision->i2c_adap, cmd, arg); | 293 | i2c_clients_command(&usbvision->i2c_adap, cmd, arg); |
302 | } | 294 | } |
303 | 295 | ||
@@ -531,21 +523,10 @@ static int usbvision_i2c_read(void *data, unsigned char addr, char *buf, | |||
531 | return rdcount; | 523 | return rdcount; |
532 | } | 524 | } |
533 | 525 | ||
534 | static struct i2c_algo_usb_data i2c_algo_template = { | ||
535 | .data = NULL, | ||
536 | .inb = usbvision_i2c_read, | ||
537 | .outb = usbvision_i2c_write, | ||
538 | .udelay = 10, | ||
539 | .mdelay = 10, | ||
540 | .timeout = 100, | ||
541 | }; | ||
542 | |||
543 | static struct i2c_adapter i2c_adap_template = { | 526 | static struct i2c_adapter i2c_adap_template = { |
544 | .owner = THIS_MODULE, | 527 | .owner = THIS_MODULE, |
545 | .name = "usbvision", | 528 | .name = "usbvision", |
546 | .id = I2C_HW_B_BT848, /* FIXME */ | 529 | .id = I2C_HW_B_BT848, /* FIXME */ |
547 | .algo = NULL, | ||
548 | .algo_data = NULL, | ||
549 | .client_register = attach_inform, | 530 | .client_register = attach_inform, |
550 | .client_unregister = detach_inform, | 531 | .client_unregister = detach_inform, |
551 | #ifdef I2C_ADAP_CLASS_TV_ANALOG | 532 | #ifdef I2C_ADAP_CLASS_TV_ANALOG |
diff --git a/drivers/media/video/usbvision/usbvision.h b/drivers/media/video/usbvision/usbvision.h index 5ad07f8a9d9b..b1645f9e572d 100644 --- a/drivers/media/video/usbvision/usbvision.h +++ b/drivers/media/video/usbvision/usbvision.h | |||
@@ -219,18 +219,6 @@ enum { | |||
219 | ((udevice)->last_error == 0) && \ | 219 | ((udevice)->last_error == 0) && \ |
220 | (!(udevice)->remove_pending)) | 220 | (!(udevice)->remove_pending)) |
221 | 221 | ||
222 | /* I2C structures */ | ||
223 | struct i2c_algo_usb_data { | ||
224 | void *data; /* private data for lowlevel routines */ | ||
225 | int (*inb) (void *data, unsigned char addr, char *buf, short len); | ||
226 | int (*outb) (void *data, unsigned char addr, char *buf, short len); | ||
227 | |||
228 | /* local settings */ | ||
229 | int udelay; | ||
230 | int mdelay; | ||
231 | int timeout; | ||
232 | }; | ||
233 | |||
234 | #define I2C_USB_ADAP_MAX 16 | 222 | #define I2C_USB_ADAP_MAX 16 |
235 | 223 | ||
236 | /* ----------------------------------------------------------------- */ | 224 | /* ----------------------------------------------------------------- */ |
@@ -383,7 +371,6 @@ struct usb_usbvision { | |||
383 | 371 | ||
384 | /* i2c Declaration Section*/ | 372 | /* i2c Declaration Section*/ |
385 | struct i2c_adapter i2c_adap; | 373 | struct i2c_adapter i2c_adap; |
386 | struct i2c_algo_usb_data i2c_algo; | ||
387 | struct i2c_client i2c_client; | 374 | struct i2c_client i2c_client; |
388 | 375 | ||
389 | struct urb *ctrlUrb; | 376 | struct urb *ctrlUrb; |
@@ -491,16 +478,6 @@ struct usb_usbvision { | |||
491 | 478 | ||
492 | int usbvision_i2c_usb_del_bus(struct i2c_adapter *); | 479 | int usbvision_i2c_usb_del_bus(struct i2c_adapter *); |
493 | 480 | ||
494 | static inline void *i2c_get_algo_usb_data (struct i2c_algo_usb_data *dev) | ||
495 | { | ||
496 | return dev->data; | ||
497 | } | ||
498 | |||
499 | static inline void i2c_set_algo_usb_data (struct i2c_algo_usb_data *dev, void *data) | ||
500 | { | ||
501 | dev->data = data; | ||
502 | } | ||
503 | |||
504 | 481 | ||
505 | /* ----------------------------------------------------------------------- */ | 482 | /* ----------------------------------------------------------------------- */ |
506 | /* usbvision specific I2C functions */ | 483 | /* usbvision specific I2C functions */ |