示例#1
0
static int tda7432_attach(struct i2c_adapter *adap, int addr,
			  unsigned short flags, int kind)
{
	struct tda7432 *t;
	struct i2c_client *client;
	d2printk("tda7432: In tda7432_attach\n");

	t = kmalloc(sizeof *t,GFP_KERNEL);
	if (!t)
		return -ENOMEM;
	memset(t,0,sizeof *t);

	client = &t->c;
        memcpy(client,&client_template,sizeof(struct i2c_client));
        client->adapter = adap;
        client->addr = addr;
	client->data = t;
	
	do_tda7432_init(client);
	MOD_INC_USE_COUNT;
	strcpy(client->name,"TDA7432");
	printk(KERN_INFO "tda7432: init\n");

	i2c_attach_client(client);
	return 0;
}
示例#2
0
static int tda7432_detach(struct i2c_client *client)
{
	struct tda7432 *t  = client->data;

	do_tda7432_init(client);
	i2c_detach_client(client);
	
	kfree(t);
	MOD_DEC_USE_COUNT;
	return 0;
}