Commit 101dca42 authored by Tomas Winkler's avatar Tomas Winkler Committed by Mauro Carvalho Chehab

[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: default avatarTomas Winkler <tomas.winkler@intel.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 7dbb3920
...@@ -666,16 +666,15 @@ int adjust_brightness(struct easycap *peasycap, int value) ...@@ -666,16 +666,15 @@ int adjust_brightness(struct easycap *peasycap, int value)
peasycap->inputset[peasycap->input].brightness_ok = 1; peasycap->inputset[peasycap->input].brightness_ok = 1;
} else } else
JOM(8, "%i=peasycap->input\n", peasycap->input); JOM(8, "%i=peasycap->input\n", peasycap->input);
mood = 0x00FF & (unsigned int)peasycap->brightness; mood = 0x00FF & (unsigned int)peasycap->brightness;
if (!write_saa(peasycap->pusb_device, 0x0A, mood)) { if (write_saa(peasycap->pusb_device, 0x0A, mood)) {
SAM("adjusting brightness to 0x%02X\n", mood);
return 0;
} else {
SAM("WARNING: failed to adjust brightness " SAM("WARNING: failed to adjust brightness "
"to 0x%02X\n", mood); "to 0x%02X\n", mood);
return -ENOENT; return -ENOENT;
} }
break; SAM("adjusting brightness to 0x%02X\n", mood);
return 0;
} }
i1++; i1++;
} }
...@@ -725,15 +724,13 @@ int adjust_contrast(struct easycap *peasycap, int value) ...@@ -725,15 +724,13 @@ int adjust_contrast(struct easycap *peasycap, int value)
JOM(8, "%i=peasycap->input\n", peasycap->input); JOM(8, "%i=peasycap->input\n", peasycap->input);
mood = 0x00FF & (unsigned int) (peasycap->contrast - 128); mood = 0x00FF & (unsigned int) (peasycap->contrast - 128);
if (!write_saa(peasycap->pusb_device, 0x0B, mood)) { if (write_saa(peasycap->pusb_device, 0x0B, mood)) {
SAM("adjusting contrast to 0x%02X\n", mood);
return 0;
} else {
SAM("WARNING: failed to adjust contrast to " SAM("WARNING: failed to adjust contrast to "
"0x%02X\n", mood); "0x%02X\n", mood);
return -ENOENT; return -ENOENT;
} }
break; SAM("adjusting contrast to 0x%02X\n", mood);
return 0;
} }
i1++; i1++;
} }
...@@ -783,14 +780,13 @@ int adjust_saturation(struct easycap *peasycap, int value) ...@@ -783,14 +780,13 @@ int adjust_saturation(struct easycap *peasycap, int value)
} else } else
JOM(8, "%i=peasycap->input\n", peasycap->input); JOM(8, "%i=peasycap->input\n", peasycap->input);
mood = 0x00FF & (unsigned int) (peasycap->saturation - 128); mood = 0x00FF & (unsigned int) (peasycap->saturation - 128);
if (!write_saa(peasycap->pusb_device, 0x0C, mood)) { if (write_saa(peasycap->pusb_device, 0x0C, mood)) {
SAM("adjusting saturation to 0x%02X\n", mood);
return 0;
} else {
SAM("WARNING: failed to adjust saturation to " SAM("WARNING: failed to adjust saturation to "
"0x%02X\n", mood); "0x%02X\n", mood);
return -ENOENT; return -ENOENT;
} }
SAM("adjusting saturation to 0x%02X\n", mood);
return 0;
break; break;
} }
i1++; i1++;
...@@ -838,13 +834,12 @@ int adjust_hue(struct easycap *peasycap, int value) ...@@ -838,13 +834,12 @@ int adjust_hue(struct easycap *peasycap, int value)
JOM(8, "%i=peasycap->input\n", peasycap->input); JOM(8, "%i=peasycap->input\n", peasycap->input);
i2 = peasycap->hue - 128; i2 = peasycap->hue - 128;
mood = 0x00FF & ((int) i2); mood = 0x00FF & ((int) i2);
if (!write_saa(peasycap->pusb_device, 0x0D, mood)) { if (write_saa(peasycap->pusb_device, 0x0D, mood)) {
SAM("adjusting hue to 0x%02X\n", mood);
return 0;
} else {
SAM("WARNING: failed to adjust hue to 0x%02X\n", mood); SAM("WARNING: failed to adjust hue to 0x%02X\n", mood);
return -ENOENT; return -ENOENT;
} }
SAM("adjusting hue to 0x%02X\n", mood);
return 0;
break; break;
} }
i1++; i1++;
...@@ -885,14 +880,12 @@ static int adjust_volume(struct easycap *peasycap, int value) ...@@ -885,14 +880,12 @@ static int adjust_volume(struct easycap *peasycap, int value)
((31 < peasycap->volume) ? 31 : ((31 < peasycap->volume) ? 31 :
(s8) peasycap->volume); (s8) peasycap->volume);
if (!audio_gainset(peasycap->pusb_device, mood)) { if (!audio_gainset(peasycap->pusb_device, mood)) {
SAM("adjusting volume to 0x%02X\n", mood);
return 0;
} else {
SAM("WARNING: failed to adjust volume to " SAM("WARNING: failed to adjust volume to "
"0x%2X\n", mood); "0x%2X\n", mood);
return -ENOENT; return -ENOENT;
} }
break; SAM("adjusting volume to 0x%02X\n", mood);
return 0;
} }
i1++; i1++;
} }
......
...@@ -514,9 +514,10 @@ int ready_saa(struct usb_device *p) ...@@ -514,9 +514,10 @@ int ready_saa(struct usb_device *p)
msleep(marktime); msleep(marktime);
j++; j++;
} }
if (max == j) if (max == j)
return -1; return -1;
else {
if (0x20 & rc) { if (0x20 & rc) {
rate = 2; rate = 2;
JOT(8, "hardware detects 60 Hz\n"); JOT(8, "hardware detects 60 Hz\n");
...@@ -530,7 +531,6 @@ int ready_saa(struct usb_device *p) ...@@ -530,7 +531,6 @@ int ready_saa(struct usb_device *p)
rate++; rate++;
JOT(8, "hardware detects no interlacing\n"); JOT(8, "hardware detects no interlacing\n");
} }
}
return 0; return 0;
} }
/****************************************************************************/ /****************************************************************************/
......
...@@ -165,14 +165,13 @@ static int easycap_open(struct inode *inode, struct file *file) ...@@ -165,14 +165,13 @@ static int easycap_open(struct inode *inode, struct file *file)
if (!peasycap->pusb_device) { if (!peasycap->pusb_device) {
SAM("ERROR: peasycap->pusb_device is NULL\n"); SAM("ERROR: peasycap->pusb_device is NULL\n");
return -EFAULT; return -EFAULT;
} else {
JOM(16, "peasycap->pusb_device=%p\n", peasycap->pusb_device);
} }
JOM(16, "peasycap->pusb_device=%p\n", peasycap->pusb_device);
file->private_data = peasycap; file->private_data = peasycap;
rc = wakeup_device(peasycap->pusb_device); rc = wakeup_device(peasycap->pusb_device);
if (0 == rc) if (rc) {
JOM(8, "wakeup_device() OK\n");
else {
SAM("ERROR: wakeup_device() rc = %i\n", rc); SAM("ERROR: wakeup_device() rc = %i\n", rc);
if (-ENODEV == rc) if (-ENODEV == rc)
SAM("ERROR: wakeup_device() returned -ENODEV\n"); SAM("ERROR: wakeup_device() returned -ENODEV\n");
...@@ -180,6 +179,7 @@ static int easycap_open(struct inode *inode, struct file *file) ...@@ -180,6 +179,7 @@ static int easycap_open(struct inode *inode, struct file *file)
SAM("ERROR: wakeup_device() rc = %i\n", rc); SAM("ERROR: wakeup_device() rc = %i\n", rc);
return rc; return rc;
} }
JOM(8, "wakeup_device() OK\n");
peasycap->input = 0; peasycap->input = 0;
rc = reset(peasycap); rc = reset(peasycap);
if (rc) { if (rc) {
...@@ -987,11 +987,11 @@ static unsigned int easycap_poll(struct file *file, poll_table *wait) ...@@ -987,11 +987,11 @@ static unsigned int easycap_poll(struct file *file, poll_table *wait)
rc = easycap_dqbuf(peasycap, 0); rc = easycap_dqbuf(peasycap, 0);
peasycap->polled = 1; peasycap->polled = 1;
mutex_unlock(&easycapdc60_dongle[kd].mutex_video); mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
if (0 == rc) if (rc)
return POLLIN | POLLRDNORM;
else
return POLLERR; return POLLERR;
}
return POLLIN | POLLRDNORM;
}
/*****************************************************************************/ /*****************************************************************************/
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* /*
...@@ -2920,6 +2920,7 @@ static int easycap_usb_probe(struct usb_interface *intf, ...@@ -2920,6 +2920,7 @@ static int easycap_usb_probe(struct usb_interface *intf,
SAY("ERROR: usb_host_interface not found\n"); SAY("ERROR: usb_host_interface not found\n");
return -EFAULT; return -EFAULT;
} }
interface = &alt->desc; interface = &alt->desc;
if (!interface) { if (!interface) {
SAY("ERROR: intf_descriptor is NULL\n"); SAY("ERROR: intf_descriptor is NULL\n");
...@@ -2979,17 +2980,8 @@ static int easycap_usb_probe(struct usb_interface *intf, ...@@ -2979,17 +2980,8 @@ static int easycap_usb_probe(struct usb_interface *intf,
if (mutex_lock_interruptible(&mutex_dongle)) { if (mutex_lock_interruptible(&mutex_dongle)) {
SAY("ERROR: cannot down mutex_dongle\n"); SAY("ERROR: cannot down mutex_dongle\n");
return -ERESTARTSYS; return -ERESTARTSYS;
} else { }
/*---------------------------------------------------------------------------*/
/*
* FOR INTERFACES 1 AND 2 THE POINTER peasycap WILL NEED TO
* TO BE THE SAME AS THAT ALLOCATED NOW FOR INTERFACE 0.
*
* NORMALLY ndong WILL NOT HAVE CHANGED SINCE INTERFACE 0 WAS
* PROBED, BUT THIS MAY NOT BE THE CASE IF, FOR EXAMPLE, TWO
* EASYCAPs ARE PLUGGED IN SIMULTANEOUSLY.
*/
/*---------------------------------------------------------------------------*/
for (ndong = 0; ndong < DONGLE_MANY; ndong++) { for (ndong = 0; ndong < DONGLE_MANY; ndong++) {
if ((!easycapdc60_dongle[ndong].peasycap) && if ((!easycapdc60_dongle[ndong].peasycap) &&
(!mutex_is_locked(&easycapdc60_dongle (!mutex_is_locked(&easycapdc60_dongle
...@@ -3004,13 +2996,14 @@ static int easycap_usb_probe(struct usb_interface *intf, ...@@ -3004,13 +2996,14 @@ static int easycap_usb_probe(struct usb_interface *intf,
break; break;
} }
} }
if (DONGLE_MANY <= ndong) { if (DONGLE_MANY <= ndong) {
SAM("ERROR: too many dongles\n"); SAM("ERROR: too many dongles\n");
mutex_unlock(&mutex_dongle); mutex_unlock(&mutex_dongle);
return -ENOMEM; return -ENOMEM;
} }
mutex_unlock(&mutex_dongle); mutex_unlock(&mutex_dongle);
}
peasycap->allocation_video_struct = sizeof(struct easycap); peasycap->allocation_video_struct = sizeof(struct easycap);
peasycap->allocation_video_page = 0; peasycap->allocation_video_page = 0;
peasycap->allocation_video_urb = 0; peasycap->allocation_video_urb = 0;
...@@ -3393,11 +3386,10 @@ static int easycap_usb_probe(struct usb_interface *intf, ...@@ -3393,11 +3386,10 @@ static int easycap_usb_probe(struct usb_interface *intf,
if (!isokalt) { if (!isokalt) {
SAM("ERROR: no viable video_altsetting_on\n"); SAM("ERROR: no viable video_altsetting_on\n");
return -ENOENT; return -ENOENT;
} else { }
peasycap->video_altsetting_on = okalt[isokalt - 1]; peasycap->video_altsetting_on = okalt[isokalt - 1];
JOM(4, "%i=video_altsetting_on <====\n", JOM(4, "%i=video_altsetting_on <====\n",
peasycap->video_altsetting_on); peasycap->video_altsetting_on);
}
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* /*
* DECIDE THE VIDEO STREAMING PARAMETERS * DECIDE THE VIDEO STREAMING PARAMETERS
...@@ -3483,7 +3475,8 @@ static int easycap_usb_probe(struct usb_interface *intf, ...@@ -3483,7 +3475,8 @@ static int easycap_usb_probe(struct usb_interface *intf,
SAM("ERROR: Could not allocate frame " SAM("ERROR: Could not allocate frame "
"buffer %i page %i\n", k, m); "buffer %i page %i\n", k, m);
return -ENOMEM; return -ENOMEM;
} else }
peasycap->allocation_video_page += 1; peasycap->allocation_video_page += 1;
peasycap->frame_buffer[k][m].pgo = pbuf; peasycap->frame_buffer[k][m].pgo = pbuf;
} }
...@@ -3514,7 +3507,7 @@ static int easycap_usb_probe(struct usb_interface *intf, ...@@ -3514,7 +3507,7 @@ static int easycap_usb_probe(struct usb_interface *intf,
" buffer %i page %i\n", k, m); " buffer %i page %i\n", k, m);
return -ENOMEM; return -ENOMEM;
} }
else
peasycap->allocation_video_page += 1; peasycap->allocation_video_page += 1;
peasycap->field_buffer[k][m].pgo = pbuf; peasycap->field_buffer[k][m].pgo = pbuf;
} }
...@@ -3541,7 +3534,7 @@ static int easycap_usb_probe(struct usb_interface *intf, ...@@ -3541,7 +3534,7 @@ static int easycap_usb_probe(struct usb_interface *intf,
SAM("ERROR: Could not allocate isoc video buffer " SAM("ERROR: Could not allocate isoc video buffer "
"%i\n", k); "%i\n", k);
return -ENOMEM; return -ENOMEM;
} else }
peasycap->allocation_video_page += peasycap->allocation_video_page +=
BIT(VIDEO_ISOC_ORDER); BIT(VIDEO_ISOC_ORDER);
...@@ -3572,14 +3565,16 @@ static int easycap_usb_probe(struct usb_interface *intf, ...@@ -3572,14 +3565,16 @@ static int easycap_usb_probe(struct usb_interface *intf,
SAM("ERROR: usb_alloc_urb returned NULL for buffer " SAM("ERROR: usb_alloc_urb returned NULL for buffer "
"%i\n", k); "%i\n", k);
return -ENOMEM; return -ENOMEM;
} else }
peasycap->allocation_video_urb += 1; peasycap->allocation_video_urb += 1;
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
pdata_urb = kzalloc(sizeof(struct data_urb), GFP_KERNEL); pdata_urb = kzalloc(sizeof(struct data_urb), GFP_KERNEL);
if (!pdata_urb) { if (!pdata_urb) {
SAM("ERROR: Could not allocate struct data_urb.\n"); SAM("ERROR: Could not allocate struct data_urb.\n");
return -ENOMEM; return -ENOMEM;
} else }
peasycap->allocation_video_struct += peasycap->allocation_video_struct +=
sizeof(struct data_urb); sizeof(struct data_urb);
...@@ -3697,13 +3692,12 @@ static int easycap_usb_probe(struct usb_interface *intf, ...@@ -3697,13 +3692,12 @@ static int easycap_usb_probe(struct usb_interface *intf,
err("Not able to register with videodev"); err("Not able to register with videodev");
videodev_release(&(peasycap->video_device)); videodev_release(&(peasycap->video_device));
return -ENODEV; return -ENODEV;
} else { }
(peasycap->registered_video)++;
peasycap->registered_video++;
SAM("registered with videodev: %i=minor\n", SAM("registered with videodev: %i=minor\n",
peasycap->video_device.minor); peasycap->video_device.minor);
peasycap->minor = peasycap->video_device.minor; peasycap->minor = peasycap->video_device.minor;
}
/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
break; break;
} }
...@@ -3737,11 +3731,10 @@ static int easycap_usb_probe(struct usb_interface *intf, ...@@ -3737,11 +3731,10 @@ static int easycap_usb_probe(struct usb_interface *intf,
if (!isokalt) { if (!isokalt) {
SAM("ERROR: no viable audio_altsetting_on\n"); SAM("ERROR: no viable audio_altsetting_on\n");
return -ENOENT; return -ENOENT;
} else { }
peasycap->audio_altsetting_on = okalt[isokalt - 1]; peasycap->audio_altsetting_on = okalt[isokalt - 1];
JOM(4, "%i=audio_altsetting_on <====\n", JOM(4, "%i=audio_altsetting_on <====\n",
peasycap->audio_altsetting_on); peasycap->audio_altsetting_on);
}
peasycap->audio_endpointnumber = okepn[isokalt - 1]; peasycap->audio_endpointnumber = okepn[isokalt - 1];
JOM(4, "%i=audio_endpointnumber\n", peasycap->audio_endpointnumber); JOM(4, "%i=audio_endpointnumber\n", peasycap->audio_endpointnumber);
...@@ -3850,7 +3843,7 @@ static int easycap_usb_probe(struct usb_interface *intf, ...@@ -3850,7 +3843,7 @@ static int easycap_usb_probe(struct usb_interface *intf,
SAM("ERROR: Could not allocate isoc audio buffer " SAM("ERROR: Could not allocate isoc audio buffer "
"%i\n", k); "%i\n", k);
return -ENOMEM; return -ENOMEM;
} else }
peasycap->allocation_audio_page += peasycap->allocation_audio_page +=
BIT(AUDIO_ISOC_ORDER); BIT(AUDIO_ISOC_ORDER);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment