diff options
author | Andy Shevchenko <andriy.shevchenko@linux.intel.com> | 2012-12-18 08:20:28 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2012-12-21 11:30:19 -0500 |
commit | bb9e31f3928dd9b1ecb66689890d1f5f3d19227c (patch) | |
tree | 1eb6c7678e972cd7b97000ac9997ed2d8a1e976a | |
parent | aa735ee9dd92118488b30924b4710061b813193f (diff) |
[media] or51211: apply pr_fmt and use pr_* macros instead of printk
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Michael Krufky <mkrufky@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r-- | drivers/media/dvb-frontends/or51211.c | 94 |
1 files changed, 43 insertions, 51 deletions
diff --git a/drivers/media/dvb-frontends/or51211.c b/drivers/media/dvb-frontends/or51211.c index 1af997eb0578..10cfc0579168 100644 --- a/drivers/media/dvb-frontends/or51211.c +++ b/drivers/media/dvb-frontends/or51211.c | |||
@@ -22,6 +22,8 @@ | |||
22 | * | 22 | * |
23 | */ | 23 | */ |
24 | 24 | ||
25 | #define pr_fmt(fmt) KBUILD_MODNAME ": %s: " fmt, __func__ | ||
26 | |||
25 | /* | 27 | /* |
26 | * This driver needs external firmware. Please use the command | 28 | * This driver needs external firmware. Please use the command |
27 | * "<kerneldir>/Documentation/dvb/get_dvb_firmware or51211" to | 29 | * "<kerneldir>/Documentation/dvb/get_dvb_firmware or51211" to |
@@ -44,9 +46,7 @@ | |||
44 | 46 | ||
45 | static int debug; | 47 | static int debug; |
46 | #define dprintk(args...) \ | 48 | #define dprintk(args...) \ |
47 | do { \ | 49 | do { if (debug) pr_debug(args); } while (0) |
48 | if (debug) printk(KERN_DEBUG "or51211: " args); \ | ||
49 | } while (0) | ||
50 | 50 | ||
51 | static u8 run_buf[] = {0x7f,0x01}; | 51 | static u8 run_buf[] = {0x7f,0x01}; |
52 | static u8 cmd_buf[] = {0x04,0x01,0x50,0x80,0x06}; // ATSC | 52 | static u8 cmd_buf[] = {0x04,0x01,0x50,0x80,0x06}; // ATSC |
@@ -80,8 +80,7 @@ static int i2c_writebytes (struct or51211_state* state, u8 reg, const u8 *buf, | |||
80 | msg.buf = (u8 *)buf; | 80 | msg.buf = (u8 *)buf; |
81 | 81 | ||
82 | if ((err = i2c_transfer (state->i2c, &msg, 1)) != 1) { | 82 | if ((err = i2c_transfer (state->i2c, &msg, 1)) != 1) { |
83 | printk(KERN_WARNING "or51211: i2c_writebytes error " | 83 | pr_warn("error (addr %02x, err == %i)\n", reg, err); |
84 | "(addr %02x, err == %i)\n", reg, err); | ||
85 | return -EREMOTEIO; | 84 | return -EREMOTEIO; |
86 | } | 85 | } |
87 | 86 | ||
@@ -98,8 +97,7 @@ static int i2c_readbytes(struct or51211_state *state, u8 reg, u8 *buf, int len) | |||
98 | msg.buf = buf; | 97 | msg.buf = buf; |
99 | 98 | ||
100 | if ((err = i2c_transfer (state->i2c, &msg, 1)) != 1) { | 99 | if ((err = i2c_transfer (state->i2c, &msg, 1)) != 1) { |
101 | printk(KERN_WARNING "or51211: i2c_readbytes error " | 100 | pr_warn("error (addr %02x, err == %i)\n", reg, err); |
102 | "(addr %02x, err == %i)\n", reg, err); | ||
103 | return -EREMOTEIO; | 101 | return -EREMOTEIO; |
104 | } | 102 | } |
105 | 103 | ||
@@ -118,11 +116,11 @@ static int or51211_load_firmware (struct dvb_frontend* fe, | |||
118 | /* Get eprom data */ | 116 | /* Get eprom data */ |
119 | tudata[0] = 17; | 117 | tudata[0] = 17; |
120 | if (i2c_writebytes(state,0x50,tudata,1)) { | 118 | if (i2c_writebytes(state,0x50,tudata,1)) { |
121 | printk(KERN_WARNING "or51211:load_firmware error eprom addr\n"); | 119 | pr_warn("error eprom addr\n"); |
122 | return -1; | 120 | return -1; |
123 | } | 121 | } |
124 | if (i2c_readbytes(state,0x50,&tudata[145],192)) { | 122 | if (i2c_readbytes(state,0x50,&tudata[145],192)) { |
125 | printk(KERN_WARNING "or51211: load_firmware error eprom\n"); | 123 | pr_warn("error eprom\n"); |
126 | return -1; | 124 | return -1; |
127 | } | 125 | } |
128 | 126 | ||
@@ -136,32 +134,32 @@ static int or51211_load_firmware (struct dvb_frontend* fe, | |||
136 | state->config->reset(fe); | 134 | state->config->reset(fe); |
137 | 135 | ||
138 | if (i2c_writebytes(state,state->config->demod_address,tudata,585)) { | 136 | if (i2c_writebytes(state,state->config->demod_address,tudata,585)) { |
139 | printk(KERN_WARNING "or51211: load_firmware error 1\n"); | 137 | pr_warn("error 1\n"); |
140 | return -1; | 138 | return -1; |
141 | } | 139 | } |
142 | msleep(1); | 140 | msleep(1); |
143 | 141 | ||
144 | if (i2c_writebytes(state,state->config->demod_address, | 142 | if (i2c_writebytes(state,state->config->demod_address, |
145 | &fw->data[393],8125)) { | 143 | &fw->data[393],8125)) { |
146 | printk(KERN_WARNING "or51211: load_firmware error 2\n"); | 144 | pr_warn("error 2\n"); |
147 | return -1; | 145 | return -1; |
148 | } | 146 | } |
149 | msleep(1); | 147 | msleep(1); |
150 | 148 | ||
151 | if (i2c_writebytes(state,state->config->demod_address,run_buf,2)) { | 149 | if (i2c_writebytes(state,state->config->demod_address,run_buf,2)) { |
152 | printk(KERN_WARNING "or51211: load_firmware error 3\n"); | 150 | pr_warn("error 3\n"); |
153 | return -1; | 151 | return -1; |
154 | } | 152 | } |
155 | 153 | ||
156 | /* Wait at least 5 msec */ | 154 | /* Wait at least 5 msec */ |
157 | msleep(10); | 155 | msleep(10); |
158 | if (i2c_writebytes(state,state->config->demod_address,run_buf,2)) { | 156 | if (i2c_writebytes(state,state->config->demod_address,run_buf,2)) { |
159 | printk(KERN_WARNING "or51211: load_firmware error 4\n"); | 157 | pr_warn("error 4\n"); |
160 | return -1; | 158 | return -1; |
161 | } | 159 | } |
162 | msleep(10); | 160 | msleep(10); |
163 | 161 | ||
164 | printk("or51211: Done.\n"); | 162 | pr_info("Done.\n"); |
165 | return 0; | 163 | return 0; |
166 | }; | 164 | }; |
167 | 165 | ||
@@ -173,14 +171,14 @@ static int or51211_setmode(struct dvb_frontend* fe, int mode) | |||
173 | state->config->setmode(fe, mode); | 171 | state->config->setmode(fe, mode); |
174 | 172 | ||
175 | if (i2c_writebytes(state,state->config->demod_address,run_buf,2)) { | 173 | if (i2c_writebytes(state,state->config->demod_address,run_buf,2)) { |
176 | printk(KERN_WARNING "or51211: setmode error 1\n"); | 174 | pr_warn("error 1\n"); |
177 | return -1; | 175 | return -1; |
178 | } | 176 | } |
179 | 177 | ||
180 | /* Wait at least 5 msec */ | 178 | /* Wait at least 5 msec */ |
181 | msleep(10); | 179 | msleep(10); |
182 | if (i2c_writebytes(state,state->config->demod_address,run_buf,2)) { | 180 | if (i2c_writebytes(state,state->config->demod_address,run_buf,2)) { |
183 | printk(KERN_WARNING "or51211: setmode error 2\n"); | 181 | pr_warn("error 2\n"); |
184 | return -1; | 182 | return -1; |
185 | } | 183 | } |
186 | 184 | ||
@@ -196,7 +194,7 @@ static int or51211_setmode(struct dvb_frontend* fe, int mode) | |||
196 | * normal +/-150kHz Carrier acquisition range | 194 | * normal +/-150kHz Carrier acquisition range |
197 | */ | 195 | */ |
198 | if (i2c_writebytes(state,state->config->demod_address,cmd_buf,3)) { | 196 | if (i2c_writebytes(state,state->config->demod_address,cmd_buf,3)) { |
199 | printk(KERN_WARNING "or51211: setmode error 3\n"); | 197 | pr_warn("error 3\n"); |
200 | return -1; | 198 | return -1; |
201 | } | 199 | } |
202 | 200 | ||
@@ -206,14 +204,14 @@ static int or51211_setmode(struct dvb_frontend* fe, int mode) | |||
206 | rec_buf[3] = 0x00; | 204 | rec_buf[3] = 0x00; |
207 | msleep(20); | 205 | msleep(20); |
208 | if (i2c_writebytes(state,state->config->demod_address,rec_buf,3)) { | 206 | if (i2c_writebytes(state,state->config->demod_address,rec_buf,3)) { |
209 | printk(KERN_WARNING "or51211: setmode error 5\n"); | 207 | pr_warn("error 5\n"); |
210 | } | 208 | } |
211 | msleep(3); | 209 | msleep(3); |
212 | if (i2c_readbytes(state,state->config->demod_address,&rec_buf[10],2)) { | 210 | if (i2c_readbytes(state,state->config->demod_address,&rec_buf[10],2)) { |
213 | printk(KERN_WARNING "or51211: setmode error 6"); | 211 | pr_warn("error 6\n"); |
214 | return -1; | 212 | return -1; |
215 | } | 213 | } |
216 | dprintk("setmode rec status %02x %02x\n",rec_buf[10],rec_buf[11]); | 214 | dprintk("rec status %02x %02x\n", rec_buf[10], rec_buf[11]); |
217 | 215 | ||
218 | return 0; | 216 | return 0; |
219 | } | 217 | } |
@@ -248,15 +246,15 @@ static int or51211_read_status(struct dvb_frontend* fe, fe_status_t* status) | |||
248 | 246 | ||
249 | /* Receiver Status */ | 247 | /* Receiver Status */ |
250 | if (i2c_writebytes(state,state->config->demod_address,snd_buf,3)) { | 248 | if (i2c_writebytes(state,state->config->demod_address,snd_buf,3)) { |
251 | printk(KERN_WARNING "or51132: read_status write error\n"); | 249 | pr_warn("write error\n"); |
252 | return -1; | 250 | return -1; |
253 | } | 251 | } |
254 | msleep(3); | 252 | msleep(3); |
255 | if (i2c_readbytes(state,state->config->demod_address,rec_buf,2)) { | 253 | if (i2c_readbytes(state,state->config->demod_address,rec_buf,2)) { |
256 | printk(KERN_WARNING "or51132: read_status read error\n"); | 254 | pr_warn("read error\n"); |
257 | return -1; | 255 | return -1; |
258 | } | 256 | } |
259 | dprintk("read_status %x %x\n",rec_buf[0],rec_buf[1]); | 257 | dprintk("%x %x\n", rec_buf[0], rec_buf[1]); |
260 | 258 | ||
261 | if (rec_buf[0] & 0x01) { /* Receiver Lock */ | 259 | if (rec_buf[0] & 0x01) { /* Receiver Lock */ |
262 | *status |= FE_HAS_SIGNAL; | 260 | *status |= FE_HAS_SIGNAL; |
@@ -306,20 +304,18 @@ static int or51211_read_snr(struct dvb_frontend* fe, u16* snr) | |||
306 | snd_buf[2] = 0x04; | 304 | snd_buf[2] = 0x04; |
307 | 305 | ||
308 | if (i2c_writebytes(state,state->config->demod_address,snd_buf,3)) { | 306 | if (i2c_writebytes(state,state->config->demod_address,snd_buf,3)) { |
309 | printk(KERN_WARNING "%s: error writing snr reg\n", | 307 | pr_warn("error writing snr reg\n"); |
310 | __func__); | ||
311 | return -1; | 308 | return -1; |
312 | } | 309 | } |
313 | if (i2c_readbytes(state,state->config->demod_address,rec_buf,2)) { | 310 | if (i2c_readbytes(state,state->config->demod_address,rec_buf,2)) { |
314 | printk(KERN_WARNING "%s: read_status read error\n", | 311 | pr_warn("read_status read error\n"); |
315 | __func__); | ||
316 | return -1; | 312 | return -1; |
317 | } | 313 | } |
318 | 314 | ||
319 | state->snr = calculate_snr(rec_buf[0], 89599047); | 315 | state->snr = calculate_snr(rec_buf[0], 89599047); |
320 | *snr = (state->snr) >> 16; | 316 | *snr = (state->snr) >> 16; |
321 | 317 | ||
322 | dprintk("%s: noise = 0x%02x, snr = %d.%02d dB\n", __func__, rec_buf[0], | 318 | dprintk("noise = 0x%02x, snr = %d.%02d dB\n", rec_buf[0], |
323 | state->snr >> 24, (((state->snr>>8) & 0xffff) * 100) >> 16); | 319 | state->snr >> 24, (((state->snr>>8) & 0xffff) * 100) >> 16); |
324 | 320 | ||
325 | return 0; | 321 | return 0; |
@@ -375,25 +371,24 @@ static int or51211_init(struct dvb_frontend* fe) | |||
375 | 371 | ||
376 | if (!state->initialized) { | 372 | if (!state->initialized) { |
377 | /* Request the firmware, this will block until it uploads */ | 373 | /* Request the firmware, this will block until it uploads */ |
378 | printk(KERN_INFO "or51211: Waiting for firmware upload " | 374 | pr_info("Waiting for firmware upload (%s)...\n", |
379 | "(%s)...\n", OR51211_DEFAULT_FIRMWARE); | 375 | OR51211_DEFAULT_FIRMWARE); |
380 | ret = config->request_firmware(fe, &fw, | 376 | ret = config->request_firmware(fe, &fw, |
381 | OR51211_DEFAULT_FIRMWARE); | 377 | OR51211_DEFAULT_FIRMWARE); |
382 | printk(KERN_INFO "or51211:Got Hotplug firmware\n"); | 378 | pr_info("Got Hotplug firmware\n"); |
383 | if (ret) { | 379 | if (ret) { |
384 | printk(KERN_WARNING "or51211: No firmware uploaded " | 380 | pr_warn("No firmware uploaded " |
385 | "(timeout or file not found?)\n"); | 381 | "(timeout or file not found?)\n"); |
386 | return ret; | 382 | return ret; |
387 | } | 383 | } |
388 | 384 | ||
389 | ret = or51211_load_firmware(fe, fw); | 385 | ret = or51211_load_firmware(fe, fw); |
390 | release_firmware(fw); | 386 | release_firmware(fw); |
391 | if (ret) { | 387 | if (ret) { |
392 | printk(KERN_WARNING "or51211: Writing firmware to " | 388 | pr_warn("Writing firmware to device failed!\n"); |
393 | "device failed!\n"); | ||
394 | return ret; | 389 | return ret; |
395 | } | 390 | } |
396 | printk(KERN_INFO "or51211: Firmware upload complete.\n"); | 391 | pr_info("Firmware upload complete.\n"); |
397 | 392 | ||
398 | /* Set operation mode in Receiver 1 register; | 393 | /* Set operation mode in Receiver 1 register; |
399 | * type 1: | 394 | * type 1: |
@@ -406,7 +401,7 @@ static int or51211_init(struct dvb_frontend* fe) | |||
406 | */ | 401 | */ |
407 | if (i2c_writebytes(state,state->config->demod_address, | 402 | if (i2c_writebytes(state,state->config->demod_address, |
408 | cmd_buf,3)) { | 403 | cmd_buf,3)) { |
409 | printk(KERN_WARNING "or51211: Load DVR Error 5\n"); | 404 | pr_warn("Load DVR Error 5\n"); |
410 | return -1; | 405 | return -1; |
411 | } | 406 | } |
412 | 407 | ||
@@ -419,13 +414,13 @@ static int or51211_init(struct dvb_frontend* fe) | |||
419 | msleep(30); | 414 | msleep(30); |
420 | if (i2c_writebytes(state,state->config->demod_address, | 415 | if (i2c_writebytes(state,state->config->demod_address, |
421 | rec_buf,3)) { | 416 | rec_buf,3)) { |
422 | printk(KERN_WARNING "or51211: Load DVR Error A\n"); | 417 | pr_warn("Load DVR Error A\n"); |
423 | return -1; | 418 | return -1; |
424 | } | 419 | } |
425 | msleep(3); | 420 | msleep(3); |
426 | if (i2c_readbytes(state,state->config->demod_address, | 421 | if (i2c_readbytes(state,state->config->demod_address, |
427 | &rec_buf[10],2)) { | 422 | &rec_buf[10],2)) { |
428 | printk(KERN_WARNING "or51211: Load DVR Error B\n"); | 423 | pr_warn("Load DVR Error B\n"); |
429 | return -1; | 424 | return -1; |
430 | } | 425 | } |
431 | 426 | ||
@@ -436,13 +431,13 @@ static int or51211_init(struct dvb_frontend* fe) | |||
436 | msleep(20); | 431 | msleep(20); |
437 | if (i2c_writebytes(state,state->config->demod_address, | 432 | if (i2c_writebytes(state,state->config->demod_address, |
438 | rec_buf,3)) { | 433 | rec_buf,3)) { |
439 | printk(KERN_WARNING "or51211: Load DVR Error C\n"); | 434 | pr_warn("Load DVR Error C\n"); |
440 | return -1; | 435 | return -1; |
441 | } | 436 | } |
442 | msleep(3); | 437 | msleep(3); |
443 | if (i2c_readbytes(state,state->config->demod_address, | 438 | if (i2c_readbytes(state,state->config->demod_address, |
444 | &rec_buf[12],2)) { | 439 | &rec_buf[12],2)) { |
445 | printk(KERN_WARNING "or51211: Load DVR Error D\n"); | 440 | pr_warn("Load DVR Error D\n"); |
446 | return -1; | 441 | return -1; |
447 | } | 442 | } |
448 | 443 | ||
@@ -454,16 +449,14 @@ static int or51211_init(struct dvb_frontend* fe) | |||
454 | get_ver_buf[4] = i+1; | 449 | get_ver_buf[4] = i+1; |
455 | if (i2c_writebytes(state,state->config->demod_address, | 450 | if (i2c_writebytes(state,state->config->demod_address, |
456 | get_ver_buf,5)) { | 451 | get_ver_buf,5)) { |
457 | printk(KERN_WARNING "or51211:Load DVR Error 6" | 452 | pr_warn("Load DVR Error 6 - %d\n", i); |
458 | " - %d\n",i); | ||
459 | return -1; | 453 | return -1; |
460 | } | 454 | } |
461 | msleep(3); | 455 | msleep(3); |
462 | 456 | ||
463 | if (i2c_readbytes(state,state->config->demod_address, | 457 | if (i2c_readbytes(state,state->config->demod_address, |
464 | &rec_buf[i*2],2)) { | 458 | &rec_buf[i*2],2)) { |
465 | printk(KERN_WARNING "or51211:Load DVR Error 7" | 459 | pr_warn("Load DVR Error 7 - %d\n", i); |
466 | " - %d\n",i); | ||
467 | return -1; | 460 | return -1; |
468 | } | 461 | } |
469 | /* If we didn't receive the right index, try again */ | 462 | /* If we didn't receive the right index, try again */ |
@@ -473,10 +466,9 @@ static int or51211_init(struct dvb_frontend* fe) | |||
473 | } | 466 | } |
474 | dprintk("read_fwbits %10ph\n", rec_buf); | 467 | dprintk("read_fwbits %10ph\n", rec_buf); |
475 | 468 | ||
476 | printk(KERN_INFO "or51211: ver TU%02x%02x%02x VSB mode %02x" | 469 | pr_info("ver TU%02x%02x%02x VSB mode %02x Status %02x\n", |
477 | " Status %02x\n", | 470 | rec_buf[2], rec_buf[4], rec_buf[6], rec_buf[12], |
478 | rec_buf[2], rec_buf[4],rec_buf[6], | 471 | rec_buf[10]); |
479 | rec_buf[12],rec_buf[10]); | ||
480 | 472 | ||
481 | rec_buf[0] = 0x04; | 473 | rec_buf[0] = 0x04; |
482 | rec_buf[1] = 0x00; | 474 | rec_buf[1] = 0x00; |
@@ -485,13 +477,13 @@ static int or51211_init(struct dvb_frontend* fe) | |||
485 | msleep(20); | 477 | msleep(20); |
486 | if (i2c_writebytes(state,state->config->demod_address, | 478 | if (i2c_writebytes(state,state->config->demod_address, |
487 | rec_buf,3)) { | 479 | rec_buf,3)) { |
488 | printk(KERN_WARNING "or51211: Load DVR Error 8\n"); | 480 | pr_warn("Load DVR Error 8\n"); |
489 | return -1; | 481 | return -1; |
490 | } | 482 | } |
491 | msleep(20); | 483 | msleep(20); |
492 | if (i2c_readbytes(state,state->config->demod_address, | 484 | if (i2c_readbytes(state,state->config->demod_address, |
493 | &rec_buf[8],2)) { | 485 | &rec_buf[8],2)) { |
494 | printk(KERN_WARNING "or51211: Load DVR Error 9\n"); | 486 | pr_warn("Load DVR Error 9\n"); |
495 | return -1; | 487 | return -1; |
496 | } | 488 | } |
497 | state->initialized = 1; | 489 | state->initialized = 1; |