lkml.org 
[lkml]   [2000]   [Nov]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH] media/radio [check_region() removal... ]

Hi!

Patch against 2.4.0-test11-pre1. It replaces check_region() by
request_region(), fixes some small bugs and tries to cleanup a bit
radio drivers... I have just seen 240t11p1ac1 and I think this
patch is superior then ac's radio part ;)

Please apply...

--
Bartlomiej Zolnierkiewicz
<bkz@linux-ide.org>
diff -uNr linux-240t11p1/drivers/media/radio/radio-aimslab.c linux/drivers/media/radio/radio-aimslab.c
--- linux-240t11p1/drivers/media/radio/radio-aimslab.c Tue Oct 3 00:17:39 2000
+++ linux/drivers/media/radio/radio-aimslab.c Thu Nov 9 00:37:48 2000
@@ -27,15 +27,17 @@
*
*/

-#include <linux/module.h> /* Modules */
-#include <linux/init.h> /* Initdata */
-#include <linux/ioport.h> /* check_region, request_region */
-#include <linux/delay.h> /* udelay */
-#include <asm/io.h> /* outb, outb_p */
-#include <asm/uaccess.h> /* copy to/from user */
-#include <linux/videodev.h> /* kernel radio structs */
-#include <linux/config.h> /* CONFIG_RADIO_RTRACK_PORT */
-#include <asm/semaphore.h> /* Lock for the I/O */
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/ioport.h>
+#include <linux/delay.h>
+#include <asm/io.h>
+#include <asm/uaccess.h>
+#include <linux/videodev.h>
+#include <linux/config.h>
+#include <asm/semaphore.h>
+
+#define RTRACK_IO_EXTENT 0x02

#ifndef CONFIG_RADIO_RTRACK_PORT
#define CONFIG_RADIO_RTRACK_PORT -1
@@ -337,30 +339,28 @@

