diff options
Diffstat (limited to 'drivers/media/radio/radio-rtrack2.c')
-rw-r--r-- | drivers/media/radio/radio-rtrack2.c | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/drivers/media/radio/radio-rtrack2.c b/drivers/media/radio/radio-rtrack2.c index 6d820e2481e7..a67079777419 100644 --- a/drivers/media/radio/radio-rtrack2.c +++ b/drivers/media/radio/radio-rtrack2.c | |||
@@ -52,6 +52,7 @@ static spinlock_t lock; | |||
52 | 52 | ||
53 | struct rt_device | 53 | struct rt_device |
54 | { | 54 | { |
55 | unsigned long in_use; | ||
55 | int port; | 56 | int port; |
56 | unsigned long curfreq; | 57 | unsigned long curfreq; |
57 | int muted; | 58 | int muted; |
@@ -153,8 +154,7 @@ static int rt_getsigstr(struct rt_device *dev) | |||
153 | static int vidioc_g_tuner(struct file *file, void *priv, | 154 | static int vidioc_g_tuner(struct file *file, void *priv, |
154 | struct v4l2_tuner *v) | 155 | struct v4l2_tuner *v) |
155 | { | 156 | { |
156 | struct video_device *dev = video_devdata(file); | 157 | struct rt_device *rt = video_drvdata(file); |
157 | struct rt_device *rt = dev->priv; | ||
158 | 158 | ||
159 | if (v->index > 0) | 159 | if (v->index > 0) |
160 | return -EINVAL; | 160 | return -EINVAL; |
@@ -173,8 +173,7 @@ static int vidioc_g_tuner(struct file *file, void *priv, | |||
173 | static int vidioc_s_frequency(struct file *file, void *priv, | 173 | static int vidioc_s_frequency(struct file *file, void *priv, |
174 | struct v4l2_frequency *f) | 174 | struct v4l2_frequency *f) |
175 | { | 175 | { |
176 | struct video_device *dev = video_devdata(file); | 176 | struct rt_device *rt = video_drvdata(file); |
177 | struct rt_device *rt = dev->priv; | ||
178 | 177 | ||
179 | rt->curfreq = f->frequency; | 178 | rt->curfreq = f->frequency; |
180 | rt_setfreq(rt, rt->curfreq); | 179 | rt_setfreq(rt, rt->curfreq); |
@@ -184,8 +183,7 @@ static int vidioc_s_frequency(struct file *file, void *priv, | |||
184 | static int vidioc_g_frequency(struct file *file, void *priv, | 183 | static int vidioc_g_frequency(struct file *file, void *priv, |
185 | struct v4l2_frequency *f) | 184 | struct v4l2_frequency *f) |
186 | { | 185 | { |
187 | struct video_device *dev = video_devdata(file); | 186 | struct rt_device *rt = video_drvdata(file); |
188 | struct rt_device *rt = dev->priv; | ||
189 | 187 | ||
190 | f->type = V4L2_TUNER_RADIO; | 188 | f->type = V4L2_TUNER_RADIO; |
191 | f->frequency = rt->curfreq; | 189 | f->frequency = rt->curfreq; |
@@ -210,8 +208,7 @@ static int vidioc_queryctrl(struct file *file, void *priv, | |||
210 | static int vidioc_g_ctrl(struct file *file, void *priv, | 208 | static int vidioc_g_ctrl(struct file *file, void *priv, |
211 | struct v4l2_control *ctrl) | 209 | struct v4l2_control *ctrl) |
212 | { | 210 | { |
213 | struct video_device *dev = video_devdata(file); | 211 | struct rt_device *rt = video_drvdata(file); |
214 | struct rt_device *rt = dev->priv; | ||
215 | 212 | ||
216 | switch (ctrl->id) { | 213 | switch (ctrl->id) { |
217 | case V4L2_CID_AUDIO_MUTE: | 214 | case V4L2_CID_AUDIO_MUTE: |
@@ -230,8 +227,7 @@ static int vidioc_g_ctrl(struct file *file, void *priv, | |||
230 | static int vidioc_s_ctrl(struct file *file, void *priv, | 227 | static int vidioc_s_ctrl(struct file *file, void *priv, |
231 | struct v4l2_control *ctrl) | 228 | struct v4l2_control *ctrl) |
232 | { | 229 | { |
233 | struct video_device *dev = video_devdata(file); | 230 | struct rt_device *rt = video_drvdata(file); |
234 | struct rt_device *rt = dev->priv; | ||
235 | 231 | ||
236 | switch (ctrl->id) { | 232 | switch (ctrl->id) { |
237 | case V4L2_CID_AUDIO_MUTE: | 233 | case V4L2_CID_AUDIO_MUTE: |
@@ -284,10 +280,21 @@ static int vidioc_s_audio(struct file *file, void *priv, | |||
284 | 280 | ||
285 | static struct rt_device rtrack2_unit; | 281 | static struct rt_device rtrack2_unit; |
286 | 282 | ||
283 | static int rtrack2_exclusive_open(struct inode *inode, struct file *file) | ||
284 | { | ||
285 | return test_and_set_bit(0, &rtrack2_unit.in_use) ? -EBUSY : 0; | ||
286 | } | ||
287 | |||
288 | static int rtrack2_exclusive_release(struct inode *inode, struct file *file) | ||
289 | { | ||
290 | clear_bit(0, &rtrack2_unit.in_use); | ||
291 | return 0; | ||
292 | } | ||
293 | |||
287 | static const struct file_operations rtrack2_fops = { | 294 | static const struct file_operations rtrack2_fops = { |
288 | .owner = THIS_MODULE, | 295 | .owner = THIS_MODULE, |
289 | .open = video_exclusive_open, | 296 | .open = rtrack2_exclusive_open, |
290 | .release = video_exclusive_release, | 297 | .release = rtrack2_exclusive_release, |
291 | .ioctl = video_ioctl2, | 298 | .ioctl = video_ioctl2, |
292 | #ifdef CONFIG_COMPAT | 299 | #ifdef CONFIG_COMPAT |
293 | .compat_ioctl = v4l_compat_ioctl32, | 300 | .compat_ioctl = v4l_compat_ioctl32, |
@@ -314,6 +321,7 @@ static struct video_device rtrack2_radio = { | |||
314 | .name = "RadioTrack II radio", | 321 | .name = "RadioTrack II radio", |
315 | .fops = &rtrack2_fops, | 322 | .fops = &rtrack2_fops, |
316 | .ioctl_ops = &rtrack2_ioctl_ops, | 323 | .ioctl_ops = &rtrack2_ioctl_ops, |
324 | .release = video_device_release_empty, | ||
317 | }; | 325 | }; |
318 | 326 | ||
319 | static int __init rtrack2_init(void) | 327 | static int __init rtrack2_init(void) |
@@ -329,7 +337,7 @@ static int __init rtrack2_init(void) | |||
329 | return -EBUSY; | 337 | return -EBUSY; |
330 | } | 338 | } |
331 | 339 | ||
332 | rtrack2_radio.priv=&rtrack2_unit; | 340 | video_set_drvdata(&rtrack2_radio, &rtrack2_unit); |
333 | 341 | ||
334 | spin_lock_init(&lock); | 342 | spin_lock_init(&lock); |
335 | if (video_register_device(&rtrack2_radio, VFL_TYPE_RADIO, radio_nr) < 0) { | 343 | if (video_register_device(&rtrack2_radio, VFL_TYPE_RADIO, radio_nr) < 0) { |