vserver 1.9.5.x5
[linux-2.6.git] / drivers / scsi / aha152x.c
index dee898d..d7b8efe 100644 (file)
 #include <asm/irq.h>
 #include <asm/io.h>
 #include <linux/blkdev.h>
-#include "scsi.h"
-#include "hosts.h"
 #include <asm/system.h>
 #include <linux/errno.h>
 #include <linux/string.h>
 #include <scsi/scsicam.h>
 
 #include "scsi.h"
+#include <scsi/scsi_host.h>
 #include "aha152x.h"
 
 
@@ -354,58 +353,58 @@ MODULE_LICENSE("GPL");
 
 #if !defined(PCMCIA)
 #if defined(MODULE)
-MODULE_PARM(io, "1-2i");
-MODULE_PARM_DESC(io,"base io address of controller");
 static int io[] = {0, 0};
+module_param_array(io, int, NULL, 0);
+MODULE_PARM_DESC(io,"base io address of controller");
 
-MODULE_PARM(irq, "1-2i");
-MODULE_PARM_DESC(irq,"interrupt for controller");
 static int irq[] = {0, 0};
+module_param_array(irq, int, NULL, 0);
+MODULE_PARM_DESC(irq,"interrupt for controller");
 
-MODULE_PARM(scsiid, "1-2i");
-MODULE_PARM_DESC(scsiid,"scsi id of controller");
 static int scsiid[] = {7, 7};
+module_param_array(scsiid, int, NULL, 0);
+MODULE_PARM_DESC(scsiid,"scsi id of controller");
 
-MODULE_PARM(reconnect, "1-2i");
-MODULE_PARM_DESC(reconnect,"allow targets to disconnect");
 static int reconnect[] = {1, 1};
+module_param_array(reconnect, int, NULL, 0);
+MODULE_PARM_DESC(reconnect,"allow targets to disconnect");
 
-MODULE_PARM(parity, "1-2i");
-MODULE_PARM_DESC(parity,"use scsi parity");
 static int parity[] = {1, 1};
+module_param_array(parity, int, NULL, 0);
+MODULE_PARM_DESC(parity,"use scsi parity");
 
-MODULE_PARM(sync, "1-2i");
-MODULE_PARM_DESC(sync,"use synchronous transfers");
 static int sync[] = {1, 1};
+module_param_array(sync, int, NULL, 0);
+MODULE_PARM_DESC(sync,"use synchronous transfers");
 
-MODULE_PARM(delay, "1-2i");
-MODULE_PARM_DESC(delay,"scsi reset delay");
 static int delay[] = {DELAY_DEFAULT, DELAY_DEFAULT};
+module_param_array(delay, int, NULL, 0);
+MODULE_PARM_DESC(delay,"scsi reset delay");
 
-MODULE_PARM(exttrans, "1-2i");
-MODULE_PARM_DESC(exttrans,"use extended translation");
 static int exttrans[] = {0, 0};
+module_param_array(exttrans, int, NULL, 0);
+MODULE_PARM_DESC(exttrans,"use extended translation");
 
 #if !defined(AHA152X_DEBUG)
-MODULE_PARM(aha152x, "1-8i");
-MODULE_PARM_DESC(aha152x, "parameters for first controller");
 static int aha152x[] = {0, 11, 7, 1, 1, 0, DELAY_DEFAULT, 0};
+module_param_array(aha152x, int, NULL, 0);
+MODULE_PARM_DESC(aha152x, "parameters for first controller");
 
-MODULE_PARM(aha152x1, "1-8i");
-MODULE_PARM_DESC(aha152x1, "parameters for second controller");
 static int aha152x1[] = {0, 11, 7, 1, 1, 0, DELAY_DEFAULT, 0};
+module_param_array(aha152x1, int, NULL, 0);
+MODULE_PARM_DESC(aha152x1, "parameters for second controller");
 #else
