]> git.hungrycats.org Git - linux/commitdiff
[PATCH] scsi/ppa.c cleanup and fixes (4/9)
authorAlexander Viro <viro@www.linux.org.uk>
Thu, 5 Feb 2004 01:46:34 +0000 (17:46 -0800)
committerLinus Torvalds <torvalds@home.osdl.org>
Thu, 5 Feb 2004 01:46:34 +0000 (17:46 -0800)
* killed include of scsi_module.h and switched from scsi_register()
to scsi_alloc_host().  We still keep the old detect logics at that point,
it will be gone later.

drivers/scsi/ppa.c
drivers/scsi/ppa.h

index 9135f2889dfcbf05079858654f52af2f348d2d18..deb10e40fa847187d77ae0394ed0e8e1193e84fb 100644 (file)
  */
 
 #include <linux/config.h>
-
-/* The following #define is to avoid a clash with hosts.c */
-#define PPA_CODE 1
-
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
 #include <linux/blkdev.h>
 #include <asm/io.h>
 #include <linux/parport.h>
 #include <linux/workqueue.h>
 #include "scsi.h"
 #include "hosts.h"
-static int ppa_release(struct Scsi_Host *);
 static void ppa_reset_pulse(unsigned int base);
 
 typedef struct {
@@ -74,17 +72,6 @@ static void ppa_wakeup(void *ref)
        return;
 }
 
-static int ppa_release(struct Scsi_Host *host)
-{
-       ppa_struct *dev = ppa_dev(host);
-       int host_no = host->unique_id;
-
-       printk("Releasing ppa%i\n", host_no);
-       scsi_unregister(host);
-       parport_unregister_device(dev->dev);
-       return 0;
-}
-
 static int ppa_pb_claim(ppa_struct *dev)
 {
        if (parport_claim(dev->dev)) {
@@ -105,25 +92,6 @@ static inline void ppa_pb_release(ppa_struct *dev)
  *                   Parallel port probing routines                        *
  ***************************************************************************/
 
-static Scsi_Host_Template driver_template = {
-       .proc_name = "ppa",
-       .proc_info = ppa_proc_info,
-       .name = "Iomega VPI0 (ppa) interface",
-       .detect = ppa_detect,
-       .release = ppa_release,
-       .queuecommand = ppa_queuecommand,
-       .eh_abort_handler = ppa_abort,
-       .eh_bus_reset_handler = ppa_reset,
-       .eh_host_reset_handler = ppa_reset,
-       .bios_param = ppa_biosparam,
-       .this_id = -1,
-       .sg_tablesize = SG_ALL,
-       .cmd_per_lun = 1,
-       .use_clustering = ENABLE_CLUSTERING,
-};
-
-#include  "scsi_module.c"
-
 /*
  * Start of Chipset kludges
  */
@@ -227,11 +195,10 @@ static int ppa_detect(Scsi_Host_Template *host)
 
                INIT_WORK(&dev->ppa_tq, ppa_interrupt, dev);
 
-               host->can_queue = PPA_CAN_QUEUE;
-               host->sg_tablesize = ppa_sg;
-               hreg = scsi_register(host, 0);
+               hreg = scsi_host_alloc(host, 0);
                if (hreg == NULL)
                        continue;
+               list_add_tail(&hreg->sht_legacy_list, &host->legacy_hosts);
                hreg->io_port = pb->base;
                hreg->n_io_port = ports;
                hreg->dma_channel = -1;
@@ -1137,4 +1104,65 @@ static int device_check(ppa_struct *dev)
        return 1;
 }
 
+static Scsi_Host_Template ppa_template = {
+       .module                 = THIS_MODULE,
+       .proc_name              = "ppa",
+       .proc_info              = ppa_proc_info,
+       .name                   = "Iomega VPI0 (ppa) interface",
+       .queuecommand           = ppa_queuecommand,
+       .eh_abort_handler       = ppa_abort,
+       .eh_bus_reset_handler   = ppa_reset,
+       .eh_host_reset_handler  = ppa_reset,
+       .bios_param             = ppa_biosparam,
+       .this_id                = -1,
+       .sg_tablesize           = SG_ALL,
+       .cmd_per_lun            = 1,
+       .use_clustering         = ENABLE_CLUSTERING,
+       .can_queue              = 1,
+};
+
+static int __init ppa_driver_init(void)
+{
+       struct scsi_host_template *sht = &ppa_template;
+       struct Scsi_Host *shost;
+       struct list_head *l;
+       int error;
+
+       INIT_LIST_HEAD(&sht->legacy_hosts);
+
+       ppa_detect(sht);
+       if (list_empty(&sht->legacy_hosts))
+               return -ENODEV;
+
+       list_for_each_entry(shost, &sht->legacy_hosts, sht_legacy_list) {
+               error = scsi_add_host(shost, NULL);
+               if (error)
+                       goto fail;
+               scsi_scan_host(shost);
+       }
+       return 0;
+ fail:
+       l = &shost->sht_legacy_list;
+       while ((l = l->prev) != &sht->legacy_hosts)
+               scsi_remove_host(list_entry(l, struct Scsi_Host, sht_legacy_list));
+       return error;
+}
+
+static void __exit ppa_driver_exit(void)
+{
+       struct scsi_host_template *sht = &ppa_template;
+       struct Scsi_Host *host, *s;
+
+       list_for_each_entry(host, &sht->legacy_hosts, sht_legacy_list)
+               scsi_remove_host(host);
+       list_for_each_entry_safe(host, s, &sht->legacy_hosts, sht_legacy_list) {
+               ppa_struct *dev = ppa_dev(host);
+               list_del(&host->sht_legacy_list);
+               scsi_host_put(host);
+               parport_unregister_device(dev->dev);
+       }
+}
+
+module_init(ppa_driver_init);
+module_exit(ppa_driver_exit);
 MODULE_LICENSE("GPL");
index 5eade3659605c3f9c84007a4d6082401d25c417d..07fc81d84a2f3549ba94b233f4d1f8c0465c30bf 100644 (file)
@@ -73,7 +73,6 @@
  */
 /* ------ END OF USER CONFIGURABLE PARAMETERS ----- */
 
-#ifdef PPA_CODE
 #include  <linux/config.h>
 #include  <linux/stddef.h>
 #include  <linux/module.h>
@@ -115,11 +114,7 @@ static char *PPA_MODE_STRING[] =
 #endif
     "Unknown"};
 
