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>
This commit is contained in:
parent
0a0ceadebd
commit
c626846147
|
@ -58,7 +58,6 @@ static int usbvision_i2c_read(void *data, unsigned char addr, char *buf,
|
|||
static inline int try_write_address(struct i2c_adapter *i2c_adap,
|
||||
unsigned char addr, int retries)
|
||||
{
|
||||
struct i2c_algo_usb_data *adap = i2c_adap->algo_data;
|
||||
void *data;
|
||||
int i, ret = -1;
|
||||
char buf[4];
|
||||
|
@ -69,10 +68,10 @@ static inline int try_write_address(struct i2c_adapter *i2c_adap,
|
|||
ret = (usbvision_i2c_write(data, addr, buf, 1));
|
||||
if (ret == 1)
|
||||
break; /* success! */
|
||||
udelay(5 /*adap->udelay */ );
|
||||
udelay(5);
|
||||
if (i == retries) /* no success */
|
||||
break;
|
||||
udelay(adap->udelay);
|
||||
udelay(10);
|
||||
}
|
||||
if (i) {
|
||||
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,
|
|||
static inline int try_read_address(struct i2c_adapter *i2c_adap,
|
||||
unsigned char addr, int retries)
|
||||
{
|
||||
struct i2c_algo_usb_data *adap = i2c_adap->algo_data;
|
||||
void *data;
|
||||
int i, ret = -1;
|
||||
char buf[4];
|
||||
|
@ -94,10 +92,10 @@ static inline int try_read_address(struct i2c_adapter *i2c_adap,
|
|||
ret = (usbvision_i2c_read(data, addr, buf, 1));
|
||||
if (ret == 1)
|
||||
break; /* success! */
|
||||
udelay(5 /*adap->udelay */ );
|
||||
udelay(5);
|
||||
if (i == retries) /* no success */
|
||||
break;
|
||||
udelay(adap->udelay);
|
||||
udelay(10);
|
||||
}
|
||||
if (i) {
|
||||
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)
|
|||
/* usbvision specific I2C functions */
|
||||
/* ----------------------------------------------------------------------- */
|
||||
static struct i2c_adapter i2c_adap_template;
|
||||
static struct i2c_algo_usb_data i2c_algo_template;
|
||||
static struct i2c_client i2c_client_template;
|
||||
|
||||
int usbvision_init_i2c(struct usb_usbvision *usbvision)
|
||||
{
|
||||
memcpy(&usbvision->i2c_adap, &i2c_adap_template,
|
||||
sizeof(struct i2c_adapter));
|
||||
memcpy(&usbvision->i2c_algo, &i2c_algo_template,
|
||||
sizeof(struct i2c_algo_usb_data));
|
||||
memcpy(&usbvision->i2c_client, &i2c_client_template,
|
||||
sizeof(struct i2c_client));
|
||||
|
||||
|
@ -266,9 +261,7 @@ int usbvision_init_i2c(struct usb_usbvision *usbvision)
|
|||
|
||||
i2c_set_adapdata(&usbvision->i2c_adap, usbvision);
|
||||
i2c_set_clientdata(&usbvision->i2c_client, usbvision);
|
||||
i2c_set_algo_usb_data(&usbvision->i2c_algo, usbvision);
|
||||
|
||||
usbvision->i2c_adap.algo_data = &usbvision->i2c_algo;
|
||||
usbvision->i2c_client.adapter = &usbvision->i2c_adap;
|
||||
|
||||
if (usbvision_write_reg(usbvision, USBVISION_SER_MODE, USBVISION_IIC_LRNACK) < 0) {
|
||||
|
@ -297,7 +290,6 @@ int usbvision_init_i2c(struct usb_usbvision *usbvision)
|
|||
void call_i2c_clients(struct usb_usbvision *usbvision, unsigned int cmd,
|
||||
void *arg)
|
||||
{
|
||||
BUG_ON(NULL == usbvision->i2c_adap.algo_data);
|
||||
i2c_clients_command(&usbvision->i2c_adap, cmd, arg);
|
||||
}
|
||||
|
||||
|
@ -531,21 +523,10 @@ static int usbvision_i2c_read(void *data, unsigned char addr, char *buf,
|
|||
return rdcount;
|
||||
}
|
||||
|
||||
static struct i2c_algo_usb_data i2c_algo_template = {
|
||||
.data = NULL,
|
||||
.inb = usbvision_i2c_read,
|
||||
.outb = usbvision_i2c_write,
|
||||
.udelay = 10,
|
||||
.mdelay = 10,
|
||||
.timeout = 100,
|
||||
};
|
||||
|
||||
static struct i2c_adapter i2c_adap_template = {
|
||||
.owner = THIS_MODULE,
|
||||
.name = "usbvision",
|
||||
.id = I2C_HW_B_BT848, /* FIXME */
|
||||
.algo = NULL,
|
||||
.algo_data = NULL,
|
||||
.client_register = attach_inform,
|
||||
.client_unregister = detach_inform,
|
||||
#ifdef I2C_ADAP_CLASS_TV_ANALOG
|
||||
|
|
|
@ -219,18 +219,6 @@ enum {
|
|||
((udevice)->last_error == 0) && \
|
||||
(!(udevice)->remove_pending))
|
||||
|
||||
/* I2C structures */
|
||||
struct i2c_algo_usb_data {
|
||||
void *data; /* private data for lowlevel routines */
|
||||
int (*inb) (void *data, unsigned char addr, char *buf, short len);
|
||||
int (*outb) (void *data, unsigned char addr, char *buf, short len);
|
||||
|
||||
/* local settings */
|
||||
int udelay;
|
||||
int mdelay;
|
||||
int timeout;
|
||||
};
|
||||
|
||||
#define I2C_USB_ADAP_MAX 16
|
||||
|
||||
/* ----------------------------------------------------------------- */
|
||||
|
@ -383,7 +371,6 @@ struct usb_usbvision {
|
|||
|
||||
/* i2c Declaration Section*/
|
||||
struct i2c_adapter i2c_adap;
|
||||
struct i2c_algo_usb_data i2c_algo;
|
||||
struct i2c_client i2c_client;
|
||||
|
||||
struct urb *ctrlUrb;
|
||||
|
@ -491,16 +478,6 @@ struct usb_usbvision {
|
|||
|
||||
int usbvision_i2c_usb_del_bus(struct i2c_adapter *);
|
||||
|
||||
static inline void *i2c_get_algo_usb_data (struct i2c_algo_usb_data *dev)
|
||||
{
|
||||
return dev->data;
|
||||
}
|
||||
|
||||
static inline void i2c_set_algo_usb_data (struct i2c_algo_usb_data *dev, void *data)
|
||||
{
|
||||
dev->data = data;
|
||||
}
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
/* usbvision specific I2C functions */
|
||||
|
|
Loading…
Reference in New Issue