-MODULE_PARM(debug, "1-2i");
-MODULE_PARM_DESC(debug, "flags for driver debugging");
 static int debug[] = {DEBUG_DEFAULT, DEBUG_DEFAULT};
+module_param_array(debug, int, NULL, 0);
+MODULE_PARM_DESC(debug, "flags for driver debugging");
 
-MODULE_PARM(aha152x, "1-9i");
-MODULE_PARM_DESC(aha152x, "parameters for first controller");
 static int aha152x[]   = {0, 11, 7, 1, 1, 1, DELAY_DEFAULT, 0, DEBUG_DEFAULT};
+module_param_array(aha152x, int, NULL, 0);
+MODULE_PARM_DESC(aha152x, "parameters for first controller");
 
-MODULE_PARM(aha152x1, "1-9i");
-MODULE_PARM_DESC(aha152x1, "parameters for second controller");
 static int aha152x1[]  = {0, 11, 7, 1, 1, 1, DELAY_DEFAULT, 0, DEBUG_DEFAULT};
+module_param_array(aha152x1, int, NULL, 0);
+MODULE_PARM_DESC(aha152x1, "parameters for second controller");
 #endif /* !defined(AHA152X_DEBUG) */
 #endif /* MODULE */
 
@@ -423,7 +422,7 @@ MODULE_DEVICE_TABLE(isapnp, id_table);
 #endif /* !PCMCIA */
 
 static int registered_count=0;
-static struct Scsi_Host *aha152x_host[2] = {0, 0};
+static struct Scsi_Host *aha152x_host[2];
 static Scsi_Host_Template aha152x_driver_template;
 
 /*
@@ -578,11 +577,11 @@ struct aha152x_scdata {
 #define MSGO(i)                        (HOSTDATA(shpnt)->msgo[i])
 #define MSGO_I                 (HOSTDATA(shpnt)->msgo_i)
 #define MSGOLEN                        (HOSTDATA(shpnt)->msgo_len)
-#define ADDMSGO(x)             (MSGOLEN<256 ? MSGO(MSGOLEN++)=x : aha152x_error(shpnt,"MSGO overflow"))
+#define ADDMSGO(x)             (MSGOLEN<256 ? (void)(MSGO(MSGOLEN++)=x) : aha152x_error(shpnt,"MSGO overflow"))
 
 #define MSGI(i)                        (HOSTDATA(shpnt)->msgi[i])
 #define MSGILEN                        (HOSTDATA(shpnt)->msgi_len)
-#define ADDMSGI(x)             (MSGILEN<256 ? MSGI(MSGILEN++)=x : aha152x_error(shpnt,"MSGI overflow"))
+#define ADDMSGI(x)             (MSGILEN<256 ? (void)(MSGI(MSGILEN++)=x) : aha152x_error(shpnt,"MSGI overflow"))
 
 #define DATA_LEN               (HOSTDATA(shpnt)->data_len)
 
@@ -648,20 +647,20 @@ static struct {
        void            (*end)(struct Scsi_Host *);
        int             spio;
 } states[] = {
-       { "idle",       0,              0,              0,              0},
-       { "unknown",    0,              0,              0,              0},
-       { "seldo",      0,              seldo_run,      0,              0},
-       { "seldi",      0,              seldi_run,      0,              0},
-       { "selto",      0,              selto_run,      0,              0},
-       { "busfree",    0,              busfree_run,    0,              0},
+       { "idle",       NULL,           NULL,           NULL,           0},
+       { "unknown",    NULL,           NULL,           NULL,           0},
+       { "seldo",      NULL,           seldo_run,      NULL,           0},
+       { "seldi",      NULL,           seldi_run,      NULL,           0},
+       { "selto",      NULL,           selto_run,      NULL,           0},
+       { "busfree",    NULL,           busfree_run,    NULL,           0},
        { "msgo",       msgo_init,      msgo_run,       msgo_end,       1},
        { "cmd",        cmd_init,       cmd_run,        cmd_end,        1},
-       { "msgi",       0,              msgi_run,       msgi_end,       1},
-       { "status",     0,              status_run,     0,              1},
+       { "msgi",       NULL,           msgi_run,       msgi_end,       1},
+       { "status",     NULL,           status_run,     NULL,           1},
        { "datai",      datai_init,     datai_run,      datai_end,      0},
        { "datao",      datao_init,     datao_run,      datao_end,      0},
-       { "parerr",     0,              parerr_run,     0,              0},
-       { "rsti",       0,              rsti_run,       0,              0},
+       { "parerr",     NULL,           parerr_run,     NULL,           0},
+       { "rsti",       NULL,           rsti_run,       NULL,           0},
 };
 
 /* setup & interrupt */
