aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/radio/radio-sf16fmi.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/radio/radio-sf16fmi.c')
-rw-r--r--drivers/media/radio/radio-sf16fmi.c34
1 files changed, 21 insertions, 13 deletions
diff --git a/drivers/media/radio/radio-sf16fmi.c b/drivers/media/radio/radio-sf16fmi.c
index 0d478f54a907..329c90bddadd 100644
--- a/drivers/media/radio/radio-sf16fmi.c
+++ b/drivers/media/radio/radio-sf16fmi.c
@@ -45,6 +45,7 @@ static struct v4l2_queryctrl radio_qctrl[] = {
45 45
46struct fmi_device 46struct fmi_device
47{ 47{
48 unsigned long in_use;
48 int port; 49 int port;
49 int curvol; /* 1 or 0 */ 50 int curvol; /* 1 or 0 */
50 unsigned long curfreq; /* freq in kHz */ 51 unsigned long curfreq; /* freq in kHz */
@@ -146,8 +147,7 @@ static int vidioc_g_tuner(struct file *file, void *priv,
146 struct v4l2_tuner *v) 147 struct v4l2_tuner *v)
147{ 148{
148 int mult; 149 int mult;
149 struct video_device *dev = video_devdata(file); 150 struct fmi_device *fmi = video_drvdata(file);
150 struct fmi_device *fmi = dev->priv;
151 151
152 if (v->index > 0) 152 if (v->index > 0)
153 return -EINVAL; 153 return -EINVAL;
@@ -175,8 +175,7 @@ static int vidioc_s_tuner(struct file *file, void *priv,
175static int vidioc_s_frequency(struct file *file, void *priv, 175static int vidioc_s_frequency(struct file *file, void *priv,
176 struct v4l2_frequency *f) 176 struct v4l2_frequency *f)
177{ 177{
178 struct video_device *dev = video_devdata(file); 178 struct fmi_device *fmi = video_drvdata(file);
179 struct fmi_device *fmi = dev->priv;
180 179
181 if (!(fmi->flags & V4L2_TUNER_CAP_LOW)) 180 if (!(fmi->flags & V4L2_TUNER_CAP_LOW))
182 f->frequency *= 1000; 181 f->frequency *= 1000;
@@ -193,8 +192,7 @@ static int vidioc_s_frequency(struct file *file, void *priv,
193static int vidioc_g_frequency(struct file *file, void *priv, 192static int vidioc_g_frequency(struct file *file, void *priv,
194 struct v4l2_frequency *f) 193 struct v4l2_frequency *f)
195{ 194{
196 struct video_device *dev = video_devdata(file); 195 struct fmi_device *fmi = video_drvdata(file);
197 struct fmi_device *fmi = dev->priv;
198 196
199 f->type = V4L2_TUNER_RADIO; 197 f->type = V4L2_TUNER_RADIO;
200 f->frequency = fmi->curfreq; 198 f->frequency = fmi->curfreq;
@@ -221,8 +219,7 @@ static int vidioc_queryctrl(struct file *file, void *priv,
221static int vidioc_g_ctrl(struct file *file, void *priv, 219static int vidioc_g_ctrl(struct file *file, void *priv,
222 struct v4l2_control *ctrl) 220 struct v4l2_control *ctrl)
223{ 221{
224 struct video_device *dev = video_devdata(file); 222 struct fmi_device *fmi = video_drvdata(file);
225 struct fmi_device *fmi = dev->priv;
226 223
227 switch (ctrl->id) { 224 switch (ctrl->id) {
228 case V4L2_CID_AUDIO_MUTE: 225 case V4L2_CID_AUDIO_MUTE:
@@ -235,8 +232,7 @@ static int vidioc_g_ctrl(struct file *file, void *priv,
235static int vidioc_s_ctrl(struct file *file, void *priv, 232static int vidioc_s_ctrl(struct file *file, void *priv,
236 struct v4l2_control *ctrl) 233 struct v4l2_control *ctrl)
237{ 234{
238 struct video_device *dev = video_devdata(file); 235 struct fmi_device *fmi = video_drvdata(file);
239 struct fmi_device *fmi = dev->priv;
240 236
241 switch (ctrl->id) { 237 switch (ctrl->id) {
242 case V4L2_CID_AUDIO_MUTE: 238 case V4L2_CID_AUDIO_MUTE:
@@ -284,10 +280,21 @@ static int vidioc_s_audio(struct file *file, void *priv,
284 280
285static struct fmi_device fmi_unit; 281static struct fmi_device fmi_unit;
286 282
283static int fmi_exclusive_open(struct inode *inode, struct file *file)
284{
285 return test_and_set_bit(0, &fmi_unit.in_use) ? -EBUSY : 0;
286}
287
288static int fmi_exclusive_release(struct inode *inode, struct file *file)
289{
290 clear_bit(0, &fmi_unit.in_use);
291 return 0;
292}
293
287static const struct file_operations fmi_fops = { 294static const struct file_operations fmi_fops = {
288 .owner = THIS_MODULE, 295 .owner = THIS_MODULE,
289 .open = video_exclusive_open, 296 .open = fmi_exclusive_open,
290 .release = video_exclusive_release, 297 .release = fmi_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 fmi_radio = {
314 .name = "SF16FMx radio", 321 .name = "SF16FMx radio",
315 .fops = &fmi_fops, 322 .fops = &fmi_fops,
316 .ioctl_ops = &fmi_ioctl_ops, 323 .ioctl_ops = &fmi_ioctl_ops,
324 .release = video_device_release_empty,
317}; 325};
318 326
319/* ladis: this is my card. does any other types exist? */ 327/* ladis: this is my card. does any other types exist? */
@@ -373,7 +381,7 @@ static int __init fmi_init(void)
373 fmi_unit.curvol = 0; 381 fmi_unit.curvol = 0;
374 fmi_unit.curfreq = 0; 382 fmi_unit.curfreq = 0;
375 fmi_unit.flags = V4L2_TUNER_CAP_LOW; 383 fmi_unit.flags = V4L2_TUNER_CAP_LOW;
376 fmi_radio.priv = &fmi_unit; 384 video_set_drvdata(&fmi_radio, &fmi_unit);
377 385
378 mutex_init(&lock); 386 mutex_init(&lock);
379 387