public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Kevin P. Fleming" <kevin@labsysgrp.com>
To: <linux-kernel@vger.kernel.org>
Cc: "Paul Bristow" <paul@paulbristow.net>
Subject: [CFT][PATCH] ide-floppy cleanups/media change detection (4/5)
Date: Sat, 12 Jan 2002 19:54:38 -0700	[thread overview]
Message-ID: <006901c19bdd$a3d9eb50$6caaa8c0@kevin> (raw)

Patch 4 follows:

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);
  }




                 reply	other threads:[~2002-01-13  2:54 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='006901c19bdd$a3d9eb50$6caaa8c0@kevin' \
    --to=kevin@labsysgrp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=paul@paulbristow.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox