Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 242128
b: refs/heads/master
c: 1309929
h: refs/heads/master
v: v3
  • Loading branch information
Hans Verkuil authored and Mauro Carvalho Chehab committed Mar 22, 2011
1 parent 0190bff commit 5b24bf4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 48 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: e64d07c92daa5c7973c1d4433f939a4e0fa3beb9
refs/heads/master: 13099294973b14f07915d0342af2be8fa0af589b
59 changes: 12 additions & 47 deletions trunk/drivers/media/radio/dsbr100.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ devices, that would be 76 and 91. */
#define STARTED 0
#define STOPPED 1

#define videodev_to_radio(d) container_of(d, struct dsbr100_device, videodev)
#define v4l2_dev_to_radio(d) container_of(d, struct dsbr100_device, v4l2_dev)

static int usb_dsbr100_probe(struct usb_interface *intf,
const struct usb_device_id *id);
Expand All @@ -151,7 +151,6 @@ struct dsbr100_device {
struct mutex v4l2_lock;
int curfreq;
int stereo;
int removed;
int status;
};

Expand Down Expand Up @@ -346,10 +345,6 @@ static int vidioc_g_tuner(struct file *file, void *priv,
{
struct dsbr100_device *radio = video_drvdata(file);

/* safety check */
if (radio->removed)
return -EIO;

if (v->index > 0)
return -EINVAL;

Expand All @@ -371,16 +366,7 @@ static int vidioc_g_tuner(struct file *file, void *priv,
static int vidioc_s_tuner(struct file *file, void *priv,
struct v4l2_tuner *v)
{
struct dsbr100_device *radio = video_drvdata(file);

/* safety check */
if (radio->removed)
return -EIO;

if (v->index > 0)
return -EINVAL;

return 0;
return v->index ? -EINVAL : 0;
}

static int vidioc_s_frequency(struct file *file, void *priv,
Expand All @@ -389,10 +375,6 @@ static int vidioc_s_frequency(struct file *file, void *priv,
struct dsbr100_device *radio = video_drvdata(file);
int retval;

/* safety check */
if (radio->removed)
return -EIO;

radio->curfreq = f->frequency;

retval = dsbr100_setfreq(radio);
Expand All @@ -406,10 +388,6 @@ static int vidioc_g_frequency(struct file *file, void *priv,
{
struct dsbr100_device *radio = video_drvdata(file);

/* safety check */
if (radio->removed)
return -EIO;

f->type = V4L2_TUNER_RADIO;
f->frequency = radio->curfreq;
return 0;
Expand All @@ -431,10 +409,6 @@ static int vidioc_g_ctrl(struct file *file, void *priv,
{
struct dsbr100_device *radio = video_drvdata(file);

/* safety check */
if (radio->removed)
return -EIO;

switch (ctrl->id) {
case V4L2_CID_AUDIO_MUTE:
ctrl->value = radio->status;
Expand All @@ -449,10 +423,6 @@ static int vidioc_s_ctrl(struct file *file, void *priv,
struct dsbr100_device *radio = video_drvdata(file);
int retval;

/* safety check */
if (radio->removed)
return -EIO;

switch (ctrl->id) {
case V4L2_CID_AUDIO_MUTE:
if (ctrl->value) {
Expand Down Expand Up @@ -494,17 +464,13 @@ static int vidioc_g_input(struct file *filp, void *priv, unsigned int *i)

static int vidioc_s_input(struct file *filp, void *priv, unsigned int i)
{
if (i != 0)
return -EINVAL;
return 0;
return i ? -EINVAL : 0;
}

static int vidioc_s_audio(struct file *file, void *priv,
struct v4l2_audio *a)
{
if (a->index != 0)
return -EINVAL;
return 0;
return a->index ? -EINVAL : 0;
}

/* USB subsystem interface begins here */
Expand All @@ -519,14 +485,13 @@ static void usb_dsbr100_disconnect(struct usb_interface *intf)
{
struct dsbr100_device *radio = usb_get_intfdata(intf);

usb_set_intfdata(intf, NULL);

v4l2_device_get(&radio->v4l2_dev);
mutex_lock(&radio->v4l2_lock);
radio->removed = 1;
mutex_unlock(&radio->v4l2_lock);

usb_set_intfdata(intf, NULL);
video_unregister_device(&radio->videodev);
v4l2_device_disconnect(&radio->v4l2_dev);
mutex_unlock(&radio->v4l2_lock);
v4l2_device_put(&radio->v4l2_dev);
}


Expand Down Expand Up @@ -576,9 +541,9 @@ static int usb_dsbr100_resume(struct usb_interface *intf)
}

/* free data structures */
static void usb_dsbr100_video_device_release(struct video_device *videodev)
static void usb_dsbr100_release(struct v4l2_device *v4l2_dev)
{
struct dsbr100_device *radio = videodev_to_radio(videodev);
struct dsbr100_device *radio = v4l2_dev_to_radio(v4l2_dev);

v4l2_device_unregister(&radio->v4l2_dev);
kfree(radio->transfer_buffer);
Expand Down Expand Up @@ -627,6 +592,7 @@ static int usb_dsbr100_probe(struct usb_interface *intf,
}

v4l2_dev = &radio->v4l2_dev;
v4l2_dev->release = usb_dsbr100_release;

retval = v4l2_device_register(&intf->dev, v4l2_dev);
if (retval < 0) {
Expand All @@ -641,10 +607,9 @@ static int usb_dsbr100_probe(struct usb_interface *intf,
radio->videodev.v4l2_dev = v4l2_dev;
radio->videodev.fops = &usb_dsbr100_fops;
radio->videodev.ioctl_ops = &usb_dsbr100_ioctl_ops;
radio->videodev.release = usb_dsbr100_video_device_release;
radio->videodev.release = video_device_release_empty;
radio->videodev.lock = &radio->v4l2_lock;

radio->removed = 0;
radio->usbdev = interface_to_usbdev(intf);
radio->curfreq = FREQ_MIN * FREQ_MUL;
radio->status = STOPPED;
Expand Down

0 comments on commit 5b24bf4

Please sign in to comment.