8250.c: less than 2400 baud fix.
[linux-2.6.git] / drivers / ide / ide-ioctls.c
index 5991b23..4d19eb9 100644 (file)
@@ -2,8 +2,10 @@
  * IDE ioctls handling.
  */
 
+#include <linux/export.h>
 #include <linux/hdreg.h>
 #include <linux/ide.h>
+#include <linux/slab.h>
 
 static const struct ide_ioctl_devset ide_ioctl_settings[] = {
 { HDIO_GET_32BIT,       HDIO_SET_32BIT,        &ide_devset_io_32bit  },
@@ -64,7 +66,8 @@ static int ide_get_identity_ioctl(ide_drive_t *drive, unsigned int cmd,
                goto out;
        }
 
-       id = kmalloc(size, GFP_KERNEL);
+       /* ata_id_to_hd_driveid() relies on 'id' to be fully allocated. */
+       id = kmalloc(ATA_ID_WORDS * 2, GFP_KERNEL);
        if (id == NULL) {
                rc = -ENOMEM;
                goto out;
@@ -118,7 +121,6 @@ static int ide_cmd_ioctl(ide_drive_t *drive, unsigned long arg)
        u8 args[4], xfer_rate = 0;
        struct ide_cmd cmd;
        struct ide_taskfile *tf = &cmd.tf;
-       u16 *id = drive->id;
 
        if (NULL == (void *) arg) {
                struct request *rq;
@@ -161,16 +163,14 @@ static int ide_cmd_ioctl(ide_drive_t *drive, unsigned long arg)
 
        if (tf->command == ATA_CMD_SET_FEATURES &&
            tf->feature == SETFEATURES_XFER &&
-           tf->nsect >= XFER_SW_DMA_0 &&
-           (id[ATA_ID_UDMA_MODES] ||
-            id[ATA_ID_MWDMA_MODES] ||
-            id[ATA_ID_SWDMA_MODES])) {
-               xfer_rate = args[1];
-               if (tf->nsect > XFER_UDMA_2 && !eighty_ninty_three(drive)) {
-                       printk(KERN_WARNING "%s: UDMA speeds >UDMA33 cannot "
-                                           "be set\n", drive->name);
+           tf->nsect >= XFER_SW_DMA_0) {
+               xfer_rate = ide_find_dma_mode(drive, tf->nsect);
+               if (xfer_rate != tf->nsect) {
+                       err = -EINVAL;
                        goto abort;
                }
+
+               cmd.tf_flags |= IDE_TFLAG_SET_XFER;
        }
 
        err = ide_raw_taskfile(drive, &cmd, buf, args[3]);
@@ -178,12 +178,6 @@ static int ide_cmd_ioctl(ide_drive_t *drive, unsigned long arg)
        args[0] = tf->status;
        args[1] = tf->error;
        args[2] = tf->nsect;
-
-       if (!err && xfer_rate) {
-               /* active-retuning-calls future */
-               ide_set_xfer_rate(drive, xfer_rate);
-               ide_driveid_update(drive);
-       }
 abort:
        if (copy_to_user((void __user *)arg, &args, 4))
                err = -EFAULT;