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)
peasycap->inputset[peasycap->input].brightness_ok = 1;
} else
JOM(8, "%i=peasycap->input\n", peasycap->input);
mood = 0x00FF & (unsigned int)peasycap->brightness;
if (!write_saa(peasycap->pusb_device, 0x0A, mood)) {
SAM("adjusting brightness to 0x%02X\n", mood);
return 0;
} else {
if (write_saa(peasycap->pusb_device, 0x0A, mood)) {
SAM("WARNING: failed to adjust brightness "
"to 0x%02X\n", mood);
return -ENOENT;
}
break;
SAM("adjusting brightness to 0x%02X\n", mood);
return 0;
}
i1++;
}
......@@ -725,15 +724,13 @@ int adjust_contrast(struct easycap *peasycap, int value)
JOM(8, "%i=peasycap->input\n", peasycap->input);
mood = 0x00FF & (unsigned int) (peasycap->contrast - 128);
if (!write_saa(peasycap->pusb_device, 0x0B, mood)) {
SAM("adjusting contrast to 0x%02X\n", mood);
return 0;
} else {
if (write_saa(peasycap->pusb_device, 0x0B, mood)) {
SAM("WARNING: failed to adjust contrast to "
"0x%02X\n", mood);
return -ENOENT;
}
break;
SAM("adjusting contrast to 0x%02X\n", mood);
return 0;
}
i1++;
}
......@@ -783,14 +780,13 @@ int adjust_saturation(struct easycap *peasycap, int value)
} else
JOM(8, "%i=peasycap->input\n", peasycap->input);
mood = 0x00FF & (unsigned int) (peasycap->saturation - 128);
if (!write_saa(peasycap->pusb_device, 0x0C, mood)) {
SAM("adjusting saturation to 0x%02X\n", mood);
return 0;
} else {
if (write_saa(peasycap->pusb_device, 0x0C, mood)) {
SAM("WARNING: failed to adjust saturation to "
"0x%02X\n", mood);
return -ENOENT;
}
SAM("adjusting saturation to 0x%02X\n", mood);
return 0;
break;
}
i1++;
......@@ -838,13 +834,12 @@ int adjust_hue(struct easycap *peasycap, int value)
JOM(8, "%i=peasycap->input\n", peasycap->input);
i2 = peasycap->hue - 128;
mood = 0x00FF & ((int) i2);
if (!write_saa(peasycap->pusb_device, 0x0D, mood)) {
SAM("adjusting hue to 0x%02X\n", mood);
return 0;
} else {
if (write_saa(peasycap->pusb_device, 0x0D, mood)) {
SAM("WARNING: failed to adjust hue to 0x%02X\n", mood);
return -ENOENT;
}
SAM("adjusting hue to 0x%02X\n", mood);
return 0;
break;
}
i1++;
......@@ -885,14 +880,12 @@ static int adjust_volume(struct easycap *peasycap, int value)
((31 < peasycap->volume) ? 31 :
(s8) peasycap->volume);
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 "
"0x%2X\n", mood);
return -ENOENT;
}
break;
SAM("adjusting volume to 0x%02X\n", mood);
return 0;
}
i1++;
}
......
......@@ -514,9 +514,10 @@ int ready_saa(struct usb_device *p)
msleep(marktime);
j++;
}
if (max == j)
return -1;
else {
if (0x20 & rc) {
rate = 2;
JOT(8, "hardware detects 60 Hz\n");
......@@ -530,7 +531,6 @@ int ready_saa(struct usb_device *p)
rate++;
JOT(8, "hardware detects no interlacing\n");
}
}
return 0;
}
/****************************************************************************/
......
......@@ -165,14 +165,13 @@ static int easycap_open(struct inode *inode, struct file *file)
if (!peasycap->pusb_device) {
SAM("ERROR: peasycap->pusb_device is NULL\n");
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;
rc = wakeup_device(peasycap->pusb_device);
if (0 == rc)
JOM(8, "wakeup_device() OK\n");
else {
if (rc) {
SAM("ERROR: wakeup_device() rc = %i\n", rc);
if (-ENODEV == rc)
SAM("ERROR: wakeup_device() returned -ENODEV\n");
......@@ -180,6 +179,7 @@ static int easycap_open(struct inode *inode, struct file *file)
SAM("ERROR: wakeup_device() rc = %i\n", rc);
return rc;
}
JOM(8, "wakeup_device() OK\n");
peasycap->input = 0;
rc = reset(peasycap);
if (rc) {
......@@ -987,11 +987,11 @@ static unsigned int easycap_poll(struct file *file, poll_table *wait)
rc = easycap_dqbuf(peasycap, 0);
peasycap->polled = 1;
mutex_unlock(&easycapdc60_dongle[kd].mutex_video);
if (0 == rc)
return POLLIN | POLLRDNORM;
else
if (rc)
return POLLERR;
}
return POLLIN | POLLRDNORM;
}
/*****************************************************************************/
/*---------------------------------------------------------------------------*/
/*
......@@ -2920,6 +2920,7 @@ static int easycap_usb_probe(struct usb_interface *intf,
SAY("ERROR: usb_host_interface not found\n");
return -EFAULT;
}
interface = &alt->desc;
if (!interface) {
SAY("ERROR: intf_descriptor is NULL\n");
......@@ -2979,17 +2980,8 @@ static int easycap_usb_probe(struct usb_interface *intf,
if (mutex_lock_interruptible(&mutex_dongle)) {
SAY("ERROR: cannot down mutex_dongle\n");
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++) {
if ((!easycapdc60_dongle[ndong].peasycap) &&
(!mutex_is_locked(&easycapdc60_dongle
......@@ -3004,13 +2996,14 @@ static int easycap_usb_probe(struct usb_interface *intf,
break;
}
}
if (DONGLE_MANY <= ndong) {
SAM("ERROR: too many dongles\n");
mutex_unlock(&mutex_dongle);
return -ENOMEM;
}
mutex_unlock(&mutex_dongle);
}
peasycap->allocation_video_struct = sizeof(struct easycap);
peasycap->allocation_video_page = 0;
peasycap->allocation_video_urb = 0;
......@@ -3393,11 +3386,10 @@ static int easycap_usb_probe(struct usb_interface *intf,
if (!isokalt) {
SAM("ERROR: no viable video_altsetting_on\n");
return -ENOENT;
} else {
}
peasycap->video_altsetting_on = okalt[isokalt - 1];
JOM(4, "%i=video_altsetting_on <====\n",
peasycap->video_altsetting_on);
}
/*---------------------------------------------------------------------------*/
/*
* DECIDE THE VIDEO STREAMING PARAMETERS
......@@ -3483,7 +3475,8 @@ static int easycap_usb_probe(struct usb_interface *intf,
SAM("ERROR: Could not allocate frame "
"buffer %i page %i\n", k, m);
return -ENOMEM;
} else
}
peasycap->allocation_video_page += 1;
peasycap->frame_buffer[k][m].pgo = pbuf;
}
......@@ -3514,7 +3507,7 @@ static int easycap_usb_probe(struct usb_interface *intf,
" buffer %i page %i\n", k, m);
return -ENOMEM;
}
else
peasycap->allocation_video_page += 1;
peasycap->field_buffer[k][m].pgo = pbuf;
}
......@@ -3541,7 +3534,7 @@ static int easycap_usb_probe(struct usb_interface *intf,
SAM("ERROR: Could not allocate isoc video buffer "
"%i\n", k);
return -ENOMEM;
} else
}
peasycap->allocation_video_page +=
BIT(VIDEO_ISOC_ORDER);
......@@ -3572,14 +3565,16 @@ static int easycap_usb_probe(struct usb_interface *intf,
SAM("ERROR: usb_alloc_urb returned NULL for buffer "
"%i\n", k);
return -ENOMEM;
} else
}
peasycap->allocation_video_urb += 1;
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
pdata_urb = kzalloc(sizeof(struct data_urb), GFP_KERNEL);
if (!pdata_urb) {
SAM("ERROR: Could not allocate struct data_urb.\n");
return -ENOMEM;
} else
}
peasycap->allocation_video_struct +=
sizeof(struct data_urb);
......@@ -3697,13 +3692,12 @@ static int easycap_usb_probe(struct usb_interface *intf,
err("Not able to register with videodev");
videodev_release(&(peasycap->video_device));
return -ENODEV;
} else {
(peasycap->registered_video)++;
}
peasycap->registered_video++;
SAM("registered with videodev: %i=minor\n",
peasycap->video_device.minor);
peasycap->minor = peasycap->video_device.minor;
}
/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
break;
}
......@@ -3737,11 +3731,10 @@ static int easycap_usb_probe(struct usb_interface *intf,
if (!isokalt) {
SAM("ERROR: no viable audio_altsetting_on\n");
return -ENOENT;
} else {
}
peasycap->audio_altsetting_on = okalt[isokalt - 1];
JOM(4, "%i=audio_altsetting_on <====\n",
peasycap->audio_altsetting_on);
}
peasycap->audio_endpointnumber = okepn[isokalt - 1];
JOM(4, "%i=audio_endpointnumber\n", peasycap->audio_endpointnumber);
......@@ -3850,7 +3843,7 @@ static int easycap_usb_probe(struct usb_interface *intf,
SAM("ERROR: Could not allocate isoc audio buffer "
"%i\n", k);
return -ENOMEM;
} else
}
peasycap->allocation_audio_page +=
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