fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / drivers / scsi / mac53c94.c
index 42654a7..753d883 100644 (file)
@@ -41,9 +41,9 @@ enum fsc_phase {
 };
 
 struct fsc_state {
-       struct  mac53c94_regs *regs;
+       struct  mac53c94_regs __iomem *regs;
        int     intr;
-       struct  dbdma_regs *dma;
+       struct  dbdma_regs __iomem *dma;
        int     dmaintr;
        int     clk_freq;
        struct  Scsi_Host *host;
@@ -60,8 +60,8 @@ struct fsc_state {
 
 static void mac53c94_init(struct fsc_state *);
 static void mac53c94_start(struct fsc_state *);
-static void mac53c94_interrupt(int, void *, struct pt_regs *);
-static irqreturn_t do_mac53c94_interrupt(int, void *, struct pt_regs *);
+static void mac53c94_interrupt(int, void *);
+static irqreturn_t do_mac53c94_interrupt(int, void *);
 static void cmd_done(struct fsc_state *, int result);
 static void set_dma_cmds(struct fsc_state *, struct scsi_cmnd *);
 
@@ -98,31 +98,31 @@ static int mac53c94_queue(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *
        return 0;
 }
 
-static int mac53c94_abort(struct scsi_cmnd *cmd)
-{
-       return FAILED;
-}
-
 static int mac53c94_host_reset(struct scsi_cmnd *cmd)
 {
        struct fsc_state *state = (struct fsc_state *) cmd->device->host->hostdata;
-       struct mac53c94_regs *regs = state->regs;
-       struct dbdma_regs *dma = state->dma;
+       struct mac53c94_regs __iomem *regs = state->regs;
+       struct dbdma_regs __iomem *dma = state->dma;
+       unsigned long flags;
+
+       spin_lock_irqsave(cmd->device->host->host_lock, flags);
 
-       st_le32(&dma->control, (RUN|PAUSE|FLUSH|WAKE) << 16);
+       writel((RUN|PAUSE|FLUSH|WAKE) << 16, &dma->control);
        writeb(CMD_SCSI_RESET, &regs->command); /* assert RST */
        udelay(100);                    /* leave it on for a while (>= 25us) */
        writeb(CMD_RESET, &regs->command);
        udelay(20);
        mac53c94_init(state);
        writeb(CMD_NOP, &regs->command);
+
+       spin_unlock_irqrestore(cmd->device->host->host_lock, flags);
        return SUCCESS;
 }
 
 static void mac53c94_init(struct fsc_state *state)
 {
-       struct mac53c94_regs *regs = state->regs;
-       struct dbdma_regs *dma = state->dma;
+       struct mac53c94_regs __iomem *regs = state->regs;
+       struct dbdma_regs __iomem *dma = state->dma;
        int x;
 
        writeb(state->host->this_id | CF1_PAR_ENABLE, &regs->config1);
@@ -143,7 +143,7 @@ static void mac53c94_init(struct fsc_state *state)
 static void mac53c94_start(struct fsc_state *state)
 {
        struct scsi_cmnd *cmd;
-       struct mac53c94_regs *regs = state->regs;
+       struct mac53c94_regs __iomem *regs = state->regs;
        int i;
 
        if (state->phase != idle || state->current_req != NULL)
@@ -177,22 +177,22 @@ static void mac53c94_start(struct fsc_state *state)
                set_dma_cmds(state, cmd);
 }
 
-static irqreturn_t do_mac53c94_interrupt(int irq, void *dev_id, struct pt_regs *ptregs)
+static irqreturn_t do_mac53c94_interrupt(int irq, void *dev_id)
 {
        unsigned long flags;
        struct Scsi_Host *dev = ((struct fsc_state *) dev_id)->current_req->device->host;
        
        spin_lock_irqsave(dev->host_lock, flags);
-       mac53c94_interrupt(irq, dev_id, ptregs);
+       mac53c94_interrupt(irq, dev_id);
        spin_unlock_irqrestore(dev->host_lock, flags);
        return IRQ_HANDLED;
 }
 
-static void mac53c94_interrupt(int irq, void *dev_id, struct pt_regs *ptregs)
+static void mac53c94_interrupt(int irq, void *dev_id)
 {
        struct fsc_state *state = (struct fsc_state *) dev_id;
-       struct mac53c94_regs *regs = state->regs;
-       struct dbdma_regs *dma = state->dma;
+       struct mac53c94_regs __iomem *regs = state->regs;
+       struct dbdma_regs __iomem *dma = state->dma;
        struct scsi_cmnd *cmd = state->current_req;
        int nb, stat, seq, intr;
        static int mac53c94_errors;
@@ -378,7 +378,7 @@ static void set_dma_cmds(struct fsc_state *state, struct scsi_cmnd *cmd)
                int nseg;
 
                total = 0;
-               scl = (struct scatterlist *) cmd->buffer;
+               scl = (struct scatterlist *) cmd->request_buffer;
                nseg = pci_map_sg(state->pdev, scl, cmd->use_sg,
                                cmd->sc_data_direction);
                for (i = 0; i < nseg; ++i) {
@@ -416,7 +416,6 @@ static struct scsi_host_template mac53c94_template = {
        .proc_name      = "53c94",
        .name           = "53C94",
        .queuecommand   = mac53c94_queue,
-       .eh_abort_handler = mac53c94_abort,
        .eh_host_reset_handler = mac53c94_host_reset,
        .can_queue      = 1,
        .this_id        = 7,
@@ -425,19 +424,20 @@ static struct scsi_host_template mac53c94_template = {
        .use_clustering = DISABLE_CLUSTERING,
 };
 
-static int mac53c94_probe(struct macio_dev *mdev, const struct of_match *match)
+static int mac53c94_probe(struct macio_dev *mdev, const struct of_device_id *match)
 {
        struct device_node *node = macio_get_of_node(mdev);
        struct pci_dev *pdev = macio_get_pci_dev(mdev);
        struct fsc_state *state;
        struct Scsi_Host *host;
        void *dma_cmd_space;
-       unsigned char *clkprop;
-       int proplen;
+       const unsigned char *clkprop;
+       int proplen, rc = -ENODEV;
 
        if (macio_resource_count(mdev) != 2 || macio_irq_count(mdev) != 2) {
-               printk(KERN_ERR "mac53c94: expected 2 addrs and intrs (got %d/%d)\n",
-                      node->n_addrs, node->n_intrs);
+               printk(KERN_ERR "mac53c94: expected 2 addrs and intrs"
+                      " (got %d/%d)\n",
+                      macio_resource_count(mdev), macio_irq_count(mdev));
                return -ENODEV;
        }
 
@@ -449,6 +449,7 @@ static int mac53c94_probe(struct macio_dev *mdev, const struct of_match *match)
                host = scsi_host_alloc(&mac53c94_template, sizeof(struct fsc_state));
        if (host == NULL) {
                printk(KERN_ERR "mac53c94: couldn't register host");
+               rc = -ENOMEM;
                goto out_release;
        }
 
@@ -458,10 +459,10 @@ static int mac53c94_probe(struct macio_dev *mdev, const struct of_match *match)
        state->pdev = pdev;
        state->mdev = mdev;
 
-       state->regs = (struct mac53c94_regs *)
+       state->regs = (struct mac53c94_regs __iomem *)
                ioremap(macio_resource_start(mdev, 0), 0x1000);
        state->intr = macio_irq(mdev, 0);
-       state->dma = (struct dbdma_regs *)
+       state->dma = (struct dbdma_regs __iomem *)
                ioremap(macio_resource_start(mdev, 1), 0x1000);
        state->dmaintr = macio_irq(mdev, 1);
        if (state->regs == NULL || state->dma == NULL) {
@@ -487,6 +488,7 @@ static int mac53c94_probe(struct macio_dev *mdev, const struct of_match *match)
                if (dma_cmd_space == 0) {
                        printk(KERN_ERR "mac53c94: couldn't allocate dma "
                               "command space for %s\n", node->full_name);
+               rc = -ENOMEM;
                        goto out_free;
                }
        state->dma_cmds = (struct dbdma_cmd *)DBDMA_ALIGN(dma_cmd_space);
@@ -496,18 +498,21 @@ static int mac53c94_probe(struct macio_dev *mdev, const struct of_match *match)
 
        mac53c94_init(state);
 
-       if (request_irq(state->intr, do_mac53c94_interrupt, 0, "53C94", state)) {
+       if (request_irq(state->intr, do_mac53c94_interrupt, 0, "53C94",state)) {
                printk(KERN_ERR "mac53C94: can't get irq %d for %s\n",
                       state->intr, node->full_name);
                goto out_free_dma;
        }
 
-       /* XXX FIXME: handle failure */
-       scsi_add_host(host, &mdev->ofdev.dev);
-       scsi_scan_host(host);
+       rc = scsi_add_host(host, &mdev->ofdev.dev);
+       if (rc != 0)
+               goto out_release_irq;
 
+       scsi_scan_host(host);
        return 0;
 
+ out_release_irq:
+       free_irq(state->intr, state);
  out_free_dma:
        kfree(state->dma_cmd_space);
  out_free:
@@ -519,7 +524,7 @@ static int mac53c94_probe(struct macio_dev *mdev, const struct of_match *match)
  out_release:
        macio_release_resources(mdev);
 
-       return  -ENODEV;
+       return rc;
 }
 
 static int mac53c94_remove(struct macio_dev *mdev)
@@ -532,9 +537,9 @@ static int mac53c94_remove(struct macio_dev *mdev)
        free_irq(fp->intr, fp);
 
        if (fp->regs)
-               iounmap((void *) fp->regs);
+               iounmap(fp->regs);
        if (fp->dma)
-               iounmap((void *) fp->dma);
+               iounmap(fp->dma);
        kfree(fp->dma_cmd_space);
 
        scsi_host_put(host);
@@ -545,15 +550,14 @@ static int mac53c94_remove(struct macio_dev *mdev)
 }
 
 
-static struct of_match mac53c94_match[] = 
+static struct of_device_id mac53c94_match[] = 
 {
        {
        .name           = "53c94",
-       .type           = OF_ANY_MATCH,
-       .compatible     = OF_ANY_MATCH
        },
        {},
 };
+MODULE_DEVICE_TABLE (of, mac53c94_match);
 
 static struct macio_driver mac53c94_driver = 
 {