Lines Matching +full:drive +full:- +full:mode
1 // SPDX-License-Identifier: GPL-2.0
3 * ide-floppy IOCTLs handling.
15 #include "ide-floppy.h"
37 static int ide_floppy_get_format_capacities(ide_drive_t *drive, in ide_floppy_get_format_capacities() argument
41 struct ide_disk_obj *floppy = drive->driver_data; in ide_floppy_get_format_capacities()
47 return -EFAULT; in ide_floppy_get_format_capacities()
50 return -EINVAL; in ide_floppy_get_format_capacities()
54 if (ide_queue_pc_tail(drive, floppy->disk, pc, pc_buf, pc->req_xfer)) { in ide_floppy_get_format_capacities()
55 printk(KERN_ERR "ide-floppy: Can't get floppy parameters\n"); in ide_floppy_get_format_capacities()
56 return -EIO; in ide_floppy_get_format_capacities()
74 break; /* User-supplied buffer too small */ in ide_floppy_get_format_capacities()
80 return -EFAULT; in ide_floppy_get_format_capacities()
85 return -EFAULT; in ide_floppy_get_format_capacities()
93 return -EFAULT; in ide_floppy_get_format_capacities()
103 pc->c[0] = GPCMD_FORMAT_UNIT; in ide_floppy_create_format_unit_cmd()
104 pc->c[1] = 0x17; in ide_floppy_create_format_unit_cmd()
116 pc->req_xfer = 12; in ide_floppy_create_format_unit_cmd()
117 pc->flags |= PC_FLAG_WRITING; in ide_floppy_create_format_unit_cmd()
120 static int ide_floppy_get_sfrp_bit(ide_drive_t *drive, struct ide_atapi_pc *pc) in ide_floppy_get_sfrp_bit() argument
122 struct ide_disk_obj *floppy = drive->driver_data; in ide_floppy_get_sfrp_bit()
125 drive->atapi_flags &= ~IDE_AFLAG_SRFP; in ide_floppy_get_sfrp_bit()
128 pc->flags |= PC_FLAG_SUPPRESS_ERROR; in ide_floppy_get_sfrp_bit()
130 if (ide_queue_pc_tail(drive, floppy->disk, pc, buf, pc->req_xfer)) in ide_floppy_get_sfrp_bit()
134 drive->atapi_flags |= IDE_AFLAG_SRFP; in ide_floppy_get_sfrp_bit()
139 static int ide_floppy_format_unit(ide_drive_t *drive, struct ide_atapi_pc *pc, in ide_floppy_format_unit() argument
142 struct ide_disk_obj *floppy = drive->driver_data; in ide_floppy_format_unit()
146 if (floppy->openers > 1) { in ide_floppy_format_unit()
148 drive->dev_flags &= ~IDE_DFLAG_FORMAT_IN_PROGRESS; in ide_floppy_format_unit()
149 return -EBUSY; in ide_floppy_format_unit()
152 drive->dev_flags |= IDE_DFLAG_FORMAT_IN_PROGRESS; in ide_floppy_format_unit()
155 * Send ATAPI_FORMAT_UNIT to the drive. in ide_floppy_format_unit()
167 * 0x01 - verify media after format. in ide_floppy_format_unit()
172 err = -EFAULT; in ide_floppy_format_unit()
176 ide_floppy_get_sfrp_bit(drive, pc); in ide_floppy_format_unit()
179 if (ide_queue_pc_tail(drive, floppy->disk, pc, buf, pc->req_xfer)) in ide_floppy_format_unit()
180 err = -EIO; in ide_floppy_format_unit()
184 drive->dev_flags &= ~IDE_DFLAG_FORMAT_IN_PROGRESS; in ide_floppy_format_unit()
192 * indicator 0-65536, with 65536=100%.
194 * If the drive does not support format progress indication, we just check
198 static int ide_floppy_get_format_progress(ide_drive_t *drive, in ide_floppy_get_format_progress() argument
202 struct ide_disk_obj *floppy = drive->driver_data; in ide_floppy_get_format_progress()
206 if (drive->atapi_flags & IDE_AFLAG_SRFP) { in ide_floppy_get_format_progress()
207 ide_create_request_sense_cmd(drive, pc); in ide_floppy_get_format_progress()
208 if (ide_queue_pc_tail(drive, floppy->disk, pc, sense_buf, in ide_floppy_get_format_progress()
209 pc->req_xfer)) in ide_floppy_get_format_progress()
210 return -EIO; in ide_floppy_get_format_progress()
212 if (floppy->sense_key == 2 && in ide_floppy_get_format_progress()
213 floppy->asc == 4 && in ide_floppy_get_format_progress()
214 floppy->ascq == 4) in ide_floppy_get_format_progress()
215 progress_indication = floppy->progress_indication; in ide_floppy_get_format_progress()
219 ide_hwif_t *hwif = drive->hwif; in ide_floppy_get_format_progress()
224 stat = hwif->tp_ops->read_status(hwif); in ide_floppy_get_format_progress()
231 return -EFAULT; in ide_floppy_get_format_progress()
236 static int ide_floppy_lockdoor(ide_drive_t *drive, struct ide_atapi_pc *pc, in ide_floppy_lockdoor() argument
239 struct ide_disk_obj *floppy = drive->driver_data; in ide_floppy_lockdoor()
240 struct gendisk *disk = floppy->disk; in ide_floppy_lockdoor()
243 if (floppy->openers > 1) in ide_floppy_lockdoor()
244 return -EBUSY; in ide_floppy_lockdoor()
246 ide_set_media_lock(drive, disk, prevent); in ide_floppy_lockdoor()
249 ide_do_start_stop(drive, disk, 2); in ide_floppy_lockdoor()
254 static int ide_floppy_format_ioctl(ide_drive_t *drive, struct ide_atapi_pc *pc, in ide_floppy_format_ioctl() argument
255 fmode_t mode, unsigned int cmd, in ide_floppy_format_ioctl() argument
262 return ide_floppy_get_format_capacities(drive, pc, argp); in ide_floppy_format_ioctl()
264 if (!(mode & FMODE_WRITE)) in ide_floppy_format_ioctl()
265 return -EPERM; in ide_floppy_format_ioctl()
266 return ide_floppy_format_unit(drive, pc, (int __user *)argp); in ide_floppy_format_ioctl()
268 return ide_floppy_get_format_progress(drive, pc, argp); in ide_floppy_format_ioctl()
270 return -ENOTTY; in ide_floppy_format_ioctl()
274 int ide_floppy_ioctl(ide_drive_t *drive, struct block_device *bdev, in ide_floppy_ioctl() argument
275 fmode_t mode, unsigned int cmd, unsigned long arg) in ide_floppy_ioctl() argument
283 err = ide_floppy_lockdoor(drive, &pc, arg, cmd); in ide_floppy_ioctl()
287 err = ide_floppy_format_ioctl(drive, &pc, mode, cmd, argp); in ide_floppy_ioctl()
288 if (err != -ENOTTY) in ide_floppy_ioctl()
296 err = scsi_cmd_blk_ioctl(bdev, mode, cmd, argp); in ide_floppy_ioctl()
298 if (err == -ENOTTY) in ide_floppy_ioctl()
299 err = generic_ide_ioctl(drive, bdev, cmd, arg); in ide_floppy_ioctl()