aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb-frontends/rtl2832_sdr.c
diff options
context:
space:
mode:
authorAntti Palosaari <crope@iki.fi>2014-12-16 10:18:01 -0500
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>2015-02-03 13:17:24 -0500
commite4e78693a18aa6dfc1388def09d5c73006d7c742 (patch)
tree73c9b8b0a2edc4e9ef35e07e7116e713f55a898b /drivers/media/dvb-frontends/rtl2832_sdr.c
parent488be13a5e7cb0d497b1c7cb79021b4d88b82b57 (diff)
[media] rtl2832_sdr: fix logging
Pass correct device, platform device, for logging system in order to format printouts correctly. Signed-off-by: Antti Palosaari <crope@iki.fi> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Diffstat (limited to 'drivers/media/dvb-frontends/rtl2832_sdr.c')
-rw-r--r--drivers/media/dvb-frontends/rtl2832_sdr.c151
1 files changed, 86 insertions, 65 deletions
diff --git a/drivers/media/dvb-frontends/rtl2832_sdr.c b/drivers/media/dvb-frontends/rtl2832_sdr.c
index 6c5b2944ecb2..361b1eb7cbb7 100644
--- a/drivers/media/dvb-frontends/rtl2832_sdr.c
+++ b/drivers/media/dvb-frontends/rtl2832_sdr.c
@@ -224,6 +224,7 @@ leave:
224static unsigned int rtl2832_sdr_convert_stream(struct rtl2832_sdr_dev *dev, 224static unsigned int rtl2832_sdr_convert_stream(struct rtl2832_sdr_dev *dev,
225 void *dst, const u8 *src, unsigned int src_len) 225 void *dst, const u8 *src, unsigned int src_len)
226{ 226{
227 struct platform_device *pdev = dev->pdev;
227 unsigned int dst_len; 228 unsigned int dst_len;
228 229
229 if (dev->pixelformat == V4L2_SDR_FMT_CU8) { 230 if (dev->pixelformat == V4L2_SDR_FMT_CU8) {
@@ -251,10 +252,9 @@ static unsigned int rtl2832_sdr_convert_stream(struct rtl2832_sdr_dev *dev,
251 252
252 dev->jiffies_next = jiffies + msecs_to_jiffies(MSECS); 253 dev->jiffies_next = jiffies + msecs_to_jiffies(MSECS);
253 dev->sample_measured = dev->sample; 254 dev->sample_measured = dev->sample;
254 dev_dbg(&dev->udev->dev, 255 dev_dbg(&pdev->dev,
255 "slen=%u samples=%u msecs=%u sample rate=%lu\n", 256 "slen=%u samples=%u msecs=%u sample rate=%lu\n",
256 src_len, samples, msecs, 257 src_len, samples, msecs, samples * 1000UL / msecs);
257 samples * 1000UL / msecs);
258 } 258 }
259 259
260 /* total number of I+Q pairs */ 260 /* total number of I+Q pairs */
@@ -270,12 +270,12 @@ static unsigned int rtl2832_sdr_convert_stream(struct rtl2832_sdr_dev *dev,
270static void rtl2832_sdr_urb_complete(struct urb *urb) 270static void rtl2832_sdr_urb_complete(struct urb *urb)
271{ 271{
272 struct rtl2832_sdr_dev *dev = urb->context; 272 struct rtl2832_sdr_dev *dev = urb->context;
273 struct platform_device *pdev = dev->pdev;
273 struct rtl2832_sdr_frame_buf *fbuf; 274 struct rtl2832_sdr_frame_buf *fbuf;
274 275
275 dev_dbg_ratelimited(&dev->udev->dev, 276 dev_dbg_ratelimited(&pdev->dev, "status=%d length=%d/%d errors=%d\n",
276 "status=%d length=%d/%d errors=%d\n", 277 urb->status, urb->actual_length,
277 urb->status, urb->actual_length, 278 urb->transfer_buffer_length, urb->error_count);
278 urb->transfer_buffer_length, urb->error_count);
279 279
280 switch (urb->status) { 280 switch (urb->status) {
281 case 0: /* success */ 281 case 0: /* success */
@@ -286,8 +286,7 @@ static void rtl2832_sdr_urb_complete(struct urb *urb)
286 case -ESHUTDOWN: 286 case -ESHUTDOWN:
287 return; 287 return;
288 default: /* error */ 288 default: /* error */
289 dev_err_ratelimited(&dev->udev->dev, "urb failed=%d\n", 289 dev_err_ratelimited(&pdev->dev, "urb failed=%d\n", urb->status);
290 urb->status);
291 break; 290 break;
292 } 291 }
293 292
@@ -298,9 +297,9 @@ static void rtl2832_sdr_urb_complete(struct urb *urb)
298 fbuf = rtl2832_sdr_get_next_fill_buf(dev); 297 fbuf = rtl2832_sdr_get_next_fill_buf(dev);
299 if (unlikely(fbuf == NULL)) { 298 if (unlikely(fbuf == NULL)) {
300 dev->vb_full++; 299 dev->vb_full++;
301 dev_notice_ratelimited(&dev->udev->dev, 300 dev_notice_ratelimited(&pdev->dev,
302 "videobuf is full, %d packets dropped\n", 301 "videobuf is full, %d packets dropped\n",
303 dev->vb_full); 302 dev->vb_full);
304 goto skip; 303 goto skip;
305 } 304 }
306 305
@@ -319,10 +318,11 @@ skip:
319 318
320static int rtl2832_sdr_kill_urbs(struct rtl2832_sdr_dev *dev) 319static int rtl2832_sdr_kill_urbs(struct rtl2832_sdr_dev *dev)
321{ 320{
321 struct platform_device *pdev = dev->pdev;
322 int i; 322 int i;
323 323
324 for (i = dev->urbs_submitted - 1; i >= 0; i--) { 324 for (i = dev->urbs_submitted - 1; i >= 0; i--) {
325 dev_dbg(&dev->udev->dev, "kill urb=%d\n", i); 325 dev_dbg(&pdev->dev, "kill urb=%d\n", i);
326 /* stop the URB */ 326 /* stop the URB */
327 usb_kill_urb(dev->urb_list[i]); 327 usb_kill_urb(dev->urb_list[i]);
328 } 328 }
@@ -333,15 +333,16 @@ static int rtl2832_sdr_kill_urbs(struct rtl2832_sdr_dev *dev)
333 333
334static int rtl2832_sdr_submit_urbs(struct rtl2832_sdr_dev *dev) 334static int rtl2832_sdr_submit_urbs(struct rtl2832_sdr_dev *dev)
335{ 335{
336 struct platform_device *pdev = dev->pdev;
336 int i, ret; 337 int i, ret;
337 338
338 for (i = 0; i < dev->urbs_initialized; i++) { 339 for (i = 0; i < dev->urbs_initialized; i++) {
339 dev_dbg(&dev->udev->dev, "submit urb=%d\n", i); 340 dev_dbg(&pdev->dev, "submit urb=%d\n", i);
340 ret = usb_submit_urb(dev->urb_list[i], GFP_ATOMIC); 341 ret = usb_submit_urb(dev->urb_list[i], GFP_ATOMIC);
341 if (ret) { 342 if (ret) {
342 dev_err(&dev->udev->dev, 343 dev_err(&pdev->dev,
343 "Could not submit urb no. %d - get them all back\n", 344 "Could not submit urb no. %d - get them all back\n",
344 i); 345 i);
345 rtl2832_sdr_kill_urbs(dev); 346 rtl2832_sdr_kill_urbs(dev);
346 return ret; 347 return ret;
347 } 348 }
@@ -353,10 +354,11 @@ static int rtl2832_sdr_submit_urbs(struct rtl2832_sdr_dev *dev)
353 354
354static int rtl2832_sdr_free_stream_bufs(struct rtl2832_sdr_dev *dev) 355static int rtl2832_sdr_free_stream_bufs(struct rtl2832_sdr_dev *dev)
355{ 356{
357 struct platform_device *pdev = dev->pdev;
356 if (dev->flags & USB_STATE_URB_BUF) { 358 if (dev->flags & USB_STATE_URB_BUF) {
357 while (dev->buf_num) { 359 while (dev->buf_num) {
358 dev->buf_num--; 360 dev->buf_num--;
359 dev_dbg(&dev->udev->dev, "free buf=%d\n", dev->buf_num); 361 dev_dbg(&pdev->dev, "free buf=%d\n", dev->buf_num);
360 usb_free_coherent(dev->udev, dev->buf_size, 362 usb_free_coherent(dev->udev, dev->buf_size,
361 dev->buf_list[dev->buf_num], 363 dev->buf_list[dev->buf_num],
362 dev->dma_addr[dev->buf_num]); 364 dev->dma_addr[dev->buf_num]);
@@ -369,26 +371,27 @@ static int rtl2832_sdr_free_stream_bufs(struct rtl2832_sdr_dev *dev)
369 371
370static int rtl2832_sdr_alloc_stream_bufs(struct rtl2832_sdr_dev *dev) 372static int rtl2832_sdr_alloc_stream_bufs(struct rtl2832_sdr_dev *dev)
371{ 373{
374 struct platform_device *pdev = dev->pdev;
372 dev->buf_num = 0; 375 dev->buf_num = 0;
373 dev->buf_size = BULK_BUFFER_SIZE; 376 dev->buf_size = BULK_BUFFER_SIZE;
374 377
375 dev_dbg(&dev->udev->dev, "all in all I will use %u bytes for streaming\n", 378 dev_dbg(&pdev->dev, "all in all I will use %u bytes for streaming\n",
376 MAX_BULK_BUFS * BULK_BUFFER_SIZE); 379 MAX_BULK_BUFS * BULK_BUFFER_SIZE);
377 380
378 for (dev->buf_num = 0; dev->buf_num < MAX_BULK_BUFS; dev->buf_num++) { 381 for (dev->buf_num = 0; dev->buf_num < MAX_BULK_BUFS; dev->buf_num++) {
379 dev->buf_list[dev->buf_num] = usb_alloc_coherent(dev->udev, 382 dev->buf_list[dev->buf_num] = usb_alloc_coherent(dev->udev,
380 BULK_BUFFER_SIZE, GFP_ATOMIC, 383 BULK_BUFFER_SIZE, GFP_ATOMIC,
381 &dev->dma_addr[dev->buf_num]); 384 &dev->dma_addr[dev->buf_num]);
382 if (!dev->buf_list[dev->buf_num]) { 385 if (!dev->buf_list[dev->buf_num]) {
383 dev_dbg(&dev->udev->dev, "alloc buf=%d failed\n", 386 dev_dbg(&pdev->dev, "alloc buf=%d failed\n",
384 dev->buf_num); 387 dev->buf_num);
385 rtl2832_sdr_free_stream_bufs(dev); 388 rtl2832_sdr_free_stream_bufs(dev);
386 return -ENOMEM; 389 return -ENOMEM;
387 } 390 }
388 391
389 dev_dbg(&dev->udev->dev, "alloc buf=%d %p (dma %llu)\n", 392 dev_dbg(&pdev->dev, "alloc buf=%d %p (dma %llu)\n",
390 dev->buf_num, dev->buf_list[dev->buf_num], 393 dev->buf_num, dev->buf_list[dev->buf_num],
391 (long long)dev->dma_addr[dev->buf_num]); 394 (long long)dev->dma_addr[dev->buf_num]);
392 dev->flags |= USB_STATE_URB_BUF; 395 dev->flags |= USB_STATE_URB_BUF;
393 } 396 }
394 397
@@ -397,13 +400,14 @@ static int rtl2832_sdr_alloc_stream_bufs(struct rtl2832_sdr_dev *dev)
397 400
398static int rtl2832_sdr_free_urbs(struct rtl2832_sdr_dev *dev) 401static int rtl2832_sdr_free_urbs(struct rtl2832_sdr_dev *dev)
399{ 402{
403 struct platform_device *pdev = dev->pdev;
400 int i; 404 int i;
401 405
402 rtl2832_sdr_kill_urbs(dev); 406 rtl2832_sdr_kill_urbs(dev);
403 407
404 for (i = dev->urbs_initialized - 1; i >= 0; i--) { 408 for (i = dev->urbs_initialized - 1; i >= 0; i--) {
405 if (dev->urb_list[i]) { 409 if (dev->urb_list[i]) {
406 dev_dbg(&dev->udev->dev, "free urb=%d\n", i); 410 dev_dbg(&pdev->dev, "free urb=%d\n", i);
407 /* free the URBs */ 411 /* free the URBs */
408 usb_free_urb(dev->urb_list[i]); 412 usb_free_urb(dev->urb_list[i]);
409 } 413 }
@@ -415,14 +419,15 @@ static int rtl2832_sdr_free_urbs(struct rtl2832_sdr_dev *dev)
415 419
416static int rtl2832_sdr_alloc_urbs(struct rtl2832_sdr_dev *dev) 420static int rtl2832_sdr_alloc_urbs(struct rtl2832_sdr_dev *dev)
417{ 421{
422 struct platform_device *pdev = dev->pdev;
418 int i, j; 423 int i, j;
419 424
420 /* allocate the URBs */ 425 /* allocate the URBs */
421 for (i = 0; i < MAX_BULK_BUFS; i++) { 426 for (i = 0; i < MAX_BULK_BUFS; i++) {
422 dev_dbg(&dev->udev->dev, "alloc urb=%d\n", i); 427 dev_dbg(&pdev->dev, "alloc urb=%d\n", i);
423 dev->urb_list[i] = usb_alloc_urb(0, GFP_ATOMIC); 428 dev->urb_list[i] = usb_alloc_urb(0, GFP_ATOMIC);
424 if (!dev->urb_list[i]) { 429 if (!dev->urb_list[i]) {
425 dev_dbg(&dev->udev->dev, "failed\n"); 430 dev_dbg(&pdev->dev, "failed\n");
426 for (j = 0; j < i; j++) 431 for (j = 0; j < i; j++)
427 usb_free_urb(dev->urb_list[j]); 432 usb_free_urb(dev->urb_list[j]);
428 return -ENOMEM; 433 return -ENOMEM;
@@ -445,9 +450,10 @@ static int rtl2832_sdr_alloc_urbs(struct rtl2832_sdr_dev *dev)
445/* Must be called with vb_queue_lock hold */ 450/* Must be called with vb_queue_lock hold */
446static void rtl2832_sdr_cleanup_queued_bufs(struct rtl2832_sdr_dev *dev) 451static void rtl2832_sdr_cleanup_queued_bufs(struct rtl2832_sdr_dev *dev)
447{ 452{
453 struct platform_device *pdev = dev->pdev;
448 unsigned long flags; 454 unsigned long flags;
449 455
450 dev_dbg(&dev->udev->dev, "\n"); 456 dev_dbg(&pdev->dev, "\n");
451 457
452 spin_lock_irqsave(&dev->queued_bufs_lock, flags); 458 spin_lock_irqsave(&dev->queued_bufs_lock, flags);
453 while (!list_empty(&dev->queued_bufs)) { 459 while (!list_empty(&dev->queued_bufs)) {
@@ -465,8 +471,9 @@ static int rtl2832_sdr_querycap(struct file *file, void *fh,
465 struct v4l2_capability *cap) 471 struct v4l2_capability *cap)
466{ 472{
467 struct rtl2832_sdr_dev *dev = video_drvdata(file); 473 struct rtl2832_sdr_dev *dev = video_drvdata(file);
474 struct platform_device *pdev = dev->pdev;
468 475
469 dev_dbg(&dev->udev->dev, "\n"); 476 dev_dbg(&pdev->dev, "\n");
470 477
471 strlcpy(cap->driver, KBUILD_MODNAME, sizeof(cap->driver)); 478 strlcpy(cap->driver, KBUILD_MODNAME, sizeof(cap->driver));
472 strlcpy(cap->card, dev->vdev.name, sizeof(cap->card)); 479 strlcpy(cap->card, dev->vdev.name, sizeof(cap->card));
@@ -483,16 +490,16 @@ static int rtl2832_sdr_queue_setup(struct vb2_queue *vq,
483 unsigned int *nplanes, unsigned int sizes[], void *alloc_ctxs[]) 490 unsigned int *nplanes, unsigned int sizes[], void *alloc_ctxs[])
484{ 491{
485 struct rtl2832_sdr_dev *dev = vb2_get_drv_priv(vq); 492 struct rtl2832_sdr_dev *dev = vb2_get_drv_priv(vq);
493 struct platform_device *pdev = dev->pdev;
486 494
487 dev_dbg(&dev->udev->dev, "nbuffers=%d\n", *nbuffers); 495 dev_dbg(&pdev->dev, "nbuffers=%d\n", *nbuffers);
488 496
489 /* Need at least 8 buffers */ 497 /* Need at least 8 buffers */
490 if (vq->num_buffers + *nbuffers < 8) 498 if (vq->num_buffers + *nbuffers < 8)
491 *nbuffers = 8 - vq->num_buffers; 499 *nbuffers = 8 - vq->num_buffers;
492 *nplanes = 1; 500 *nplanes = 1;
493 sizes[0] = PAGE_ALIGN(dev->buffersize); 501 sizes[0] = PAGE_ALIGN(dev->buffersize);
494 dev_dbg(&dev->udev->dev, "nbuffers=%d sizes[0]=%d\n", 502 dev_dbg(&pdev->dev, "nbuffers=%d sizes[0]=%d\n", *nbuffers, sizes[0]);
495 *nbuffers, sizes[0]);
496 return 0; 503 return 0;
497} 504}
498 505
@@ -536,7 +543,7 @@ static int rtl2832_sdr_set_adc(struct rtl2832_sdr_dev *dev)
536 u64 u64tmp; 543 u64 u64tmp;
537 u32 u32tmp; 544 u32 u32tmp;
538 545
539 dev_dbg(&dev->udev->dev, "f_adc=%u\n", dev->f_adc); 546 dev_dbg(&pdev->dev, "f_adc=%u\n", dev->f_adc);
540 547
541 if (!test_bit(POWER_ON, &dev->flags)) 548 if (!test_bit(POWER_ON, &dev->flags))
542 return 0; 549 return 0;
@@ -570,7 +577,7 @@ static int rtl2832_sdr_set_adc(struct rtl2832_sdr_dev *dev)
570 u64tmp = -u64tmp; 577 u64tmp = -u64tmp;
571 u32tmp = u64tmp & 0x3fffff; 578 u32tmp = u64tmp & 0x3fffff;
572 579
573 dev_dbg(&dev->udev->dev, "f_if=%u if_ctl=%08x\n", f_if, u32tmp); 580 dev_dbg(&pdev->dev, "f_if=%u if_ctl=%08x\n", f_if, u32tmp);
574 581
575 buf[0] = (u32tmp >> 16) & 0xff; 582 buf[0] = (u32tmp >> 16) & 0xff;
576 buf[1] = (u32tmp >> 8) & 0xff; 583 buf[1] = (u32tmp >> 8) & 0xff;
@@ -739,7 +746,7 @@ static int rtl2832_sdr_set_adc(struct rtl2832_sdr_dev *dev)
739 ret = rtl2832_sdr_wr_regs(dev, 0x011, "\xf4", 1); 746 ret = rtl2832_sdr_wr_regs(dev, 0x011, "\xf4", 1);
740 break; 747 break;
741 default: 748 default:
742 dev_notice(&dev->udev->dev, "Unsupported tuner\n"); 749 dev_notice(&pdev->dev, "Unsupported tuner\n");
743 } 750 }
744 751
745 /* software reset */ 752 /* software reset */
@@ -756,9 +763,10 @@ err:
756 763
757static void rtl2832_sdr_unset_adc(struct rtl2832_sdr_dev *dev) 764static void rtl2832_sdr_unset_adc(struct rtl2832_sdr_dev *dev)
758{ 765{
766 struct platform_device *pdev = dev->pdev;
759 int ret; 767 int ret;
760 768
761 dev_dbg(&dev->udev->dev, "\n"); 769 dev_dbg(&pdev->dev, "\n");
762 770
763 /* PID filter */ 771 /* PID filter */
764 ret = rtl2832_sdr_wr_regs(dev, 0x061, "\xe0", 1); 772 ret = rtl2832_sdr_wr_regs(dev, 0x061, "\xe0", 1);
@@ -792,6 +800,7 @@ err:
792 800
793static int rtl2832_sdr_set_tuner_freq(struct rtl2832_sdr_dev *dev) 801static int rtl2832_sdr_set_tuner_freq(struct rtl2832_sdr_dev *dev)
794{ 802{
803 struct platform_device *pdev = dev->pdev;
795 struct dvb_frontend *fe = dev->fe; 804 struct dvb_frontend *fe = dev->fe;
796 struct dtv_frontend_properties *c = &fe->dtv_property_cache; 805 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
797 struct v4l2_ctrl *bandwidth_auto; 806 struct v4l2_ctrl *bandwidth_auto;
@@ -819,8 +828,8 @@ static int rtl2832_sdr_set_tuner_freq(struct rtl2832_sdr_dev *dev)
819 c->frequency = dev->f_tuner; 828 c->frequency = dev->f_tuner;
820 c->delivery_system = SYS_DVBT; 829 c->delivery_system = SYS_DVBT;
821 830
822 dev_dbg(&dev->udev->dev, "frequency=%u bandwidth=%d\n", 831 dev_dbg(&pdev->dev, "frequency=%u bandwidth=%d\n",
823 c->frequency, c->bandwidth_hz); 832 c->frequency, c->bandwidth_hz);
824 833
825 if (!test_bit(POWER_ON, &dev->flags)) 834 if (!test_bit(POWER_ON, &dev->flags))
826 return 0; 835 return 0;
@@ -833,9 +842,10 @@ static int rtl2832_sdr_set_tuner_freq(struct rtl2832_sdr_dev *dev)
833 842
834static int rtl2832_sdr_set_tuner(struct rtl2832_sdr_dev *dev) 843static int rtl2832_sdr_set_tuner(struct rtl2832_sdr_dev *dev)
835{ 844{
845 struct platform_device *pdev = dev->pdev;
836 struct dvb_frontend *fe = dev->fe; 846 struct dvb_frontend *fe = dev->fe;
837 847
838 dev_dbg(&dev->udev->dev, "\n"); 848 dev_dbg(&pdev->dev, "\n");
839 849
840 if (fe->ops.tuner_ops.init) 850 if (fe->ops.tuner_ops.init)
841 fe->ops.tuner_ops.init(fe); 851 fe->ops.tuner_ops.init(fe);
@@ -845,9 +855,10 @@ static int rtl2832_sdr_set_tuner(struct rtl2832_sdr_dev *dev)
845 855
846static void rtl2832_sdr_unset_tuner(struct rtl2832_sdr_dev *dev) 856static void rtl2832_sdr_unset_tuner(struct rtl2832_sdr_dev *dev)
847{ 857{
858 struct platform_device *pdev = dev->pdev;
848 struct dvb_frontend *fe = dev->fe; 859 struct dvb_frontend *fe = dev->fe;
849 860
850 dev_dbg(&dev->udev->dev, "\n"); 861 dev_dbg(&pdev->dev, "\n");
851 862
852 if (fe->ops.tuner_ops.sleep) 863 if (fe->ops.tuner_ops.sleep)
853 fe->ops.tuner_ops.sleep(fe); 864 fe->ops.tuner_ops.sleep(fe);
@@ -858,9 +869,10 @@ static void rtl2832_sdr_unset_tuner(struct rtl2832_sdr_dev *dev)
858static int rtl2832_sdr_start_streaming(struct vb2_queue *vq, unsigned int count) 869static int rtl2832_sdr_start_streaming(struct vb2_queue *vq, unsigned int count)
859{ 870{
860 struct rtl2832_sdr_dev *dev = vb2_get_drv_priv(vq); 871 struct rtl2832_sdr_dev *dev = vb2_get_drv_priv(vq);
872 struct platform_device *pdev = dev->pdev;
861 int ret; 873 int ret;
862 874
863 dev_dbg(&dev->udev->dev, "\n"); 875 dev_dbg(&pdev->dev, "\n");
864 876
865 if (!dev->udev) 877 if (!dev->udev)
866 return -ENODEV; 878 return -ENODEV;
@@ -912,8 +924,9 @@ err:
912static void rtl2832_sdr_stop_streaming(struct vb2_queue *vq) 924static void rtl2832_sdr_stop_streaming(struct vb2_queue *vq)
913{ 925{
914 struct rtl2832_sdr_dev *dev = vb2_get_drv_priv(vq); 926 struct rtl2832_sdr_dev *dev = vb2_get_drv_priv(vq);
927 struct platform_device *pdev = dev->pdev;
915 928
916 dev_dbg(&dev->udev->dev, "\n"); 929 dev_dbg(&pdev->dev, "\n");
917 930
918 mutex_lock(&dev->v4l2_lock); 931 mutex_lock(&dev->v4l2_lock);
919 932
@@ -950,8 +963,9 @@ static int rtl2832_sdr_g_tuner(struct file *file, void *priv,
950 struct v4l2_tuner *v) 963 struct v4l2_tuner *v)
951{ 964{
952 struct rtl2832_sdr_dev *dev = video_drvdata(file); 965 struct rtl2832_sdr_dev *dev = video_drvdata(file);
966 struct platform_device *pdev = dev->pdev;
953 967
954 dev_dbg(&dev->udev->dev, "index=%d type=%d\n", v->index, v->type); 968 dev_dbg(&pdev->dev, "index=%d type=%d\n", v->index, v->type);
955 969
956 if (v->index == 0) { 970 if (v->index == 0) {
957 strlcpy(v->name, "ADC: Realtek RTL2832", sizeof(v->name)); 971 strlcpy(v->name, "ADC: Realtek RTL2832", sizeof(v->name));
@@ -976,8 +990,9 @@ static int rtl2832_sdr_s_tuner(struct file *file, void *priv,
976 const struct v4l2_tuner *v) 990 const struct v4l2_tuner *v)
977{ 991{
978 struct rtl2832_sdr_dev *dev = video_drvdata(file); 992 struct rtl2832_sdr_dev *dev = video_drvdata(file);
993 struct platform_device *pdev = dev->pdev;
979 994
980 dev_dbg(&dev->udev->dev, "\n"); 995 dev_dbg(&pdev->dev, "\n");
981 996
982 if (v->index > 1) 997 if (v->index > 1)
983 return -EINVAL; 998 return -EINVAL;
@@ -988,9 +1003,10 @@ static int rtl2832_sdr_enum_freq_bands(struct file *file, void *priv,
988 struct v4l2_frequency_band *band) 1003 struct v4l2_frequency_band *band)
989{ 1004{
990 struct rtl2832_sdr_dev *dev = video_drvdata(file); 1005 struct rtl2832_sdr_dev *dev = video_drvdata(file);
1006 struct platform_device *pdev = dev->pdev;
991 1007
992 dev_dbg(&dev->udev->dev, "tuner=%d type=%d index=%d\n", 1008 dev_dbg(&pdev->dev, "tuner=%d type=%d index=%d\n",
993 band->tuner, band->type, band->index); 1009 band->tuner, band->type, band->index);
994 1010
995 if (band->tuner == 0) { 1011 if (band->tuner == 0) {
996 if (band->index >= ARRAY_SIZE(bands_adc)) 1012 if (band->index >= ARRAY_SIZE(bands_adc))
@@ -1013,10 +1029,10 @@ static int rtl2832_sdr_g_frequency(struct file *file, void *priv,
1013 struct v4l2_frequency *f) 1029 struct v4l2_frequency *f)
1014{ 1030{
1015 struct rtl2832_sdr_dev *dev = video_drvdata(file); 1031 struct rtl2832_sdr_dev *dev = video_drvdata(file);
1032 struct platform_device *pdev = dev->pdev;
1016 int ret = 0; 1033 int ret = 0;
1017 1034
1018 dev_dbg(&dev->udev->dev, "tuner=%d type=%d\n", 1035 dev_dbg(&pdev->dev, "tuner=%d type=%d\n", f->tuner, f->type);
1019 f->tuner, f->type);
1020 1036
1021 if (f->tuner == 0) { 1037 if (f->tuner == 0) {
1022 f->frequency = dev->f_adc; 1038 f->frequency = dev->f_adc;
@@ -1035,10 +1051,11 @@ static int rtl2832_sdr_s_frequency(struct file *file, void *priv,
1035 const struct v4l2_frequency *f) 1051 const struct v4l2_frequency *f)
1036{ 1052{
1037 struct rtl2832_sdr_dev *dev = video_drvdata(file); 1053 struct rtl2832_sdr_dev *dev = video_drvdata(file);
1054 struct platform_device *pdev = dev->pdev;
1038 int ret, band; 1055 int ret, band;
1039 1056
1040 dev_dbg(&dev->udev->dev, "tuner=%d type=%d frequency=%u\n", 1057 dev_dbg(&pdev->dev, "tuner=%d type=%d frequency=%u\n",
1041 f->tuner, f->type, f->frequency); 1058 f->tuner, f->type, f->frequency);
1042 1059
1043 /* ADC band midpoints */ 1060 /* ADC band midpoints */
1044 #define BAND_ADC_0 ((bands_adc[0].rangehigh + bands_adc[1].rangelow) / 2) 1061 #define BAND_ADC_0 ((bands_adc[0].rangehigh + bands_adc[1].rangelow) / 2)
@@ -1056,13 +1073,13 @@ static int rtl2832_sdr_s_frequency(struct file *file, void *priv,
1056 bands_adc[band].rangelow, 1073 bands_adc[band].rangelow,
1057 bands_adc[band].rangehigh); 1074 bands_adc[band].rangehigh);
1058 1075
1059 dev_dbg(&dev->udev->dev, "ADC frequency=%u Hz\n", dev->f_adc); 1076 dev_dbg(&pdev->dev, "ADC frequency=%u Hz\n", dev->f_adc);
1060 ret = rtl2832_sdr_set_adc(dev); 1077 ret = rtl2832_sdr_set_adc(dev);
1061 } else if (f->tuner == 1) { 1078 } else if (f->tuner == 1) {
1062 dev->f_tuner = clamp_t(unsigned int, f->frequency, 1079 dev->f_tuner = clamp_t(unsigned int, f->frequency,
1063 bands_fm[0].rangelow, 1080 bands_fm[0].rangelow,
1064 bands_fm[0].rangehigh); 1081 bands_fm[0].rangehigh);
1065 dev_dbg(&dev->udev->dev, "RF frequency=%u Hz\n", f->frequency); 1082 dev_dbg(&pdev->dev, "RF frequency=%u Hz\n", f->frequency);
1066 1083
1067 ret = rtl2832_sdr_set_tuner_freq(dev); 1084 ret = rtl2832_sdr_set_tuner_freq(dev);
1068 } else { 1085 } else {
@@ -1076,8 +1093,9 @@ static int rtl2832_sdr_enum_fmt_sdr_cap(struct file *file, void *priv,
1076 struct v4l2_fmtdesc *f) 1093 struct v4l2_fmtdesc *f)
1077{ 1094{
1078 struct rtl2832_sdr_dev *dev = video_drvdata(file); 1095 struct rtl2832_sdr_dev *dev = video_drvdata(file);
1096 struct platform_device *pdev = dev->pdev;
1079 1097
1080 dev_dbg(&dev->udev->dev, "\n"); 1098 dev_dbg(&pdev->dev, "\n");
1081 1099
1082 if (f->index >= dev->num_formats) 1100 if (f->index >= dev->num_formats)
1083 return -EINVAL; 1101 return -EINVAL;
@@ -1092,8 +1110,9 @@ static int rtl2832_sdr_g_fmt_sdr_cap(struct file *file, void *priv,
1092 struct v4l2_format *f) 1110 struct v4l2_format *f)
1093{ 1111{
1094 struct rtl2832_sdr_dev *dev = video_drvdata(file); 1112 struct rtl2832_sdr_dev *dev = video_drvdata(file);
1113 struct platform_device *pdev = dev->pdev;
1095 1114
1096 dev_dbg(&dev->udev->dev, "\n"); 1115 dev_dbg(&pdev->dev, "\n");
1097 1116
1098 f->fmt.sdr.pixelformat = dev->pixelformat; 1117 f->fmt.sdr.pixelformat = dev->pixelformat;
1099 f->fmt.sdr.buffersize = dev->buffersize; 1118 f->fmt.sdr.buffersize = dev->buffersize;
@@ -1107,11 +1126,12 @@ static int rtl2832_sdr_s_fmt_sdr_cap(struct file *file, void *priv,
1107 struct v4l2_format *f) 1126 struct v4l2_format *f)
1108{ 1127{
1109 struct rtl2832_sdr_dev *dev = video_drvdata(file); 1128 struct rtl2832_sdr_dev *dev = video_drvdata(file);
1129 struct platform_device *pdev = dev->pdev;
1110 struct vb2_queue *q = &dev->vb_queue; 1130 struct vb2_queue *q = &dev->vb_queue;
1111 int i; 1131 int i;
1112 1132
1113 dev_dbg(&dev->udev->dev, "pixelformat fourcc %4.4s\n", 1133 dev_dbg(&pdev->dev, "pixelformat fourcc %4.4s\n",
1114 (char *)&f->fmt.sdr.pixelformat); 1134 (char *)&f->fmt.sdr.pixelformat);
1115 1135
1116 if (vb2_is_busy(q)) 1136 if (vb2_is_busy(q))
1117 return -EBUSY; 1137 return -EBUSY;
@@ -1138,10 +1158,11 @@ static int rtl2832_sdr_try_fmt_sdr_cap(struct file *file, void *priv,
1138 struct v4l2_format *f) 1158 struct v4l2_format *f)
1139{ 1159{
1140 struct rtl2832_sdr_dev *dev = video_drvdata(file); 1160 struct rtl2832_sdr_dev *dev = video_drvdata(file);
1161 struct platform_device *pdev = dev->pdev;
1141 int i; 1162 int i;
1142 1163
1143 dev_dbg(&dev->udev->dev, "pixelformat fourcc %4.4s\n", 1164 dev_dbg(&pdev->dev, "pixelformat fourcc %4.4s\n",
1144 (char *)&f->fmt.sdr.pixelformat); 1165 (char *)&f->fmt.sdr.pixelformat);
1145 1166
1146 memset(f->fmt.sdr.reserved, 0, sizeof(f->fmt.sdr.reserved)); 1167 memset(f->fmt.sdr.reserved, 0, sizeof(f->fmt.sdr.reserved));
1147 for (i = 0; i < dev->num_formats; i++) { 1168 for (i = 0; i < dev->num_formats; i++) {
@@ -1210,13 +1231,13 @@ static int rtl2832_sdr_s_ctrl(struct v4l2_ctrl *ctrl)
1210 container_of(ctrl->handler, struct rtl2832_sdr_dev, 1231 container_of(ctrl->handler, struct rtl2832_sdr_dev,
1211 hdl); 1232 hdl);
1212 struct dvb_frontend *fe = dev->fe; 1233 struct dvb_frontend *fe = dev->fe;
1234 struct platform_device *pdev = dev->pdev;
1213 struct dtv_frontend_properties *c = &fe->dtv_property_cache; 1235 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
1214 int ret; 1236 int ret;
1215 1237
1216 dev_dbg(&dev->udev->dev, 1238 dev_dbg(&pdev->dev, "id=%d name=%s val=%d min=%lld max=%lld step=%lld\n",
1217 "id=%d name=%s val=%d min=%lld max=%lld step=%lld\n", 1239 ctrl->id, ctrl->name, ctrl->val, ctrl->minimum, ctrl->maximum,
1218 ctrl->id, ctrl->name, ctrl->val, 1240 ctrl->step);
1219 ctrl->minimum, ctrl->maximum, ctrl->step);
1220 1241
1221 switch (ctrl->id) { 1242 switch (ctrl->id) {
1222 case V4L2_CID_RF_TUNER_BANDWIDTH_AUTO: 1243 case V4L2_CID_RF_TUNER_BANDWIDTH_AUTO:
@@ -1375,7 +1396,7 @@ static int rtl2832_sdr_probe(struct platform_device *pdev)
1375 1396
1376 /* Register the v4l2_device structure */ 1397 /* Register the v4l2_device structure */
1377 dev->v4l2_dev.release = rtl2832_sdr_video_release; 1398 dev->v4l2_dev.release = rtl2832_sdr_video_release;
1378 ret = v4l2_device_register(&dev->udev->dev, &dev->v4l2_dev); 1399 ret = v4l2_device_register(&pdev->dev, &dev->v4l2_dev);
1379 if (ret) { 1400 if (ret) {
1380 dev_err(&pdev->dev, "Failed to register v4l2-device %d\n", ret); 1401 dev_err(&pdev->dev, "Failed to register v4l2-device %d\n", ret);
1381 goto err_v4l2_ctrl_handler_free; 1402 goto err_v4l2_ctrl_handler_free;