aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@redhat.com>2012-06-29 13:24:18 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-06-29 18:04:12 -0400
commit2a5f6720ff45e7545c3058bc6bfdb498247b4f5c (patch)
tree6105b22edb6663b0dd699a672a48fe5f59002364 /drivers/media/dvb
parent177bc7dade38b5bd02dbcd008f92135b2c7a92b6 (diff)
[media] drxk: pass drxk priv struct instead of I2C adapter to i2c calls
As it will be using the unlocked version of i2c_transfer during firmware loads, make sure that the priv state routine will be used on all I2C calls, in preparation for the next patch that will implement an exclusive lock mode to be used during firmware load, at drxk_init. Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/dvb')
-rw-r--r--drivers/media/dvb/frontends/drxk_hard.c34
1 files changed, 20 insertions, 14 deletions
diff --git a/drivers/media/dvb/frontends/drxk_hard.c b/drivers/media/dvb/frontends/drxk_hard.c
index 4cb8d1e83fb0..5b3a17ce3d1d 100644
--- a/drivers/media/dvb/frontends/drxk_hard.c
+++ b/drivers/media/dvb/frontends/drxk_hard.c
@@ -308,16 +308,22 @@ static u32 Log10Times100(u32 x)
308/* I2C **********************************************************************/ 308/* I2C **********************************************************************/
309/****************************************************************************/ 309/****************************************************************************/
310 310
311static int i2c_read1(struct i2c_adapter *adapter, u8 adr, u8 *val) 311static int drxk_i2c_transfer(struct drxk_state *state, struct i2c_msg *msgs,
312 unsigned len)
313{
314 return i2c_transfer(state->i2c, msgs, len);
315}
316
317static int i2c_read1(struct drxk_state *state, u8 adr, u8 *val)
312{ 318{
313 struct i2c_msg msgs[1] = { {.addr = adr, .flags = I2C_M_RD, 319 struct i2c_msg msgs[1] = { {.addr = adr, .flags = I2C_M_RD,
314 .buf = val, .len = 1} 320 .buf = val, .len = 1}
315 }; 321 };
316 322
317 return i2c_transfer(adapter, msgs, 1); 323 return drxk_i2c_transfer(state, msgs, 1);
318} 324}
319 325
320static int i2c_write(struct i2c_adapter *adap, u8 adr, u8 *data, int len) 326static int i2c_write(struct drxk_state *state, u8 adr, u8 *data, int len)
321{ 327{
322 int status; 328 int status;
323 struct i2c_msg msg = { 329 struct i2c_msg msg = {
@@ -330,7 +336,7 @@ static int i2c_write(struct i2c_adapter *adap, u8 adr, u8 *data, int len)
330 printk(KERN_CONT " %02x", data[i]); 336 printk(KERN_CONT " %02x", data[i]);
331 printk(KERN_CONT "\n"); 337 printk(KERN_CONT "\n");
332 } 338 }
333 status = i2c_transfer(adap, &msg, 1); 339 status = drxk_i2c_transfer(state, &msg, 1);
334 if (status >= 0 && status != 1) 340 if (status >= 0 && status != 1)
335 status = -EIO; 341 status = -EIO;
336 342
@@ -340,7 +346,7 @@ static int i2c_write(struct i2c_adapter *adap, u8 adr, u8 *data, int len)
340 return status; 346 return status;
341} 347}
342 348
343static int i2c_read(struct i2c_adapter *adap, 349static int i2c_read(struct drxk_state *state,
344 u8 adr, u8 *msg, int len, u8 *answ, int alen) 350 u8 adr, u8 *msg, int len, u8 *answ, int alen)
345{ 351{
346 int status; 352 int status;
@@ -351,7 +357,7 @@ static int i2c_read(struct i2c_adapter *adap,
351 .buf = answ, .len = alen} 357 .buf = answ, .len = alen}
352 }; 358 };
353 359
354 status = i2c_transfer(adap, msgs, 2); 360 status = drxk_i2c_transfer(state, msgs, 2);
355 if (status != 2) { 361 if (status != 2) {
356 if (debug > 2) 362 if (debug > 2)
357 printk(KERN_CONT ": ERROR!\n"); 363 printk(KERN_CONT ": ERROR!\n");
@@ -394,7 +400,7 @@ static int read16_flags(struct drxk_state *state, u32 reg, u16 *data, u8 flags)
394 len = 2; 400 len = 2;
395 } 401 }
396 dprintk(2, "(0x%08x, 0x%02x)\n", reg, flags); 402 dprintk(2, "(0x%08x, 0x%02x)\n", reg, flags);
397 status = i2c_read(state->i2c, adr, mm1, len, mm2, 2); 403 status = i2c_read(state, adr, mm1, len, mm2, 2);
398 if (status < 0) 404 if (status < 0)
399 return status; 405 return status;
400 if (data) 406 if (data)
@@ -428,7 +434,7 @@ static int read32_flags(struct drxk_state *state, u32 reg, u32 *data, u8 flags)
428 len = 2; 434 len = 2;
429 } 435 }
430 dprintk(2, "(0x%08x, 0x%02x)\n", reg, flags); 436 dprintk(2, "(0x%08x, 0x%02x)\n", reg, flags);
431 status = i2c_read(state->i2c, adr, mm1, len, mm2, 4); 437 status = i2c_read(state, adr, mm1, len, mm2, 4);
432 if (status < 0) 438 if (status < 0)
433 return status; 439 return status;
434 if (data) 440 if (data)
@@ -464,7 +470,7 @@ static int write16_flags(struct drxk_state *state, u32 reg, u16 data, u8 flags)
464 mm[len + 1] = (data >> 8) & 0xff; 470 mm[len + 1] = (data >> 8) & 0xff;
465 471
466 dprintk(2, "(0x%08x, 0x%04x, 0x%02x)\n", reg, data, flags); 472 dprintk(2, "(0x%08x, 0x%04x, 0x%02x)\n", reg, data, flags);
467 return i2c_write(state->i2c, adr, mm, len + 2); 473 return i2c_write(state, adr, mm, len + 2);
468} 474}
469 475
470static int write16(struct drxk_state *state, u32 reg, u16 data) 476static int write16(struct drxk_state *state, u32 reg, u16 data)
@@ -495,7 +501,7 @@ static int write32_flags(struct drxk_state *state, u32 reg, u32 data, u8 flags)
495 mm[len + 3] = (data >> 24) & 0xff; 501 mm[len + 3] = (data >> 24) & 0xff;
496 dprintk(2, "(0x%08x, 0x%08x, 0x%02x)\n", reg, data, flags); 502 dprintk(2, "(0x%08x, 0x%08x, 0x%02x)\n", reg, data, flags);
497 503
498 return i2c_write(state->i2c, adr, mm, len + 4); 504 return i2c_write(state, adr, mm, len + 4);
499} 505}
500 506
501static int write32(struct drxk_state *state, u32 reg, u32 data) 507static int write32(struct drxk_state *state, u32 reg, u32 data)
@@ -542,7 +548,7 @@ static int write_block(struct drxk_state *state, u32 Address,
542 printk(KERN_CONT " %02x", pBlock[i]); 548 printk(KERN_CONT " %02x", pBlock[i]);
543 printk(KERN_CONT "\n"); 549 printk(KERN_CONT "\n");
544 } 550 }
545 status = i2c_write(state->i2c, state->demod_address, 551 status = i2c_write(state, state->demod_address,
546 &state->Chunk[0], Chunk + AdrLength); 552 &state->Chunk[0], Chunk + AdrLength);
547 if (status < 0) { 553 if (status < 0) {
548 printk(KERN_ERR "drxk: %s: i2c write error at addr 0x%02x\n", 554 printk(KERN_ERR "drxk: %s: i2c write error at addr 0x%02x\n",
@@ -568,17 +574,17 @@ int PowerUpDevice(struct drxk_state *state)
568 574
569 dprintk(1, "\n"); 575 dprintk(1, "\n");
570 576
571 status = i2c_read1(state->i2c, state->demod_address, &data); 577 status = i2c_read1(state, state->demod_address, &data);
572 if (status < 0) { 578 if (status < 0) {
573 do { 579 do {
574 data = 0; 580 data = 0;
575 status = i2c_write(state->i2c, state->demod_address, 581 status = i2c_write(state, state->demod_address,
576 &data, 1); 582 &data, 1);
577 msleep(10); 583 msleep(10);
578 retryCount++; 584 retryCount++;
579 if (status < 0) 585 if (status < 0)
580 continue; 586 continue;
581 status = i2c_read1(state->i2c, state->demod_address, 587 status = i2c_read1(state, state->demod_address,
582 &data); 588 &data);
583 } while (status < 0 && 589 } while (status < 0 &&
584 (retryCount < DRXK_MAX_RETRIES_POWERUP)); 590 (retryCount < DRXK_MAX_RETRIES_POWERUP));