lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:	Fri, 11 Jan 2008 14:14:28 +0100
From:	Borislav Petkov <bbpetkov@...oo.de>
To:	<bzolnier@...il.com>
Cc:	linux-kernel@...r.kernel.org, linux-ide@...r.kernel.org,
	Borislav Petkov <bbpetkov@...oo.de>
Subject: [PATCH 16/21] ide-floppy: use an xfer_func_t and io_buf_t typedefs in order to unify rw

Also, move xfer_func_t typedef to the ide.h since it is used by two drivers
now (more coming).

Signed-off-by: Borislav Petkov <bbpetkov@...oo.de>
---
 drivers/ide/ide-cd.c     |    2 --
 drivers/ide/ide-floppy.c |   37 ++++++++++++++++++-------------------
 include/linux/ide.h      |    3 +++
 3 files changed, 21 insertions(+), 21 deletions(-)

diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index 3b3e6c1..7e53a03 100644
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -604,8 +604,6 @@ static ide_startstop_t cdrom_transfer_packet_command (ide_drive_t *drive,
  * Block read functions.
  */
 
-typedef void (xfer_func_t)(ide_drive_t *, void *, u32);
-
 static void ide_cd_pad_transfer(ide_drive_t *drive, xfer_func_t *xf, int len)
 {
 	while (len > 0) {
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c
index 6e8926a..c889c16 100644
--- a/drivers/ide/ide-floppy.c
+++ b/drivers/ide/ide-floppy.c
@@ -491,19 +491,22 @@ static void idefloppy_retry_pc(ide_drive_t *drive)
 	idefloppy_queue_pc_head(drive, pc, rq);
 }
 
-/*
- * The usual interrupt handler called during a packet command.
- */
+typedef void (io_buf_t)(ide_drive_t *, idefloppy_pc_t *, unsigned int);
+
+/*  The usual interrupt handler called during a packet command. */
 static ide_startstop_t idefloppy_pc_intr(ide_drive_t *drive)
 {
 	idefloppy_floppy_t *floppy = drive->driver_data;
 	ide_hwif_t *hwif = drive->hwif;
 	idefloppy_pc_t *pc = floppy->pc;
 	struct request *rq = pc->rq;
+	xfer_func_t *xferfunc;
+	io_buf_t *iobuf_func;
 	unsigned int temp;
 	u16 bcount;
 	u8 stat, ireason;
 	int dma_error = 0;
+	int write = (rq_data_dir(rq) == WRITE) ? 1 : 0;
 
 	debug_log("Reached %s interrupt handler\n", __FUNCTION__);
 
@@ -511,9 +514,7 @@ static ide_startstop_t idefloppy_pc_intr(ide_drive_t *drive)
 		dma_error = HWIF(drive)->ide_dma_end(drive);
 		if (dma_error) {
 			printk(KERN_ERR "%s: DMA %s error\n", drive->name,
-					rq_data_dir(rq) == WRITE ?
-					"write" :
-					"read");
+					write ?	"write" : "read");
 			set_bit(PC_DMA_ERROR, &pc->flags);
 		} else {
 			pc->actually_transferred = pc->request_transfer;
@@ -568,7 +569,7 @@ static ide_startstop_t idefloppy_pc_intr(ide_drive_t *drive)
 	ireason = hwif->INB(IDE_IREASON_REG);
 
 	if (ireason & CD) {
-		printk(KERN_ERR "ide-floppy: CoD != 0 in idefloppy_pc_intr\n");
+		printk(KERN_ERR "ide-floppy: CoD != 0 in %s\n", __FUNCTION__);
 		return ide_do_reset(drive);
 	}
 	if (((ireason & IO) == IO) == test_bit(PC_WRITING, &pc->flags)) {
@@ -600,20 +601,18 @@ static ide_startstop_t idefloppy_pc_intr(ide_drive_t *drive)
 		}
 	}
 	if (test_bit(PC_WRITING, &pc->flags)) {
-		if (pc->buffer != NULL)
-			/* Write the current buffer */
-			hwif->atapi_output_bytes(drive, pc->current_position,
-						 bcount);
-		else
-			idefloppy_output_buffers(drive, pc, bcount);
+		xferfunc = hwif->atapi_output_bytes;
+		iobuf_func = &idefloppy_output_buffers;
 	} else {
-		if (pc->buffer != NULL)
-			/* Read the current buffer */
-			hwif->atapi_input_bytes(drive, pc->current_position,
-						bcount);
-		else
-			idefloppy_input_buffers(drive, pc, bcount);
+		xferfunc = hwif->atapi_input_bytes;
+		iobuf_func = &idefloppy_input_buffers;
 	}
+
+	if (pc->buffer != NULL)
+		xferfunc(drive, pc->current_position, bcount);
+	else
+		iobuf_func(drive, pc, bcount);
+
 	/* Update the current position */
 	pc->actually_transferred += bcount;
 	pc->current_position += bcount;
diff --git a/include/linux/ide.h b/include/linux/ide.h
index bfbc975..a6cf280 100644
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -626,6 +626,9 @@ typedef struct hwif_s {
 typedef ide_startstop_t (ide_handler_t)(ide_drive_t *);
 typedef int (ide_expiry_t)(ide_drive_t *);
 
+/* used by ide-cd, ide-floppy, etc. */
+typedef void (xfer_func_t)(ide_drive_t *, void *, u32);
+
 typedef struct hwgroup_s {
 		/* irq handler, if active */
 	ide_startstop_t	(*handler)(ide_drive_t *);
-- 
1.5.3.7

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