mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Borislav Petkov <bbpetkov@yahoo.de>
To: linux-ide@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: bzolnier@gmail.com, Borislav Petkov <bbpetkov@yahoo.de>
Subject: [RESEND PATCH 05/10] ide-floppy: factor out ioctl handlers from idefloppy_ioctl()
Date: Thu,  3 Jan 2008 14:20:04 +0100	[thread overview]
Message-ID: <1199366409-26016-6-git-send-email-bbpetkov@yahoo.de> (raw)
In-Reply-To: <1199366409-26016-5-git-send-email-bbpetkov@yahoo.de>

There should be no functional change resulting from this patch.

Signed-off-by: Borislav Petkov <bbpetkov@yahoo.de>
---
 drivers/ide/ide-floppy.c |   90 +++++++++++++++++++++++++++++-----------------
 1 files changed, 57 insertions(+), 33 deletions(-)

diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c
index 196a697..7823447 100644
--- a/drivers/ide/ide-floppy.c
+++ b/drivers/ide/ide-floppy.c
@@ -1600,6 +1600,58 @@ static int idefloppy_getgeo(struct block_device *bdev, struct hd_geometry *geo)
 	return 0;
 }
 
+static int idefloppy_lockdoor(struct inode *inode, idefloppy_pc_t *pc,
+		int event, unsigned int cmd)
+{
+	struct block_device *bdev = inode->i_bdev;
+	struct ide_floppy_obj *floppy = ide_floppy_g(bdev->bd_disk);
+	ide_drive_t *drive = floppy->drive;
+
+	if (floppy->openers > 1)
+		return -EBUSY;
+
+	/* 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, event);
+		(void) idefloppy_queue_pc_tail(drive, pc);
+	}
+
+	if (cmd == CDROMEJECT) {
+		idefloppy_create_start_stop_cmd(pc, 2);
+		(void) idefloppy_queue_pc_tail(drive, pc);
+	}
+
+	return 0;
+}
+
+static
+int idefloppy_format_start(struct file *file, struct inode *inode,
+		void __user *argp)
+{
+	struct block_device *bdev = inode->i_bdev;
+	struct ide_floppy_obj *floppy = ide_floppy_g(bdev->bd_disk);
+	ide_drive_t *drive = floppy->drive;
+	int err;
+
+	if (!(file->f_mode & 2))
+		return -EPERM;
+
+	if (floppy->openers > 1) {
+		/* Don't format if someone is using the disk */
+		clear_bit(IDEFLOPPY_FORMAT_IN_PROGRESS, &floppy->flags);
+		return -EBUSY;
+	}
+
+	set_bit(IDEFLOPPY_FORMAT_IN_PROGRESS, &floppy->flags);
+
+	err = idefloppy_begin_format(drive, argp);
+	if (err)
+		clear_bit(IDEFLOPPY_FORMAT_IN_PROGRESS, &floppy->flags);
+
+	return err;
+}
+
 static int idefloppy_ioctl(struct inode *inode, struct file *file,
 			unsigned int cmd, unsigned long arg)
 {
@@ -1612,47 +1664,19 @@ static int idefloppy_ioctl(struct inode *inode, struct file *file,
 	idefloppy_pc_t pc;
 
 	switch (cmd) {
+
 	case CDROMEJECT:
 		prevent = 0;
 		/* fall through */
-	case CDROM_LOCKDOOR:
-		if (floppy->openers > 1)
-			return -EBUSY;
 
-		/* 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);
-		}
-		return 0;
+	case CDROM_LOCKDOOR:
+		return idefloppy_lockdoor(inode, &pc, prevent, cmd);
 	case IDEFLOPPY_IOCTL_FORMAT_SUPPORTED:
 		return 0;
 	case IDEFLOPPY_IOCTL_FORMAT_GET_CAPACITY:
 		return idefloppy_get_format_capacities(drive, argp);
 	case IDEFLOPPY_IOCTL_FORMAT_START:
-
-		if (!(file->f_mode & 2))
-			return -EPERM;
-
-		if (floppy->openers > 1) {
-
-			/* Don't format if someone is using the disk */
-			clear_bit(IDEFLOPPY_FORMAT_IN_PROGRESS,
-				  &floppy->flags);
-			return -EBUSY;
-		}
-
-		set_bit(IDEFLOPPY_FORMAT_IN_PROGRESS, &floppy->flags);
-
-		err = idefloppy_begin_format(drive, argp);
-		if (err)
-			clear_bit(IDEFLOPPY_FORMAT_IN_PROGRESS, &floppy->flags);
-		return err;
+		return idefloppy_format_start(file, inode, argp);
 		/*
 		 * Note, the bit will be cleared when the device is
 		 * closed.  This is the cleanest way to handle the
@@ -1669,7 +1693,7 @@ static int idefloppy_ioctl(struct inode *inode, struct file *file,
 	 */
 	if (cmd != CDROM_SEND_PACKET && cmd != SCSI_IOCTL_SEND_COMMAND)
 		err = scsi_cmd_ioctl(file, bdev->bd_disk->queue,
-					bdev->bd_disk, cmd, argp);
+				bdev->bd_disk, cmd, argp);
 	else
 		err = -ENOTTY;
 
-- 
1.5.3.7


  reply	other threads:[~2008-01-03 13:23 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-03 13:19 [RESEND PATCH 0/10] ide-floppy redux p1 Borislav Petkov
2008-01-03 13:20 ` [RESEND PATCH 01/10] move ide-floppy historical changelog to Documentation/ide/ChangeLog.ide-floppy.1996-2002; Borislav Petkov
2008-01-03 13:20   ` [RESEND PATCH 02/10] ide-floppy: move ide-floppy struct and macro defs into its own header. While at it Borislav Petkov
2008-01-03 13:20     ` [RESEND PATCH 03/10] ide-floppy: convert to generic packet commands Borislav Petkov
2008-01-03 13:20       ` [RESEND PATCH 04/10] ide-floppy: cleanup debugging macros Borislav Petkov
2008-01-03 13:20         ` Borislav Petkov [this message]
2008-01-03 13:20           ` [RESEND PATCH 06/10] ide-floppy: report DMA handling in idefloppy_pc_intr() properly Borislav Petkov
2008-01-03 13:20             ` [RESEND PATCH 07/10] ide-floppy: remove unnecessary ->handler != NULL check Borislav Petkov
2008-01-03 13:20               ` [RESEND PATCH 08/10] ide-floppy: mv idefloppy_{should_,}report_error Borislav Petkov
2008-01-03 13:20                 ` [RESEND PATCH 09/10] ide-floppy: use test_bit wrappers for testing flags Borislav Petkov
2008-01-03 13:20                   ` [RESEND PATCH 10/10] ide-floppy: replace ntoh{s,l} and hton{s,l} calls with the generic byteorder macros Borislav Petkov
2008-01-04  1:29                     ` Bartlomiej Zolnierkiewicz
2008-01-05 16:10                   ` [RESEND PATCH 09/10] ide-floppy: use test_bit wrappers for testing flags Bartlomiej Zolnierkiewicz
2008-01-05 15:54                 ` [RESEND PATCH 08/10] ide-floppy: mv idefloppy_{should_,}report_error Bartlomiej Zolnierkiewicz
2008-01-04  1:24               ` [RESEND PATCH 07/10] ide-floppy: remove unnecessary ->handler != NULL check Bartlomiej Zolnierkiewicz
2008-01-05 15:46             ` [RESEND PATCH 06/10] ide-floppy: report DMA handling in idefloppy_pc_intr() properly Bartlomiej Zolnierkiewicz
2008-01-05 21:45               ` Borislav Petkov
2008-01-06 15:21                 ` Bartlomiej Zolnierkiewicz
2008-01-05 15:12           ` [RESEND PATCH 05/10] ide-floppy: factor out ioctl handlers from idefloppy_ioctl() Bartlomiej Zolnierkiewicz
2008-01-04  1:19         ` [RESEND PATCH 04/10] ide-floppy: cleanup debugging macros Bartlomiej Zolnierkiewicz
2008-01-04  1:04       ` [RESEND PATCH 03/10] ide-floppy: convert to generic packet commands Bartlomiej Zolnierkiewicz
2008-01-04 22:49     ` [RESEND PATCH 02/10] ide-floppy: move ide-floppy struct and macro defs into its own header. While at it Bartlomiej Zolnierkiewicz
2008-01-05 12:45       ` Borislav Petkov
2008-01-05 13:15         ` Bartlomiej Zolnierkiewicz
2008-01-04  0:36   ` [RESEND PATCH 01/10] move ide-floppy historical changelog to Documentation/ide/ChangeLog.ide-floppy.1996-2002; Bartlomiej Zolnierkiewicz
2008-01-04  0:14 ` [RESEND PATCH 0/10] ide-floppy redux p1 Bartlomiej Zolnierkiewicz

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=1199366409-26016-6-git-send-email-bbpetkov@yahoo.de \
    --to=bbpetkov@yahoo.de \
    --cc=bzolnier@gmail.com \
    --cc=linux-ide@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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

Powered by JetHome