diff options
author | Hans Verkuil <hans.verkuil@cisco.com> | 2013-05-29 02:55:15 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2013-06-13 10:35:47 -0400 |
commit | 5f454d82e5958e59c16580b9b4531f4bbc7231f7 (patch) | |
tree | 323852d98e5d31124955295f508e2c815941cbbe /drivers/media/usb/hdpvr/hdpvr-video.c | |
parent | 79f10b625e5eff93c8fad54ba345e5f35feb8461 (diff) |
[media] hdpvr: improve error handling
get_video_info() should never return EFAULT, instead it should return
the low-level usb_control_msg() error. Add a valid field to the hdpvr_video_info
struct so the driver can easily check if a valid format was detected.
Whenever get_video_info is called and it returns an error (e.g. usb_control_msg
failed), then return that error to userspace as well.
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-video.c')
-rw-r--r-- | drivers/media/usb/hdpvr/hdpvr-video.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/drivers/media/usb/hdpvr/hdpvr-video.c b/drivers/media/usb/hdpvr/hdpvr-video.c index e9471059056e..4f8567aa99d8 100644 --- a/drivers/media/usb/hdpvr/hdpvr-video.c +++ b/drivers/media/usb/hdpvr/hdpvr-video.c | |||
@@ -285,7 +285,10 @@ static int hdpvr_start_streaming(struct hdpvr_device *dev) | |||
285 | return -EAGAIN; | 285 | return -EAGAIN; |
286 | 286 | ||
287 | ret = get_video_info(dev, &vidinf); | 287 | ret = get_video_info(dev, &vidinf); |
288 | if (ret) { | 288 | if (ret < 0) |
289 | return ret; | ||
290 | |||
291 | if (!vidinf.valid) { | ||
289 | msleep(250); | 292 | msleep(250); |
290 | v4l2_dbg(MSG_INFO, hdpvr_debug, &dev->v4l2_dev, | 293 | v4l2_dbg(MSG_INFO, hdpvr_debug, &dev->v4l2_dev, |
291 | "no video signal at input %d\n", dev->options.video_input); | 294 | "no video signal at input %d\n", dev->options.video_input); |
@@ -617,15 +620,12 @@ static int vidioc_querystd(struct file *file, void *_fh, v4l2_std_id *a) | |||
617 | if (dev->options.video_input == HDPVR_COMPONENT) | 620 | if (dev->options.video_input == HDPVR_COMPONENT) |
618 | return fh->legacy_mode ? 0 : -ENODATA; | 621 | return fh->legacy_mode ? 0 : -ENODATA; |
619 | ret = get_video_info(dev, &vid_info); | 622 | ret = get_video_info(dev, &vid_info); |
620 | if (ret) | 623 | if (vid_info.valid && vid_info.width == 720 && |
621 | return 0; | ||
622 | if (vid_info.width == 720 && | ||
623 | (vid_info.height == 480 || vid_info.height == 576)) { | 624 | (vid_info.height == 480 || vid_info.height == 576)) { |
624 | *a = (vid_info.height == 480) ? | 625 | *a = (vid_info.height == 480) ? |
625 | V4L2_STD_525_60 : V4L2_STD_625_50; | 626 | V4L2_STD_525_60 : V4L2_STD_625_50; |
626 | } | 627 | } |
627 | 628 | return ret; | |
628 | return 0; | ||
629 | } | 629 | } |
630 | 630 | ||
631 | static int vidioc_s_dv_timings(struct file *file, void *_fh, | 631 | static int vidioc_s_dv_timings(struct file *file, void *_fh, |
@@ -679,6 +679,8 @@ static int vidioc_query_dv_timings(struct file *file, void *_fh, | |||
679 | return -ENODATA; | 679 | return -ENODATA; |
680 | ret = get_video_info(dev, &vid_info); | 680 | ret = get_video_info(dev, &vid_info); |
681 | if (ret) | 681 | if (ret) |
682 | return ret; | ||
683 | if (!vid_info.valid) | ||
682 | return -ENOLCK; | 684 | return -ENOLCK; |
683 | interlaced = vid_info.fps <= 30; | 685 | interlaced = vid_info.fps <= 30; |
684 | for (i = 0; i < ARRAY_SIZE(hdpvr_dv_timings); i++) { | 686 | for (i = 0; i < ARRAY_SIZE(hdpvr_dv_timings); i++) { |
@@ -1008,7 +1010,9 @@ static int vidioc_g_fmt_vid_cap(struct file *file, void *_fh, | |||
1008 | struct hdpvr_video_info vid_info; | 1010 | struct hdpvr_video_info vid_info; |
1009 | 1011 | ||
1010 | ret = get_video_info(dev, &vid_info); | 1012 | ret = get_video_info(dev, &vid_info); |
1011 | if (ret) | 1013 | if (ret < 0) |
1014 | return ret; | ||
1015 | if (!vid_info.valid) | ||
1012 | return -EFAULT; | 1016 | return -EFAULT; |
1013 | f->fmt.pix.width = vid_info.width; | 1017 | f->fmt.pix.width = vid_info.width; |
1014 | f->fmt.pix.height = vid_info.height; | 1018 | f->fmt.pix.height = vid_info.height; |