int ide_task_ioctl (ide_drive_t *drive, unsigned int cmd, unsigned long arg) { void __user *p = (void __user *)arg; int err = 0; u8 args[7]; ide_task_t task; if (copy_from_user(args, p, 7)) return -EFAULT; memset(&task, 0, sizeof(task)); memcpy(&task.tf_array[7], &args[1], 6); task.tf.command = args[0]; task.tf_flags = IDE_TFLAG_TF | IDE_TFLAG_DEVICE; err = ide_no_data_taskfile(drive, &task); args[0] = task.tf.command; memcpy(&args[1], &task.tf_array[7], 6); if (copy_to_user(p, args, 7)) err = -EFAULT; return err; }
/** * taskfile_load_raw - send taskfile registers to drive * @drive: drive to which output is sent * @gtf: raw ATA taskfile register set (0x1f1 - 0x1f7) * * Outputs IDE taskfile to the drive. */ static int taskfile_load_raw(ide_drive_t *drive, const struct taskfile_array *gtf) { ide_task_t args; int err = 0; DEBPRINT("(0x1f1-1f7): hex: " "%02x %02x %02x %02x %02x %02x %02x\n", gtf->tfa[0], gtf->tfa[1], gtf->tfa[2], gtf->tfa[3], gtf->tfa[4], gtf->tfa[5], gtf->tfa[6]); memset(&args, 0, sizeof(ide_task_t)); /* convert gtf to IDE Taskfile */ memcpy(&args.tf_array[7], >f->tfa, 7); args.tf_flags = IDE_TFLAG_TF | IDE_TFLAG_DEVICE; if (ide_noacpitfs) { DEBPRINT("_GTF execution disabled\n"); return err; } err = ide_no_data_taskfile(drive, &args); if (err) printk(KERN_ERR "%s: ide_no_data_taskfile failed: %u\n", __FUNCTION__, err); return err; }
static int smart_enable(ide_drive_t *drive) { struct ide_cmd cmd; struct ide_taskfile *tf = &cmd.tf; memset(&cmd, 0, sizeof(cmd)); tf->feature = ATA_SMART_ENABLE; tf->lbam = ATA_SMART_LBAM_PASS; tf->lbah = ATA_SMART_LBAH_PASS; tf->command = ATA_CMD_SMART; cmd.valid.out.tf = IDE_VALID_OUT_TF | IDE_VALID_DEVICE; cmd.valid.in.tf = IDE_VALID_IN_TF | IDE_VALID_DEVICE; return ide_no_data_taskfile(drive, &cmd); }
static int set_xfer_rate (ide_drive_t *drive, int arg) { ide_task_t task; int err; if (arg < XFER_PIO_0 || arg > XFER_UDMA_6) return -EINVAL; memset(&task, 0, sizeof(task)); task.tf.command = ATA_CMD_SET_FEATURES; task.tf.feature = SETFEATURES_XFER; task.tf.nsect = (u8)arg; task.tf_flags = IDE_TFLAG_OUT_FEATURE | IDE_TFLAG_OUT_NSECT | IDE_TFLAG_IN_NSECT; err = ide_no_data_taskfile(drive, &task); if (!err) { ide_set_xfer_rate(drive, (u8) arg); ide_driveid_update(drive); } return err; }