aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/radio/radio-gemtek-pci.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/radio/radio-gemtek-pci.c')
-rw-r--r--drivers/media/radio/radio-gemtek-pci.c42
1 files changed, 24 insertions, 18 deletions
diff --git a/drivers/media/radio/radio-gemtek-pci.c b/drivers/media/radio/radio-gemtek-pci.c
index 5cd7f032298d..e15bee6d7cfc 100644
--- a/drivers/media/radio/radio-gemtek-pci.c
+++ b/drivers/media/radio/radio-gemtek-pci.c
@@ -100,9 +100,8 @@ struct gemtek_pci_card {
100 u8 mute; 100 u8 mute;
101}; 101};
102 102
103static const char rcsid[] = "$Id: radio-gemtek-pci.c,v 1.1 2001/07/23 08:08:16 ted Exp ted $";
104
105static int nr_radio = -1; 103static int nr_radio = -1;
104static unsigned long in_use;
106 105
107static inline u8 gemtek_pci_out( u16 value, u32 port ) 106static inline u8 gemtek_pci_out( u16 value, u32 port )
108{ 107{
@@ -205,8 +204,7 @@ static int vidioc_querycap(struct file *file, void *priv,
205static int vidioc_g_tuner(struct file *file, void *priv, 204static int vidioc_g_tuner(struct file *file, void *priv,
206 struct v4l2_tuner *v) 205 struct v4l2_tuner *v)
207{ 206{
208 struct video_device *dev = video_devdata(file); 207 struct gemtek_pci_card *card = video_drvdata(file);
209 struct gemtek_pci_card *card = dev->priv;
210 208
211 if (v->index > 0) 209 if (v->index > 0)
212 return -EINVAL; 210 return -EINVAL;
@@ -233,8 +231,7 @@ static int vidioc_s_tuner(struct file *file, void *priv,
233static int vidioc_s_frequency(struct file *file, void *priv, 231static int vidioc_s_frequency(struct file *file, void *priv,
234 struct v4l2_frequency *f) 232 struct v4l2_frequency *f)
235{ 233{
236 struct video_device *dev = video_devdata(file); 234 struct gemtek_pci_card *card = video_drvdata(file);
237 struct gemtek_pci_card *card = dev->priv;
238 235
239 if ( (f->frequency < GEMTEK_PCI_RANGE_LOW) || 236 if ( (f->frequency < GEMTEK_PCI_RANGE_LOW) ||
240 (f->frequency > GEMTEK_PCI_RANGE_HIGH) ) 237 (f->frequency > GEMTEK_PCI_RANGE_HIGH) )
@@ -248,8 +245,7 @@ static int vidioc_s_frequency(struct file *file, void *priv,
248static int vidioc_g_frequency(struct file *file, void *priv, 245static int vidioc_g_frequency(struct file *file, void *priv,
249 struct v4l2_frequency *f) 246 struct v4l2_frequency *f)
250{ 247{
251 struct video_device *dev = video_devdata(file); 248 struct gemtek_pci_card *card = video_drvdata(file);
252 struct gemtek_pci_card *card = dev->priv;
253 249
254 f->type = V4L2_TUNER_RADIO; 250 f->type = V4L2_TUNER_RADIO;
255 f->frequency = card->current_frequency; 251 f->frequency = card->current_frequency;
@@ -273,8 +269,7 @@ static int vidioc_queryctrl(struct file *file, void *priv,
273static int vidioc_g_ctrl(struct file *file, void *priv, 269static int vidioc_g_ctrl(struct file *file, void *priv,
274 struct v4l2_control *ctrl) 270 struct v4l2_control *ctrl)
275{ 271{
276 struct video_device *dev = video_devdata(file); 272 struct gemtek_pci_card *card = video_drvdata(file);
277 struct gemtek_pci_card *card = dev->priv;
278 273
279 switch (ctrl->id) { 274 switch (ctrl->id) {
280 case V4L2_CID_AUDIO_MUTE: 275 case V4L2_CID_AUDIO_MUTE:
@@ -293,8 +288,7 @@ static int vidioc_g_ctrl(struct file *file, void *priv,
293static int vidioc_s_ctrl(struct file *file, void *priv, 288static int vidioc_s_ctrl(struct file *file, void *priv,
294 struct v4l2_control *ctrl) 289 struct v4l2_control *ctrl)
295{ 290{
296 struct video_device *dev = video_devdata(file); 291 struct gemtek_pci_card *card = video_drvdata(file);
297 struct gemtek_pci_card *card = dev->priv;
298 292
299 switch (ctrl->id) { 293 switch (ctrl->id) {
300 case V4L2_CID_AUDIO_MUTE: 294 case V4L2_CID_AUDIO_MUTE:
@@ -364,10 +358,21 @@ MODULE_DEVICE_TABLE( pci, gemtek_pci_id );
364 358
365static int mx = 1; 359static int mx = 1;
366 360
361static int gemtek_pci_exclusive_open(struct inode *inode, struct file *file)
362{
363 return test_and_set_bit(0, &in_use) ? -EBUSY : 0;
364}
365
366static int gemtek_pci_exclusive_release(struct inode *inode, struct file *file)
367{
368 clear_bit(0, &in_use);
369 return 0;
370}
371
367static const struct file_operations gemtek_pci_fops = { 372static const struct file_operations gemtek_pci_fops = {
368 .owner = THIS_MODULE, 373 .owner = THIS_MODULE,
369 .open = video_exclusive_open, 374 .open = gemtek_pci_exclusive_open,
370 .release = video_exclusive_release, 375 .release = gemtek_pci_exclusive_release,
371 .ioctl = video_ioctl2, 376 .ioctl = video_ioctl2,
372#ifdef CONFIG_COMPAT 377#ifdef CONFIG_COMPAT
373 .compat_ioctl = v4l_compat_ioctl32, 378 .compat_ioctl = v4l_compat_ioctl32,
@@ -391,9 +396,10 @@ static const struct v4l2_ioctl_ops gemtek_pci_ioctl_ops = {
391}; 396};
392 397
393static struct video_device vdev_template = { 398static struct video_device vdev_template = {
394 .name = "Gemtek PCI Radio", 399 .name = "Gemtek PCI Radio",
395 .fops = &gemtek_pci_fops, 400 .fops = &gemtek_pci_fops,
396 .ioctl_ops = &gemtek_pci_ioctl_ops, 401 .ioctl_ops = &gemtek_pci_ioctl_ops,
402 .release = video_device_release_empty,
397}; 403};
398 404
399static int __devinit gemtek_pci_probe( struct pci_dev *pci_dev, const struct pci_device_id *pci_id ) 405static int __devinit gemtek_pci_probe( struct pci_dev *pci_dev, const struct pci_device_id *pci_id )
@@ -431,7 +437,7 @@ static int __devinit gemtek_pci_probe( struct pci_dev *pci_dev, const struct pci
431 } 437 }
432 438
433 card->videodev = devradio; 439 card->videodev = devradio;
434 devradio->priv = card; 440 video_set_drvdata(devradio, card);
435 gemtek_pci_mute( card ); 441 gemtek_pci_mute( card );
436 442
437 printk( KERN_INFO "Gemtek PCI Radio (rev. %d) found at 0x%04x-0x%04x.\n", 443 printk( KERN_INFO "Gemtek PCI Radio (rev. %d) found at 0x%04x-0x%04x.\n",