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>
This commit is contained in:
parent
6275163e3d
commit
df9b5d4cf6
@ -36,11 +36,6 @@
|
|||||||
#include <linux/jiffies.h>
|
#include <linux/jiffies.h>
|
||||||
#include <asm/io.h>
|
#include <asm/io.h>
|
||||||
|
|
||||||
static struct i2c_algo_bit_data bttv_i2c_algo_bit_template;
|
|
||||||
static struct i2c_adapter bttv_i2c_adap_sw_template;
|
|
||||||
static struct i2c_adapter bttv_i2c_adap_hw_template;
|
|
||||||
static struct i2c_client bttv_i2c_client_template;
|
|
||||||
|
|
||||||
static int attach_inform(struct i2c_client *client);
|
static int attach_inform(struct i2c_client *client);
|
||||||
|
|
||||||
static int i2c_debug;
|
static int i2c_debug;
|
||||||
@ -104,7 +99,7 @@ static int bttv_bit_getsda(void *data)
|
|||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct i2c_algo_bit_data bttv_i2c_algo_bit_template = {
|
static struct i2c_algo_bit_data __devinitdata bttv_i2c_algo_bit_template = {
|
||||||
.setsda = bttv_bit_setsda,
|
.setsda = bttv_bit_setsda,
|
||||||
.setscl = bttv_bit_setscl,
|
.setscl = bttv_bit_setscl,
|
||||||
.getsda = bttv_bit_getsda,
|
.getsda = bttv_bit_getsda,
|
||||||
@ -113,14 +108,6 @@ static struct i2c_algo_bit_data bttv_i2c_algo_bit_template = {
|
|||||||
.timeout = 200,
|
.timeout = 200,
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct i2c_adapter bttv_i2c_adap_sw_template = {
|
|
||||||
.owner = THIS_MODULE,
|
|
||||||
.class = I2C_CLASS_TV_ANALOG,
|
|
||||||
.name = "bttv",
|
|
||||||
.id = I2C_HW_B_BT848,
|
|
||||||
.client_register = attach_inform,
|
|
||||||
};
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------- */
|
/* ----------------------------------------------------------------------- */
|
||||||
/* I2C functions - hardware i2c */
|
/* I2C functions - hardware i2c */
|
||||||
|
|
||||||
@ -270,20 +257,11 @@ static int bttv_i2c_xfer(struct i2c_adapter *i2c_adap, struct i2c_msg *msgs, int
|
|||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct i2c_algorithm bttv_algo = {
|
static const struct i2c_algorithm bttv_algo = {
|
||||||
.master_xfer = bttv_i2c_xfer,
|
.master_xfer = bttv_i2c_xfer,
|
||||||
.functionality = functionality,
|
.functionality = functionality,
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct i2c_adapter bttv_i2c_adap_hw_template = {
|
|
||||||
.owner = THIS_MODULE,
|
|
||||||
.class = I2C_CLASS_TV_ANALOG,
|
|
||||||
.name = "bt878",
|
|
||||||
.id = I2C_HW_B_BT848 /* FIXME */,
|
|
||||||
.algo = &bttv_algo,
|
|
||||||
.client_register = attach_inform,
|
|
||||||
};
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------- */
|
/* ----------------------------------------------------------------------- */
|
||||||
/* I2C functions - common stuff */
|
/* I2C functions - common stuff */
|
||||||
|
|
||||||
@ -332,10 +310,6 @@ void bttv_call_i2c_clients(struct bttv *btv, unsigned int cmd, void *arg)
|
|||||||
i2c_clients_command(&btv->c.i2c_adap, cmd, arg);
|
i2c_clients_command(&btv->c.i2c_adap, cmd, arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct i2c_client bttv_i2c_client_template = {
|
|
||||||
.name = "bttv internal",
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/* read I2C */
|
/* read I2C */
|
||||||
int bttv_I2CRead(struct bttv *btv, unsigned char addr, char *probe_for)
|
int 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)
|
|||||||
/* init + register i2c algo-bit adapter */
|
/* init + register i2c algo-bit adapter */
|
||||||
int __devinit init_bttv_i2c(struct bttv *btv)
|
int __devinit init_bttv_i2c(struct bttv *btv)
|
||||||
{
|
{
|
||||||
memcpy(&btv->i2c_client, &bttv_i2c_client_template,
|
strlcpy(btv->i2c_client.name, "bttv internal", I2C_NAME_SIZE);
|
||||||
sizeof(bttv_i2c_client_template));
|
|
||||||
|
|
||||||
if (i2c_hw)
|
if (i2c_hw)
|
||||||
btv->use_i2c_hw = 1;
|
btv->use_i2c_hw = 1;
|
||||||
if (btv->use_i2c_hw) {
|
if (btv->use_i2c_hw) {
|
||||||
/* bt878 */
|
/* bt878 */
|
||||||
memcpy(&btv->c.i2c_adap, &bttv_i2c_adap_hw_template,
|
strlcpy(btv->c.i2c_adap.name, "bt878",
|
||||||
sizeof(bttv_i2c_adap_hw_template));
|
sizeof(btv->c.i2c_adap.name));
|
||||||
|
btv->c.i2c_adap.id = I2C_HW_B_BT848; /* FIXME */
|
||||||
|
btv->c.i2c_adap.algo = &bttv_algo;
|
||||||
} else {
|
} else {
|
||||||
/* bt848 */
|
/* bt848 */
|
||||||
/* Prevents usage of invalid delay values */
|
/* Prevents usage of invalid delay values */
|
||||||
if (i2c_udelay<5)
|
if (i2c_udelay<5)
|
||||||
i2c_udelay=5;
|
i2c_udelay=5;
|
||||||
bttv_i2c_algo_bit_template.udelay=i2c_udelay;
|
|
||||||
|
|
||||||
memcpy(&btv->c.i2c_adap, &bttv_i2c_adap_sw_template,
|
strlcpy(btv->c.i2c_adap.name, "bttv",
|
||||||
sizeof(bttv_i2c_adap_sw_template));
|
sizeof(btv->c.i2c_adap.name));
|
||||||
|
btv->c.i2c_adap.id = I2C_HW_B_BT848;
|
||||||
memcpy(&btv->i2c_algo, &bttv_i2c_algo_bit_template,
|
memcpy(&btv->i2c_algo, &bttv_i2c_algo_bit_template,
|
||||||
sizeof(bttv_i2c_algo_bit_template));
|
sizeof(bttv_i2c_algo_bit_template));
|
||||||
|
btv->i2c_algo.udelay = i2c_udelay;
|
||||||
btv->i2c_algo.data = btv;
|
btv->i2c_algo.data = btv;
|
||||||
btv->c.i2c_adap.algo_data = &btv->i2c_algo;
|
btv->c.i2c_adap.algo_data = &btv->i2c_algo;
|
||||||
}
|
}
|
||||||
|
btv->c.i2c_adap.owner = THIS_MODULE;
|
||||||
|
btv->c.i2c_adap.class = I2C_CLASS_TV_ANALOG;
|
||||||
|
btv->c.i2c_adap.client_register = attach_inform;
|
||||||
|
|
||||||
btv->c.i2c_adap.dev.parent = &btv->c.pci->dev;
|
btv->c.i2c_adap.dev.parent = &btv->c.pci->dev;
|
||||||
snprintf(btv->c.i2c_adap.name, sizeof(btv->c.i2c_adap.name),
|
snprintf(btv->c.i2c_adap.name, sizeof(btv->c.i2c_adap.name),
|
||||||
|
Loading…
Reference in New Issue
Block a user