@@ -757,7 +756,7 @@ static inline struct Scsi_Host *lookup_irq(int irqno)
                if(aha152x_host[i] && aha152x_host[i]->irq==irqno)
                        return aha152x_host[i];
 
-       return 0;
+       return NULL;
 }
 
 static irqreturn_t swintr(int irqno, void *dev_id, struct pt_regs *regs)
@@ -893,7 +892,7 @@ struct Scsi_Host *aha152x_probe_one(struct aha152x_setup *setup)
                goto out_host_put;
        }
 
-       if( scsi_add_host(shpnt, 0) ) {
+       if( scsi_add_host(shpnt, NULL) ) {
                free_irq(shpnt->irq, shpnt);
                printk(KERN_ERR "aha152x%d: failed to add host.\n", shpnt->host_no);
                goto out_host_put;
@@ -906,10 +905,10 @@ struct Scsi_Host *aha152x_probe_one(struct aha152x_setup *setup)
        return shpnt;
 
 out_host_put:
-       aha152x_host[registered_count]=0;
+       aha152x_host[registered_count]=NULL;
        scsi_host_put(shpnt);
 
-       return 0;
+       return NULL;
 }
 
 void aha152x_release(struct Scsi_Host *shpnt)
@@ -1012,7 +1011,7 @@ static int aha152x_internal_queue(Scsi_Cmnd *SCpnt, struct semaphore *sem, int p
                }
        }
 
