Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 114203
b: refs/heads/master
c: 5bb1536
h: refs/heads/master
i:
  114201: dda1be6
  114199: 0bebe0b
v: v3
  • Loading branch information
Bartlomiej Zolnierkiewicz committed Oct 13, 2008
1 parent ea94e81 commit 2bfd5eb
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 56 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 14d83b12c931b03dbe6b3dc79122db02521c890b
refs/heads/master: 5bb1536a07cca0b66f2bb41dfdf84140939b8f1f
52 changes: 1 addition & 51 deletions trunk/drivers/ide/ide-floppy.c
Original file line number Diff line number Diff line change
Expand Up @@ -765,56 +765,6 @@ static int idefloppy_getgeo(struct block_device *bdev, struct hd_geometry *geo)
return 0;
}

static int ide_floppy_lockdoor(ide_drive_t *drive, struct ide_atapi_pc *pc,
unsigned long arg, unsigned int cmd)
{
idefloppy_floppy_t *floppy = drive->driver_data;
struct gendisk *disk = floppy->disk;
int prevent = (arg && cmd != CDROMEJECT) ? 1 : 0;

if (floppy->openers > 1)
return -EBUSY;

ide_set_media_lock(drive, disk, prevent);

if (cmd == CDROMEJECT)
ide_do_start_stop(drive, disk, 2);

return 0;
}

static int idefloppy_ioctl(struct inode *inode, struct file *file,
unsigned int cmd, unsigned long arg)
{
struct block_device *bdev = inode->i_bdev;
struct ide_floppy_obj *floppy = ide_drv_g(bdev->bd_disk,
ide_floppy_obj);
ide_drive_t *drive = floppy->drive;
struct ide_atapi_pc pc;
void __user *argp = (void __user *)arg;
int err;

if (cmd == CDROMEJECT || cmd == CDROM_LOCKDOOR)
return ide_floppy_lockdoor(drive, &pc, arg, cmd);

err = ide_floppy_format_ioctl(drive, file, cmd, argp);
if (err != -ENOTTY)
return err;

/*
* skip SCSI_IOCTL_SEND_COMMAND (deprecated)
* and CDROM_SEND_PACKET (legacy) ioctls
*/
if (cmd != CDROM_SEND_PACKET && cmd != SCSI_IOCTL_SEND_COMMAND)
err = scsi_cmd_ioctl(file, bdev->bd_disk->queue,
bdev->bd_disk, cmd, argp);

if (err == -ENOTTY)
err = generic_ide_ioctl(drive, file, bdev, cmd, arg);

return err;
}

static int idefloppy_media_changed(struct gendisk *disk)
{
struct ide_floppy_obj *floppy = ide_drv_g(disk, ide_floppy_obj);
Expand Down Expand Up @@ -842,7 +792,7 @@ static struct block_device_operations idefloppy_ops = {
.owner = THIS_MODULE,
.open = idefloppy_open,
.release = idefloppy_release,
.ioctl = idefloppy_ioctl,
.ioctl = ide_floppy_ioctl,
.getgeo = idefloppy_getgeo,
.media_changed = idefloppy_media_changed,
.revalidate_disk = idefloppy_revalidate_disk
Expand Down
3 changes: 1 addition & 2 deletions trunk/drivers/ide/ide-floppy.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ void ide_floppy_create_mode_sense_cmd(struct ide_atapi_pc *, u8);
void ide_floppy_create_read_capacity_cmd(struct ide_atapi_pc *);

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

#endif /*__IDE_FLOPPY_H */
54 changes: 52 additions & 2 deletions trunk/drivers/ide/ide-floppy_ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,26 @@ static int ide_floppy_get_format_progress(ide_drive_t *drive, int __user *arg)
return 0;
}

int ide_floppy_format_ioctl(ide_drive_t *drive, struct file *file,
unsigned int cmd, void __user *argp)
static int ide_floppy_lockdoor(ide_drive_t *drive, struct ide_atapi_pc *pc,
unsigned long arg, unsigned int cmd)
{
idefloppy_floppy_t *floppy = drive->driver_data;
struct gendisk *disk = floppy->disk;
int prevent = (arg && cmd != CDROMEJECT) ? 1 : 0;

if (floppy->openers > 1)
return -EBUSY;

ide_set_media_lock(drive, disk, prevent);

if (cmd == CDROMEJECT)
ide_do_start_stop(drive, disk, 2);

return 0;
}

static int ide_floppy_format_ioctl(ide_drive_t *drive, struct file *file,
unsigned int cmd, void __user *argp)
{
switch (cmd) {
case IDEFLOPPY_IOCTL_FORMAT_SUPPORTED:
Expand All @@ -241,3 +259,35 @@ int ide_floppy_format_ioctl(ide_drive_t *drive, struct file *file,
return -ENOTTY;
}
}

int ide_floppy_ioctl(struct inode *inode, struct file *file,
unsigned int cmd, unsigned long arg)
{
struct block_device *bdev = inode->i_bdev;
struct ide_floppy_obj *floppy = ide_drv_g(bdev->bd_disk,
ide_floppy_obj);
ide_drive_t *drive = floppy->drive;
struct ide_atapi_pc pc;
void __user *argp = (void __user *)arg;
int err;

if (cmd == CDROMEJECT || cmd == CDROM_LOCKDOOR)
return ide_floppy_lockdoor(drive, &pc, arg, cmd);

err = ide_floppy_format_ioctl(drive, file, cmd, argp);
if (err != -ENOTTY)
return err;

/*
* skip SCSI_IOCTL_SEND_COMMAND (deprecated)
* and CDROM_SEND_PACKET (legacy) ioctls
*/
if (cmd != CDROM_SEND_PACKET && cmd != SCSI_IOCTL_SEND_COMMAND)
err = scsi_cmd_ioctl(file, bdev->bd_disk->queue,
bdev->bd_disk, cmd, argp);

if (err == -ENOTTY)
err = generic_ide_ioctl(drive, file, bdev, cmd, arg);

return err;
}

0 comments on commit 2bfd5eb

Please sign in to comment.