summaryrefslogtreecommitdiff
path: root/drivers/media/usb/hdpvr/hdpvr-control.c
diff options
context:
space:
mode:
authorLeonid Kegulskiy <leo@lumanate.com>2013-05-13 07:10:42 -0300
committerMauro Carvalho Chehab <mchehab@redhat.com>2013-05-27 08:51:51 -0300
commit4d601c4ca272959ba837b8279f4873b55caaf619 (patch)
tree6984c7677f02a3c07900001334e3f8fc53b2e84b /drivers/media/usb/hdpvr/hdpvr-control.c
parentff29feb9146d1c0020f2ccbb25369582c6a16681 (diff)
[media] hdpvr: Removed unnecessary use of kzalloc() in get_video_info()
[mchehab@redhat.com: CodingStyle fixes] Signed-off-by: Leonid Kegulskiy <leo@lumanate.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/usb/hdpvr/hdpvr-control.c')
-rw-r--r--drivers/media/usb/hdpvr/hdpvr-control.c25
1 files changed, 9 insertions, 16 deletions
diff --git a/drivers/media/usb/hdpvr/hdpvr-control.c b/drivers/media/usb/hdpvr/hdpvr-control.c
index ae8f229d1141..df6bcb524d80 100644
--- a/drivers/media/usb/hdpvr/hdpvr-control.c
+++ b/drivers/media/usb/hdpvr/hdpvr-control.c
@@ -45,20 +45,10 @@ int hdpvr_config_call(struct hdpvr_device *dev, uint value, u8 valbuf)
return ret < 0 ? ret : 0;
}
-struct hdpvr_video_info *get_video_info(struct hdpvr_device *dev)
+int get_video_info(struct hdpvr_device *dev, struct hdpvr_video_info *vidinf)
{
- struct hdpvr_video_info *vidinf = NULL;
-#ifdef HDPVR_DEBUG
- char print_buf[15];
-#endif
int ret;
- vidinf = kzalloc(sizeof(struct hdpvr_video_info), GFP_KERNEL);
- if (!vidinf) {
- v4l2_err(&dev->v4l2_dev, "out of memory\n");
- goto err;
- }
-
mutex_lock(&dev->usbc_mutex);
ret = usb_control_msg(dev->udev,
usb_rcvctrlpipe(dev->udev, 0),
@@ -74,6 +64,7 @@ struct hdpvr_video_info *get_video_info(struct hdpvr_device *dev)
#ifdef HDPVR_DEBUG
if (hdpvr_debug & MSG_INFO) {
+ char print_buf[15];
hex_dump_to_buffer(dev->usbc_buf, 5, 16, 1, print_buf,
sizeof(print_buf), 0);
v4l2_dbg(MSG_INFO, hdpvr_debug, &dev->v4l2_dev,
@@ -82,12 +73,14 @@ struct hdpvr_video_info *get_video_info(struct hdpvr_device *dev)
#endif
mutex_unlock(&dev->usbc_mutex);
- if (!vidinf->width || !vidinf->height || !vidinf->fps) {
- kfree(vidinf);
- vidinf = NULL;
+ if ((ret > 0 && ret != 5) ||/* fail if unexpected byte count returned */
+ !vidinf->width || /* preserve original behavior - */
+ !vidinf->height || /* fail if no signal is detected */
+ !vidinf->fps) {
+ ret = -EFAULT;
}
-err:
- return vidinf;
+
+ return ret < 0 ? ret : 0;
}
int get_input_lines_info(struct hdpvr_device *dev)