diff options
author | Mauro Carvalho Chehab <mchehab@redhat.com> | 2013-01-22 06:13:08 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2013-01-22 06:13:08 -0500 |
commit | f66d81b54dac26d4e601d4d7faca53f3bdc98427 (patch) | |
tree | 2881ff47774b7e32d7ede89ff98976b5e817e217 | |
parent | dd4493ef34cb4062d59d87717aaf8a1c27d450c9 (diff) |
[media] mb86a20s: convert it to use dev_info/dev_err/dev_dbg
Instead of having its own set of macros, use the Kernel default
ones for debug, error and info.
While here, do some cleanup on the debug printk's.
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r-- | drivers/media/dvb-frontends/mb86a20s.c | 96 |
1 files changed, 52 insertions, 44 deletions
diff --git a/drivers/media/dvb-frontends/mb86a20s.c b/drivers/media/dvb-frontends/mb86a20s.c index b348f97aa7b5..c52ae2ea0bf9 100644 --- a/drivers/media/dvb-frontends/mb86a20s.c +++ b/drivers/media/dvb-frontends/mb86a20s.c | |||
@@ -24,18 +24,6 @@ static int debug = 1; | |||
24 | module_param(debug, int, 0644); | 24 | module_param(debug, int, 0644); |
25 | MODULE_PARM_DESC(debug, "Activates frontend debugging (default:0)"); | 25 | MODULE_PARM_DESC(debug, "Activates frontend debugging (default:0)"); |
26 | 26 | ||
27 | #define rc(args...) do { \ | ||
28 | printk(KERN_ERR "mb86a20s: " args); \ | ||
29 | } while (0) | ||
30 | |||
31 | #define dprintk(args...) \ | ||
32 | do { \ | ||
33 | if (debug) { \ | ||
34 | printk(KERN_DEBUG "mb86a20s: %s: ", __func__); \ | ||
35 | printk(args); \ | ||
36 | } \ | ||
37 | } while (0) | ||
38 | |||
39 | struct mb86a20s_state { | 27 | struct mb86a20s_state { |
40 | struct i2c_adapter *i2c; | 28 | struct i2c_adapter *i2c; |
41 | const struct mb86a20s_config *config; | 29 | const struct mb86a20s_config *config; |
@@ -190,8 +178,9 @@ static int mb86a20s_i2c_writereg(struct mb86a20s_state *state, | |||
190 | 178 | ||
191 | rc = i2c_transfer(state->i2c, &msg, 1); | 179 | rc = i2c_transfer(state->i2c, &msg, 1); |
192 | if (rc != 1) { | 180 | if (rc != 1) { |
193 | printk("%s: writereg error (rc == %i, reg == 0x%02x," | 181 | dev_err(&state->i2c->dev, |
194 | " data == 0x%02x)\n", __func__, rc, reg, data); | 182 | "%s: writereg error (rc == %i, reg == 0x%02x, data == 0x%02x)\n", |
183 | __func__, rc, reg, data); | ||
195 | return rc; | 184 | return rc; |
196 | } | 185 | } |
197 | 186 | ||
@@ -225,8 +214,9 @@ static int mb86a20s_i2c_readreg(struct mb86a20s_state *state, | |||
225 | rc = i2c_transfer(state->i2c, msg, 2); | 214 | rc = i2c_transfer(state->i2c, msg, 2); |
226 | 215 | ||
227 | if (rc != 2) { | 216 | if (rc != 2) { |
228 | rc("%s: reg=0x%x (error=%d)\n", __func__, reg, rc); | 217 | dev_err(&state->i2c->dev, "%s: reg=0x%x (error=%d)\n", |
229 | return rc; | 218 | __func__, reg, rc); |
219 | return (rc < 0) ? rc : -EIO; | ||
230 | } | 220 | } |
231 | 221 | ||
232 | return val; | 222 | return val; |
@@ -245,7 +235,6 @@ static int mb86a20s_read_status(struct dvb_frontend *fe, fe_status_t *status) | |||
245 | struct mb86a20s_state *state = fe->demodulator_priv; | 235 | struct mb86a20s_state *state = fe->demodulator_priv; |
246 | int val; | 236 | int val; |
247 | 237 | ||
248 | dprintk("\n"); | ||
249 | *status = 0; | 238 | *status = 0; |
250 | 239 | ||
251 | val = mb86a20s_readreg(state, 0x0a) & 0xf; | 240 | val = mb86a20s_readreg(state, 0x0a) & 0xf; |
@@ -267,7 +256,8 @@ static int mb86a20s_read_status(struct dvb_frontend *fe, fe_status_t *status) | |||
267 | if (val >= 8) /* Maybe 9? */ | 256 | if (val >= 8) /* Maybe 9? */ |
268 | *status |= FE_HAS_LOCK; | 257 | *status |= FE_HAS_LOCK; |
269 | 258 | ||
270 | dprintk("val = %d, status = 0x%02x\n", val, *status); | 259 | dev_dbg(&state->i2c->dev, "%s: Status = 0x%02x (state = %d)\n", |
260 | __func__, *status, val); | ||
271 | 261 | ||
272 | return 0; | 262 | return 0; |
273 | } | 263 | } |
@@ -278,8 +268,6 @@ static int mb86a20s_read_signal_strength(struct dvb_frontend *fe, u16 *strength) | |||
278 | unsigned rf_max, rf_min, rf; | 268 | unsigned rf_max, rf_min, rf; |
279 | u8 val; | 269 | u8 val; |
280 | 270 | ||
281 | dprintk("\n"); | ||
282 | |||
283 | if (fe->ops.i2c_gate_ctrl) | 271 | if (fe->ops.i2c_gate_ctrl) |
284 | fe->ops.i2c_gate_ctrl(fe, 0); | 272 | fe->ops.i2c_gate_ctrl(fe, 0); |
285 | 273 | ||
@@ -300,12 +288,13 @@ static int mb86a20s_read_signal_strength(struct dvb_frontend *fe, u16 *strength) | |||
300 | rf_max = (rf_max + rf_min) / 2; | 288 | rf_max = (rf_max + rf_min) / 2; |
301 | if (rf_max - rf_min < 4) { | 289 | if (rf_max - rf_min < 4) { |
302 | *strength = (((rf_max + rf_min) / 2) * 65535) / 4095; | 290 | *strength = (((rf_max + rf_min) / 2) * 65535) / 4095; |
291 | dev_dbg(&state->i2c->dev, | ||
292 | "%s: signal strength = %d (%d < RF=%d < %d)\n", | ||
293 | __func__, rf, rf_min, rf >> 4, rf_max); | ||
303 | break; | 294 | break; |
304 | } | 295 | } |
305 | } while (1); | 296 | } while (1); |
306 | 297 | ||
307 | dprintk("signal strength = %d\n", *strength); | ||
308 | |||
309 | if (fe->ops.i2c_gate_ctrl) | 298 | if (fe->ops.i2c_gate_ctrl) |
310 | fe->ops.i2c_gate_ctrl(fe, 1); | 299 | fe->ops.i2c_gate_ctrl(fe, 1); |
311 | 300 | ||
@@ -419,15 +408,17 @@ static int mb86a20s_get_segment_count(struct mb86a20s_state *state, | |||
419 | unsigned layer) | 408 | unsigned layer) |
420 | { | 409 | { |
421 | int rc, count; | 410 | int rc, count; |
422 | |||
423 | static unsigned char reg[] = { | 411 | static unsigned char reg[] = { |
424 | [0] = 0x89, /* Layer A */ | 412 | [0] = 0x89, /* Layer A */ |
425 | [1] = 0x8d, /* Layer B */ | 413 | [1] = 0x8d, /* Layer B */ |
426 | [2] = 0x91, /* Layer C */ | 414 | [2] = 0x91, /* Layer C */ |
427 | }; | 415 | }; |
428 | 416 | ||
417 | dev_dbg(&state->i2c->dev, "%s called.\n", __func__); | ||
418 | |||
429 | if (layer >= ARRAY_SIZE(reg)) | 419 | if (layer >= ARRAY_SIZE(reg)) |
430 | return -EINVAL; | 420 | return -EINVAL; |
421 | |||
431 | rc = mb86a20s_writereg(state, 0x6d, reg[layer]); | 422 | rc = mb86a20s_writereg(state, 0x6d, reg[layer]); |
432 | if (rc < 0) | 423 | if (rc < 0) |
433 | return rc; | 424 | return rc; |
@@ -436,13 +427,18 @@ static int mb86a20s_get_segment_count(struct mb86a20s_state *state, | |||
436 | return rc; | 427 | return rc; |
437 | count = (rc >> 4) & 0x0f; | 428 | count = (rc >> 4) & 0x0f; |
438 | 429 | ||
430 | dev_dbg(&state->i2c->dev, "%s: segments: %d.\n", __func__, count); | ||
431 | |||
439 | return count; | 432 | return count; |
440 | } | 433 | } |
441 | 434 | ||
442 | static void mb86a20s_reset_frontend_cache(struct dvb_frontend *fe) | 435 | static void mb86a20s_reset_frontend_cache(struct dvb_frontend *fe) |
443 | { | 436 | { |
437 | struct mb86a20s_state *state = fe->demodulator_priv; | ||
444 | struct dtv_frontend_properties *c = &fe->dtv_property_cache; | 438 | struct dtv_frontend_properties *c = &fe->dtv_property_cache; |
445 | 439 | ||
440 | dev_dbg(&state->i2c->dev, "%s called.\n", __func__); | ||
441 | |||
446 | /* Fixed parameters */ | 442 | /* Fixed parameters */ |
447 | c->delivery_system = SYS_ISDBT; | 443 | c->delivery_system = SYS_ISDBT; |
448 | c->bandwidth_hz = 6000000; | 444 | c->bandwidth_hz = 6000000; |
@@ -461,6 +457,8 @@ static int mb86a20s_get_frontend(struct dvb_frontend *fe) | |||
461 | struct dtv_frontend_properties *c = &fe->dtv_property_cache; | 457 | struct dtv_frontend_properties *c = &fe->dtv_property_cache; |
462 | int i, rc; | 458 | int i, rc; |
463 | 459 | ||
460 | dev_dbg(&state->i2c->dev, "%s called.\n", __func__); | ||
461 | |||
464 | /* Reset frontend cache to default values */ | 462 | /* Reset frontend cache to default values */ |
465 | mb86a20s_reset_frontend_cache(fe); | 463 | mb86a20s_reset_frontend_cache(fe); |
466 | 464 | ||
@@ -479,9 +477,12 @@ static int mb86a20s_get_frontend(struct dvb_frontend *fe) | |||
479 | /* Get per-layer data */ | 477 | /* Get per-layer data */ |
480 | 478 | ||
481 | for (i = 0; i < 3; i++) { | 479 | for (i = 0; i < 3; i++) { |
480 | dev_dbg(&state->i2c->dev, "%s: getting data for layer %c.\n", | ||
481 | __func__, 'A' + i); | ||
482 | |||
482 | rc = mb86a20s_get_segment_count(state, i); | 483 | rc = mb86a20s_get_segment_count(state, i); |
483 | if (rc < 0) | 484 | if (rc < 0) |
484 | goto error; | 485 | goto noperlayer_error; |
485 | if (rc >= 0 && rc < 14) | 486 | if (rc >= 0 && rc < 14) |
486 | c->layer[i].segment_count = rc; | 487 | c->layer[i].segment_count = rc; |
487 | else { | 488 | else { |
@@ -491,15 +492,21 @@ static int mb86a20s_get_frontend(struct dvb_frontend *fe) | |||
491 | c->isdbt_layer_enabled |= 1 << i; | 492 | c->isdbt_layer_enabled |= 1 << i; |
492 | rc = mb86a20s_get_modulation(state, i); | 493 | rc = mb86a20s_get_modulation(state, i); |
493 | if (rc < 0) | 494 | if (rc < 0) |
494 | goto error; | 495 | goto noperlayer_error; |
496 | dev_dbg(&state->i2c->dev, "%s: modulation %d.\n", | ||
497 | __func__, rc); | ||
495 | c->layer[i].modulation = rc; | 498 | c->layer[i].modulation = rc; |
496 | rc = mb86a20s_get_fec(state, i); | 499 | rc = mb86a20s_get_fec(state, i); |
497 | if (rc < 0) | 500 | if (rc < 0) |
498 | goto error; | 501 | goto noperlayer_error; |
502 | dev_dbg(&state->i2c->dev, "%s: FEC %d.\n", | ||
503 | __func__, rc); | ||
499 | c->layer[i].fec = rc; | 504 | c->layer[i].fec = rc; |
500 | rc = mb86a20s_get_interleaving(state, i); | 505 | rc = mb86a20s_get_interleaving(state, i); |
501 | if (rc < 0) | 506 | if (rc < 0) |
502 | goto error; | 507 | goto noperlayer_error; |
508 | dev_dbg(&state->i2c->dev, "%s: interleaving %d.\n", | ||
509 | __func__, rc); | ||
503 | c->layer[i].interleaving = rc; | 510 | c->layer[i].interleaving = rc; |
504 | } | 511 | } |
505 | 512 | ||
@@ -544,7 +551,7 @@ static int mb86a20s_get_frontend(struct dvb_frontend *fe) | |||
544 | } | 551 | } |
545 | } | 552 | } |
546 | 553 | ||
547 | error: | 554 | noperlayer_error: |
548 | if (fe->ops.i2c_gate_ctrl) | 555 | if (fe->ops.i2c_gate_ctrl) |
549 | fe->ops.i2c_gate_ctrl(fe, 1); | 556 | fe->ops.i2c_gate_ctrl(fe, 1); |
550 | 557 | ||
@@ -558,7 +565,7 @@ static int mb86a20s_initfe(struct dvb_frontend *fe) | |||
558 | int rc; | 565 | int rc; |
559 | u8 regD5 = 1; | 566 | u8 regD5 = 1; |
560 | 567 | ||
561 | dprintk("\n"); | 568 | dev_dbg(&state->i2c->dev, "%s called.\n", __func__); |
562 | 569 | ||
563 | if (fe->ops.i2c_gate_ctrl) | 570 | if (fe->ops.i2c_gate_ctrl) |
564 | fe->ops.i2c_gate_ctrl(fe, 0); | 571 | fe->ops.i2c_gate_ctrl(fe, 0); |
@@ -585,10 +592,11 @@ err: | |||
585 | 592 | ||
586 | if (rc < 0) { | 593 | if (rc < 0) { |
587 | state->need_init = true; | 594 | state->need_init = true; |
588 | printk(KERN_INFO "mb86a20s: Init failed. Will try again later\n"); | 595 | dev_info(&state->i2c->dev, |
596 | "mb86a20s: Init failed. Will try again later\n"); | ||
589 | } else { | 597 | } else { |
590 | state->need_init = false; | 598 | state->need_init = false; |
591 | dprintk("Initialization succeeded.\n"); | 599 | dev_dbg(&state->i2c->dev, "Initialization succeeded.\n"); |
592 | } | 600 | } |
593 | return rc; | 601 | return rc; |
594 | } | 602 | } |
@@ -603,8 +611,7 @@ static int mb86a20s_set_frontend(struct dvb_frontend *fe) | |||
603 | */ | 611 | */ |
604 | struct dtv_frontend_properties *c = &fe->dtv_property_cache; | 612 | struct dtv_frontend_properties *c = &fe->dtv_property_cache; |
605 | #endif | 613 | #endif |
606 | 614 | dev_dbg(&state->i2c->dev, "%s called.\n", __func__); | |
607 | dprintk("\n"); | ||
608 | 615 | ||
609 | /* | 616 | /* |
610 | * Gate should already be opened, but it doesn't hurt to | 617 | * Gate should already be opened, but it doesn't hurt to |
@@ -612,7 +619,6 @@ static int mb86a20s_set_frontend(struct dvb_frontend *fe) | |||
612 | */ | 619 | */ |
613 | if (fe->ops.i2c_gate_ctrl) | 620 | if (fe->ops.i2c_gate_ctrl) |
614 | fe->ops.i2c_gate_ctrl(fe, 1); | 621 | fe->ops.i2c_gate_ctrl(fe, 1); |
615 | dprintk("Calling tuner set parameters\n"); | ||
616 | fe->ops.tuner_ops.set_params(fe); | 622 | fe->ops.tuner_ops.set_params(fe); |
617 | 623 | ||
618 | /* | 624 | /* |
@@ -637,13 +643,11 @@ static int mb86a20s_set_frontend(struct dvb_frontend *fe) | |||
637 | return rc; | 643 | return rc; |
638 | } | 644 | } |
639 | 645 | ||
640 | |||
641 | static int mb86a20s_read_status_gate(struct dvb_frontend *fe, | 646 | static int mb86a20s_read_status_gate(struct dvb_frontend *fe, |
642 | fe_status_t *status) | 647 | fe_status_t *status) |
643 | { | 648 | { |
644 | int ret; | 649 | int ret; |
645 | 650 | ||
646 | dprintk("\n"); | ||
647 | *status = 0; | 651 | *status = 0; |
648 | 652 | ||
649 | if (fe->ops.i2c_gate_ctrl) | 653 | if (fe->ops.i2c_gate_ctrl) |
@@ -663,9 +667,10 @@ static int mb86a20s_tune(struct dvb_frontend *fe, | |||
663 | unsigned int *delay, | 667 | unsigned int *delay, |
664 | fe_status_t *status) | 668 | fe_status_t *status) |
665 | { | 669 | { |
670 | struct mb86a20s_state *state = fe->demodulator_priv; | ||
666 | int rc = 0; | 671 | int rc = 0; |
667 | 672 | ||
668 | dprintk("\n"); | 673 | dev_dbg(&state->i2c->dev, "%s called.\n", __func__); |
669 | 674 | ||
670 | if (re_tune) | 675 | if (re_tune) |
671 | rc = mb86a20s_set_frontend(fe); | 676 | rc = mb86a20s_set_frontend(fe); |
@@ -680,7 +685,7 @@ static void mb86a20s_release(struct dvb_frontend *fe) | |||
680 | { | 685 | { |
681 | struct mb86a20s_state *state = fe->demodulator_priv; | 686 | struct mb86a20s_state *state = fe->demodulator_priv; |
682 | 687 | ||
683 | dprintk("\n"); | 688 | dev_dbg(&state->i2c->dev, "%s called.\n", __func__); |
684 | 689 | ||
685 | kfree(state); | 690 | kfree(state); |
686 | } | 691 | } |
@@ -690,15 +695,16 @@ static struct dvb_frontend_ops mb86a20s_ops; | |||
690 | struct dvb_frontend *mb86a20s_attach(const struct mb86a20s_config *config, | 695 | struct dvb_frontend *mb86a20s_attach(const struct mb86a20s_config *config, |
691 | struct i2c_adapter *i2c) | 696 | struct i2c_adapter *i2c) |
692 | { | 697 | { |
698 | struct mb86a20s_state *state; | ||
693 | u8 rev; | 699 | u8 rev; |
694 | 700 | ||
695 | /* allocate memory for the internal state */ | 701 | /* allocate memory for the internal state */ |
696 | struct mb86a20s_state *state = | 702 | state = kzalloc(sizeof(struct mb86a20s_state), GFP_KERNEL); |
697 | kzalloc(sizeof(struct mb86a20s_state), GFP_KERNEL); | ||
698 | 703 | ||
699 | dprintk("\n"); | 704 | dev_dbg(&state->i2c->dev, "%s called.\n", __func__); |
700 | if (state == NULL) { | 705 | if (state == NULL) { |
701 | rc("Unable to kzalloc\n"); | 706 | dev_err(&state->i2c->dev, |
707 | "%s: unable to allocate memory for state\n", __func__); | ||
702 | goto error; | 708 | goto error; |
703 | } | 709 | } |
704 | 710 | ||
@@ -715,9 +721,11 @@ struct dvb_frontend *mb86a20s_attach(const struct mb86a20s_config *config, | |||
715 | rev = mb86a20s_readreg(state, 0); | 721 | rev = mb86a20s_readreg(state, 0); |
716 | 722 | ||
717 | if (rev == 0x13) { | 723 | if (rev == 0x13) { |
718 | printk(KERN_INFO "Detected a Fujitsu mb86a20s frontend\n"); | 724 | dev_info(&state->i2c->dev, |
725 | "Detected a Fujitsu mb86a20s frontend\n"); | ||
719 | } else { | 726 | } else { |
720 | printk(KERN_ERR "Frontend revision %d is unknown - aborting.\n", | 727 | dev_dbg(&state->i2c->dev, |
728 | "Frontend revision %d is unknown - aborting.\n", | ||
721 | rev); | 729 | rev); |
722 | goto error; | 730 | goto error; |
723 | } | 731 | } |