Lines Matching +full:drive +full:- +full:mode
1 // SPDX-License-Identifier: GPL-2.0
3 * ide-floppy IOCTLs handling.
16 #include "ide-floppy.h"
38 static int ide_floppy_get_format_capacities(ide_drive_t *drive, in ide_floppy_get_format_capacities() argument
42 struct ide_disk_obj *floppy = drive->driver_data; in ide_floppy_get_format_capacities()
48 return -EFAULT; in ide_floppy_get_format_capacities()
51 return -EINVAL; in ide_floppy_get_format_capacities()
55 if (ide_queue_pc_tail(drive, floppy->disk, pc, pc_buf, pc->req_xfer)) { in ide_floppy_get_format_capacities()
56 printk(KERN_ERR "ide-floppy: Can't get floppy parameters\n"); in ide_floppy_get_format_capacities()
57 return -EIO; in ide_floppy_get_format_capacities()
75 break; /* User-supplied buffer too small */ in ide_floppy_get_format_capacities()
81 return -EFAULT; in ide_floppy_get_format_capacities()
86 return -EFAULT; in ide_floppy_get_format_capacities()
94 return -EFAULT; in ide_floppy_get_format_capacities()
104 pc->c[0] = GPCMD_FORMAT_UNIT; in ide_floppy_create_format_unit_cmd()
105 pc->c[1] = 0x17; in ide_floppy_create_format_unit_cmd()
117 pc->req_xfer = 12; in ide_floppy_create_format_unit_cmd()
118 pc->flags |= PC_FLAG_WRITING; in ide_floppy_create_format_unit_cmd()
121 static int ide_floppy_get_sfrp_bit(ide_drive_t *drive, struct ide_atapi_pc *pc) in ide_floppy_get_sfrp_bit() argument
123 struct ide_disk_obj *floppy = drive->driver_data; in ide_floppy_get_sfrp_bit()
126 drive->atapi_flags &= ~IDE_AFLAG_SRFP; in ide_floppy_get_sfrp_bit()
129 pc->flags |= PC_FLAG_SUPPRESS_ERROR; in ide_floppy_get_sfrp_bit()
131 if (ide_queue_pc_tail(drive, floppy->disk, pc, buf, pc->req_xfer)) in ide_floppy_get_sfrp_bit()
135 drive->atapi_flags |= IDE_AFLAG_SRFP; in ide_floppy_get_sfrp_bit()
140 static int ide_floppy_format_unit(ide_drive_t *drive, struct ide_atapi_pc *pc, in ide_floppy_format_unit() argument
143 struct ide_disk_obj *floppy = drive->driver_data; in ide_floppy_format_unit()
147 if (floppy->openers > 1) { in ide_floppy_format_unit()
149 drive->dev_flags &= ~IDE_DFLAG_FORMAT_IN_PROGRESS; in ide_floppy_format_unit()
150 return -EBUSY; in ide_floppy_format_unit()
153 drive->dev_flags |= IDE_DFLAG_FORMAT_IN_PROGRESS; in ide_floppy_format_unit()
156 * Send ATAPI_FORMAT_UNIT to the drive. in ide_floppy_format_unit()
168 * 0x01 - verify media after format. in ide_floppy_format_unit()
173 err = -EFAULT; in ide_floppy_format_unit()
177 ide_floppy_get_sfrp_bit(drive, pc); in ide_floppy_format_unit()
180 if (ide_queue_pc_tail(drive, floppy->disk, pc, buf, pc->req_xfer)) in ide_floppy_format_unit()
181 err = -EIO; in ide_floppy_format_unit()
185 drive->dev_flags &= ~IDE_DFLAG_FORMAT_IN_PROGRESS; in ide_floppy_format_unit()
193 * indicator 0-65536, with 65536=100%.
195 * If the drive does not support format progress indication, we just check
199 static int ide_floppy_get_format_progress(ide_drive_t *drive, in ide_floppy_get_format_progress() argument
203 struct ide_disk_obj *floppy = drive->driver_data; in ide_floppy_get_format_progress()
207 if (drive->atapi_flags & IDE_AFLAG_SRFP) { in ide_floppy_get_format_progress()
208 ide_create_request_sense_cmd(drive, pc); in ide_floppy_get_format_progress()
209 if (ide_queue_pc_tail(drive, floppy->disk, pc, sense_buf, in ide_floppy_get_format_progress()
210 pc->req_xfer)) in ide_floppy_get_format_progress()
211 return -EIO; in ide_floppy_get_format_progress()
213 if (floppy->sense_key == 2 && in ide_floppy_get_format_progress()
214 floppy->asc == 4 && in ide_floppy_get_format_progress()
215 floppy->ascq == 4) in ide_floppy_get_format_progress()
216 progress_indication = floppy->progress_indication; in ide_floppy_get_format_progress()
220 ide_hwif_t *hwif = drive->hwif; in ide_floppy_get_format_progress()
225 stat = hwif->tp_ops->read_status(hwif); in ide_floppy_get_format_progress()
232 return -EFAULT; in ide_floppy_get_format_progress()
237 static int ide_floppy_lockdoor(ide_drive_t *drive, struct ide_atapi_pc *pc, in ide_floppy_lockdoor() argument
240 struct ide_disk_obj *floppy = drive->driver_data; in ide_floppy_lockdoor()
241 struct gendisk *disk = floppy->disk; in ide_floppy_lockdoor()
244 if (floppy->openers > 1) in ide_floppy_lockdoor()
245 return -EBUSY; in ide_floppy_lockdoor()
247 ide_set_media_lock(drive, disk, prevent); in ide_floppy_lockdoor()
250 ide_do_start_stop(drive, disk, 2); in ide_floppy_lockdoor()
255 static int ide_floppy_format_ioctl(ide_drive_t *drive, struct ide_atapi_pc *pc, in ide_floppy_format_ioctl() argument
256 fmode_t mode, unsigned int cmd, in ide_floppy_format_ioctl() argument
263 return ide_floppy_get_format_capacities(drive, pc, argp); in ide_floppy_format_ioctl()
265 if (!(mode & FMODE_WRITE)) in ide_floppy_format_ioctl()
266 return -EPERM; in ide_floppy_format_ioctl()
267 return ide_floppy_format_unit(drive, pc, (int __user *)argp); in ide_floppy_format_ioctl()
269 return ide_floppy_get_format_progress(drive, pc, argp); in ide_floppy_format_ioctl()
271 return -ENOTTY; in ide_floppy_format_ioctl()
275 int ide_floppy_ioctl(ide_drive_t *drive, struct block_device *bdev, in ide_floppy_ioctl() argument
276 fmode_t mode, unsigned int cmd, unsigned long arg) in ide_floppy_ioctl() argument
284 err = ide_floppy_lockdoor(drive, &pc, arg, cmd); in ide_floppy_ioctl()
288 err = ide_floppy_format_ioctl(drive, &pc, mode, cmd, argp); in ide_floppy_ioctl()
289 if (err != -ENOTTY) in ide_floppy_ioctl()
297 err = scsi_cmd_blk_ioctl(bdev, mode, cmd, argp); in ide_floppy_ioctl()
299 if (err == -ENOTTY) in ide_floppy_ioctl()
300 err = generic_ide_ioctl(drive, bdev, cmd, arg); in ide_floppy_ioctl()
308 int ide_floppy_compat_ioctl(ide_drive_t *drive, struct block_device *bdev, in ide_floppy_compat_ioctl() argument
309 fmode_t mode, unsigned int cmd, unsigned long arg) in ide_floppy_compat_ioctl() argument
317 err = ide_floppy_lockdoor(drive, &pc, arg, cmd); in ide_floppy_compat_ioctl()
321 err = ide_floppy_format_ioctl(drive, &pc, mode, cmd, argp); in ide_floppy_compat_ioctl()
322 if (err != -ENOTTY) in ide_floppy_compat_ioctl()
330 err = scsi_cmd_blk_ioctl(bdev, mode, cmd, argp); in ide_floppy_compat_ioctl()
332 if (err == -ENOTTY) in ide_floppy_compat_ioctl()
333 err = generic_ide_ioctl(drive, bdev, cmd, arg); in ide_floppy_compat_ioctl()