Re: [PATCH 7/16] gdth: make some virt ctrlr code common

2007-09-30 Thread Christoph Hellwig
On Sun, Sep 30, 2007 at 10:01:56PM +0200, Boaz Harrosh wrote:
> 
>   * New function gdth_register_virt() replaces the three
> basically-duplicate copies of virtual controller registration.

I think we can just kill this one if 8/16 goes in..

-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 7/16] gdth: make some virt ctrlr code common

2007-09-30 Thread Boaz Harrosh

  * New function gdth_register_virt() replaces the three
basically-duplicate copies of virtual controller registration.

  Signed-off-by: Jeff Garzik <[EMAIL PROTECTED]>
  Signed-off-by: Boaz Harrosh <[EMAIL PROTECTED]>
---
 drivers/scsi/gdth.c |   80 ++-
 1 files changed, 41 insertions(+), 39 deletions(-)

diff --git a/drivers/scsi/gdth.c b/drivers/scsi/gdth.c
index 4fa6609..b31c5eb 100644
--- a/drivers/scsi/gdth.c
+++ b/drivers/scsi/gdth.c
@@ -3925,6 +3925,44 @@ int __init option_setup(char *str)
 return 1;
 }
 
+static int __init gdth_register_virt(struct scsi_host_template *shtp,
+gdth_ha_str *ha, int hanum,
+struct device *dev, bool isa_dma)
+{
+   struct Scsi_Host *shp;
+   unchar b;
+   int done = 0;
+
+   if (!virt_ctr)
+   return 0;
+
+   virt_ctr = 1;
+
+   /* register addit. SCSI channels as virtual controllers */
+   for (b = 1; b < ha->bus_cnt + 1; ++b) {
+   shp = scsi_register(shtp, sizeof(gdth_num_str));
+
+   if (isa_dma) {
+   shp->unchecked_isa_dma = 1;
+   shp->dma_channel = ha->drq;
+   } else {
+   shp->unchecked_isa_dma = 0;
+   shp->dma_channel = 0xff;
+   }
+
+   shp->irq = ha->irq;
+
+   gdth_push_vshp(shp);
+
+   NUMDATA(shp)->hanum = (ushort)hanum;
+   NUMDATA(shp)->busnum = b;
+
+   done++;
+   }
+
+   return done ? 0 : -ENODEV;
+}
+
 
 static int __init gdth_detect(struct scsi_host_template *shtp)
 {
@@ -5017,19 +5055,7 @@ static int gdth_isa_probe_one(struct scsi_host_template 
*shtp, ulong32 isa_bios)
shp->max_id  = ha->tid_cnt;
shp->max_lun = MAXLUN;
shp->max_channel = virt_ctr ? 0 : ha->bus_cnt;
-   if (virt_ctr) {
-   virt_ctr = 1;
-   /* register addit. SCSI channels as virtual controllers */
-   for (b = 1; b < ha->bus_cnt + 1; ++b) {
-   shp = scsi_register(shtp,sizeof(gdth_num_str));
-   shp->unchecked_isa_dma = 1;
-   shp->irq = ha->irq;
-   shp->dma_channel = ha->drq;
-   gdth_ctr_vtab[gdth_ctr_vcount++] = shp;
-   NUMDATA(shp)->hanum = (ushort)hanum;
-   NUMDATA(shp)->busnum = b;
-   }
-   }
+   gdth_register_virt(shtp, ha, hanum, NULL, true);
 
spin_lock_init(&ha->smp_lock);
gdth_enable_int(hanum);
@@ -5159,19 +5185,7 @@ static int gdth_eisa_probe_one(struct scsi_host_template 
*shtp,
shp->max_id  = ha->tid_cnt;
shp->max_lun = MAXLUN;
shp->max_channel = virt_ctr ? 0 : ha->bus_cnt;
-   if (virt_ctr) {
-   virt_ctr = 1;
-   /* register addit. SCSI channels as virtual controllers */
-   for (b = 1; b < ha->bus_cnt + 1; ++b) {
-   shp = scsi_register(shtp,sizeof(gdth_num_str));
-   shp->unchecked_isa_dma = 0;
-   shp->irq = ha->irq;
-   shp->dma_channel = 0xff;
-   gdth_ctr_vtab[gdth_ctr_vcount++] = shp;
-   NUMDATA(shp)->hanum = (ushort)hanum;
-   NUMDATA(shp)->busnum = b;
-   }
-   }
+   gdth_register_virt(shtp, ha, hanum, NULL, false);
 
spin_lock_init(&ha->smp_lock);
gdth_enable_int(hanum);
@@ -5310,19 +5324,7 @@ static int gdth_pci_probe_one(struct scsi_host_template 
*shtp,
shp->max_id  = ha->tid_cnt;
shp->max_lun = MAXLUN;
shp->max_channel = virt_ctr ? 0 : ha->bus_cnt;
-   if (virt_ctr) {
-   virt_ctr = 1;
-   /* register addit. SCSI channels as virtual controllers */
-   for (b = 1; b < ha->bus_cnt + 1; ++b) {
-   shp = scsi_register(shtp,sizeof(gdth_num_str));
-   shp->unchecked_isa_dma = 0;
-   shp->irq = ha->irq;
-   shp->dma_channel = 0xff;
-   gdth_ctr_vtab[gdth_ctr_vcount++] = shp;
-   NUMDATA(shp)->hanum = (ushort)hanum;
-   NUMDATA(shp)->busnum = b;
-   }
-   }
+   gdth_register_virt(shtp, ha, hanum, &pcistr[ctr].pdev->dev, false);
 
spin_lock_init(&ha->smp_lock);
gdth_enable_int(hanum);
-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html