-/* This is a global option */
-int ppa_sg = SG_ALL;           /* enable/disable scatter-gather. */
-
 /* other options */
-#define PPA_CAN_QUEUE   1      /* use "queueing" interface */
 #define PPA_BURST_SIZE 512     /* data burst size */
 #define PPA_SELECT_TMO  5000   /* how long to wait for target ? */
 #define PPA_SPIN_TMO    50000  /* ppa_wait loop limiter */
@@ -152,23 +147,7 @@ int ppa_sg = SG_ALL;               /* enable/disable scatter-gather. */
 #endif
 
 static int ppa_engine(ppa_struct *, Scsi_Cmnd *);
-static int ppa_in(ppa_struct *, char *, int);
 static int ppa_init(ppa_struct *);
 static void ppa_interrupt(void *);
-static int ppa_out(ppa_struct *, char *, int);
-
-#else
-#define ppa_release 0
-#endif
-
-static int ppa_detect(Scsi_Host_Template *);
-const char *ppa_info(struct Scsi_Host *);
-int ppa_command(Scsi_Cmnd *);
-static int ppa_queuecommand(Scsi_Cmnd *, void (*done) (Scsi_Cmnd *));
-static int ppa_abort(Scsi_Cmnd *);
-static int ppa_reset(Scsi_Cmnd *);
-static int ppa_proc_info(struct Scsi_Host *host, char *, char **, off_t, int, int);
-static int ppa_biosparam(struct scsi_device *, struct block_device *,
-               sector_t, int *);
 
 #endif                         /* _PPA_H */