diff options
Diffstat (limited to 'drivers/staging/cx25821/cx25821-i2c.c')
-rw-r--r-- | drivers/staging/cx25821/cx25821-i2c.c | 72 |
1 files changed, 36 insertions, 36 deletions
diff --git a/drivers/staging/cx25821/cx25821-i2c.c b/drivers/staging/cx25821/cx25821-i2c.c index 16303f80d4f..0667b3f8eb9 100644 --- a/drivers/staging/cx25821/cx25821-i2c.c +++ b/drivers/staging/cx25821/cx25821-i2c.c | |||
@@ -88,9 +88,9 @@ static int i2c_sendbytes(struct i2c_adapter *i2c_adap, const struct i2c_msg *msg | |||
88 | dprintk(1, "%s(msg->len=%d)\n", __func__, msg->len); | 88 | dprintk(1, "%s(msg->len=%d)\n", __func__, msg->len); |
89 | 89 | ||
90 | /* Deal with i2c probe functions with zero payload */ | 90 | /* Deal with i2c probe functions with zero payload */ |
91 | if (msg->len == 0) | 91 | if (msg->len == 0) |
92 | { | 92 | { |
93 | cx_write(bus->reg_addr, msg->addr << 25); | 93 | cx_write(bus->reg_addr, msg->addr << 25); |
94 | cx_write(bus->reg_ctrl, bus->i2c_period | (1 << 2)); | 94 | cx_write(bus->reg_ctrl, bus->i2c_period | (1 << 2)); |
95 | 95 | ||
96 | if (!i2c_wait_done(i2c_adap)) | 96 | if (!i2c_wait_done(i2c_adap)) |
@@ -106,7 +106,7 @@ static int i2c_sendbytes(struct i2c_adapter *i2c_adap, const struct i2c_msg *msg | |||
106 | /* dev, reg + first byte */ | 106 | /* dev, reg + first byte */ |
107 | addr = (msg->addr << 25) | msg->buf[0]; | 107 | addr = (msg->addr << 25) | msg->buf[0]; |
108 | wdata = msg->buf[0]; | 108 | wdata = msg->buf[0]; |
109 | 109 | ||
110 | ctrl = bus->i2c_period | (1 << 12) | (1 << 2); | 110 | ctrl = bus->i2c_period | (1 << 12) | (1 << 2); |
111 | 111 | ||
112 | if (msg->len > 1) | 112 | if (msg->len > 1) |
@@ -125,7 +125,7 @@ static int i2c_sendbytes(struct i2c_adapter *i2c_adap, const struct i2c_msg *msg | |||
125 | if (retval == 0) | 125 | if (retval == 0) |
126 | goto eio; | 126 | goto eio; |
127 | 127 | ||
128 | if (i2c_debug) | 128 | if (i2c_debug) |
129 | { | 129 | { |
130 | if (!(ctrl & I2C_NOSTOP)) | 130 | if (!(ctrl & I2C_NOSTOP)) |
131 | printk(" >\n"); | 131 | printk(" >\n"); |
@@ -152,14 +152,14 @@ static int i2c_sendbytes(struct i2c_adapter *i2c_adap, const struct i2c_msg *msg | |||
152 | if (retval == 0) | 152 | if (retval == 0) |
153 | goto eio; | 153 | goto eio; |
154 | 154 | ||
155 | if (i2c_debug) | 155 | if (i2c_debug) |
156 | { | 156 | { |
157 | dprintk(1, " %02x", msg->buf[cnt]); | 157 | dprintk(1, " %02x", msg->buf[cnt]); |
158 | if (!(ctrl & I2C_NOSTOP)) | 158 | if (!(ctrl & I2C_NOSTOP)) |
159 | dprintk(1, " >\n"); | 159 | dprintk(1, " >\n"); |
160 | } | 160 | } |
161 | } | 161 | } |
162 | 162 | ||
163 | return msg->len; | 163 | return msg->len; |
164 | 164 | ||
165 | eio: | 165 | eio: |
@@ -244,18 +244,18 @@ static int i2c_xfer(struct i2c_adapter *i2c_adap, struct i2c_msg *msgs, int num) | |||
244 | 244 | ||
245 | dprintk(1, "%s(num = %d)\n", __func__, num); | 245 | dprintk(1, "%s(num = %d)\n", __func__, num); |
246 | 246 | ||
247 | for (i = 0 ; i < num; i++) | 247 | for (i = 0 ; i < num; i++) |
248 | { | 248 | { |
249 | dprintk(1, "%s(num = %d) addr = 0x%02x len = 0x%x\n", | 249 | dprintk(1, "%s(num = %d) addr = 0x%02x len = 0x%x\n", |
250 | __func__, num, msgs[i].addr, msgs[i].len); | 250 | __func__, num, msgs[i].addr, msgs[i].len); |
251 | 251 | ||
252 | if (msgs[i].flags & I2C_M_RD) | 252 | if (msgs[i].flags & I2C_M_RD) |
253 | { | 253 | { |
254 | /* read */ | 254 | /* read */ |
255 | retval = i2c_readbytes(i2c_adap, &msgs[i], 0); | 255 | retval = i2c_readbytes(i2c_adap, &msgs[i], 0); |
256 | } | 256 | } |
257 | else if (i + 1 < num && (msgs[i + 1].flags & I2C_M_RD) && | 257 | else if (i + 1 < num && (msgs[i + 1].flags & I2C_M_RD) && |
258 | msgs[i].addr == msgs[i + 1].addr) | 258 | msgs[i].addr == msgs[i + 1].addr) |
259 | { | 259 | { |
260 | /* write then read from same address */ | 260 | /* write then read from same address */ |
261 | retval = i2c_sendbytes(i2c_adap, &msgs[i], msgs[i + 1].len); | 261 | retval = i2c_sendbytes(i2c_adap, &msgs[i], msgs[i + 1].len); |
@@ -264,13 +264,13 @@ static int i2c_xfer(struct i2c_adapter *i2c_adap, struct i2c_msg *msgs, int num) | |||
264 | goto err; | 264 | goto err; |
265 | i++; | 265 | i++; |
266 | retval = i2c_readbytes(i2c_adap, &msgs[i], 1); | 266 | retval = i2c_readbytes(i2c_adap, &msgs[i], 1); |
267 | } | 267 | } |
268 | else | 268 | else |
269 | { | 269 | { |
270 | /* write */ | 270 | /* write */ |
271 | retval = i2c_sendbytes(i2c_adap, &msgs[i], 0); | 271 | retval = i2c_sendbytes(i2c_adap, &msgs[i], 0); |
272 | } | 272 | } |
273 | 273 | ||
274 | if (retval < 0) | 274 | if (retval < 0) |
275 | goto err; | 275 | goto err; |
276 | } | 276 | } |
@@ -283,9 +283,9 @@ static int i2c_xfer(struct i2c_adapter *i2c_adap, struct i2c_msg *msgs, int num) | |||
283 | 283 | ||
284 | static u32 cx25821_functionality(struct i2c_adapter *adap) | 284 | static u32 cx25821_functionality(struct i2c_adapter *adap) |
285 | { | 285 | { |
286 | return I2C_FUNC_SMBUS_EMUL | | 286 | return I2C_FUNC_SMBUS_EMUL | |
287 | I2C_FUNC_I2C | | 287 | I2C_FUNC_I2C | |
288 | I2C_FUNC_SMBUS_WORD_DATA | | 288 | I2C_FUNC_SMBUS_WORD_DATA | |
289 | I2C_FUNC_SMBUS_READ_WORD_DATA | | 289 | I2C_FUNC_SMBUS_READ_WORD_DATA | |
290 | I2C_FUNC_SMBUS_WRITE_WORD_DATA; | 290 | I2C_FUNC_SMBUS_WRITE_WORD_DATA; |
291 | } | 291 | } |
@@ -334,7 +334,7 @@ int cx25821_i2c_register(struct cx25821_i2c *bus) | |||
334 | 334 | ||
335 | //set up the I2c | 335 | //set up the I2c |
336 | bus->i2c_client.addr = (0x88>>1); | 336 | bus->i2c_client.addr = (0x88>>1); |
337 | 337 | ||
338 | return bus->i2c_rc; | 338 | return bus->i2c_rc; |
339 | } | 339 | } |
340 | 340 | ||
@@ -375,19 +375,19 @@ int cx25821_i2c_read(struct cx25821_i2c *bus, u16 reg_addr, int *value) | |||
375 | int v = 0; | 375 | int v = 0; |
376 | u8 addr[2] = {0, 0}; | 376 | u8 addr[2] = {0, 0}; |
377 | u8 buf[4] = {0,0,0,0}; | 377 | u8 buf[4] = {0,0,0,0}; |
378 | 378 | ||
379 | struct i2c_msg msgs[2]={ | 379 | struct i2c_msg msgs[2]={ |
380 | { | 380 | { |
381 | .addr = client->addr, | 381 | .addr = client->addr, |
382 | .flags = 0, | 382 | .flags = 0, |
383 | .len = 2, | 383 | .len = 2, |
384 | .buf = addr, | 384 | .buf = addr, |
385 | }, { | 385 | }, { |
386 | .addr = client->addr, | 386 | .addr = client->addr, |
387 | .flags = I2C_M_RD, | 387 | .flags = I2C_M_RD, |
388 | .len = 4, | 388 | .len = 4, |
389 | .buf = buf, | 389 | .buf = buf, |
390 | } | 390 | } |
391 | }; | 391 | }; |
392 | 392 | ||
393 | 393 | ||
@@ -401,23 +401,23 @@ int cx25821_i2c_read(struct cx25821_i2c *bus, u16 reg_addr, int *value) | |||
401 | v = (buf[3]<<24) | (buf[2]<<16) | (buf[1]<<8) | buf[0]; | 401 | v = (buf[3]<<24) | (buf[2]<<16) | (buf[1]<<8) | buf[0]; |
402 | *value = v; | 402 | *value = v; |
403 | 403 | ||
404 | return v; | 404 | return v; |
405 | } | 405 | } |
406 | 406 | ||
407 | 407 | ||
408 | int cx25821_i2c_write(struct cx25821_i2c *bus, u16 reg_addr, int value) | 408 | int cx25821_i2c_write(struct cx25821_i2c *bus, u16 reg_addr, int value) |
409 | { | 409 | { |
410 | struct i2c_client *client = &bus->i2c_client; | 410 | struct i2c_client *client = &bus->i2c_client; |
411 | int retval = 0; | 411 | int retval = 0; |
412 | u8 buf[6] = {0, 0, 0, 0, 0, 0}; | 412 | u8 buf[6] = {0, 0, 0, 0, 0, 0}; |
413 | 413 | ||
414 | struct i2c_msg msgs[1]={ | 414 | struct i2c_msg msgs[1]={ |
415 | { | 415 | { |
416 | .addr = client->addr, | 416 | .addr = client->addr, |
417 | .flags = 0, | 417 | .flags = 0, |
418 | .len = 6, | 418 | .len = 6, |
419 | .buf = buf, | 419 | .buf = buf, |
420 | } | 420 | } |
421 | }; | 421 | }; |
422 | 422 | ||
423 | 423 | ||