diff options
author | Leonid Kegulskiy <leo@lumanate.com> | 2013-05-13 06:10:42 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2013-05-27 07:51:51 -0400 |
commit | 4d601c4ca272959ba837b8279f4873b55caaf619 (patch) | |
tree | 6984c7677f02a3c07900001334e3f8fc53b2e84b /drivers/media/usb/hdpvr | |
parent | ff29feb9146d1c0020f2ccbb25369582c6a16681 (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')
-rw-r--r-- | drivers/media/usb/hdpvr/hdpvr-control.c | 25 | ||||
-rw-r--r-- | drivers/media/usb/hdpvr/hdpvr-video.c | 54 | ||||
-rw-r--r-- | drivers/media/usb/hdpvr/hdpvr.h | 2 |
3 files changed, 37 insertions, 44 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) | |||
45 | return ret < 0 ? ret : 0; | 45 | return ret < 0 ? ret : 0; |
46 | } | 46 | } |
47 | 47 | ||
48 | struct hdpvr_video_info *get_video_info(struct hdpvr_device *dev) | 48 | int get_video_info(struct hdpvr_device *dev, struct hdpvr_video_info *vidinf) |
49 | { | 49 | { |
50 | struct hdpvr_video_info *vidinf = NULL; | ||
51 | #ifdef HDPVR_DEBUG | ||
52 | char print_buf[15]; | ||
53 | #endif | ||
54 | int ret; | 50 | int ret; |
55 | 51 | ||
56 | vidinf = kzalloc(sizeof(struct hdpvr_video_info), GFP_KERNEL); | ||
57 | if (!vidinf) { | ||
58 | v4l2_err(&dev->v4l2_dev, "out of memory\n"); | ||
59 | goto err; | ||
60 | } | ||
61 | |||
62 | mutex_lock(&dev->usbc_mutex); | 52 | mutex_lock(&dev->usbc_mutex); |
63 | ret = usb_control_msg(dev->udev, | 53 | ret = usb_control_msg(dev->udev, |
64 | usb_rcvctrlpipe(dev->udev, 0), | 54 | usb_rcvctrlpipe(dev->udev, 0), |
@@ -74,6 +64,7 @@ struct hdpvr_video_info *get_video_info(struct hdpvr_device *dev) | |||
74 | 64 | ||
75 | #ifdef HDPVR_DEBUG | 65 | #ifdef HDPVR_DEBUG |
76 | if (hdpvr_debug & MSG_INFO) { | 66 | if (hdpvr_debug & MSG_INFO) { |
67 | char print_buf[15]; | ||
77 | hex_dump_to_buffer(dev->usbc_buf, 5, 16, 1, print_buf, | 68 | hex_dump_to_buffer(dev->usbc_buf, 5, 16, 1, print_buf, |
78 | sizeof(print_buf), 0); | 69 | sizeof(print_buf), 0); |
79 | v4l2_dbg(MSG_INFO, hdpvr_debug, &dev->v4l2_dev, | 70 | v4l2_dbg(MSG_INFO, hdpvr_debug, &dev->v4l2_dev, |
@@ -82,12 +73,14 @@ struct hdpvr_video_info *get_video_info(struct hdpvr_device *dev) | |||
82 | #endif | 73 | #endif |
83 | mutex_unlock(&dev->usbc_mutex); | 74 | mutex_unlock(&dev->usbc_mutex); |
84 | 75 | ||
85 | if (!vidinf->width || !vidinf->height || !vidinf->fps) { | 76 | if ((ret > 0 && ret != 5) ||/* fail if unexpected byte count returned */ |
86 | kfree(vidinf); | 77 | !vidinf->width || /* preserve original behavior - */ |
87 | vidinf = NULL; | 78 | !vidinf->height || /* fail if no signal is detected */ |
79 | !vidinf->fps) { | ||
80 | ret = -EFAULT; | ||
88 | } | 81 | } |
89 | err: | 82 | |
90 | return vidinf; | 83 | return ret < 0 ? ret : 0; |
91 | } | 84 | } |
92 | 85 | ||
93 | int get_input_lines_info(struct hdpvr_device *dev) | 86 | int get_input_lines_info(struct hdpvr_device *dev) |
diff --git a/drivers/media/usb/hdpvr/hdpvr-video.c b/drivers/media/usb/hdpvr/hdpvr-video.c index cd90ba81a5bb..2d02b490756b 100644 --- a/drivers/media/usb/hdpvr/hdpvr-video.c +++ b/drivers/media/usb/hdpvr/hdpvr-video.c | |||
@@ -277,20 +277,19 @@ error: | |||
277 | static int hdpvr_start_streaming(struct hdpvr_device *dev) | 277 | static int hdpvr_start_streaming(struct hdpvr_device *dev) |
278 | { | 278 | { |
279 | int ret; | 279 | int ret; |
280 | struct hdpvr_video_info *vidinf; | 280 | struct hdpvr_video_info vidinf; |
281 | 281 | ||
282 | if (dev->status == STATUS_STREAMING) | 282 | if (dev->status == STATUS_STREAMING) |
283 | return 0; | 283 | return 0; |
284 | else if (dev->status != STATUS_IDLE) | 284 | else if (dev->status != STATUS_IDLE) |
285 | return -EAGAIN; | 285 | return -EAGAIN; |
286 | 286 | ||
287 | vidinf = get_video_info(dev); | 287 | ret = get_video_info(dev, &vidinf); |
288 | 288 | ||
289 | if (vidinf) { | 289 | if (!ret) { |
290 | v4l2_dbg(MSG_BUFFER, hdpvr_debug, &dev->v4l2_dev, | 290 | v4l2_dbg(MSG_BUFFER, hdpvr_debug, &dev->v4l2_dev, |
291 | "video signal: %dx%d@%dhz\n", vidinf->width, | 291 | "video signal: %dx%d@%dhz\n", vidinf.width, |
292 | vidinf->height, vidinf->fps); | 292 | vidinf.height, vidinf.fps); |
293 | kfree(vidinf); | ||
294 | 293 | ||
295 | /* start streaming 2 request */ | 294 | /* start streaming 2 request */ |
296 | ret = usb_control_msg(dev->udev, | 295 | ret = usb_control_msg(dev->udev, |
@@ -610,21 +609,22 @@ static int vidioc_g_std(struct file *file, void *_fh, | |||
610 | static int vidioc_querystd(struct file *file, void *_fh, v4l2_std_id *a) | 609 | static int vidioc_querystd(struct file *file, void *_fh, v4l2_std_id *a) |
611 | { | 610 | { |
612 | struct hdpvr_device *dev = video_drvdata(file); | 611 | struct hdpvr_device *dev = video_drvdata(file); |
613 | struct hdpvr_video_info *vid_info; | 612 | struct hdpvr_video_info vid_info; |
614 | struct hdpvr_fh *fh = _fh; | 613 | struct hdpvr_fh *fh = _fh; |
614 | int ret; | ||
615 | 615 | ||
616 | *a = V4L2_STD_ALL; | 616 | *a = V4L2_STD_ALL; |
617 | if (dev->options.video_input == HDPVR_COMPONENT) | 617 | if (dev->options.video_input == HDPVR_COMPONENT) |
618 | return fh->legacy_mode ? 0 : -ENODATA; | 618 | return fh->legacy_mode ? 0 : -ENODATA; |
619 | vid_info = get_video_info(dev); | 619 | ret = get_video_info(dev, &vid_info); |
620 | if (vid_info == NULL) | 620 | if (ret) |
621 | return 0; | 621 | return 0; |
622 | if (vid_info->width == 720 && | 622 | if (vid_info.width == 720 && |
623 | (vid_info->height == 480 || vid_info->height == 576)) { | 623 | (vid_info.height == 480 || vid_info.height == 576)) { |
624 | *a = (vid_info->height == 480) ? | 624 | *a = (vid_info.height == 480) ? |
625 | V4L2_STD_525_60 : V4L2_STD_625_50; | 625 | V4L2_STD_525_60 : V4L2_STD_625_50; |
626 | } | 626 | } |
627 | kfree(vid_info); | 627 | |
628 | return 0; | 628 | return 0; |
629 | } | 629 | } |
630 | 630 | ||
@@ -669,7 +669,7 @@ static int vidioc_query_dv_timings(struct file *file, void *_fh, | |||
669 | { | 669 | { |
670 | struct hdpvr_device *dev = video_drvdata(file); | 670 | struct hdpvr_device *dev = video_drvdata(file); |
671 | struct hdpvr_fh *fh = _fh; | 671 | struct hdpvr_fh *fh = _fh; |
672 | struct hdpvr_video_info *vid_info; | 672 | struct hdpvr_video_info vid_info; |
673 | bool interlaced; | 673 | bool interlaced; |
674 | int ret = 0; | 674 | int ret = 0; |
675 | int i; | 675 | int i; |
@@ -677,10 +677,10 @@ static int vidioc_query_dv_timings(struct file *file, void *_fh, | |||
677 | fh->legacy_mode = false; | 677 | fh->legacy_mode = false; |
678 | if (dev->options.video_input) | 678 | if (dev->options.video_input) |
679 | return -ENODATA; | 679 | return -ENODATA; |
680 | vid_info = get_video_info(dev); | 680 | ret = get_video_info(dev, &vid_info); |
681 | if (vid_info == NULL) | 681 | if (ret) |
682 | return -ENOLCK; | 682 | return -ENOLCK; |
683 | interlaced = vid_info->fps <= 30; | 683 | interlaced = vid_info.fps <= 30; |
684 | for (i = 0; i < ARRAY_SIZE(hdpvr_dv_timings); i++) { | 684 | for (i = 0; i < ARRAY_SIZE(hdpvr_dv_timings); i++) { |
685 | const struct v4l2_bt_timings *bt = &hdpvr_dv_timings[i].bt; | 685 | const struct v4l2_bt_timings *bt = &hdpvr_dv_timings[i].bt; |
686 | unsigned hsize; | 686 | unsigned hsize; |
@@ -692,17 +692,17 @@ static int vidioc_query_dv_timings(struct file *file, void *_fh, | |||
692 | bt->il_vfrontporch + bt->il_vsync + bt->il_vbackporch + | 692 | bt->il_vfrontporch + bt->il_vsync + bt->il_vbackporch + |
693 | bt->height; | 693 | bt->height; |
694 | fps = (unsigned)bt->pixelclock / (hsize * vsize); | 694 | fps = (unsigned)bt->pixelclock / (hsize * vsize); |
695 | if (bt->width != vid_info->width || | 695 | if (bt->width != vid_info.width || |
696 | bt->height != vid_info->height || | 696 | bt->height != vid_info.height || |
697 | bt->interlaced != interlaced || | 697 | bt->interlaced != interlaced || |
698 | (fps != vid_info->fps && fps + 1 != vid_info->fps)) | 698 | (fps != vid_info.fps && fps + 1 != vid_info.fps)) |
699 | continue; | 699 | continue; |
700 | *timings = hdpvr_dv_timings[i]; | 700 | *timings = hdpvr_dv_timings[i]; |
701 | break; | 701 | break; |
702 | } | 702 | } |
703 | if (i == ARRAY_SIZE(hdpvr_dv_timings)) | 703 | if (i == ARRAY_SIZE(hdpvr_dv_timings)) |
704 | ret = -ERANGE; | 704 | ret = -ERANGE; |
705 | kfree(vid_info); | 705 | |
706 | return ret; | 706 | return ret; |
707 | } | 707 | } |
708 | 708 | ||
@@ -992,6 +992,7 @@ static int vidioc_g_fmt_vid_cap(struct file *file, void *_fh, | |||
992 | { | 992 | { |
993 | struct hdpvr_device *dev = video_drvdata(file); | 993 | struct hdpvr_device *dev = video_drvdata(file); |
994 | struct hdpvr_fh *fh = _fh; | 994 | struct hdpvr_fh *fh = _fh; |
995 | int ret; | ||
995 | 996 | ||
996 | /* | 997 | /* |
997 | * The original driver would always returns the current detected | 998 | * The original driver would always returns the current detected |
@@ -1004,14 +1005,13 @@ static int vidioc_g_fmt_vid_cap(struct file *file, void *_fh, | |||
1004 | * last set format. | 1005 | * last set format. |
1005 | */ | 1006 | */ |
1006 | if (fh->legacy_mode) { | 1007 | if (fh->legacy_mode) { |
1007 | struct hdpvr_video_info *vid_info; | 1008 | struct hdpvr_video_info vid_info; |
1008 | 1009 | ||
1009 | vid_info = get_video_info(dev); | 1010 | ret = get_video_info(dev, &vid_info); |
1010 | if (!vid_info) | 1011 | if (ret) |
1011 | return -EFAULT; | 1012 | return -EFAULT; |
1012 | f->fmt.pix.width = vid_info->width; | 1013 | f->fmt.pix.width = vid_info.width; |
1013 | f->fmt.pix.height = vid_info->height; | 1014 | f->fmt.pix.height = vid_info.height; |
1014 | kfree(vid_info); | ||
1015 | } else { | 1015 | } else { |
1016 | f->fmt.pix.width = dev->width; | 1016 | f->fmt.pix.width = dev->width; |
1017 | f->fmt.pix.height = dev->height; | 1017 | f->fmt.pix.height = dev->height; |
diff --git a/drivers/media/usb/hdpvr/hdpvr.h b/drivers/media/usb/hdpvr/hdpvr.h index 1478f3d57630..808ea7a0efe5 100644 --- a/drivers/media/usb/hdpvr/hdpvr.h +++ b/drivers/media/usb/hdpvr/hdpvr.h | |||
@@ -303,7 +303,7 @@ int hdpvr_set_audio(struct hdpvr_device *dev, u8 input, | |||
303 | int hdpvr_config_call(struct hdpvr_device *dev, uint value, | 303 | int hdpvr_config_call(struct hdpvr_device *dev, uint value, |
304 | unsigned char valbuf); | 304 | unsigned char valbuf); |
305 | 305 | ||
306 | struct hdpvr_video_info *get_video_info(struct hdpvr_device *dev); | 306 | int get_video_info(struct hdpvr_device *dev, struct hdpvr_video_info *vid_info); |
307 | 307 | ||
308 | /* :0 s b8 81 1800 0003 0003 3 < */ | 308 | /* :0 s b8 81 1800 0003 0003 3 < */ |
309 | /* :0 0 3 = 0301ff */ | 309 | /* :0 0 3 = 0301ff */ |