]> err.no Git - linux-2.6/commitdiff
[PATCH] libata: ata_dev_init_params() fixes
authorAlbert Lee <albertcc@tw.ibm.com>
Mon, 27 Mar 2006 08:39:18 +0000 (16:39 +0800)
committerJeff Garzik <jeff@garzik.org>
Thu, 30 Mar 2006 00:30:28 +0000 (19:30 -0500)
ata_dev_init_params() fixes:
- Get the "heads" and "sectors" parameters from caller instead of implicitly from dev->id[].
- Return AC_ERR_INVALID instead of 0 if an invalid parameter is found

Signed-off-by: Albert Lee <albertcc@tw.ibm.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
drivers/scsi/libata-core.c

index ac19505f7f1f3a77ed26a2f49e6b669f26732e77..21b0ed583b8a7273e5391c8d221c634d031fb578 100644 (file)
@@ -62,7 +62,9 @@
 #include "libata.h"
 
 static unsigned int ata_dev_init_params(struct ata_port *ap,
-                                       struct ata_device *dev);
+                                       struct ata_device *dev,
+                                       u16 heads,
+                                       u16 sectors);
 static void ata_set_mode(struct ata_port *ap);
 static unsigned int ata_dev_set_xfermode(struct ata_port *ap,
                                         struct ata_device *dev);
@@ -1156,7 +1158,7 @@ static int ata_dev_read_id(struct ata_port *ap, struct ata_device *dev,
                 * Some drives were very specific about that exact sequence.
                 */
                if (ata_id_major_version(id) < 4 || !ata_id_has_lba(id)) {
-                       err_mask = ata_dev_init_params(ap, dev);
+                       err_mask = ata_dev_init_params(ap, dev, id[3], id[6]);
                        if (err_mask) {
                                rc = -EIO;
                                reason = "INIT_DEV_PARAMS failed";
@@ -2748,16 +2750,16 @@ static unsigned int ata_dev_set_xfermode(struct ata_port *ap,
  */
 
 static unsigned int ata_dev_init_params(struct ata_port *ap,
-                                       struct ata_device *dev)
+                                       struct ata_device *dev,
+                                       u16 heads,
+                                       u16 sectors)
 {
        struct ata_taskfile tf;
        unsigned int err_mask;
-       u16 sectors = dev->id[6];
-       u16 heads   = dev->id[3];
 
        /* Number of sectors per track 1-255. Number of heads 1-16 */
        if (sectors < 1 || sectors > 255 || heads < 1 || heads > 16)
-               return 0;
+               return AC_ERR_INVALID;
 
        /* set up init dev params taskfile */
        DPRINTK("init dev params \n");