aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil@xs4all.nl>2009-03-06 11:51:33 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-03-30 11:43:12 -0400
commit2710e6aa3f15cb008577ce31fc469e8af7466075 (patch)
tree71ec3beec3394160318575c4eb0639b6ee98b460
parent087c61848cd1837321dc94d398b33cc863efc764 (diff)
V4L/DVB (10886): radio-maxiradio: convert to v4l2_device.
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r--drivers/media/radio/radio-maxiradio.c375
1 files changed, 186 insertions, 189 deletions
diff --git a/drivers/media/radio/radio-maxiradio.c b/drivers/media/radio/radio-maxiradio.c
index c5dc00aa9c9f..f43e4a6811a3 100644
--- a/drivers/media/radio/radio-maxiradio.c
+++ b/drivers/media/radio/radio-maxiradio.c
@@ -37,38 +37,33 @@
37#include <linux/init.h> 37#include <linux/init.h>
38#include <linux/ioport.h> 38#include <linux/ioport.h>
39#include <linux/delay.h> 39#include <linux/delay.h>
40#include <asm/io.h>
41#include <asm/uaccess.h>
42#include <linux/mutex.h> 40#include <linux/mutex.h>
43
44#include <linux/pci.h> 41#include <linux/pci.h>
45#include <linux/videodev2.h> 42#include <linux/videodev2.h>
46#include <media/v4l2-common.h> 43#include <linux/version.h> /* for KERNEL_VERSION MACRO */
44#include <linux/io.h>
45#include <linux/uaccess.h>
46#include <media/v4l2-device.h>
47#include <media/v4l2-ioctl.h> 47#include <media/v4l2-ioctl.h>
48 48
49MODULE_AUTHOR("Dimitromanolakis Apostolos, apdim@grecian.net");
50MODULE_DESCRIPTION("Radio driver for the Guillemot Maxi Radio FM2000 radio.");
51MODULE_LICENSE("GPL");
52
53static int radio_nr = -1;
54module_param(radio_nr, int, 0);
55
56static int debug;
57
58module_param(debug, int, 0644);
59MODULE_PARM_DESC(debug, "activates debug info");
60
49#define DRIVER_VERSION "0.77" 61#define DRIVER_VERSION "0.77"
50 62
51#include <linux/version.h> /* for KERNEL_VERSION MACRO */ 63#define RADIO_VERSION KERNEL_VERSION(0, 7, 7)
52#define RADIO_VERSION KERNEL_VERSION(0,7,7) 64
53 65#define dprintk(dev, num, fmt, arg...) \
54static struct video_device maxiradio_radio; 66 v4l2_dbg(num, debug, &dev->v4l2_dev, fmt, ## arg)
55
56#define dprintk(num, fmt, arg...) \
57 do { \
58 if (maxiradio_radio.debug >= num) \
59 printk(KERN_DEBUG "%s: " fmt, \
60 maxiradio_radio.name, ## arg); } while (0)
61
62static struct v4l2_queryctrl radio_qctrl[] = {
63 {
64 .id = V4L2_CID_AUDIO_MUTE,
65 .name = "Mute",
66 .minimum = 0,
67 .maximum = 1,
68 .default_value = 1,
69 .type = V4L2_CTRL_TYPE_BOOLEAN,
70 }
71};
72 67
73#ifndef PCI_VENDOR_ID_GUILLEMOT 68#ifndef PCI_VENDOR_ID_GUILLEMOT
74#define PCI_VENDOR_ID_GUILLEMOT 0x5046 69#define PCI_VENDOR_ID_GUILLEMOT 0x5046
@@ -80,90 +75,70 @@ static struct v4l2_queryctrl radio_qctrl[] = {
80 75
81 76
82/* TEA5757 pin mappings */ 77/* TEA5757 pin mappings */
83static const int clk = 1, data = 2, wren = 4, mo_st = 8, power = 16 ; 78static const int clk = 1, data = 2, wren = 4, mo_st = 8, power = 16;
84
85static int radio_nr = -1;
86module_param(radio_nr, int, 0);
87 79
88static unsigned long in_use; 80#define FREQ_LO (50 * 16000)
89 81#define FREQ_HI (150 * 16000)
90#define FREQ_LO 50*16000
91#define FREQ_HI 150*16000
92 82
93#define FREQ_IF 171200 /* 10.7*16000 */ 83#define FREQ_IF 171200 /* 10.7*16000 */
94#define FREQ_STEP 200 /* 12.5*16 */ 84#define FREQ_STEP 200 /* 12.5*16 */
95 85
96/* (x==fmhz*16*1000) -> bits */ 86/* (x==fmhz*16*1000) -> bits */
97#define FREQ2BITS(x) ((( (unsigned int)(x)+FREQ_IF+(FREQ_STEP<<1)) \ 87#define FREQ2BITS(x) \
98 /(FREQ_STEP<<2))<<2) 88 ((((unsigned int)(x) + FREQ_IF + (FREQ_STEP << 1)) / (FREQ_STEP << 2)) << 2)
99 89
100#define BITS2FREQ(x) ((x) * FREQ_STEP - FREQ_IF) 90#define BITS2FREQ(x) ((x) * FREQ_STEP - FREQ_IF)
101 91
102 92
103static int maxiradio_exclusive_open(struct file *file) 93struct maxiradio
104{ 94{
105 return test_and_set_bit(0, &in_use) ? -EBUSY : 0; 95 struct v4l2_device v4l2_dev;
106} 96 struct video_device vdev;
107 97 struct pci_dev *pdev;
108static int maxiradio_exclusive_release(struct file *file)
109{
110 clear_bit(0, &in_use);
111 return 0;
112}
113
114static const struct v4l2_file_operations maxiradio_fops = {
115 .owner = THIS_MODULE,
116 .open = maxiradio_exclusive_open,
117 .release = maxiradio_exclusive_release,
118 .ioctl = video_ioctl2,
119};
120 98
121static struct radio_device 99 u16 io; /* base of radio io */
122{ 100 u16 muted; /* VIDEO_AUDIO_MUTE */
123 __u16 io, /* base of radio io */ 101 u16 stereo; /* VIDEO_TUNER_STEREO_ON */
124 muted, /* VIDEO_AUDIO_MUTE */ 102 u16 tuned; /* signal strength (0 or 0xffff) */
125 stereo, /* VIDEO_TUNER_STEREO_ON */
126 tuned; /* signal strength (0 or 0xffff) */
127 103
128 unsigned long freq; 104 unsigned long freq;
129 105
130 struct mutex lock; 106 struct mutex lock;
131} radio_unit = {
132 .muted =1,
133 .freq = FREQ_LO,
134}; 107};
135 108
136static void outbit(unsigned long bit, __u16 io) 109static inline struct maxiradio *to_maxiradio(struct v4l2_device *v4l2_dev)
137{ 110{
138 if (bit != 0) 111 return container_of(v4l2_dev, struct maxiradio, v4l2_dev);
139 {
140 outb( power|wren|data ,io); udelay(4);
141 outb( power|wren|data|clk ,io); udelay(4);
142 outb( power|wren|data ,io); udelay(4);
143 }
144 else
145 {
146 outb( power|wren ,io); udelay(4);
147 outb( power|wren|clk ,io); udelay(4);
148 outb( power|wren ,io); udelay(4);
149 }
150} 112}
151 113
152static void turn_power(__u16 io, int p) 114static void outbit(unsigned long bit, u16 io)
115{
116 int val = power | wren | (bit ? data : 0);
117
118 outb(val, io);
119 udelay(4);
120 outb(val | clk, io);
121 udelay(4);
122 outb(val, io);
123 udelay(4);
124}
125
126static void turn_power(struct maxiradio *dev, int p)
153{ 127{
154 if (p != 0) { 128 if (p != 0) {
155 dprintk(1, "Radio powered on\n"); 129 dprintk(dev, 1, "Radio powered on\n");
156 outb(power, io); 130 outb(power, dev->io);
157 } else { 131 } else {
158 dprintk(1, "Radio powered off\n"); 132 dprintk(dev, 1, "Radio powered off\n");
159 outb(0,io); 133 outb(0, dev->io);
160 } 134 }
161} 135}
162 136
163static void set_freq(__u16 io, __u32 freq) 137static void set_freq(struct maxiradio *dev, u32 freq)
164{ 138{
165 unsigned long int si; 139 unsigned long int si;
166 int bl; 140 int bl;
141 int io = dev->io;
167 int val = FREQ2BITS(freq); 142 int val = FREQ2BITS(freq);
168 143
169 /* TEA5757 shift register bits (see pdf) */ 144 /* TEA5757 shift register bits (see pdf) */
@@ -188,14 +163,14 @@ static void set_freq(__u16 io, __u32 freq)
188 si >>= 1; 163 si >>= 1;
189 } 164 }
190 165
191 dprintk(1, "Radio freq set to %d.%02d MHz\n", 166 dprintk(dev, 1, "Radio freq set to %d.%02d MHz\n",
192 freq / 16000, 167 freq / 16000,
193 freq % 16000 * 100 / 16000); 168 freq % 16000 * 100 / 16000);
194 169
195 turn_power(io, 1); 170 turn_power(dev, 1);
196} 171}
197 172
198static int get_stereo(__u16 io) 173static int get_stereo(u16 io)
199{ 174{
200 outb(power,io); 175 outb(power,io);
201 udelay(4); 176 udelay(4);
@@ -203,7 +178,7 @@ static int get_stereo(__u16 io)
203 return !(inb(io) & mo_st); 178 return !(inb(io) & mo_st);
204} 179}
205 180
206static int get_tune(__u16 io) 181static int get_tune(u16 io)
207{ 182{
208 outb(power+clk,io); 183 outb(power+clk,io);
209 udelay(4); 184 udelay(4);
@@ -212,95 +187,84 @@ static int get_tune(__u16 io)
212} 187}
213 188
214 189
215static int vidioc_querycap (struct file *file, void *priv, 190static int vidioc_querycap(struct file *file, void *priv,
216 struct v4l2_capability *v) 191 struct v4l2_capability *v)
217{ 192{
218 strlcpy(v->driver, "radio-maxiradio", sizeof (v->driver)); 193 struct maxiradio *dev = video_drvdata(file);
219 strlcpy(v->card, "Maxi Radio FM2000 radio", sizeof (v->card));
220 sprintf(v->bus_info,"ISA");
221 v->version = RADIO_VERSION;
222 v->capabilities = V4L2_CAP_TUNER;
223 194
195 strlcpy(v->driver, "radio-maxiradio", sizeof(v->driver));
196 strlcpy(v->card, "Maxi Radio FM2000 radio", sizeof(v->card));
197 snprintf(v->bus_info, sizeof(v->bus_info), "PCI:%s", pci_name(dev->pdev));
198 v->version = RADIO_VERSION;
199 v->capabilities = V4L2_CAP_TUNER | V4L2_CAP_RADIO;
224 return 0; 200 return 0;
225} 201}
226 202
227static int vidioc_g_tuner (struct file *file, void *priv, 203static int vidioc_g_tuner(struct file *file, void *priv,
228 struct v4l2_tuner *v) 204 struct v4l2_tuner *v)
229{ 205{
230 struct radio_device *card = video_drvdata(file); 206 struct maxiradio *dev = video_drvdata(file);
231 207
232 if (v->index > 0) 208 if (v->index > 0)
233 return -EINVAL; 209 return -EINVAL;
234 210
235 memset(v,0,sizeof(*v)); 211 mutex_lock(&dev->lock);
236 strcpy(v->name, "FM"); 212 strlcpy(v->name, "FM", sizeof(v->name));
237 v->type = V4L2_TUNER_RADIO; 213 v->type = V4L2_TUNER_RADIO;
238 214 v->rangelow = FREQ_LO;
239 v->rangelow=FREQ_LO; 215 v->rangehigh = FREQ_HI;
240 v->rangehigh=FREQ_HI; 216 v->rxsubchans = V4L2_TUNER_SUB_MONO | V4L2_TUNER_SUB_STEREO;
241 v->rxsubchans =V4L2_TUNER_SUB_MONO|V4L2_TUNER_SUB_STEREO; 217 v->capability = V4L2_TUNER_CAP_LOW;
242 v->capability=V4L2_TUNER_CAP_LOW; 218 if (get_stereo(dev->io))
243 if(get_stereo(card->io))
244 v->audmode = V4L2_TUNER_MODE_STEREO; 219 v->audmode = V4L2_TUNER_MODE_STEREO;
245 else 220 else
246 v->audmode = V4L2_TUNER_MODE_MONO; 221 v->audmode = V4L2_TUNER_MODE_MONO;
247 v->signal=0xffff*get_tune(card->io); 222 v->signal = 0xffff * get_tune(dev->io);
223 mutex_unlock(&dev->lock);
248 224
249 return 0; 225 return 0;
250} 226}
251 227
252static int vidioc_s_tuner (struct file *file, void *priv, 228static int vidioc_s_tuner(struct file *file, void *priv,
253 struct v4l2_tuner *v) 229 struct v4l2_tuner *v)
254{ 230{
255 if (v->index > 0) 231 return v->index ? -EINVAL : 0;
256 return -EINVAL;
257
258 return 0;
259}
260
261static int vidioc_g_audio (struct file *file, void *priv,
262 struct v4l2_audio *a)
263{
264 if (a->index > 1)
265 return -EINVAL;
266
267 strcpy(a->name, "FM");
268 a->capability = V4L2_AUDCAP_STEREO;
269 return 0;
270} 232}
271 233
272static int vidioc_g_input(struct file *filp, void *priv, unsigned int *i) 234static int vidioc_g_input(struct file *filp, void *priv, unsigned int *i)
273{ 235{
274 *i = 0; 236 *i = 0;
275
276 return 0; 237 return 0;
277} 238}
278 239
279static int vidioc_s_input(struct file *filp, void *priv, unsigned int i) 240static int vidioc_s_input(struct file *filp, void *priv, unsigned int i)
280{ 241{
281 if (i != 0) 242 return i ? -EINVAL : 0;
282 return -EINVAL; 243}
283 244
245static int vidioc_g_audio(struct file *file, void *priv,
246 struct v4l2_audio *a)
247{
248 a->index = 0;
249 strlcpy(a->name, "Radio", sizeof(a->name));
250 a->capability = V4L2_AUDCAP_STEREO;
284 return 0; 251 return 0;
285} 252}
286 253
287 254
288static int vidioc_s_audio (struct file *file, void *priv, 255static int vidioc_s_audio(struct file *file, void *priv,
289 struct v4l2_audio *a) 256 struct v4l2_audio *a)
290{ 257{
291 if (a->index != 0) 258 return a->index ? -EINVAL : 0;
292 return -EINVAL;
293
294 return 0;
295} 259}
296 260
297static int vidioc_s_frequency (struct file *file, void *priv, 261static int vidioc_s_frequency(struct file *file, void *priv,
298 struct v4l2_frequency *f) 262 struct v4l2_frequency *f)
299{ 263{
300 struct radio_device *card = video_drvdata(file); 264 struct maxiradio *dev = video_drvdata(file);
301 265
302 if (f->frequency < FREQ_LO || f->frequency > FREQ_HI) { 266 if (f->frequency < FREQ_LO || f->frequency > FREQ_HI) {
303 dprintk(1, "radio freq (%d.%02d MHz) out of range (%d-%d)\n", 267 dprintk(dev, 1, "radio freq (%d.%02d MHz) out of range (%d-%d)\n",
304 f->frequency / 16000, 268 f->frequency / 16000,
305 f->frequency % 16000 * 100 / 16000, 269 f->frequency % 16000 * 100 / 16000,
306 FREQ_LO / 16000, FREQ_HI / 16000); 270 FREQ_LO / 16000, FREQ_HI / 16000);
@@ -308,75 +272,91 @@ static int vidioc_s_frequency (struct file *file, void *priv,
308 return -EINVAL; 272 return -EINVAL;
309 } 273 }
310 274
311 card->freq = f->frequency; 275 mutex_lock(&dev->lock);
312 set_freq(card->io, card->freq); 276 dev->freq = f->frequency;
277 set_freq(dev, dev->freq);
313 msleep(125); 278 msleep(125);
279 mutex_unlock(&dev->lock);
314 280
315 return 0; 281 return 0;
316} 282}
317 283
318static int vidioc_g_frequency (struct file *file, void *priv, 284static int vidioc_g_frequency(struct file *file, void *priv,
319 struct v4l2_frequency *f) 285 struct v4l2_frequency *f)
320{ 286{
321 struct radio_device *card = video_drvdata(file); 287 struct maxiradio *dev = video_drvdata(file);
322 288
323 f->type = V4L2_TUNER_RADIO; 289 f->type = V4L2_TUNER_RADIO;
324 f->frequency = card->freq; 290 f->frequency = dev->freq;
325 291
326 dprintk(4, "radio freq is %d.%02d MHz", 292 dprintk(dev, 4, "radio freq is %d.%02d MHz",
327 f->frequency / 16000, 293 f->frequency / 16000,
328 f->frequency % 16000 * 100 / 16000); 294 f->frequency % 16000 * 100 / 16000);
329 295
330 return 0; 296 return 0;
331} 297}
332 298
333static int vidioc_queryctrl (struct file *file, void *priv, 299static int vidioc_queryctrl(struct file *file, void *priv,
334 struct v4l2_queryctrl *qc) 300 struct v4l2_queryctrl *qc)
335{ 301{
336 int i; 302 switch (qc->id) {
337 303 case V4L2_CID_AUDIO_MUTE:
338 for (i = 0; i < ARRAY_SIZE(radio_qctrl); i++) { 304 return v4l2_ctrl_query_fill(qc, 0, 1, 1, 1);
339 if (qc->id && qc->id == radio_qctrl[i].id) {
340 memcpy(qc, &(radio_qctrl[i]), sizeof(*qc));
341 return (0);
342 }
343 } 305 }
344
345 return -EINVAL; 306 return -EINVAL;
346} 307}
347 308
348static int vidioc_g_ctrl (struct file *file, void *priv, 309static int vidioc_g_ctrl(struct file *file, void *priv,
349 struct v4l2_control *ctrl) 310 struct v4l2_control *ctrl)
350{ 311{
351 struct radio_device *card = video_drvdata(file); 312 struct maxiradio *dev = video_drvdata(file);
352 313
353 switch (ctrl->id) { 314 switch (ctrl->id) {
354 case V4L2_CID_AUDIO_MUTE: 315 case V4L2_CID_AUDIO_MUTE:
355 ctrl->value=card->muted; 316 ctrl->value = dev->muted;
356 return (0); 317 return 0;
357 } 318 }
358 319
359 return -EINVAL; 320 return -EINVAL;
360} 321}
361 322
362static int vidioc_s_ctrl (struct file *file, void *priv, 323static int vidioc_s_ctrl(struct file *file, void *priv,
363 struct v4l2_control *ctrl) 324 struct v4l2_control *ctrl)
364{ 325{
365 struct radio_device *card = video_drvdata(file); 326 struct maxiradio *dev = video_drvdata(file);
366 327
367 switch (ctrl->id) { 328 switch (ctrl->id) {
368 case V4L2_CID_AUDIO_MUTE: 329 case V4L2_CID_AUDIO_MUTE:
369 card->muted = ctrl->value; 330 mutex_lock(&dev->lock);
370 if(card->muted) 331 dev->muted = ctrl->value;
371 turn_power(card->io, 0); 332 if (dev->muted)
372 else 333 turn_power(dev, 0);
373 set_freq(card->io, card->freq); 334 else
374 return 0; 335 set_freq(dev, dev->freq);
336 mutex_unlock(&dev->lock);
337 return 0;
375 } 338 }
376 339
377 return -EINVAL; 340 return -EINVAL;
378} 341}
379 342
343static int maxiradio_open(struct file *file)
344{
345 return 0;
346}
347
348static int maxiradio_release(struct file *file)
349{
350 return 0;
351}
352
353static const struct v4l2_file_operations maxiradio_fops = {
354 .owner = THIS_MODULE,
355 .open = maxiradio_open,
356 .release = maxiradio_release,
357 .ioctl = video_ioctl2,
358};
359
380static const struct v4l2_ioctl_ops maxiradio_ioctl_ops = { 360static const struct v4l2_ioctl_ops maxiradio_ioctl_ops = {
381 .vidioc_querycap = vidioc_querycap, 361 .vidioc_querycap = vidioc_querycap,
382 .vidioc_g_tuner = vidioc_g_tuner, 362 .vidioc_g_tuner = vidioc_g_tuner,
@@ -392,60 +372,84 @@ static const struct v4l2_ioctl_ops maxiradio_ioctl_ops = {
392 .vidioc_s_ctrl = vidioc_s_ctrl, 372 .vidioc_s_ctrl = vidioc_s_ctrl,
393}; 373};
394 374
395static struct video_device maxiradio_radio = {
396 .name = "Maxi Radio FM2000 radio",
397 .fops = &maxiradio_fops,
398 .ioctl_ops = &maxiradio_ioctl_ops,
399 .release = video_device_release_empty,
400};
401
402static int __devinit maxiradio_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) 375static int __devinit maxiradio_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
403{ 376{
404 if(!request_region(pci_resource_start(pdev, 0), 377 struct maxiradio *dev;
378 struct v4l2_device *v4l2_dev;
379 int retval = -ENOMEM;
380
381 dev = kzalloc(sizeof(*dev), GFP_KERNEL);
382 if (dev == NULL) {
383 dev_err(&pdev->dev, "not enough memory\n");
384 return -ENOMEM;
385 }
386
387 v4l2_dev = &dev->v4l2_dev;
388 mutex_init(&dev->lock);
389 dev->pdev = pdev;
390 dev->muted = 1;
391 dev->freq = FREQ_LO;
392
393 strlcpy(v4l2_dev->name, "maxiradio", sizeof(v4l2_dev->name));
394
395 retval = v4l2_device_register(&pdev->dev, v4l2_dev);
396 if (retval < 0) {
397 v4l2_err(v4l2_dev, "Could not register v4l2_device\n");
398 goto errfr;
399 }
400
401 if (!request_region(pci_resource_start(pdev, 0),
405 pci_resource_len(pdev, 0), "Maxi Radio FM 2000")) { 402 pci_resource_len(pdev, 0), "Maxi Radio FM 2000")) {
406 printk(KERN_ERR "radio-maxiradio: can't reserve I/O ports\n"); 403 v4l2_err(v4l2_dev, "can't reserve I/O ports\n");
407 goto err_out; 404 goto err_out;
408 } 405 }
409 406
410 if (pci_enable_device(pdev)) 407 if (pci_enable_device(pdev))
411 goto err_out_free_region; 408 goto err_out_free_region;
412 409
413 radio_unit.io = pci_resource_start(pdev, 0); 410 dev->io = pci_resource_start(pdev, 0);
414 mutex_init(&radio_unit.lock); 411 strlcpy(dev->vdev.name, v4l2_dev->name, sizeof(dev->vdev.name));
415 video_set_drvdata(&maxiradio_radio, &radio_unit); 412 dev->vdev.v4l2_dev = v4l2_dev;
413 dev->vdev.fops = &maxiradio_fops;
414 dev->vdev.ioctl_ops = &maxiradio_ioctl_ops;
415 dev->vdev.release = video_device_release_empty;
416 video_set_drvdata(&dev->vdev, dev);
416 417
417 if (video_register_device(&maxiradio_radio, VFL_TYPE_RADIO, radio_nr) < 0) { 418 if (video_register_device(&dev->vdev, VFL_TYPE_RADIO, radio_nr) < 0) {
418 printk("radio-maxiradio: can't register device!"); 419 v4l2_err(v4l2_dev, "can't register device!");
419 goto err_out_free_region; 420 goto err_out_free_region;
420 } 421 }
421 422
422 printk(KERN_INFO "radio-maxiradio: version " 423 v4l2_info(v4l2_dev, "version " DRIVER_VERSION
423 DRIVER_VERSION 424 " time " __TIME__ " " __DATE__ "\n");
424 " time "
425 __TIME__ " "
426 __DATE__
427 "\n");
428 425
429 printk(KERN_INFO "radio-maxiradio: found Guillemot MAXI Radio device (io = 0x%x)\n", 426 v4l2_info(v4l2_dev, "found Guillemot MAXI Radio device (io = 0x%x)\n",
430 radio_unit.io); 427 dev->io);
431 return 0; 428 return 0;
432 429
433err_out_free_region: 430err_out_free_region:
434 release_region(pci_resource_start(pdev, 0), pci_resource_len(pdev, 0)); 431 release_region(pci_resource_start(pdev, 0), pci_resource_len(pdev, 0));
435err_out: 432err_out:
433 v4l2_device_unregister(v4l2_dev);
434errfr:
435 kfree(dev);
436 return -ENODEV; 436 return -ENODEV;
437} 437}
438 438
439static void __devexit maxiradio_remove_one(struct pci_dev *pdev) 439static void __devexit maxiradio_remove_one(struct pci_dev *pdev)
440{ 440{
441 video_unregister_device(&maxiradio_radio); 441 struct v4l2_device *v4l2_dev = dev_get_drvdata(&pdev->dev);
442 struct maxiradio *dev = to_maxiradio(v4l2_dev);
443
444 video_unregister_device(&dev->vdev);
445 v4l2_device_unregister(&dev->v4l2_dev);
442 release_region(pci_resource_start(pdev, 0), pci_resource_len(pdev, 0)); 446 release_region(pci_resource_start(pdev, 0), pci_resource_len(pdev, 0));
443} 447}
444 448
445static struct pci_device_id maxiradio_pci_tbl[] = { 449static struct pci_device_id maxiradio_pci_tbl[] = {
446 { PCI_VENDOR_ID_GUILLEMOT, PCI_DEVICE_ID_GUILLEMOT_MAXIRADIO, 450 { PCI_VENDOR_ID_GUILLEMOT, PCI_DEVICE_ID_GUILLEMOT_MAXIRADIO,
447 PCI_ANY_ID, PCI_ANY_ID, }, 451 PCI_ANY_ID, PCI_ANY_ID, },
448 { 0,} 452 { 0 }
449}; 453};
450 454
451MODULE_DEVICE_TABLE(pci, maxiradio_pci_tbl); 455MODULE_DEVICE_TABLE(pci, maxiradio_pci_tbl);
@@ -469,10 +473,3 @@ static void __exit maxiradio_radio_exit(void)
469 473
470module_init(maxiradio_radio_init); 474module_init(maxiradio_radio_init);
471module_exit(maxiradio_radio_exit); 475module_exit(maxiradio_radio_exit);
472
473MODULE_AUTHOR("Dimitromanolakis Apostolos, apdim@grecian.net");
474MODULE_DESCRIPTION("Radio driver for the Guillemot Maxi Radio FM2000 radio.");
475MODULE_LICENSE("GPL");
476
477module_param_named(debug,maxiradio_radio.debug, int, 0644);
478MODULE_PARM_DESC(debug,"activates debug info");