summaryrefslogtreecommitdiff
path: root/v4l/i2c-compat.h
blob: 39fa183fa5eaf8c0f2aed75b3e97a31bdff52844 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/*
 * $Id: i2c-compat.h,v 1.3 2005/10/16 12:13:58 mchehab Exp $
 *
 * some i2c layer compatibility stuff -- to avoid cluttering up the
 * i2c modules with tons of #ifdefs
 */

#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,66)

static inline void *i2c_get_adapdata(struct i2c_adapter *dev)
{
	return dev->data;
}

static inline void i2c_set_adapdata(struct i2c_adapter *dev, void *data)
{
	dev->data = data;
}

static inline void *i2c_get_clientdata(struct i2c_client *dev)
{
	return dev->data;
}

static inline void i2c_set_clientdata(struct i2c_client *dev, void *data)
{
	dev->data = data;
}

#define I2C_DEVNAME(str)   .name = str

static inline char *i2c_clientname(struct i2c_client *c)
{
	return c->name;
}

static inline void i2c_clients_command(struct i2c_adapter *adap,
				       unsigned int cmd, void *arg)
{
	int i;

	for (i = 0; i < I2C_CLIENT_MAX; i++) {
		if (NULL == adap->clients[i])
			continue;
		if (NULL == adap->clients[i]->driver->command)
			continue;
		adap->clients[i]->driver->command(adap->clients[i],cmd,arg);
	}
}

#endif

/*
 * Local variables:
 * c-basic-offset: 8
 * End:
 */