-       SCNEXT(SCpnt)           = 0;
+       SCNEXT(SCpnt)           = NULL;
        SCSEM(SCpnt)            = sem;
 
        /* setup scratch area
@@ -1069,7 +1068,7 @@ static int aha152x_queue(Scsi_Cmnd *SCpnt, void (*done)(Scsi_Cmnd *))
        }
 #endif
 
-       return aha152x_internal_queue(SCpnt, 0, 0, done);
+       return aha152x_internal_queue(SCpnt, NULL, 0, done);
 }
 
 
@@ -1120,7 +1119,7 @@ static int aha152x_abort(Scsi_Cmnd *SCpnt)
                DO_UNLOCK(flags);
 
                kfree(SCpnt->host_scribble);
-               SCpnt->host_scribble=0;
+               SCpnt->host_scribble=NULL;
 
                return SUCCESS;
        } 
@@ -1185,7 +1184,7 @@ static int aha152x_device_reset(Scsi_Cmnd * SCpnt)
 
        SCpnt->cmd_len         = 0;
        SCpnt->use_sg          = 0;
-       SCpnt->request_buffer  = 0;
+       SCpnt->request_buffer  = NULL;
        SCpnt->request_bufflen = 0;
 
        init_timer(&timer);
@@ -1210,7 +1209,7 @@ static int aha152x_device_reset(Scsi_Cmnd * SCpnt)
                if (!HOSTDATA(shpnt)->commands)
                        SETPORT(PORTA, 0);
                kfree(SCpnt->host_scribble);
-               SCpnt->host_scribble=0;
+               SCpnt->host_scribble=NULL;
 
                ret = SUCCESS;
        } else {
@@ -1242,7 +1241,7 @@ static void free_hard_reset_SCs(struct Scsi_Host *shpnt, Scsi_Cmnd **SCs)
                        next = SCNEXT(ptr);
                } else {
                        printk(DEBUG_LEAD "queue corrupted at %p\n", CMDINFO(ptr), ptr);
-                       next = 0;
+                       next = NULL;
                }
 
                if (!ptr->device->soft_reset) {
@@ -1250,7 +1249,7 @@ static void free_hard_reset_SCs(struct Scsi_Host *shpnt, Scsi_Cmnd **SCs)
                        remove_SC(SCs, ptr);
                        HOSTDATA(shpnt)->commands--;
                        kfree(ptr->host_scribble);
-                       ptr->host_scribble=0;
+                       ptr->host_scribble=NULL;
                }
 
                ptr = next;
@@ -1387,7 +1386,7 @@ static int aha152x_biosparam(struct scsi_device *sdev, struct block_device *bdev
                                       "aha152x: unable to verify geometry for disk with >1GB.\n"
                                       "         Using default translation. Please verify yourself.\n"
                                       "         Perhaps you need to enable extended translation in the driver.\n"
-                                      "         See /usr/src/linux/Documentation/scsi/aha152x.txt for details.\n");
+                                      "         See Documentation/scsi/aha152x.txt for details.\n");
                        }
                } else {
                        info_array[0] = info[0];
@@ -1416,7 +1415,7 @@ static void done(struct Scsi_Host *shpnt, int error)
                        printk(ERR_LEAD "there's already a completed command %p - will cause abort\n", CMDINFO(CURRENT_SC), DONE_SC);
 
                DONE_SC = CURRENT_SC;
-               CURRENT_SC = 0;
+               CURRENT_SC = NULL;
                DONE_SC->result = error;
        } else
                printk(KERN_ERR "aha152x: done() called outside of command\n");
@@ -1539,7 +1538,7 @@ static void busfree_run(struct Scsi_Host *shpnt)
 #endif
                        append_SC(&DISCONNECTED_SC, CURRENT_SC);
                        CURRENT_SC->SCp.phase |= 1 << 16;
-                       CURRENT_SC = 0;
+                       CURRENT_SC = NULL;
 
                } else {
                        done(shpnt, DID_ERROR << 16);
@@ -1587,7 +1586,7 @@ static void busfree_run(struct Scsi_Host *shpnt)
 
                        if(!(DONE_SC->SCp.Status & not_issued)) {
                                Scsi_Cmnd *ptr = DONE_SC;
-                               DONE_SC=0;
+                               DONE_SC=NULL;
 #if 0
                                DPRINTK(debug_eh, ERR_LEAD "requesting sense\n", CMDINFO(ptr));
 #endif
@@ -1604,7 +1603,7 @@ static void busfree_run(struct Scsi_Host *shpnt)
                                ptr->request_bufflen = sizeof(ptr->sense_buffer);
                        
                                DO_UNLOCK(flags);
-                               aha152x_internal_queue(ptr, 0, check_condition, ptr->scsi_done);
+                               aha152x_internal_queue(ptr, NULL, check_condition, ptr->scsi_done);
                                DO_LOCK(flags);
 #if 0
                        } else {
@@ -1620,7 +1619,7 @@ static void busfree_run(struct Scsi_Host *shpnt)
                        int lun=DONE_SC->device->lun & 0x7;
 #endif
                        Scsi_Cmnd *ptr = DONE_SC;
-                       DONE_SC=0;
+                       DONE_SC=NULL;
 
                        /* turn led off, when no commands are in the driver */
                        HOSTDATA(shpnt)->commands--;
@@ -1629,7 +1628,7 @@ static void busfree_run(struct Scsi_Host *shpnt)
 
                        if(ptr->scsi_done != reset_done) {
                                kfree(ptr->host_scribble);
-                               ptr->host_scribble=0;
+                               ptr->host_scribble=NULL;
                        }
 
                        DO_UNLOCK(flags);
