]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/ide/ide.c
ide: move ioctls handling to ide-ioctls.c
[linux-2.6-omap-h63xx.git] / drivers / ide / ide.c
index 4d0c661e78a5b78885e7c40262f5f6c2417630b2..349d7fa7558532f4cf6f378ec92619e443b91b54 100644 (file)
@@ -96,8 +96,6 @@ void ide_init_port_data(ide_hwif_t *hwif, unsigned int index)
        hwif->name[2]   = 'e';
        hwif->name[3]   = '0' + index;
 
-       hwif->bus_state = BUSSTATE_ON;
-
        init_completion(&hwif->gendev_rel_comp);
 
        hwif->tp_ops = &default_tp_ops;
@@ -252,8 +250,6 @@ void ide_init_port_hw(ide_hwif_t *hwif, hw_regs_t *hw)
 
 DEFINE_MUTEX(ide_setting_mtx);
 
-EXPORT_SYMBOL_GPL(ide_setting_mtx);
-
 /**
  *     ide_spin_wait_hwgroup   -       wait for group
  *     @drive: drive in the group
@@ -493,178 +489,6 @@ static int generic_ide_resume(struct device *dev)
        return err;
 }
 
-static int generic_drive_reset(ide_drive_t *drive)
-{
-       struct request *rq;
-       int ret = 0;
-
-       rq = blk_get_request(drive->queue, READ, __GFP_WAIT);
-       rq->cmd_type = REQ_TYPE_SPECIAL;
-       rq->cmd_len = 1;
-       rq->cmd[0] = REQ_DRIVE_RESET;
-       rq->cmd_flags |= REQ_SOFTBARRIER;
-       if (blk_execute_rq(drive->queue, NULL, rq, 1))
-               ret = rq->errors;
-       blk_put_request(rq);
-       return ret;
-}
-
-static inline void ide_id_to_hd_driveid(u16 *id)
-{
-#ifdef __BIG_ENDIAN
-       /* accessed in struct hd_driveid as 8-bit values */
-       id[ATA_ID_MAX_MULTSECT]  = __cpu_to_le16(id[ATA_ID_MAX_MULTSECT]);
-       id[ATA_ID_CAPABILITY]    = __cpu_to_le16(id[ATA_ID_CAPABILITY]);
-       id[ATA_ID_OLD_PIO_MODES] = __cpu_to_le16(id[ATA_ID_OLD_PIO_MODES]);
-       id[ATA_ID_OLD_DMA_MODES] = __cpu_to_le16(id[ATA_ID_OLD_DMA_MODES]);
-       id[ATA_ID_MULTSECT]      = __cpu_to_le16(id[ATA_ID_MULTSECT]);
-
-       /* as 32-bit values */
-       *(u32 *)&id[ATA_ID_LBA_CAPACITY] = ata_id_u32(id, ATA_ID_LBA_CAPACITY);
-       *(u32 *)&id[ATA_ID_SPG]          = ata_id_u32(id, ATA_ID_SPG);
-
-       /* as 64-bit value */
-       *(u64 *)&id[ATA_ID_LBA_CAPACITY_2] =
-               ata_id_u64(id, ATA_ID_LBA_CAPACITY_2);
-#endif
-}
-
-static int ide_get_identity_ioctl(ide_drive_t *drive, unsigned int cmd,
-                                 unsigned long arg)
-{
-       u16 *id = NULL;
-       int size = (cmd == HDIO_GET_IDENTITY) ? (ATA_ID_WORDS * 2) : 142;
-       int rc = 0;
-
-       if (drive->id_read == 0) {
-               rc = -ENOMSG;
-               goto out;
-       }
-
-       id = kmalloc(size, GFP_KERNEL);
-       if (id == NULL) {
-               rc = -ENOMEM;
-               goto out;
-       }
-
-       memcpy(id, drive->id, size);
-       ide_id_to_hd_driveid(id);
-
-       if (copy_to_user((void __user *)arg, id, size))
-               rc = -EFAULT;
-
-       kfree(id);
-out:
-       return rc;
-}
-
-int generic_ide_ioctl(ide_drive_t *drive, struct file *file, struct block_device *bdev,
-                       unsigned int cmd, unsigned long arg)
-{
-       unsigned long flags;
-       int err = 0, (*getfunc)(ide_drive_t *), (*setfunc)(ide_drive_t *, int);
-
-       switch (cmd) {
-       case HDIO_GET_32BIT:        getfunc = get_io_32bit;      goto read_val;
-       case HDIO_GET_KEEPSETTINGS: getfunc = get_ksettings;     goto read_val;
-       case HDIO_GET_UNMASKINTR:   getfunc = get_unmaskirq;     goto read_val;
-       case HDIO_GET_DMA:          getfunc = get_using_dma;     goto read_val;
-       case HDIO_SET_32BIT:        setfunc = set_io_32bit;      goto set_val;
-       case HDIO_SET_KEEPSETTINGS: setfunc = set_ksettings;     goto set_val;
-       case HDIO_SET_PIO_MODE:     setfunc = set_pio_mode;      goto set_val;
-       case HDIO_SET_UNMASKINTR:   setfunc = set_unmaskirq;     goto set_val;
-       case HDIO_SET_DMA:          setfunc = set_using_dma;     goto set_val;
-       }
-
-       switch (cmd) {
-               case HDIO_OBSOLETE_IDENTITY:
-               case HDIO_GET_IDENTITY:
-                       if (bdev != bdev->bd_contains)
-                               return -EINVAL;
-                       return ide_get_identity_ioctl(drive, cmd, arg);
-               case HDIO_GET_NICE:
-                       return put_user(drive->dsc_overlap      <<      IDE_NICE_DSC_OVERLAP    |
-                                       drive->nice1 << IDE_NICE_1,
-                                       (long __user *) arg);
-#ifdef CONFIG_IDE_TASK_IOCTL
-               case HDIO_DRIVE_TASKFILE:
-                       if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SYS_RAWIO))
-                               return -EACCES;
-                       switch(drive->media) {
-                               case ide_disk:
-                                       return ide_taskfile_ioctl(drive, cmd, arg);
-                               default:
-                                       return -ENOMSG;
-                       }
-#endif /* CONFIG_IDE_TASK_IOCTL */
-
-               case HDIO_DRIVE_CMD:
-                       if (!capable(CAP_SYS_RAWIO))
-                               return -EACCES;
-                       return ide_cmd_ioctl(drive, cmd, arg);
-
-               case HDIO_DRIVE_TASK:
-                       if (!capable(CAP_SYS_RAWIO))
-                               return -EACCES;
-                       return ide_task_ioctl(drive, cmd, arg);
-               case HDIO_SET_NICE:
-                       if (!capable(CAP_SYS_ADMIN)) return -EACCES;
-                       if (arg != (arg & ((1 << IDE_NICE_DSC_OVERLAP) | (1 << IDE_NICE_1))))
-                               return -EPERM;
-                       if (((arg >> IDE_NICE_DSC_OVERLAP) & 1) &&
-                           (drive->media == ide_disk ||
-                            drive->media == ide_floppy ||
-                            drive->scsi))
-                               return -EPERM;
-                       drive->dsc_overlap = (arg >> IDE_NICE_DSC_OVERLAP) & 1;
-                       drive->nice1 = (arg >> IDE_NICE_1) & 1;
-                       return 0;
-               case HDIO_DRIVE_RESET:
-                       if (!capable(CAP_SYS_ADMIN))
-                               return -EACCES;
-
-                       return generic_drive_reset(drive);
-
-               case HDIO_GET_BUSSTATE:
-                       if (!capable(CAP_SYS_ADMIN))
-                               return -EACCES;
-                       if (put_user(HWIF(drive)->bus_state, (long __user *)arg))
-                               return -EFAULT;
-                       return 0;
-
-               case HDIO_SET_BUSSTATE:
-                       if (!capable(CAP_SYS_ADMIN))
-                               return -EACCES;
-                       return -EOPNOTSUPP;
-               default:
-                       return -EINVAL;
-       }
-
-read_val:
-       mutex_lock(&ide_setting_mtx);
-       spin_lock_irqsave(&ide_lock, flags);
-       err = getfunc(drive);
-       spin_unlock_irqrestore(&ide_lock, flags);
-       mutex_unlock(&ide_setting_mtx);
-       return err >= 0 ? put_user(err, (long __user *)arg) : err;
-
-set_val:
-       if (bdev != bdev->bd_contains)
-               err = -EINVAL;
-       else {
-               if (!capable(CAP_SYS_ADMIN))
-                       err = -EACCES;
-               else {
-                       mutex_lock(&ide_setting_mtx);
-                       err = setfunc(drive, arg);
-                       mutex_unlock(&ide_setting_mtx);
-               }
-       }
-       return err;
-}
-
-EXPORT_SYMBOL(generic_ide_ioctl);
-
 /**
  * ide_device_get      -       get an additional reference to a ide_drive_t
  * @drive:     device to get a reference to