Thanks for the trouble.

Your patch had some problem in the maxiradio_radio_init function as
pci_register_driver returns the number of devices found and not 0 when
succesful. I fixed it and here is my patch against the original driver.

Diff output is still weird.
        
--- radio-maxiradio.c.orig      Wed Feb  7 00:27:37 2001
+++ radio-maxiradio.c   Wed Feb  7 22:50:12 2001
@@ -17,6 +17,9 @@
  *
  *
  * CHANGES:
+ *   0.75b
+ *     - better pci interface thanks to Francois Romieu <[EMAIL PROTECTED]>
+ *
  *   0.75
  *     - tiding up
  *     - removed support for multiple devices as it didn't work anyway
@@ -309,80 +312,80 @@
        MOD_DEC_USE_COUNT;
 }
 
-
-inline static __u16 radio_install(struct pci_dev *pcidev);
-
 MODULE_AUTHOR("Dimitromanolakis Apostolos, [EMAIL PROTECTED]");
 MODULE_DESCRIPTION("Radio driver for the Guillemot Maxi Radio FM2000 radio.");
 
 EXPORT_NO_SYMBOLS;
 
-void __exit maxiradio_radio_exit(void)
+static int __devinit maxiradio_init_one(struct pci_dev *pdev, const struct 
+pci_device_id *ent)
 {
-       video_unregister_device(&maxiradio_radio);
+       if(!request_region(pci_resource_start(pdev, 0),
+                          pci_resource_len(pdev, 0), "Maxi Radio FM 2000")) {
+               printk(KERN_ERR "radio-maxiradio: can't reserve I/O ports\n");
+               goto err_out;
+       }
 
-       release_region(radio_unit.io,4);
-}
+       if (pci_enable_device(pdev))
+               goto err_out_free_region;
 
-int __init maxiradio_radio_init(void)
-{
-       struct pci_dev *pcidev = NULL;
-       int found;
-       
-       if(!pci_present())
-               return -ENODEV;
-       
-       found = 0;
+       radio_unit.io = pci_resource_start(pdev, 0);
+       init_MUTEX(&radio_unit.lock);
+       maxiradio_radio.priv = &radio_unit;
 
-       pcidev = pci_find_device(PCI_VENDOR_ID_GUILLEMOT, 
-                                                       
PCI_DEVICE_ID_GUILLEMOT_MAXIRADIO,
-                                                 pcidev);
-                                                       
-       found += radio_install(pcidev);
-               
-       if(found == 0) {
-               printk(KERN_INFO "radio-maxiradio: no devices found.\n");
-               return -ENODEV;
+       if(video_register_device(&maxiradio_radio, VFL_TYPE_RADIO)==-1) {
+               printk("radio-maxiradio: can't register device!");
+               goto err_out_free_region;
        }
 
+       printk(KERN_INFO "radio-maxiradio: version "
+              DRIVER_VERSION
+              " time "
+              __TIME__ "  "
+              __DATE__
+              "\n");
+
+       printk(KERN_INFO "radio-maxiradio: found Guillemot MAXI Radio device (io = 
+0x%x)\n",
+              radio_unit.io);
        return 0;
-}
 
-module_init(maxiradio_radio_init);
-module_exit(maxiradio_radio_exit);
+err_out_free_region:
+       release_region(pci_resource_start(pdev, 0), pci_resource_len(pdev, 0));
+err_out:
+       return -ENODEV;
+}
 
-inline static __u16 radio_install(struct pci_dev *pcidev)
+static void __devexit maxiradio_remove_one(struct pci_dev *pdev)
 {
-       radio_unit.io = pcidev->resource[0].start;
+       video_unregister_device(&maxiradio_radio);
+       release_region(pci_resource_start(pdev, 0), pci_resource_len(pdev, 0));
+}
 
-       pci_enable_device(pcidev);
-       maxiradio_radio.priv = &radio_unit;
-       init_MUTEX(&radio_unit.lock);
-       
-       if(video_register_device(&maxiradio_radio, VFL_TYPE_RADIO)==-1) {
-               printk("radio-maxiradio: can't register device!");
-                       return 0;
-               }
-               
-               
-       printk(KERN_INFO "radio-maxiradio: version "
-              DRIVER_VERSION 
-              "\n");
-                                        
-       printk(KERN_INFO 
-               "radio-maxiradio: found Guillemot MAXI Radio device (io = 0x%x)\n",
-               radio_unit.io
-               );
+static struct pci_device_id maxiradio_pci_tbl[] __devinitdata = {
+       { PCI_VENDOR_ID_GUILLEMOT, PCI_DEVICE_ID_GUILLEMOT_MAXIRADIO,
+               PCI_ANY_ID, PCI_ANY_ID, },
+       { 0,}
+};
 
+MODULE_DEVICE_TABLE(pci, maxiradio_pci_tbl);
 
-       if(!request_region(radio_unit.io, 4, "Maxi Radio FM 2000"))
-               {
-                       printk(KERN_ERR "radio-maxiradio: port 0x%x already in use\n",
-                       radio_unit.io);
-                       
-                       return 0;
-               }
+static struct pci_driver maxiradio_driver = {
+       name:           "radio-maxiradio",
+       id_table:       maxiradio_pci_tbl,
+       probe:          maxiradio_init_one,
+       remove:         maxiradio_remove_one,
+};
+
+int __init maxiradio_radio_init(void)
+{
+       int count = pci_register_driver(&maxiradio_driver);
+       
+       if(count > 0) return 0; else return -ENODEV;
+}
 
-       return 1;
+void __exit maxiradio_radio_exit(void)
+{
+       pci_unregister_driver(&maxiradio_driver);
 }
 
+module_init(maxiradio_radio_init);
+module_exit(maxiradio_radio_exit);
$ insmod ./radio-maxiradio.o
./radio-maxiradio.o: init_module: Device or resource busy
$ dmesg | tail -2
radio-maxiradio: version 0.75 time 00:28:21  Feb  7 2001
radio-maxiradio: found Guillemot MAXI Radio device (io = 0x6100)
$ cat /proc/ioports 
Segmentation fault

Reply via email to