Skip to content

Commit 5bb1536

Browse files
committed
ide-floppy: move all ioctl handling to ide-floppy_ioctl.c (take 2)
While at it: - idefloppy_ioctl() -> ide_floppy_ioctl() v2: Fix for idefloppy_ioctl name change from Stephen Rothwell. Cc: Borislav Petkov <petkovbb@gmail.com> Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
1 parent 14d83b1 commit 5bb1536

3 files changed

Lines changed: 54 additions & 55 deletions

File tree

‎drivers/ide/ide-floppy.c‎

Lines changed: 1 addition & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -765,56 +765,6 @@ static int idefloppy_getgeo(struct block_device *bdev, struct hd_geometry *geo)
765765
return 0;
766766
}
767767

768-
static int ide_floppy_lockdoor(ide_drive_t *drive, struct ide_atapi_pc *pc,
769-
unsigned long arg, unsigned int cmd)
770-
{
771-
idefloppy_floppy_t *floppy = drive->driver_data;
772-
struct gendisk *disk = floppy->disk;
773-
int prevent = (arg && cmd != CDROMEJECT) ? 1 : 0;
774-
775-
if (floppy->openers > 1)
776-
return -EBUSY;
777-
778-
ide_set_media_lock(drive, disk, prevent);
779-
780-
if (cmd == CDROMEJECT)
781-
ide_do_start_stop(drive, disk, 2);
782-
783-
return 0;
784-
}
785-
786-
static int idefloppy_ioctl(struct inode *inode, struct file *file,
787-
unsigned int cmd, unsigned long arg)
788-
{
789-
struct block_device *bdev = inode->i_bdev;
790-
struct ide_floppy_obj *floppy = ide_drv_g(bdev->bd_disk,
791-
ide_floppy_obj);
792-
ide_drive_t *drive = floppy->drive;
793-
struct ide_atapi_pc pc;
794-
void __user *argp = (void __user *)arg;
795-
int err;
796-
797-
if (cmd == CDROMEJECT || cmd == CDROM_LOCKDOOR)
798-
return ide_floppy_lockdoor(drive, &pc, arg, cmd);
799-
800-
err = ide_floppy_format_ioctl(drive, file, cmd, argp);
801-
if (err != -ENOTTY)
802-
return err;
803-
804-
/*
805-
* skip SCSI_IOCTL_SEND_COMMAND (deprecated)
806-
* and CDROM_SEND_PACKET (legacy) ioctls
807-
*/
808-
if (cmd != CDROM_SEND_PACKET && cmd != SCSI_IOCTL_SEND_COMMAND)
809-
err = scsi_cmd_ioctl(file, bdev->bd_disk->queue,
810-
bdev->bd_disk, cmd, argp);
811-
812-
if (err == -ENOTTY)
813-
err = generic_ide_ioctl(drive, file, bdev, cmd, arg);
814-
815-
return err;
816-
}
817-
818768
static int idefloppy_media_changed(struct gendisk *disk)
819769
{
820770
struct ide_floppy_obj *floppy = ide_drv_g(disk, ide_floppy_obj);
@@ -842,7 +792,7 @@ static struct block_device_operations idefloppy_ops = {
842792
.owner = THIS_MODULE,
843793
.open = idefloppy_open,
844794
.release = idefloppy_release,
845-
.ioctl = idefloppy_ioctl,
795+
.ioctl = ide_floppy_ioctl,
846796
.getgeo = idefloppy_getgeo,
847797
.media_changed = idefloppy_media_changed,
848798
.revalidate_disk = idefloppy_revalidate_disk

‎drivers/ide/ide-floppy.h‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ void ide_floppy_create_mode_sense_cmd(struct ide_atapi_pc *, u8);
5050
void ide_floppy_create_read_capacity_cmd(struct ide_atapi_pc *);
5151

5252
/* ide-floppy_ioctl.c */
53-
int ide_floppy_format_ioctl(ide_drive_t *, struct file *, unsigned int,
54-
void __user *);
53+
int ide_floppy_ioctl(struct inode *, struct file *, unsigned, unsigned long);
5554

5655
#endif /*__IDE_FLOPPY_H */

‎drivers/ide/ide-floppy_ioctl.c‎

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,26 @@ static int ide_floppy_get_format_progress(ide_drive_t *drive, int __user *arg)
223223
return 0;
224224
}
225225

226-
int ide_floppy_format_ioctl(ide_drive_t *drive, struct file *file,
227-
unsigned int cmd, void __user *argp)
226+
static int ide_floppy_lockdoor(ide_drive_t *drive, struct ide_atapi_pc *pc,
227+
unsigned long arg, unsigned int cmd)
228+
{
229+
idefloppy_floppy_t *floppy = drive->driver_data;
230+
struct gendisk *disk = floppy->disk;
231+
int prevent = (arg && cmd != CDROMEJECT) ? 1 : 0;
232+
233+
if (floppy->openers > 1)
234+
return -EBUSY;
235+
236+
ide_set_media_lock(drive, disk, prevent);
237+
238+
if (cmd == CDROMEJECT)
239+
ide_do_start_stop(drive, disk, 2);
240+
241+
return 0;
242+
}
243+
244+
static int ide_floppy_format_ioctl(ide_drive_t *drive, struct file *file,
245+
unsigned int cmd, void __user *argp)
228246
{
229247
switch (cmd) {
230248
case IDEFLOPPY_IOCTL_FORMAT_SUPPORTED:
@@ -241,3 +259,35 @@ int ide_floppy_format_ioctl(ide_drive_t *drive, struct file *file,
241259
return -ENOTTY;
242260
}
243261
}
262+
263+
int ide_floppy_ioctl(struct inode *inode, struct file *file,
264+
unsigned int cmd, unsigned long arg)
265+
{
266+
struct block_device *bdev = inode->i_bdev;
267+
struct ide_floppy_obj *floppy = ide_drv_g(bdev->bd_disk,
268+
ide_floppy_obj);
269+
ide_drive_t *drive = floppy->drive;
270+
struct ide_atapi_pc pc;
271+
void __user *argp = (void __user *)arg;
272+
int err;
273+
274+
if (cmd == CDROMEJECT || cmd == CDROM_LOCKDOOR)
275+
return ide_floppy_lockdoor(drive, &pc, arg, cmd);
276+
277+
err = ide_floppy_format_ioctl(drive, file, cmd, argp);
278+
if (err != -ENOTTY)
279+
return err;
280+
281+
/*
282+
* skip SCSI_IOCTL_SEND_COMMAND (deprecated)
283+
* and CDROM_SEND_PACKET (legacy) ioctls
284+
*/
285+
if (cmd != CDROM_SEND_PACKET && cmd != SCSI_IOCTL_SEND_COMMAND)
286+
err = scsi_cmd_ioctl(file, bdev->bd_disk->queue,
287+
bdev->bd_disk, cmd, argp);
288+
289+
if (err == -ENOTTY)
290+
err = generic_ide_ioctl(drive, file, bdev, cmd, arg);
291+
292+
return err;
293+
}

0 commit comments

Comments
 (0)