]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/ata/libata-core.c
libata: Avoid overflow in ata_tf_to_lba48() when tf->hba_lbal > 127
[linux-2.6-omap-h63xx.git] / drivers / ata / libata-core.c
index 8cb0b360bfd83e7ae88909e3c5884f39c0191b7f..8824c8da3f2f88abea82ab1de951313ef811bf76 100644 (file)
@@ -1268,7 +1268,7 @@ u64 ata_tf_to_lba48(const struct ata_taskfile *tf)
 
        sectors |= ((u64)(tf->hob_lbah & 0xff)) << 40;
        sectors |= ((u64)(tf->hob_lbam & 0xff)) << 32;
-       sectors |= (tf->hob_lbal & 0xff) << 24;
+       sectors |= ((u64)(tf->hob_lbal & 0xff)) << 24;
        sectors |= (tf->lbah & 0xff) << 16;
        sectors |= (tf->lbam & 0xff) << 8;
        sectors |= (tf->lbal & 0xff);
@@ -1602,7 +1602,6 @@ unsigned long ata_id_xfermask(const u16 *id)
 /**
  *     ata_pio_queue_task - Queue port_task
  *     @ap: The ata_port to queue port_task for
- *     @fn: workqueue function to be scheduled
  *     @data: data for @fn to use
  *     @delay: delay time in msecs for workqueue function
  *
@@ -4156,29 +4155,33 @@ static int cable_is_40wire(struct ata_port *ap)
        struct ata_link *link;
        struct ata_device *dev;
 
-       /* If the controller thinks we are 40 wire, we are */
+       /* If the controller thinks we are 40 wire, we are. */
        if (ap->cbl == ATA_CBL_PATA40)
                return 1;
-       /* If the controller thinks we are 80 wire, we are */
+
+       /* If the controller thinks we are 80 wire, we are. */
        if (ap->cbl == ATA_CBL_PATA80 || ap->cbl == ATA_CBL_SATA)
                return 0;
-       /* If the system is known to be 40 wire short cable (eg laptop),
-          then we allow 80 wire modes even if the drive isn't sure */
+
+       /* If the system is known to be 40 wire short cable (eg
+        * laptop), then we allow 80 wire modes even if the drive
+        * isn't sure.
+        */
        if (ap->cbl == ATA_CBL_PATA40_SHORT)
                return 0;
-       /* If the controller doesn't know we scan
-
-          - Note: We look for all 40 wire detects at this point.
-            Any 80 wire detect is taken to be 80 wire cable
-            because
-            - In many setups only the one drive (slave if present)
-               will give a valid detect
-             - If you have a non detect capable drive you don't
-               want it to colour the choice
-        */
+
+       /* If the controller doesn't know, we scan.
+        *
+        * Note: We look for all 40 wire detects at this point.  Any
+        *       80 wire detect is taken to be 80 wire cable because
+        * - in many setups only the one drive (slave if present) will
+        *   give a valid detect
+        * - if you have a non detect capable drive you don't want it
+        *   to colour the choice
+        */
        ata_port_for_each_link(link, ap) {
                ata_link_for_each_dev(dev, link) {
-                       if (!ata_is_40wire(dev))
+                       if (ata_dev_enabled(dev) && !ata_is_40wire(dev))
                                return 0;
                }
        }
@@ -4553,6 +4556,7 @@ void swap_buf_le16(u16 *buf, unsigned int buf_words)
 /**
  *     ata_qc_new_init - Request an available ATA command, and initialize it
  *     @dev: Device from whom we request an available command structure
+ *     @tag: command tag
  *
  *     LOCKING:
  *     None.
@@ -4643,7 +4647,6 @@ static void ata_verify_xfer(struct ata_queued_cmd *qc)
 /**
  *     ata_qc_complete - Complete an active ATA command
  *     @qc: Command to complete
- *     @err_mask: ATA Status register contents
  *
  *     Indicate to the mid and upper layers that an ATA
  *     command has completed, with either an ok or not-ok status.