static int __init rtrack_init(void)
{
- if(io==-1)
- {
- printk(KERN_ERR "You must set an I/O address with io=0x???\n");
+ printk(KERN_INFO "AIMSlab RadioTrack/RadioReveal card driver.\n");
+
+ if(io == -1) {
+ printk(KERN_ERR "rtrack: you must set an I/O address with io=0x???\n");
return -EINVAL;
}
-
- if (check_region(io, 2))
- {
+ printk(KERN_INFO "rtrack: port 0x%x.\n", io);
+ if (!request_region(io, RTRACK_IO_EXTENT, "rtrack")) {
printk(KERN_ERR "rtrack: port 0x%x already in use\n", io);
return -EBUSY;
}

rtrack_radio.priv=&rtrack_unit;
-
- if(video_register_device(&rtrack_radio, VFL_TYPE_RADIO)==-1)
+
+ if(video_register_device(&rtrack_radio, VFL_TYPE_RADIO) == -1) {
+ release_region(io, RTRACK_IO_EXTENT);
return -EINVAL;
-
- request_region(io, 2, "rtrack");
- printk(KERN_INFO "AIMSlab RadioTrack/RadioReveal card driver.\n");
+ }

/* Set up the I/O locking */
-
init_MUTEX(&lock);
-
+
/* mute card - prevents noisy bootups */

/* this ensures that the volume is all the way down */
@@ -379,12 +379,11 @@

EXPORT_NO_SYMBOLS;

-static void __exit cleanup_rtrack_module(void)
+static void __exit rtrack_cleanup(void)
{
video_unregister_device(&rtrack_radio);
- release_region(io,2);
+ release_region(io, RTRACK_IO_EXTENT);
}

module_init(rtrack_init);
-module_exit(cleanup_rtrack_module);
-
+module_exit(rtrack_cleanup);
diff -uNr linux-240t11p1/drivers/media/radio/radio-aztech.c linux/drivers/media/radio/radio-aztech.c
--- linux-240t11p1/drivers/media/radio/radio-aztech.c Tue Oct 3 00:17:39 2000
+++ linux/drivers/media/radio/radio-aztech.c Thu Nov 9 00:37:32 2000
@@ -24,14 +24,16 @@
* - tuning structure changed - no more character arrays, other changes
*/

-#include <linux/module.h> /* Modules */
-#include <linux/init.h> /* Initdata */
-#include <linux/ioport.h> /* check_region, request_region */
-#include <linux/delay.h> /* udelay */
-#include <asm/io.h> /* outb, outb_p */
-#include <asm/uaccess.h> /* copy to/from user */
-#include <linux/videodev.h> /* kernel radio structs */
-#include <linux/config.h> /* CONFIG_RADIO_AZTECH_PORT */
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/ioport.h>
+#include <linux/delay.h>
+#include <asm/io.h>
+#include <asm/uaccess.h>
+#include <linux/videodev.h>
+#include <linux/config.h>
+
+#define AZTECH_IO_EXTENT 0x02

/* acceptable ports: 0x350 (JP3 shorted), 0x358 (JP3 open) */

@@ -288,28 +290,29 @@

static int __init aztech_init(void)
{
- if(io==-1)
- {
- printk(KERN_ERR "You must set an I/O address with io=0x???\n");
+ printk(KERN_INFO "Aztech radio card driver v1.00/19990224 rkroll@exploits.org\n");
+
+ if (io == -1) {
+ printk(KERN_ERR "aztech: you must set an I/O address with io=0x???\n");
return -EINVAL;
}
-
- if (check_region(io, 2))
- {
+ printk(KERN_INFO "aztech: port 0x%x.\n", io);
+ if (!request_region(io, AZTECH_IO_EXTENT, "aztech")) {
printk(KERN_ERR "aztech: port 0x%x already in use\n", io);
return -EBUSY;
}

init_MUTEX(&lock);
aztech_radio.priv=&aztech_unit;
-
- if(video_register_device(&aztech_radio, VFL_TYPE_RADIO)==-1)
+
+ if(video_register_device(&aztech_radio, VFL_TYPE_RADIO) == -1) {
+ release_region(io, AZTECH_IO_EXTENT);
return -EINVAL;
-
- request_region(io, 2, "aztech");
- printk(KERN_INFO "Aztech radio card driver v1.00/19990224 rkroll@exploits.org\n");
+ }
+
/* mute card - prevents noisy bootups */
outb (0, io);
+
return 0;
}

@@ -323,7 +326,7 @@
static void __exit aztech_cleanup(void)
{
video_unregister_device(&aztech_radio);
- release_region(io,2);
+ release_region(io, AZTECH_IO_EXTENT);
}

module_init(aztech_init);
diff -uNr linux-240t11p1/drivers/media/radio/radio-cadet.c linux/drivers/media/radio/radio-cadet.c
--- linux-240t11p1/drivers/media/radio/radio-cadet.c Wed Nov 8 19:47:33 2000
+++ linux/drivers/media/radio/radio-cadet.c Thu Nov 9 00:37:11 2000
@@ -18,16 +18,18 @@
*
*/

-#include <linux/module.h> /* Modules */
-#include <linux/init.h> /* Initdata */
-#include <linux/ioport.h> /* check_region, request_region */
-#include <linux/delay.h> /* udelay */
-#include <asm/io.h> /* outb, outb_p */
-#include <asm/uaccess.h> /* copy to/from user */
-#include <linux/videodev.h> /* kernel radio structs */
-#include <linux/config.h> /* CONFIG_RADIO_CADET_PORT */
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/ioport.h>
+#include <linux/delay.h>
+#include <asm/io.h>
+#include <asm/uaccess.h>
+#include <linux/videodev.h>
+#include <linux/config.h>
#include <linux/param.h>

+#define CADET_IO_EXTENT 0x02
+
#ifndef CONFIG_RADIO_CADET_PORT
#define CONFIG_RADIO_CADET_PORT 0x330
#endif
@@ -44,10 +46,6 @@
static unsigned char rdsbuf[RDS_BUFFER];
static int cadet_lock=0;

-#ifndef MODULE
-static int cadet_probe(void);
-#endif
-
#ifdef CONFIG_ISAPNP
#include <linux/isapnp.h>

@@ -326,13 +324,13 @@
if(cadet_lock==0) {
outb(0x3,io); /* Select RDS Decoder Control */
if((inb(io+1)&0x20)!=0) {
- printk(KERN_CRIT "cadet: RDS fifo overflow\n");
+ printk(KERN_ERR "cadet: RDS fifo overflow\n");
}
outb(0x80,io); /* Select RDS fifo */
while((inb(io)&0x80)!=0) {
rdsbuf[rdsin++]=inb(io+1);
if(rdsin==rdsout) {
- printk(KERN_CRIT "cadet: RDS buffer overflow\n");
+ printk(KERN_ERR "cadet: RDS buffer overflow\n");
}
}
}
@@ -556,7 +554,7 @@
};

#ifdef CONFIG_ISAPNP
-static int isapnp_cadet_probe(void)
+static int __init isapnp_cadet_probe(void)
{
dev = isapnp_find_dev (NULL, ISAPNP_VENDOR('M','S','M'),
ISAPNP_FUNCTION(0x0c24), NULL);
@@ -568,63 +566,70 @@
if (!(dev->resource[0].flags & IORESOURCE_IO))
return -ENODEV;
if (dev->activate(dev)<0) {
- printk ("radio-cadet: isapnp configure failed (out of resources?)\n");
+ printk(KERN_ERR "cadet: ISAPnP configure failed (out of resources?)\n");
return -ENOMEM;
}

io = dev->resource[0].start;

- printk ("radio-cadet: ISAPnP reports card at %#x\n", io);
+ printk(KERN_INFO "cadet: ISAPnP reports card at %#x\n", io);

return io;
}
-#endif /* CONFIG_ISAPNP */
+#endif /* CONFIG_ISAPNP */

-#ifdef MODULE
-static int cadet_probe(void)
+#ifndef MODULE
+static int __init cadet_probe(void)
{
static int iovals[8]={0x330,0x332,0x334,0x336,0x338,0x33a,0x33c,0x33e};
int i;

for(i=0;i<8;i++) {
io=iovals[i];
- if(check_region(io,2)>=0) {
+ if(request_region(io, CADET_IO_EXTENT, "cadet")) > 0) {
cadet_setfreq(1410);
- if(cadet_getfreq()==1410) {
- return io;
- }
+ if(cadet_getfreq() == 1410)
+ return io;
+ release_region(io, CADET_IO_EXTENT);
}
}
- return -1;
+ return -ENODEV;
}
-#endif /* MODULE */
+#endif /* MODULE */

static int __init cadet_init(void)
{
+ printk(KERN_INFO "ADS Cadet Radio card driver.\n");
+
#ifdef CONFIG_ISAPNP
io = isapnp_cadet_probe();

if (io < 0)
- return (io);
+ return io;
#else
#ifndef MODULE /* only probe on non-ISAPnP monolithic compiles */
- io = cadet_probe ();
+ io = cadet_probe();
+
+ if(io > 0)
+ goto reg;
#endif /* MODULE */
#endif /* CONFIG_ISAPNP */

if(io < 0) {
-#ifdef MODULE
- printk(KERN_ERR "You must set an I/O address with io=0x???\n");
-#endif
- return -EINVAL;
+#ifdef MODULE
+ printk(KERN_ERR "cadet: you must set an I/O address with io=0x???\n");
+#endif /* MODULE */
+ return -EINVAL;
}
- if (!request_region(io,2,"cadet"))
+ if (!request_region(io, CADET_IO_EXTENT, "cadet"))
return -EBUSY;
+reg:
+ printk(KERN_INFO "cadet: port 0x%x.\n", io);
if(video_register_device(&cadet_radio,VFL_TYPE_RADIO)==-1) {
- release_region(io,2);
+ release_region(io, CADET_IO_EXTENT);
return -EINVAL;
}
- printk(KERN_INFO "ADS Cadet Radio Card at 0x%x\n",io);
+
return 0;
}

@@ -637,10 +642,10 @@

EXPORT_NO_SYMBOLS;

-static void __exit cadet_cleanup_module(void)
+static void __exit cadet_cleanup(void)
{
video_unregister_device(&cadet_radio);
- release_region(io,2);
+ release_region(io, CADET_IO_EXTENT);

#ifdef CONFIG_ISAPNP
if (dev)
@@ -649,5 +654,4 @@
}

module_init(cadet_init);
-module_exit(cadet_cleanup_module);
-
+module_exit(cadet_cleanup);
diff -uNr linux-240t11p1/drivers/media/radio/radio-gemtek.c linux/drivers/media/radio/radio-gemtek.c
--- linux-240t11p1/drivers/media/radio/radio-gemtek.c Tue Oct 3 00:17:39 2000
+++ linux/drivers/media/radio/radio-gemtek.c Thu Nov 9 00:36:10 2000
@@ -15,16 +15,18 @@
*
*/

-#include <linux/module.h> /* Modules */
-#include <linux/init.h> /* Initdata */
-#include <linux/ioport.h> /* check_region, request_region */
-#include <linux/delay.h> /* udelay */
-#include <asm/io.h> /* outb, outb_p */
-#include <asm/uaccess.h> /* copy to/from user */
-#include <linux/videodev.h> /* kernel radio structs */
-#include <linux/config.h> /* CONFIG_RADIO_GEMTEK_PORT */
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/ioport.h>
+#include <linux/delay.h>
+#include <asm/io.h>
+#include <asm/uaccess.h>
+#include <linux/videodev.h>
+#include <linux/config.h>
#include <linux/spinlock.h>

+#define GEMTEK_IO_EXTENT 0x04
+
#ifndef CONFIG_RADIO_GEMTEK_PORT
#define CONFIG_RADIO_GEMTEK_PORT -1
#endif
@@ -264,25 +266,24 @@

static int __init gemtek_init(void)
{
- if(io==-1)
- {
+ printk(KERN_INFO "GemTek radio card driver.\n");
+
+ if(io == -1) {
printk(KERN_ERR "You must set an I/O address with io=0x20c, io=0x30c, io=0x24c or io=0x34c (io=0x020c or io=0x248 for the combined sound/radiocard)\n");
return -EINVAL;
}
-
- if (check_region(io, 4))
- {
+ printk(KERN_INFO "gemtek: port 0x%x.\n", io);
+ if(!request_region(io, GEMTEK_IO_EXTENT, "gemtek")) {
printk(KERN_ERR "gemtek: port 0x%x already in use\n", io);
return -EBUSY;
}

gemtek_radio.priv=&gemtek_unit;
-
- if(video_register_device(&gemtek_radio, VFL_TYPE_RADIO)==-1)
+
+ if(video_register_device(&gemtek_radio, VFL_TYPE_RADIO) == -1) {
+ release_region(io, GEMTEK_IO_EXTENT);
return -EINVAL;
-
- request_region(io, 4, "gemtek");
- printk(KERN_INFO "GemTek Radio Card driver.\n");
+ }

spin_lock_init(&lock);
/* mute card - prevents noisy bootups */
@@ -297,7 +298,7 @@
}

MODULE_AUTHOR("Jonas Munsin");
-MODULE_DESCRIPTION("A driver for the GemTek Radio Card");
+MODULE_DESCRIPTION("A driver for the GemTek radio card");
MODULE_PARM(io, "i");
MODULE_PARM_DESC(io, "I/O address of the GemTek card (0x20c, 0x30c, 0x24c or 0x34c (0x20c or 0x248 have been reported to work for the combined sound/radiocard)).");

@@ -306,14 +307,8 @@
static void __exit gemtek_cleanup(void)
{
video_unregister_device(&gemtek_radio);
- release_region(io,4);
+ release_region(io, GEMTEK_IO_EXTENT);
}

module_init(gemtek_init);
module_exit(gemtek_cleanup);
-
-/*
- Local variables:
- compile-command: "gcc -c -DMODVERSIONS -D__KERNEL__ -DMODULE -O6 -Wall -Wstrict-prototypes -I /home/blp/tmp/linux-2.1.111-rtrack/include radio-rtrack2.c"
- End:
-*/
diff -uNr linux-240t11p1/drivers/media/radio/radio-maestro.c linux/drivers/media/radio/radio-maestro.c
--- linux-240t11p1/drivers/media/radio/radio-maestro.c Tue Oct 3 14:27:34 2000
+++ linux/drivers/media/radio/radio-maestro.c Thu Nov 9 00:05:07 2000
@@ -367,7 +367,7 @@

if(radio_power_on(&radio_unit)) {
if(video_register_device(&maestro_radio, VFL_TYPE_RADIO)==-1) {
- printk("radio-maestro: can't register device!");
+ printk(KERN_ERR "radio-maestro: can't register device!");
return 0;
}
printk(KERN_INFO "radio-maestro: version "
diff -uNr linux-240t11p1/drivers/media/radio/radio-rtrack2.c linux/drivers/media/radio/radio-rtrack2.c
--- linux-240t11p1/drivers/media/radio/radio-rtrack2.c Tue Oct 3 00:17:39 2000
+++ linux/drivers/media/radio/radio-rtrack2.c Thu Nov 9 00:35:31 2000
@@ -8,16 +8,18 @@
*
*/

-#include <linux/module.h> /* Modules */
-#include <linux/init.h> /* Initdata */
-#include <linux/ioport.h> /* check_region, request_region */
-#include <linux/delay.h> /* udelay */
-#include <asm/io.h> /* outb, outb_p */
-#include <asm/uaccess.h> /* copy to/from user */
-#include <linux/videodev.h> /* kernel radio structs */
-#include <linux/config.h> /* CONFIG_RADIO_RTRACK2_PORT */
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/ioport.h>
+#include <linux/delay.h>
+#include <asm/io.h>
+#include <asm/uaccess.h>
+#include <linux/videodev.h>
+#include <linux/config.h>
#include <linux/spinlock.h>

+#define RTRACK2_IO_EXTENT 0x04
+
#ifndef CONFIG_RADIO_RTRACK2_PORT
#define CONFIG_RADIO_RTRACK2_PORT -1
#endif
@@ -230,25 +232,25 @@

static int __init rtrack2_init(void)
{
- if(io==-1)
- {
- printk(KERN_ERR "You must set an I/O address with io=0x20c or io=0x30c\n");
+ printk(KERN_INFO "AIMSlab Radiotrack II card driver.\n");
+
+ if(io == -1) {
+ printk(KERN_ERR "rtrack2: You must set an I/O address with io=0x20c or io=0x30c\n");
return -EINVAL;
}
- if (check_region(io, 4))
- {
+ printk(KERN_INFO "rtrack2: port 0x%x.\n", io);
+ if (!request_region(io, RTRACK2_IO_EXTENT, "rtrack2")) {
printk(KERN_ERR "rtrack2: port 0x%x already in use\n", io);
return -EBUSY;
}

rtrack2_radio.priv=&rtrack2_unit;

- spin_lock_init(&lock);
- if(video_register_device(&rtrack2_radio, VFL_TYPE_RADIO)==-1)
+ spin_lock_init(&lock);
+ if(video_register_device(&rtrack2_radio, VFL_TYPE_RADIO) == -1) {
+ release_region(io, RTRACK2_IO_EXTENT);
return -EINVAL;
-
- request_region(io, 4, "rtrack2");
- printk(KERN_INFO "AIMSlab Radiotrack II card driver.\n");
+ }

/* mute card - prevents noisy bootups */
outb(1, io);
@@ -264,17 +266,11 @@

EXPORT_NO_SYMBOLS;

-static void __exit rtrack2_cleanup_module(void)
+static void __exit rtrack2_cleanup(void)
{
video_unregister_device(&rtrack2_radio);
- release_region(io,4);
+ release_region(io, RTRACK2_IO_EXTENT);
}

module_init(rtrack2_init);
-module_exit(rtrack2_cleanup_module);
-
-/*
- Local variables:
- compile-command: "gcc -c -DMODVERSIONS -D__KERNEL__ -DMODULE -O6 -Wall -Wstrict-prototypes -I /home/blp/tmp/linux-2.1.111-rtrack/include radio-rtrack2.c"
- End:
-*/
+module_exit(rtrack2_cleanup);
diff -uNr linux-240t11p1/drivers/media/radio/radio-sf16fmi.c linux/drivers/media/radio/radio-sf16fmi.c
--- linux-240t11p1/drivers/media/radio/radio-sf16fmi.c Tue Oct 3 00:17:39 2000
+++ linux/drivers/media/radio/radio-sf16fmi.c Thu Nov 9 00:35:12 2000
@@ -14,14 +14,14 @@
*
*/

-#include <linux/module.h> /* Modules */
-#include <linux/init.h> /* Initdata */
-#include <linux/ioport.h> /* check_region, request_region */
-#include <linux/delay.h> /* udelay */
-#include <asm/io.h> /* outb, outb_p */
-#include <asm/uaccess.h> /* copy to/from user */
-#include <linux/videodev.h> /* kernel radio structs */
-#include <linux/config.h> /* CONFIG_RADIO_SF16MI_PORT */
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/ioport.h>
+#include <linux/delay.h>
+#include <asm/io.h>
+#include <asm/uaccess.h>
+#include <linux/videodev.h>
+#include <linux/config.h>
#include <asm/semaphore.h>

struct fmi_device
@@ -32,6 +32,8 @@
__u32 flags;
};

+#define SF16FMI_IO_EXTENT 0x02
+
#ifndef CONFIG_RADIO_SF16FMI_PORT
#define CONFIG_RADIO_SF16FMI_PORT -1
#endif
@@ -291,13 +293,14 @@

static int __init fmi_init(void)
{
- if(io==-1)
- {
- printk(KERN_ERR "You must set an I/O address with io=0x???\n");
+ printk(KERN_INFO "SF16FMx radio card driver (c) 1998 Petr Vandrovec <vandrove@vc.cvut.cz>\n");
+
+ if(io == -1) {
+ printk(KERN_ERR "fmi: You must set an I/O address with io=0x???\n");
return -EINVAL;
}
- if (check_region(io, 2))
- {
+ printk(KERN_INFO "fmi: port 0x%x.\n", io);
+ if (!request_region(io, SF16FMI_IO_EXTENT, "fmi")) {
printk(KERN_ERR "fmi: port 0x%x already in use\n", io);
return -EBUSY;
}
@@ -307,33 +310,32 @@
fmi_unit.curfreq = 0;
fmi_unit.flags = VIDEO_TUNER_LOW;
fmi_radio.priv = &fmi_unit;
-
+
init_MUTEX(&lock);
-
- if(video_register_device(&fmi_radio, VFL_TYPE_RADIO)==-1)
+
+ if(video_register_device(&fmi_radio, VFL_TYPE_RADIO) == -1) {
+ release_region(io, SF16FMI_IO_EXTENT);
return -EINVAL;
-
- request_region(io, 2, "fmi");
- printk(KERN_INFO "SF16FMx radio card driver at 0x%x.\n", io);
- printk(KERN_INFO "(c) 1998 Petr Vandrovec, vandrove@vc.cvut.cz.\n");
+ }
+
/* mute card - prevents noisy bootups */
fmi_mute(io);
+
return 0;
}

MODULE_AUTHOR("Petr Vandrovec, vandrove@vc.cvut.cz and M. Kirkwood");
-MODULE_DESCRIPTION("A driver for the SF16MI radio.");
+MODULE_DESCRIPTION("A driver for the SF16FMx radio card.");
MODULE_PARM(io, "i");
-MODULE_PARM_DESC(io, "I/O address of the SF16MI card (0x284 or 0x384)");
+MODULE_PARM_DESC(io, "I/O address of the SF16FMx card (0x284 or 0x384)");

EXPORT_NO_SYMBOLS;

-static void __exit fmi_cleanup_module(void)
+static void __exit fmi_cleanup(void)
{
video_unregister_device(&fmi_radio);
- release_region(io,2);
+ release_region(io, SF16FMI_IO_EXTENT);
}

module_init(fmi_init);
-module_exit(fmi_cleanup_module);
-
+module_exit(fmi_cleanup);
diff -uNr linux-240t11p1/drivers/media/radio/radio-terratec.c linux/drivers/media/radio/radio-terratec.c
--- linux-240t11p1/drivers/media/radio/radio-terratec.c Tue Oct 3 00:17:39 2000
+++ linux/drivers/media/radio/radio-terratec.c Thu Nov 9 00:34:41 2000
@@ -23,16 +23,18 @@
*
*/

-#include <linux/module.h> /* Modules */
-#include <linux/init.h> /* Initdata */
-#include <linux/ioport.h> /* check_region, request_region */
-#include <linux/delay.h> /* udelay */
-#include <asm/io.h> /* outb, outb_p */
-#include <asm/uaccess.h> /* copy to/from user */
-#include <linux/videodev.h> /* kernel radio structs */
-#include <linux/config.h> /* CONFIG_RADIO_TERRATEC_PORT */
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/ioport.h>
+#include <linux/delay.h>
+#include <asm/io.h>
+#include <asm/uaccess.h>
+#include <linux/videodev.h>
+#include <linux/config.h>
#include <linux/spinlock.h>

+#define TERRATEC_IO_EXTENT 0x02
+
#ifndef CONFIG_RADIO_TERRATEC_PORT
#define CONFIG_RADIO_TERRATEC_PORT 0x590
#endif
@@ -309,26 +311,26 @@

static int __init terratec_init(void)
{
- if(io==-1)
- {
- printk(KERN_ERR "You must set an I/O address with io=0x???\n");
+ printk(KERN_INFO "TerraTec ActivRadio Standalone card driver.\n");
+
+ if(io == -1) {
+ printk(KERN_ERR "terratec: you must set an I/O address with io=0x???\n");
return -EINVAL;
}
- if (check_region(io, 2))
- {
- printk(KERN_ERR "TerraTec: port 0x%x already in use\n", io);
+ printk("terratec: port 0x%x.\n", io);
+ if(!request_region(io, TERRATEC_IO_EXTENT, "terratec")) {
+ printk(KERN_ERR "terratec: port 0x%x already in use\n", io);
return -EBUSY;
}

terratec_radio.priv=&terratec_unit;
-
+
spin_lock_init(&lock);
-
- if(video_register_device(&terratec_radio, VFL_TYPE_RADIO)==-1)
+
+ if(video_register_device(&terratec_radio, VFL_TYPE_RADIO) == -1) {
+ release_region(io, TERRATEC_IO_EXTENT);
return -EINVAL;
-
- request_region(io, 2, "terratec");
- printk(KERN_INFO "TERRATEC ActivRadio Standalone card driver.\n");
+ }

/* mute card - prevents noisy bootups */

@@ -349,10 +351,8 @@
static void __exit terratec_cleanup_module(void)
{
video_unregister_device(&terratec_radio);
- release_region(io,2);
- printk(KERN_INFO "TERRATEC ActivRadio Standalone card driver unloaded.\n");
+ release_region(io, TERRATEC_IO_EXTENT);
}

module_init(terratec_init);
module_exit(terratec_cleanup_module);
-
diff -uNr linux-240t11p1/drivers/media/radio/radio-trust.c linux/drivers/media/radio/radio-trust.c
--- linux-240t11p1/drivers/media/radio/radio-trust.c Tue Oct 3 00:17:39 2000
+++ linux/drivers/media/radio/radio-trust.c Thu Nov 9 00:34:20 2000
@@ -22,7 +22,9 @@
#include <asm/io.h>
#include <asm/uaccess.h>
#include <linux/videodev.h>
-#include <linux/config.h> /* CONFIG_RADIO_TRUST_PORT */
+#include <linux/config.h>
+
+#define TRUST_IO_EXTENT 0x02

/* acceptable ports: 0x350 (JP3 shorted), 0x358 (JP3 open) */

@@ -286,7 +288,7 @@

static struct video_device trust_radio=
{
- "Trust FM Radio",
+ "Trust FM radio",
VID_TYPE_TUNER,
VID_HARDWARE_TRUST,
tr_open,
@@ -301,20 +303,21 @@

static int __init trust_init(void)
{
+ printk(KERN_INFO "Trust FM radio card driver v1.0.\n");
+
if(io == -1) {
- printk(KERN_ERR "You must set an I/O address with io=0x???\n");
+ printk(KERN_ERR "trust: you must set an I/O address with io=0x???\n");
return -EINVAL;
}
- if(check_region(io, 2)) {
+ printk(KERN_INFO "trust: port 0x%x.\n", io);
+ if(!request_region(io, TRUST_IO_EXTENT, "trust")) {
printk(KERN_ERR "trust: port 0x%x already in use\n", io);
return -EBUSY;
}
- if(video_register_device(&trust_radio, VFL_TYPE_RADIO)==-1)
+ if(video_register_device(&trust_radio, VFL_TYPE_RADIO) == -1) {
+ release_region(io, TRUST_IO_EXTENT);
return -EINVAL;
-
- request_region(io, 2, "Trust FM Radio");
-
- printk(KERN_INFO "Trust FM Radio card driver v1.0.\n");
+ }

write_i2c(2, TDA7318_ADDR, 0x80); /* speaker att. LF = 0 dB */
write_i2c(2, TDA7318_ADDR, 0xa0); /* speaker att. RF = 0 dB */
@@ -340,11 +343,11 @@

EXPORT_NO_SYMBOLS;

-static void __exit cleanup_trust_module(void)
+static void __exit trust_cleanup(void)
{
video_unregister_device(&trust_radio);
- release_region(io, 2);
+ release_region(io, TRUST_IO_EXTENT);
}

module_init(trust_init);
-module_exit(cleanup_trust_module);
+module_exit(trust_cleanup);
diff -uNr linux-240t11p1/drivers/media/radio/radio-typhoon.c linux/drivers/media/radio/radio-typhoon.c
--- linux-240t11p1/drivers/media/radio/radio-typhoon.c Tue Oct 3 00:17:39 2000
+++ linux/drivers/media/radio/radio-typhoon.c Thu Nov 9 00:33:37 2000
@@ -29,17 +29,19 @@
* completely silent.
*/

-#include <linux/module.h> /* Modules */
-#include <linux/init.h> /* Initdata */
-#include <linux/ioport.h> /* check_region, request_region */
-#include <linux/proc_fs.h> /* radio card status report */
-#include <asm/io.h> /* outb, outb_p */
-#include <asm/uaccess.h> /* copy to/from user */
-#include <linux/videodev.h> /* kernel radio structs */
-#include <linux/config.h> /* CONFIG_RADIO_TYPHOON_* */
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/ioport.h>
+#include <linux/proc_fs.h>
+#include <asm/io.h>
+#include <asm/uaccess.h>
+#include <linux/videodev.h>
+#include <linux/config.h>

#define BANNER "Typhoon Radio Card driver v0.1\n"

+#define TYPHOON_IO_EXTENT 0x08
+
#ifndef CONFIG_RADIO_TYPHOON_PORT
#define CONFIG_RADIO_TYPHOON_PORT -1
#endif
@@ -283,7 +285,7 @@

static struct video_device typhoon_radio =
{
- "Typhoon Radio",
+ "Typhoon radio",
VID_TYPE_TUNER,
VID_HARDWARE_TYPHOON,
typhoon_open,
@@ -341,6 +343,8 @@

static int __init typhoon_init(void)
{
+ printk(KERN_INFO BANNER);
+
#ifdef MODULE
if (io == -1) {
printk(KERN_ERR "radio-typhoon: You must set an I/O address with io=0x316 or io=0x336\n");
@@ -356,20 +360,19 @@
typhoon_unit.mutefreq = mutefreq;
#endif /* MODULE */

- printk(KERN_INFO BANNER);
io = typhoon_unit.iobase;
- if (check_region(io, 8)) {
- printk(KERN_ERR "radio-typhoon: port 0x%x already in use\n",
- typhoon_unit.iobase);
+ printk(KERN_INFO "radio-typhoon: port 0x%x.\n", io);
+ if (!request_region(io, TYPHOON_IO_EXTENT, "typhoon")) {
+ printk(KERN_ERR "radio-typhoon: port 0x%x already in use\n", io);
return -EBUSY;
}

typhoon_radio.priv = &typhoon_unit;
- if (video_register_device(&typhoon_radio, VFL_TYPE_RADIO) == -1)
+ if (video_register_device(&typhoon_radio, VFL_TYPE_RADIO) == -1) {
+ release_region(io, TYPHOON_IO_EXTENT);
return -EINVAL;
+ }

- request_region(typhoon_unit.iobase, 8, "typhoon");
- printk(KERN_INFO "radio-typhoon: port 0x%x.\n", typhoon_unit.iobase);
printk(KERN_INFO "radio-typhoon: mute frequency is %lu kHz.\n",
typhoon_unit.mutefreq);
typhoon_unit.mutefreq <<= 4;
@@ -379,24 +382,23 @@

#ifdef CONFIG_RADIO_TYPHOON_PROC_FS
if (!create_proc_info_entry("driver/radio-typhoon", 0, NULL,
- typhoon_get_info))
- printk(KERN_ERR "radio-typhoon: registering /proc/driver/radio-typhoon failed\n");
+ typhoon_get_info)) {
+ printk(KERN_ERR "radio-typhoon: registering /proc/driver/radio-typhoon failed\n");
+ release_region(io, TYPHOON_IO_EXTENT);
+ }
#endif
-
return 0;
}

-static void __exit typhoon_cleanup_module(void)
+static void __exit typhoon_cleanup(void)
{

#ifdef CONFIG_RADIO_TYPHOON_PROC_FS
remove_proc_entry("driver/radio-typhoon", NULL);
#endif
-
video_unregister_device(&typhoon_radio);
- release_region(io, 8);
+ release_region(io, TYPHOON_IO_EXTENT);
}

module_init(typhoon_init);
-module_exit(typhoon_cleanup_module);
-
+module_exit(typhoon_cleanup);
diff -uNr linux-240t11p1/drivers/media/radio/radio-zoltrix.c linux/drivers/media/radio/radio-zoltrix.c
--- linux-240t11p1/drivers/media/radio/radio-zoltrix.c Tue Oct 3 00:17:39 2000
+++ linux/drivers/media/radio/radio-zoltrix.c Thu Nov 9 00:44:15 2000
@@ -25,14 +25,16 @@
* - Reworked ioctl functions
*/

-#include <linux/module.h> /* Modules */
-#include <linux/init.h> /* Initdata */
-#include <linux/ioport.h> /* check_region, request_region */
-#include <linux/delay.h> /* udelay */
-#include <asm/io.h> /* outb, outb_p */
-#include <asm/uaccess.h> /* copy to/from user */
-#include <linux/videodev.h> /* kernel radio structs */
-#include <linux/config.h> /* CONFIG_RADIO_ZOLTRIX_PORT */
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/ioport.h>
+#include <linux/delay.h>
+#include <asm/io.h>
+#include <asm/uaccess.h>
+#include <linux/videodev.h>
+#include <linux/config.h>
+
+#define ZOLTRIX_IO_EXTENT 0x02

#ifndef CONFIG_RADIO_ZOLTRIX_PORT
#define CONFIG_RADIO_ZOLTRIX_PORT -1
@@ -356,28 +358,30 @@

static int __init zoltrix_init(void)
{
+ printk(KERN_INFO "Zoltrix Radio Plus card driver.\n");
+
if (io == -1) {
- printk(KERN_ERR "You must set an I/O address with io=0x???\n");
+ printk(KERN_ERR "zoltrix: you must set an I/O address with io=0x???\n");
return -EINVAL;
}
- if (check_region(io, 2)) {
- printk(KERN_ERR "zoltrix: port 0x%x already in use\n", io);
- return -EBUSY;
- }
+ printk(KERN_INFO "zoltrix: port 0x%x.\n", io);
if ((io != 0x20c) && (io != 0x30c)) {
printk(KERN_ERR "zoltrix: invalid port, try 0x20c or 0x30c\n");
return -ENXIO;
}
+ if (!request_region(io, ZOLTRIX_IO_EXTENT, "zoltrix")) {
+ printk(KERN_ERR "zoltrix: port 0x%x already in use\n", io);
+ return -EBUSY;
+ }
zoltrix_radio.priv = &zoltrix_unit;

- if (video_register_device(&zoltrix_radio, VFL_TYPE_RADIO) == -1)
+ if (video_register_device(&zoltrix_radio, VFL_TYPE_RADIO) == -1) {
+ release_region(io, ZOLTRIX_IO_EXTENT);
return -EINVAL;
-
- request_region(io, 2, "zoltrix");
- printk(KERN_INFO "Zoltrix Radio Plus card driver.\n");
+ }

init_MUTEX(&zoltrix_unit.lock);
-
+
/* mute card - prevents noisy bootups */

/* this ensures that the volume is all the way down */
@@ -401,12 +405,11 @@

EXPORT_NO_SYMBOLS;

-static void __exit zoltrix_cleanup_module(void)
+static void __exit zoltrix_cleanup(void)
{
video_unregister_device(&zoltrix_radio);
- release_region(io, 2);
+ release_region(io, ZOLTRIX_IO_EXTENT);
}

module_init(zoltrix_init);
-module_exit(zoltrix_cleanup_module);
-
+module_exit(zoltrix_cleanup);
\
 
 \ /
  Last update: 2005-03-22 12:45    [W:0.091 / U:0.216 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site