aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging
diff options
context:
space:
mode:
authorTomas Winkler <tomas.winkler@intel.com>2011-11-09 06:26:35 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2011-11-24 16:12:53 -0500
commit101dca425da49edb3093000d72490216fa322911 (patch)
treed2cfbb4d549ca851a208a22dbff3d7f71e6c2c57 /drivers/staging
parent7dbb3920252dcb3662e934b134ccb5129f62cbad (diff)
[media] easycap: streamline the code
change statements of types if (err) return err else do something and if (ok) do something else return err into if (err) return err do something Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/staging')
-rw-r--r--drivers/staging/media/easycap/easycap_ioctl.c37
-rw-r--r--drivers/staging/media/easycap/easycap_low.c26
-rw-r--r--drivers/staging/media/easycap/easycap_main.c127
3 files changed, 88 insertions, 102 deletions
diff --git a/drivers/staging/media/easycap/easycap_ioctl.c b/drivers/staging/media/easycap/easycap_ioctl.c
index acb9c842ca33..ccab5cace240 100644
--- a/drivers/staging/media/easycap/easycap_ioctl.c
+++ b/drivers/staging/media/easycap/easycap_ioctl.c
@@ -666,16 +666,15 @@ int adjust_brightness(struct easycap *peasycap, int value)
666 peasycap->inputset[peasycap->input].brightness_ok = 1; 666 peasycap->inputset[peasycap->input].brightness_ok = 1;
667 } else 667 } else
668 JOM(8, "%i=peasycap->input\n", peasycap->input); 668 JOM(8, "%i=peasycap->input\n", peasycap->input);
669
669 mood = 0x00FF & (unsigned int)peasycap->brightness; 670 mood = 0x00FF & (unsigned int)peasycap->brightness;
670 if (!write_saa(peasycap->pusb_device, 0x0A, mood)) { 671 if (write_saa(peasycap->pusb_device, 0x0A, mood)) {
671 SAM("adjusting brightness to 0x%02X\n", mood);
672 return 0;
673 } else {
674 SAM("WARNING: failed to adjust brightness " 672 SAM("WARNING: failed to adjust brightness "
675 "to 0x%02X\n", mood); 673 "to 0x%02X\n", mood);
676 return -ENOENT; 674 return -ENOENT;
677 } 675 }
678 break; 676 SAM("adjusting brightness to 0x%02X\n", mood);
677 return 0;
679 } 678 }
680 i1++; 679 i1++;
681 } 680 }
@@ -725,15 +724,13 @@ int adjust_contrast(struct easycap *peasycap, int value)
725 JOM(8, "%i=peasycap->input\n", peasycap->input); 724 JOM(8, "%i=peasycap->input\n", peasycap->input);
726 725
727 mood = 0x00FF & (unsigned int) (peasycap->contrast - 128); 726 mood = 0x00FF & (unsigned int) (peasycap->contrast - 128);
728 if (!write_saa(peasycap->pusb_device, 0x0B, mood)) { 727 if (write_saa(peasycap->pusb_device, 0x0B, mood)) {
729 SAM("adjusting contrast to 0x%02X\n", mood);
730 return 0;
731 } else {
732 SAM("WARNING: failed to adjust contrast to " 728 SAM("WARNING: failed to adjust contrast to "
733 "0x%02X\n", mood); 729 "0x%02X\n", mood);
734 return -ENOENT; 730 return -ENOENT;
735 } 731 }
736 break; 732 SAM("adjusting contrast to 0x%02X\n", mood);
733 return 0;
737 } 734 }
738 i1++; 735 i1++;
739 } 736 }
@@ -783,14 +780,13 @@ int adjust_saturation(struct easycap *peasycap, int value)
783 } else 780 } else
784 JOM(8, "%i=peasycap->input\n", peasycap->input); 781 JOM(8, "%i=peasycap->input\n", peasycap->input);
785 mood = 0x00FF & (unsigned int) (peasycap->saturation - 128); 782 mood = 0x00FF & (unsigned int) (peasycap->saturation - 128);
786 if (!write_saa(peasycap->pusb_device, 0x0C, mood)) { 783 if (write_saa(peasycap->pusb_device, 0x0C, mood)) {
787 SAM("adjusting saturation to 0x%02X\n", mood);
788 return 0;
789 } else {
790 SAM("WARNING: failed to adjust saturation to " 784 SAM("WARNING: failed to adjust saturation to "
791 "0x%02X\n", mood); 785 "0x%02X\n", mood);
792 return -ENOENT; 786 return -ENOENT;
793 } 787 }
788 SAM("adjusting saturation to 0x%02X\n", mood);
789 return 0;
794 break; 790 break;
795 } 791 }
796 i1++; 792 i1++;
@@ -838,13 +834,12 @@ int adjust_hue(struct easycap *peasycap, int value)
838 JOM(8, "%i=peasycap->input\n", peasycap->input); 834 JOM(8, "%i=peasycap->input\n", peasycap->input);
839 i2 = peasycap->hue - 128; 835 i2 = peasycap->hue - 128;
840 mood = 0x00FF & ((int) i2); 836 mood = 0x00FF & ((int) i2);
841 if (!write_saa(peasycap->pusb_device, 0x0D, mood)) { 837 if (write_saa(peasycap->pusb_device, 0x0D, mood)) {
842 SAM("adjusting hue to 0x%02X\n", mood);
843 return 0;
844 } else {
845 SAM("WARNING: failed to adjust hue to 0x%02X\n", mood); 838 SAM("WARNING: failed to adjust hue to 0x%02X\n", mood);
846 return -ENOENT; 839 return -ENOENT;
847 } 840 }
841 SAM("adjusting hue to 0x%02X\n", mood);
842 return 0;
848 break; 843 break;
849 } 844 }
850 i1++; 845 i1++;
@@ -885,14 +880,12 @@ static int adjust_volume(struct easycap *peasycap, int value)
885 ((31 < peasycap->volume) ? 31 : 880 ((31 < peasycap->volume) ? 31 :
886 (s8) peasycap->volume); 881 (s8) peasycap->volume);
887 if (!audio_gainset(peasycap->pusb_device, mood)) { 882 if (!audio_gainset(peasycap->pusb_device, mood)) {
888 SAM("adjusting volume to 0x%02X\n", mood);
889 return 0;
890 } else {
891 SAM("WARNING: failed to adjust volume to " 883 SAM("WARNING: failed to adjust volume to "
892 "0x%2X\n", mood); 884 "0x%2X\n", mood);
893 return -ENOENT; 885 return -ENOENT;
894 } 886 }
895 break; 887 SAM("adjusting volume to 0x%02X\n", mood);
888 return 0;
896 } 889 }
897 i1++; 890 i1++;
898 } 891 }
diff --git a/drivers/staging/media/easycap/easycap_low.c b/drivers/staging/media/easycap/easycap_low.c
index ef37de88a6b5..212830b177cc 100644
--- a/drivers/staging/media/easycap/easycap_low.c
+++ b/drivers/staging/media/easycap/easycap_low.c
@@ -514,22 +514,22 @@ int ready_saa(struct usb_device *p)
514 msleep(marktime); 514 msleep(marktime);
515 j++; 515 j++;
516 } 516 }
517
517 if (max == j) 518 if (max == j)
518 return -1; 519 return -1;
520
521 if (0x20 & rc) {
522 rate = 2;
523 JOT(8, "hardware detects 60 Hz\n");
524 } else {
525 rate = 0;
526 JOT(8, "hardware detects 50 Hz\n");
527 }
528 if (0x80 & rc)
529 JOT(8, "hardware detects interlacing\n");
519 else { 530 else {
520 if (0x20 & rc) { 531 rate++;
521 rate = 2; 532 JOT(8, "hardware detects no interlacing\n");
522 JOT(8, "hardware detects 60 Hz\n");
523 } else {
524 rate = 0;
525 JOT(8, "hardware detects 50 Hz\n");
526 }
527 if (0x80 & rc)
528 JOT(8, "hardware detects interlacing\n");
529 else {
530 rate++;
531 JOT(8, "hardware detects no interlacing\n");
532 }
533 } 533 }
534 return 0; 534 return 0;
535} 535}
diff --git a/drivers/staging/media/easycap/easycap_main.c b/drivers/staging/media/easycap/easycap_main.c
index 94fd1167d4a8..044c762f337a 100644
--- a/drivers/staging/media/easycap/easycap_main.c
+++ b/drivers/staging/media/easycap/easycap_main.c
@@ -165,14 +165,13 @@ static int easycap_open(struct inode *inode, struct file *file)
165 if (!peasycap->pusb_device) { 165 if (!peasycap->pusb_device) {
166 SAM("ERROR: peasycap->pusb_device is NULL\n"); 166 SAM("ERROR: peasycap->pusb_device is NULL\n");
167 return -EFAULT; 167 return -EFAULT;
168 } else {
169 JOM(16, "peasycap->pusb_device=%p\n", peasycap->pusb_device);
170 } 168 }
169
170 JOM(16, "peasycap->pusb_device=%p\n", peasycap->pusb_device);
171
171 file->private_data = peasycap; 172 file->private_data = peasycap;
172 rc = wakeup_device(peasycap->pusb_device); 173 rc = wakeup_device(peasycap->pusb_device);
173 if (0 == rc) 174 if (rc) {
174 JOM(8, "wakeup_device() OK\n");
175 else {
176 SAM("ERROR: wakeup_device() rc = %i\n", rc); 175 SAM("ERROR: wakeup_device() rc = %i\n", rc);
177 if (-ENODEV == rc) 176 if (-ENODEV == rc)
178 SAM("ERROR: wakeup_device() returned -ENODEV\n"); 177 SAM("ERROR: wakeup_device() returned -ENODEV\n");
@@ -180,6 +179,7 @@ static int easycap_open(struct inode *inode, struct file *file)
180 SAM("ERROR: wakeup_device() rc = %i\n", rc); 179 SAM("ERROR: wakeup_device() rc = %i\n", rc);
181 return rc; 180 return rc;
182 } 181 }
182 JOM(8, "wakeup_device() OK\n");
183 peasycap->input = 0; 183 peasycap->input = 0;
184 rc = reset(peasycap); 184 rc = reset(peasycap);
185 if (rc) { 185 if (rc) {
@@ -987,11 +987,11 @@ static unsigned int easycap_poll(struct file *file, poll_table *wait)
987 rc = easycap_dqbuf(peasycap, 0); 987 rc = easycap_dqbuf(peasycap, 0);
988 peasycap->polled = 1; 988 peasycap->polled = 1;
989 mutex_unlock(&easycapdc60_dongle[kd].mutex_video); 989 mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
990 if (0 == rc) 990 if (rc)
991 return POLLIN | POLLRDNORM;
992 else
993 return POLLERR; 991 return POLLERR;
994 } 992
993 return POLLIN | POLLRDNORM;
994}
995/*****************************************************************************/ 995/*****************************************************************************/
996/*---------------------------------------------------------------------------*/ 996/*---------------------------------------------------------------------------*/
997/* 997/*
@@ -2920,6 +2920,7 @@ static int easycap_usb_probe(struct usb_interface *intf,
2920 SAY("ERROR: usb_host_interface not found\n"); 2920 SAY("ERROR: usb_host_interface not found\n");
2921 return -EFAULT; 2921 return -EFAULT;
2922 } 2922 }
2923
2923 interface = &alt->desc; 2924 interface = &alt->desc;
2924 if (!interface) { 2925 if (!interface) {
2925 SAY("ERROR: intf_descriptor is NULL\n"); 2926 SAY("ERROR: intf_descriptor is NULL\n");
@@ -2979,38 +2980,30 @@ static int easycap_usb_probe(struct usb_interface *intf,
2979 if (mutex_lock_interruptible(&mutex_dongle)) { 2980 if (mutex_lock_interruptible(&mutex_dongle)) {
2980 SAY("ERROR: cannot down mutex_dongle\n"); 2981 SAY("ERROR: cannot down mutex_dongle\n");
2981 return -ERESTARTSYS; 2982 return -ERESTARTSYS;
2982 } else { 2983 }
2983/*---------------------------------------------------------------------------*/ 2984
2984 /* 2985 for (ndong = 0; ndong < DONGLE_MANY; ndong++) {
2985 * FOR INTERFACES 1 AND 2 THE POINTER peasycap WILL NEED TO 2986 if ((!easycapdc60_dongle[ndong].peasycap) &&
2986 * TO BE THE SAME AS THAT ALLOCATED NOW FOR INTERFACE 0. 2987 (!mutex_is_locked(&easycapdc60_dongle
2987 * 2988 [ndong].mutex_video)) &&
2988 * NORMALLY ndong WILL NOT HAVE CHANGED SINCE INTERFACE 0 WAS 2989 (!mutex_is_locked(&easycapdc60_dongle
2989 * PROBED, BUT THIS MAY NOT BE THE CASE IF, FOR EXAMPLE, TWO 2990 [ndong].mutex_audio))) {
2990 * EASYCAPs ARE PLUGGED IN SIMULTANEOUSLY. 2991 easycapdc60_dongle[ndong].peasycap = peasycap;
2991 */ 2992 peasycap->isdongle = ndong;
2992/*---------------------------------------------------------------------------*/ 2993 JOM(8, "intf[%i]: peasycap-->easycap"
2993 for (ndong = 0; ndong < DONGLE_MANY; ndong++) { 2994 "_dongle[%i].peasycap\n",
2994 if ((!easycapdc60_dongle[ndong].peasycap) && 2995 bInterfaceNumber, ndong);
2995 (!mutex_is_locked(&easycapdc60_dongle 2996 break;
2996 [ndong].mutex_video)) &&
2997 (!mutex_is_locked(&easycapdc60_dongle
2998 [ndong].mutex_audio))) {
2999 easycapdc60_dongle[ndong].peasycap = peasycap;
3000 peasycap->isdongle = ndong;
3001 JOM(8, "intf[%i]: peasycap-->easycap"
3002 "_dongle[%i].peasycap\n",
3003 bInterfaceNumber, ndong);
3004 break;
3005 }
3006 }
3007 if (DONGLE_MANY <= ndong) {
3008 SAM("ERROR: too many dongles\n");
3009 mutex_unlock(&mutex_dongle);
3010 return -ENOMEM;
3011 } 2997 }
2998 }
2999
3000 if (DONGLE_MANY <= ndong) {
3001 SAM("ERROR: too many dongles\n");
3012 mutex_unlock(&mutex_dongle); 3002 mutex_unlock(&mutex_dongle);
3003 return -ENOMEM;
3013 } 3004 }
3005 mutex_unlock(&mutex_dongle);
3006
3014 peasycap->allocation_video_struct = sizeof(struct easycap); 3007 peasycap->allocation_video_struct = sizeof(struct easycap);
3015 peasycap->allocation_video_page = 0; 3008 peasycap->allocation_video_page = 0;
3016 peasycap->allocation_video_urb = 0; 3009 peasycap->allocation_video_urb = 0;
@@ -3393,11 +3386,10 @@ static int easycap_usb_probe(struct usb_interface *intf,
3393 if (!isokalt) { 3386 if (!isokalt) {
3394 SAM("ERROR: no viable video_altsetting_on\n"); 3387 SAM("ERROR: no viable video_altsetting_on\n");
3395 return -ENOENT; 3388 return -ENOENT;
3396 } else {
3397 peasycap->video_altsetting_on = okalt[isokalt - 1];
3398 JOM(4, "%i=video_altsetting_on <====\n",
3399 peasycap->video_altsetting_on);
3400 } 3389 }
3390 peasycap->video_altsetting_on = okalt[isokalt - 1];
3391 JOM(4, "%i=video_altsetting_on <====\n",
3392 peasycap->video_altsetting_on);
3401/*---------------------------------------------------------------------------*/ 3393/*---------------------------------------------------------------------------*/
3402/* 3394/*
3403 * DECIDE THE VIDEO STREAMING PARAMETERS 3395 * DECIDE THE VIDEO STREAMING PARAMETERS
@@ -3483,8 +3475,9 @@ static int easycap_usb_probe(struct usb_interface *intf,
3483 SAM("ERROR: Could not allocate frame " 3475 SAM("ERROR: Could not allocate frame "
3484 "buffer %i page %i\n", k, m); 3476 "buffer %i page %i\n", k, m);
3485 return -ENOMEM; 3477 return -ENOMEM;
3486 } else 3478 }
3487 peasycap->allocation_video_page += 1; 3479
3480 peasycap->allocation_video_page += 1;
3488 peasycap->frame_buffer[k][m].pgo = pbuf; 3481 peasycap->frame_buffer[k][m].pgo = pbuf;
3489 } 3482 }
3490 peasycap->frame_buffer[k][m].pto = 3483 peasycap->frame_buffer[k][m].pto =
@@ -3513,11 +3506,11 @@ static int easycap_usb_probe(struct usb_interface *intf,
3513 SAM("ERROR: Could not allocate field" 3506 SAM("ERROR: Could not allocate field"
3514 " buffer %i page %i\n", k, m); 3507 " buffer %i page %i\n", k, m);
3515 return -ENOMEM; 3508 return -ENOMEM;
3516 }
3517 else
3518 peasycap->allocation_video_page += 1;
3519 peasycap->field_buffer[k][m].pgo = pbuf;
3520 } 3509 }
3510
3511 peasycap->allocation_video_page += 1;
3512 peasycap->field_buffer[k][m].pgo = pbuf;
3513 }
3521 peasycap->field_buffer[k][m].pto = 3514 peasycap->field_buffer[k][m].pto =
3522 peasycap->field_buffer[k][m].pgo; 3515 peasycap->field_buffer[k][m].pgo;
3523 } 3516 }
@@ -3541,9 +3534,9 @@ static int easycap_usb_probe(struct usb_interface *intf,
3541 SAM("ERROR: Could not allocate isoc video buffer " 3534 SAM("ERROR: Could not allocate isoc video buffer "
3542 "%i\n", k); 3535 "%i\n", k);
3543 return -ENOMEM; 3536 return -ENOMEM;
3544 } else 3537 }
3545 peasycap->allocation_video_page += 3538 peasycap->allocation_video_page +=
3546 BIT(VIDEO_ISOC_ORDER); 3539 BIT(VIDEO_ISOC_ORDER);
3547 3540
3548 peasycap->video_isoc_buffer[k].pgo = pbuf; 3541 peasycap->video_isoc_buffer[k].pgo = pbuf;
3549 peasycap->video_isoc_buffer[k].pto = 3542 peasycap->video_isoc_buffer[k].pto =
@@ -3572,15 +3565,17 @@ static int easycap_usb_probe(struct usb_interface *intf,
3572 SAM("ERROR: usb_alloc_urb returned NULL for buffer " 3565 SAM("ERROR: usb_alloc_urb returned NULL for buffer "
3573 "%i\n", k); 3566 "%i\n", k);
3574 return -ENOMEM; 3567 return -ENOMEM;
3575 } else 3568 }
3576 peasycap->allocation_video_urb += 1; 3569
3570 peasycap->allocation_video_urb += 1;
3577/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ 3571/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
3578 pdata_urb = kzalloc(sizeof(struct data_urb), GFP_KERNEL); 3572 pdata_urb = kzalloc(sizeof(struct data_urb), GFP_KERNEL);
3579 if (!pdata_urb) { 3573 if (!pdata_urb) {
3580 SAM("ERROR: Could not allocate struct data_urb.\n"); 3574 SAM("ERROR: Could not allocate struct data_urb.\n");
3581 return -ENOMEM; 3575 return -ENOMEM;
3582 } else 3576 }
3583 peasycap->allocation_video_struct += 3577
3578 peasycap->allocation_video_struct +=
3584 sizeof(struct data_urb); 3579 sizeof(struct data_urb);
3585 3580
3586 pdata_urb->purb = purb; 3581 pdata_urb->purb = purb;
@@ -3697,13 +3692,12 @@ static int easycap_usb_probe(struct usb_interface *intf,
3697 err("Not able to register with videodev"); 3692 err("Not able to register with videodev");
3698 videodev_release(&(peasycap->video_device)); 3693 videodev_release(&(peasycap->video_device));
3699 return -ENODEV; 3694 return -ENODEV;
3700 } else {
3701 (peasycap->registered_video)++;
3702 SAM("registered with videodev: %i=minor\n",
3703 peasycap->video_device.minor);
3704 peasycap->minor = peasycap->video_device.minor;
3705 } 3695 }
3706/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ 3696
3697 peasycap->registered_video++;
3698 SAM("registered with videodev: %i=minor\n",
3699 peasycap->video_device.minor);
3700 peasycap->minor = peasycap->video_device.minor;
3707 3701
3708 break; 3702 break;
3709 } 3703 }
@@ -3737,11 +3731,10 @@ static int easycap_usb_probe(struct usb_interface *intf,
3737 if (!isokalt) { 3731 if (!isokalt) {
3738 SAM("ERROR: no viable audio_altsetting_on\n"); 3732 SAM("ERROR: no viable audio_altsetting_on\n");
3739 return -ENOENT; 3733 return -ENOENT;
3740 } else {
3741 peasycap->audio_altsetting_on = okalt[isokalt - 1];
3742 JOM(4, "%i=audio_altsetting_on <====\n",
3743 peasycap->audio_altsetting_on);
3744 } 3734 }
3735 peasycap->audio_altsetting_on = okalt[isokalt - 1];
3736 JOM(4, "%i=audio_altsetting_on <====\n",
3737 peasycap->audio_altsetting_on);
3745 3738
3746 peasycap->audio_endpointnumber = okepn[isokalt - 1]; 3739 peasycap->audio_endpointnumber = okepn[isokalt - 1];
3747 JOM(4, "%i=audio_endpointnumber\n", peasycap->audio_endpointnumber); 3740 JOM(4, "%i=audio_endpointnumber\n", peasycap->audio_endpointnumber);
@@ -3850,8 +3843,8 @@ static int easycap_usb_probe(struct usb_interface *intf,
3850 SAM("ERROR: Could not allocate isoc audio buffer " 3843 SAM("ERROR: Could not allocate isoc audio buffer "
3851 "%i\n", k); 3844 "%i\n", k);
3852 return -ENOMEM; 3845 return -ENOMEM;
3853 } else 3846 }
3854 peasycap->allocation_audio_page += 3847 peasycap->allocation_audio_page +=
3855 BIT(AUDIO_ISOC_ORDER); 3848 BIT(AUDIO_ISOC_ORDER);
3856 3849
3857 peasycap->audio_isoc_buffer[k].pgo = pbuf; 3850 peasycap->audio_isoc_buffer[k].pgo = pbuf;