diff options
author | Steven Toth <stoth@hauppauge.com> | 2008-04-18 20:39:11 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2008-04-24 13:09:43 -0400 |
commit | bc3c613cef903e73e7365986a1943b0124350018 (patch) | |
tree | 4414b3d5d059d0e0faacafc03724e7cbf38c9fa1 /drivers/media/video/au0828/au0828-i2c.c | |
parent | 9c26de555dd3c2cb9833b4d324150aa6b5547b91 (diff) |
V4L/DVB (7625): au0828: Cleanup
Signed-off-by: Steven Toth <stoth@hauppauge.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video/au0828/au0828-i2c.c')
-rw-r--r-- | drivers/media/video/au0828/au0828-i2c.c | 45 |
1 files changed, 14 insertions, 31 deletions
diff --git a/drivers/media/video/au0828/au0828-i2c.c b/drivers/media/video/au0828/au0828-i2c.c index 3e7482481152..4545a9cbaa6d 100644 --- a/drivers/media/video/au0828/au0828-i2c.c +++ b/drivers/media/video/au0828/au0828-i2c.c | |||
@@ -29,19 +29,14 @@ | |||
29 | 29 | ||
30 | #include <media/v4l2-common.h> | 30 | #include <media/v4l2-common.h> |
31 | 31 | ||
32 | static unsigned int i2c_debug; | 32 | unsigned int i2c_debug = 0; |
33 | module_param(i2c_debug, int, 0644); | 33 | module_param(i2c_debug, int, 0444); |
34 | MODULE_PARM_DESC(i2c_debug, "enable debug messages [i2c]"); | 34 | MODULE_PARM_DESC(i2c_debug, "enable debug messages [i2c]"); |
35 | 35 | ||
36 | static unsigned int i2c_scan = 0; | 36 | unsigned int i2c_scan = 0; |
37 | module_param(i2c_scan, int, 0444); | 37 | module_param(i2c_scan, int, 0444); |
38 | MODULE_PARM_DESC(i2c_scan, "scan i2c bus at insmod time"); | 38 | MODULE_PARM_DESC(i2c_scan, "scan i2c bus at insmod time"); |
39 | 39 | ||
40 | #define dprintk(level, fmt, arg...)\ | ||
41 | do { if (i2c_debug >= level)\ | ||
42 | printk(KERN_DEBUG "%s/0: " fmt, DRIVER_NAME, ## arg);\ | ||
43 | } while (0) | ||
44 | |||
45 | #define I2C_WAIT_DELAY 512 | 40 | #define I2C_WAIT_DELAY 512 |
46 | #define I2C_WAIT_RETRY 64 | 41 | #define I2C_WAIT_RETRY 64 |
47 | 42 | ||
@@ -146,7 +141,7 @@ static int i2c_sendbytes(struct i2c_adapter *i2c_adap, | |||
146 | int i, strobe = 0; | 141 | int i, strobe = 0; |
147 | struct au0828_dev *dev = i2c_adap->algo_data; | 142 | struct au0828_dev *dev = i2c_adap->algo_data; |
148 | 143 | ||
149 | dprintk(1, "%s()\n", __FUNCTION__); | 144 | dprintk(4, "%s()\n", __FUNCTION__); |
150 | 145 | ||
151 | au0828_write(dev, REG_2FF, 0x01); | 146 | au0828_write(dev, REG_2FF, 0x01); |
152 | au0828_write(dev, REG_202, 0x07); | 147 | au0828_write(dev, REG_202, 0x07); |
@@ -154,13 +149,11 @@ static int i2c_sendbytes(struct i2c_adapter *i2c_adap, | |||
154 | /* Hardware needs 8 bit addresses */ | 149 | /* Hardware needs 8 bit addresses */ |
155 | au0828_write(dev, REG_203, msg->addr << 1); | 150 | au0828_write(dev, REG_203, msg->addr << 1); |
156 | 151 | ||
157 | if (i2c_debug) | 152 | dprintk(4, "SEND: %02x\n", msg->addr); |
158 | dprintk(1, "SEND: %02x\n", msg->addr); | ||
159 | 153 | ||
160 | for (i=0; i < msg->len;) { | 154 | for (i=0; i < msg->len;) { |
161 | 155 | ||
162 | if (i2c_debug) | 156 | dprintk(4, " %02x\n", msg->buf[i]); |
163 | dprintk(1, " %02x\n", msg->buf[i]); | ||
164 | 157 | ||
165 | au0828_write(dev, REG_205, msg->buf[i]); | 158 | au0828_write(dev, REG_205, msg->buf[i]); |
166 | 159 | ||
@@ -187,8 +180,7 @@ static int i2c_sendbytes(struct i2c_adapter *i2c_adap, | |||
187 | if (!i2c_wait_done(i2c_adap)) | 180 | if (!i2c_wait_done(i2c_adap)) |
188 | return -EIO; | 181 | return -EIO; |
189 | 182 | ||
190 | if (i2c_debug) | 183 | dprintk(4, "\n"); |
191 | dprintk(1, "\n"); | ||
192 | 184 | ||
193 | return msg->len; | 185 | return msg->len; |
194 | } | 186 | } |
@@ -200,7 +192,7 @@ static int i2c_readbytes(struct i2c_adapter *i2c_adap, | |||
200 | struct au0828_dev *dev = i2c_adap->algo_data; | 192 | struct au0828_dev *dev = i2c_adap->algo_data; |
201 | int i; | 193 | int i; |
202 | 194 | ||
203 | dprintk(1, "%s()\n", __FUNCTION__); | 195 | dprintk(4, "%s()\n", __FUNCTION__); |
204 | 196 | ||
205 | au0828_write(dev, REG_2FF, 0x01); | 197 | au0828_write(dev, REG_2FF, 0x01); |
206 | au0828_write(dev, REG_202, 0x07); | 198 | au0828_write(dev, REG_202, 0x07); |
@@ -208,8 +200,7 @@ static int i2c_readbytes(struct i2c_adapter *i2c_adap, | |||
208 | /* Hardware needs 8 bit addresses */ | 200 | /* Hardware needs 8 bit addresses */ |
209 | au0828_write(dev, REG_203, msg->addr << 1); | 201 | au0828_write(dev, REG_203, msg->addr << 1); |
210 | 202 | ||
211 | if (i2c_debug) | 203 | dprintk(4, " RECV:\n"); |
212 | dprintk(1, " RECV:\n"); | ||
213 | 204 | ||
214 | /* Deal with i2c_scan */ | 205 | /* Deal with i2c_scan */ |
215 | if (msg->len == 0) { | 206 | if (msg->len == 0) { |
@@ -233,14 +224,12 @@ static int i2c_readbytes(struct i2c_adapter *i2c_adap, | |||
233 | 224 | ||
234 | msg->buf[i-1] = au0828_read(dev, REG_209) & 0xff; | 225 | msg->buf[i-1] = au0828_read(dev, REG_209) & 0xff; |
235 | 226 | ||
236 | if (i2c_debug) | 227 | dprintk(4, " %02x\n", msg->buf[i-1]); |
237 | dprintk(1, " %02x\n", msg->buf[i-1]); | ||
238 | } | 228 | } |
239 | if (!i2c_wait_done(i2c_adap)) | 229 | if (!i2c_wait_done(i2c_adap)) |
240 | return -EIO; | 230 | return -EIO; |
241 | 231 | ||
242 | if (i2c_debug) | 232 | dprintk(4, "\n"); |
243 | dprintk(1, "\n"); | ||
244 | 233 | ||
245 | return msg->len; | 234 | return msg->len; |
246 | } | 235 | } |
@@ -250,10 +239,10 @@ static int i2c_xfer(struct i2c_adapter *i2c_adap, | |||
250 | { | 239 | { |
251 | int i, retval = 0; | 240 | int i, retval = 0; |
252 | 241 | ||
253 | dprintk(1, "%s(num = %d)\n", __FUNCTION__, num); | 242 | dprintk(4, "%s(num = %d)\n", __FUNCTION__, num); |
254 | 243 | ||
255 | for (i = 0 ; i < num; i++) { | 244 | for (i = 0 ; i < num; i++) { |
256 | dprintk(1, "%s(num = %d) addr = 0x%02x len = 0x%x\n", | 245 | dprintk(4, "%s(num = %d) addr = 0x%02x len = 0x%x\n", |
257 | __FUNCTION__, num, msgs[i].addr, msgs[i].len); | 246 | __FUNCTION__, num, msgs[i].addr, msgs[i].len); |
258 | if (msgs[i].flags & I2C_M_RD) { | 247 | if (msgs[i].flags & I2C_M_RD) { |
259 | /* read */ | 248 | /* read */ |
@@ -384,6 +373,7 @@ int au0828_i2c_register(struct au0828_dev *dev) | |||
384 | do_i2c_scan(DRIVER_NAME, &dev->i2c_client); | 373 | do_i2c_scan(DRIVER_NAME, &dev->i2c_client); |
385 | } else | 374 | } else |
386 | printk("%s: i2c bus register FAILED\n", DRIVER_NAME); | 375 | printk("%s: i2c bus register FAILED\n", DRIVER_NAME); |
376 | |||
387 | return dev->i2c_rc; | 377 | return dev->i2c_rc; |
388 | } | 378 | } |
389 | 379 | ||
@@ -393,10 +383,3 @@ int au0828_i2c_unregister(struct au0828_dev *dev) | |||
393 | return 0; | 383 | return 0; |
394 | } | 384 | } |
395 | 385 | ||
396 | /* ----------------------------------------------------------------------- */ | ||
397 | |||
398 | /* | ||
399 | * Local variables: | ||
400 | * c-basic-offset: 8 | ||
401 | * End: | ||
402 | */ | ||