diff -X dontdiff -urN linux-3/drivers/ide/ide-floppy.c
linux-4/drivers/ide/ide-floppy.c
--- linux-3/drivers/ide/ide-floppy.c Sat Jan 12 17:26:13 2002
+++ linux-4/drivers/ide/ide-floppy.c Sat Jan 12 19:00:33 2002
@@ -1647,6 +1647,27 @@
return (0);
}
+static int idefloppy_lockunlock(ide_drive_t *drive, int lock)
+{
+ idefloppy_pc_t *pc;
+ idefloppy_floppy_t *floppy = drive->driver_data;
+
+ /* The IOMEGA Clik! Drive doesn't support this command - no room for an
eject mechanism */
+ if (test_bit(IDEFLOPPY_CLIK_DRIVE, &floppy->flags)) {
+ return 0;
+ }
+
+ if ((pc = (idefloppy_pc_t *) kmalloc (sizeof (idefloppy_pc_t),
GFP_KERNEL)) == NULL) {
+ printk (KERN_ERR "ide-floppy: %s: Can't allocate a packet command
structure\n", drive->name);
+ return 1;
+ }
+ memset (pc, 0, sizeof (idefloppy_pc_t));
+ idefloppy_create_prevent_cmd (pc, lock ? 1 : 0);
+ (void) idefloppy_queue_pc_tail (drive, pc);
+ kfree(pc);
+ return 0;
+}
+
/*
* Our special ide-floppy ioctl's.
*
@@ -1661,28 +1682,23 @@
switch (cmd) {
case CDROMEJECT:
- prevent = 0;
- /* fall through */
- case CDROM_LOCKDOOR:
if (drive->usage > 1)
return -EBUSY;
-
+ (void) idefloppy_lockunlock (drive, 0);
if ((pc = (idefloppy_pc_t *) kmalloc (sizeof (idefloppy_pc_t),
GFP_KERNEL)) == NULL) {
printk (KERN_ERR "ide-floppy: %s: Can't allocate a packet command
structure\n", drive->name);
return (-EIO);
}
memset (pc, 0, sizeof (idefloppy_pc_t));
- /* The IOMEGA Clik! Drive doesn't support this command - no room for an
eject mechanism */
- if (!test_bit(IDEFLOPPY_CLIK_DRIVE, &floppy->flags)) {
- idefloppy_create_prevent_cmd (pc, prevent);
- (void) idefloppy_queue_pc_tail (drive, pc);
- }
- if (cmd == CDROMEJECT) {
- idefloppy_create_start_stop_cmd (pc, 2);
- (void) idefloppy_queue_pc_tail (drive, pc);
- }
+ idefloppy_create_start_stop_cmd (pc, 2);
+ (void) idefloppy_queue_pc_tail (drive, pc);
kfree (pc);
return 0;
+ case CDROM_LOCKDOOR:
+ if (drive->usage > 1)
+ return -EBUSY;
+ (void) idefloppy_lockunlock (drive, prevent);
+ return 0;
case IDEFLOPPY_IOCTL_FORMAT_SUPPORTED:
return (0);
case IDEFLOPPY_IOCTL_FORMAT_GET_CAPACITY:
@@ -1784,11 +1800,7 @@
return -EROFS;
}
set_bit (IDEFLOPPY_MEDIA_CHANGED, &floppy->flags);
- /* IOMEGA Clik! drives do not support lock/unlock commands */
- if (!test_bit(IDEFLOPPY_CLIK_DRIVE, &floppy->flags)) {
- idefloppy_create_prevent_cmd (pc, 1);
- (void) idefloppy_queue_pc_tail (drive, pc);
- }
+ (void) idefloppy_lockunlock (drive, 1);
check_disk_change(inode->i_rdev);
kfree (pc);
}
@@ -1803,7 +1815,6 @@
static void idefloppy_release (struct inode *inode, struct file *filp,
ide_drive_t *drive)
{
- idefloppy_pc_t *pc;
#if IDEFLOPPY_DEBUG_LOG
printk (KERN_INFO "Reached idefloppy_release\n");
@@ -1814,17 +1825,7 @@
invalidate_bdev (inode->i_bdev, 0);
- /* IOMEGA Clik! drives do not support lock/unlock commands */
- if (!test_bit(IDEFLOPPY_CLIK_DRIVE, &floppy->flags)) {
- if ((pc = (idefloppy_pc_t *) kmalloc (sizeof (idefloppy_pc_t),
GFP_KERNEL)) == NULL) {
- printk (KERN_ERR "ide-floppy: %s: Can't allocate a packet command
structure\n", drive->name);
- } else {
- memset (pc, 0, sizeof (idefloppy_pc_t));
- idefloppy_create_prevent_cmd (pc, 0);
- (void) idefloppy_queue_pc_tail (drive, pc);
- kfree (pc);
- }
- }
+ (void) idefloppy_lockunlock (drive, 0);
clear_bit(IDEFLOPPY_FORMAT_IN_PROGRESS, &floppy->flags);
}
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/