diff options
author | Chris Pascoe <c.pascoe@itee.uq.edu.au> | 2007-11-19 02:31:58 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2008-01-25 16:02:22 -0500 |
commit | 7d58d1117ec02f5fe22ddd03ca08fe2a8c777ea2 (patch) | |
tree | 1672eb110109e87ab050415d7727383e8e26f2dc /drivers/media/video/tuner-i2c.h | |
parent | e155d908f72cc429b538c101ee8ffcd10a44b69b (diff) |
V4L/DVB (6633): xc2028: make register reads atomic
Issuing register reads as a separate address write and data read transactions
means that other I2C activity could occur in between and state could get out
of sync. Issue both the write and read in a single transaction so that the
i2c layer can prevent other users accessing the bus until we are complete.
Signed-off-by: Chris Pascoe <c.pascoe@itee.uq.edu.au>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video/tuner-i2c.h')
-rw-r--r-- | drivers/media/video/tuner-i2c.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/drivers/media/video/tuner-i2c.h b/drivers/media/video/tuner-i2c.h index b5ac189ba40f..d7cf72c3fd71 100644 --- a/drivers/media/video/tuner-i2c.h +++ b/drivers/media/video/tuner-i2c.h | |||
@@ -46,6 +46,19 @@ static inline int tuner_i2c_xfer_recv(struct tuner_i2c_props *props, char *buf, | |||
46 | return (ret == 1) ? len : ret; | 46 | return (ret == 1) ? len : ret; |
47 | } | 47 | } |
48 | 48 | ||
49 | static inline int tuner_i2c_xfer_send_recv(struct tuner_i2c_props *props, | ||
50 | char *obuf, int olen, | ||
51 | char *ibuf, int ilen) | ||
52 | { | ||
53 | struct i2c_msg msg[2] = { { .addr = props->addr, .flags = 0, | ||
54 | .buf = obuf, .len = olen }, | ||
55 | { .addr = props->addr, .flags = I2C_M_RD, | ||
56 | .buf = ibuf, .len = ilen } }; | ||
57 | int ret = i2c_transfer(props->adap, msg, 2); | ||
58 | |||
59 | return (ret == 2) ? ilen : ret; | ||
60 | } | ||
61 | |||
49 | #ifndef __TUNER_DRIVER_H__ | 62 | #ifndef __TUNER_DRIVER_H__ |
50 | #define tuner_warn(fmt, arg...) do { \ | 63 | #define tuner_warn(fmt, arg...) do { \ |
51 | printk(KERN_WARNING "%s %d-%04x: " fmt, PREFIX, \ | 64 | printk(KERN_WARNING "%s %d-%04x: " fmt, PREFIX, \ |