@@ -1639,7 +1638,7 @@ static void busfree_run(struct Scsi_Host *shpnt)
                        DO_LOCK(flags);
                }
 
-               DONE_SC=0;
+               DONE_SC=NULL;
 #if defined(AHA152X_STAT)
        } else {
                HOSTDATA(shpnt)->busfree_without_done_command++;
@@ -1781,7 +1780,7 @@ static void seldi_run(struct Scsi_Host *shpnt)
                append_SC(&ISSUE_SC, CURRENT_SC);
                DO_UNLOCK(flags);
 
-               CURRENT_SC = 0;
+               CURRENT_SC = NULL;
        }
 
        if(!DISCONNECTED_SC) {
@@ -2504,7 +2503,7 @@ static void rsti_run(struct Scsi_Host *shpnt)
                        remove_SC(&DISCONNECTED_SC, ptr);
 
                        kfree(ptr->host_scribble);
-                       ptr->host_scribble=0;
+                       ptr->host_scribble=NULL;
 
                        ptr->result =  DID_RESET << 16;
                        ptr->scsi_done(ptr);
@@ -2977,7 +2976,7 @@ static void show_queues(struct Scsi_Host *shpnt)
                printk(KERN_DEBUG "none\n");
 
        printk(KERN_DEBUG "disconnected_SC:\n");
-       for (ptr = DISCONNECTED_SC; ptr; ptr = SCDATA(ptr) ? SCNEXT(ptr) : 0)
+       for (ptr = DISCONNECTED_SC; ptr; ptr = SCDATA(ptr) ? SCNEXT(ptr) : NULL)
                show_command(ptr);
 
        disp_ports(shpnt);
@@ -3455,7 +3454,7 @@ static int aha152x_proc_info(struct Scsi_Host *shpnt, char *buffer, char **start
 
        if(thislength<0) {
                DPRINTK(debug_procinfo, KERN_DEBUG "aha152x_proc_info: output too short\n");
-               *start = 0;
+               *start = NULL;
                return 0;
        }
 
@@ -3639,7 +3638,7 @@ static int __init aha152x_init(void)
        aha152x_config conf;
 #endif
 #ifdef __ISAPNP__
-       struct pnp_dev *dev=0, *pnpdev[2] = {0, 0};
+       struct pnp_dev *dev=NULL, *pnpdev[2] = {NULL, NULL};
 #endif
 
        if ( setup_count ) {
@@ -3831,10 +3830,15 @@ static int __init aha152x_init(void)
        if (setup_count<ARRAY_SIZE(setup)) {
 #if !defined(SKIP_BIOSTEST)
                ok = 0;
-               for (i = 0; i < ARRAY_SIZE(addresses) && !ok; i++)
+               for (i = 0; i < ARRAY_SIZE(addresses) && !ok; i++) {
+                       void __iomem *p = ioremap(addresses[i], 0x4000);
+                       if (!p)
+                               continue;
                        for (j = 0; j<ARRAY_SIZE(signatures) && !ok; j++)
-                               ok = isa_check_signature(addresses[i] + signatures[j].sig_offset,
+                               ok = check_signature(p + signatures[j].sig_offset,
                                                                signatures[j].signature, signatures[j].sig_length);
+                       iounmap(p);
+               }
                if (!ok && setup_count == 0)
                        return 0;
 
@@ -3902,7 +3906,7 @@ static int __init aha152x_init(void)
 #if defined(__ISAPNP__)
                        } else if( pnpdev[i] ) {
                                HOSTDATA(shpnt)->pnpdev=pnpdev[i];
-                               pnpdev[i]=0;
+                               pnpdev[i]=NULL;
 #endif
                        }
                } else {
@@ -3924,7 +3928,7 @@ static void __exit aha152x_exit(void)
 
        for(i=0; i<ARRAY_SIZE(setup); i++) {
                aha152x_release(aha152x_host[i]);
-               aha152x_host[i]=0;
+               aha152x_host[i]=NULL;
        }
 }