Merge branch 'master'
[pandora-kernel.git] / drivers / scsi / sata_qstor.c
index 93fd06f..de3f266 100644 (file)
@@ -6,21 +6,24 @@
  *  Copyright 2005 Pacific Digital Corporation.
  *  (OSL/GPL code release authorized by Jalil Fadavi).
  *
- *  The contents of this file are subject to the Open
- *  Software License version 1.1 that can be found at
- *  http://www.opensource.org/licenses/osl-1.1.txt and is included herein
- *  by reference.
  *
- *  Alternatively, the contents of this file may be used under the terms
- *  of the GNU General Public License version 2 (the "GPL") as distributed
- *  in the kernel source COPYING file, in which case the provisions of
- *  the GPL are applicable instead of the above.  If you wish to allow
- *  the use of your version of this file only under the terms of the
- *  GPL and not to allow others to use your version of this file under
- *  the OSL, indicate your decision by deleting the provisions above and
- *  replace them with the notice and other provisions required by the GPL.
- *  If you do not delete the provisions above, a recipient may use your
- *  version of this file under either the OSL or the GPL.
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2, or (at your option)
+ *  any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; see the file COPYING.  If not, write to
+ *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ *
+ *  libata documentation is available via 'make {ps|pdf}docs',
+ *  as Documentation/DocBook/libata.*
  *
  */
 
@@ -48,8 +51,6 @@ enum {
        QS_PRD_BYTES            = QS_MAX_PRD * 16,
        QS_PKT_BYTES            = QS_CPB_BYTES + QS_PRD_BYTES,
 
-       QS_DMA_BOUNDARY         = ~0UL,
-
        /* global register offsets */
        QS_HCF_CNFG3            = 0x0003, /* host configuration offset */
        QS_HID_HPHY             = 0x0004, /* host physical interface info */
@@ -98,6 +99,10 @@ enum {
        board_2068_idx          = 0,    /* QStor 4-port SATA/RAID */
 };
 
+enum {
+       QS_DMA_BOUNDARY         = ~0UL
+};
+
 typedef enum { qs_state_idle, qs_state_pkt, qs_state_mmio } qs_state_t;
 
 struct qs_port_priv {
@@ -142,7 +147,7 @@ static Scsi_Host_Template qs_ata_sht = {
        .bios_param             = ata_std_bios_param,
 };
 
-static struct ata_port_operations qs_ata_ops = {
+static const struct ata_port_operations qs_ata_ops = {
        .port_disable           = ata_port_disable,
        .tf_load                = ata_tf_load,
        .tf_read                = ata_tf_read,
@@ -265,16 +270,17 @@ static void qs_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val)
 
 static void qs_fill_sg(struct ata_queued_cmd *qc)
 {
-       struct scatterlist *sg = qc->sg;
+       struct scatterlist *sg;
        struct ata_port *ap = qc->ap;
        struct qs_port_priv *pp = ap->private_data;
        unsigned int nelem;
        u8 *prd = pp->pkt + QS_CPB_BYTES;
 
-       assert(sg != NULL);
+       assert(qc->__sg != NULL);
        assert(qc->n_elem > 0);
 
-       for (nelem = 0; nelem < qc->n_elem; nelem++,sg++) {
+       nelem = 0;
+       ata_for_each_sg(sg, qc) {
                u64 addr;
                u32 len;
 
@@ -288,6 +294,7 @@ static void qs_fill_sg(struct ata_queued_cmd *qc)
 
                VPRINTK("PRD[%u] = (0x%llX, 0x%X)\n", nelem,
                                        (unsigned long long)addr, len);
+               nelem++;
        }
 }
 
@@ -491,7 +498,7 @@ static int qs_port_start(struct ata_port *ap)
        if (rc)
                return rc;
        qs_enter_reg_mode(ap);
-       pp = kcalloc(1, sizeof(*pp), GFP_KERNEL);
+       pp = kzalloc(sizeof(*pp), GFP_KERNEL);
        if (!pp) {
                rc = -ENOMEM;
                goto err_out;
@@ -535,11 +542,12 @@ static void qs_port_stop(struct ata_port *ap)
 static void qs_host_stop(struct ata_host_set *host_set)
 {
        void __iomem *mmio_base = host_set->mmio_base;
+       struct pci_dev *pdev = to_pci_dev(host_set->dev);
 
        writeb(0, mmio_base + QS_HCT_CTRL); /* disable host interrupts */
        writeb(QS_CNFG3_GSRST, mmio_base + QS_HCF_CNFG3); /* global reset */
 
-       ata_host_stop(host_set);
+       pci_iounmap(pdev, mmio_base);
 }
 
 static void qs_host_init(unsigned int chip_id, struct ata_probe_ent *pe)
@@ -643,8 +651,7 @@ static int qs_ata_init_one(struct pci_dev *pdev,
                goto err_out_regions;
        }
 
-       mmio_base = ioremap(pci_resource_start(pdev, 4),
-                           pci_resource_len(pdev, 4));
+       mmio_base = pci_iomap(pdev, 4, 0);
        if (mmio_base == NULL) {
                rc = -ENOMEM;
                goto err_out_regions;
@@ -694,7 +701,7 @@ static int qs_ata_init_one(struct pci_dev *pdev,
        return 0;
 
 err_out_iounmap:
-       iounmap(mmio_base);
+       pci_iounmap(pdev, mmio_base);
 err_out_regions:
        pci_release_regions(pdev);
 err_out: