[PATCH 17/36] aha1542: split out code from aha1542_hw_init

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Split out bus times related block of aha1542_hw_init into separate function
aha1542_set_bus_times.

Signed-off-by: Ondrej Zary <linux@xxxxxxxxxxxxxxxxxxxx>
---
 drivers/scsi/aha1542.c |   65 ++++++++++++++++++++++++++----------------------
 1 file changed, 35 insertions(+), 30 deletions(-)

diff --git a/drivers/scsi/aha1542.c b/drivers/scsi/aha1542.c
index 4bfba45..b8e4952 100644
--- a/drivers/scsi/aha1542.c
+++ b/drivers/scsi/aha1542.c
@@ -867,6 +867,40 @@ static int __init do_setup(char *str)
 __setup("aha1542=",do_setup);
 #endif
 
+/* Set the Bus on/off-times as not to ruin floppy performance */
+static void aha1542_set_bus_times(int indx)
+{
+	unsigned int base_io = bases[indx];
+	u8 oncmd[] = {CMD_BUSON_TIME, 7};
+	u8 offcmd[] = {CMD_BUSOFF_TIME, 5};
+
+	if (setup_called[indx]) {
+		oncmd[1] = setup_buson[indx];
+		offcmd[1] = setup_busoff[indx];
+	}
+	aha1542_intr_reset(base_io);
+	aha1542_out(base_io, oncmd, 2);
+	if (!wait_mask(INTRFLAGS(base_io), INTRMASK, HACC, 0, 0))
+		goto fail;
+	aha1542_intr_reset(base_io);
+	aha1542_out(base_io, offcmd, 2);
+	if (!wait_mask(INTRFLAGS(base_io), INTRMASK, HACC, 0, 0))
+		goto fail;
+	if (setup_dmaspeed[indx] >= 0) {
+		u8 dmacmd[] = {CMD_DMASPEED, 0};
+		dmacmd[1] = setup_dmaspeed[indx];
+		aha1542_intr_reset(base_io);
+		aha1542_out(base_io, dmacmd, 2);
+		if (!wait_mask(INTRFLAGS(base_io), INTRMASK, HACC, 0, 0))
+			goto fail;
+	}
+	aha1542_intr_reset(base_io);
+	return;
+fail:
+	printk(KERN_ERR "setting bus on/off-time failed\n");
+	aha1542_intr_reset(base_io);
+}
+
 /* return non-zero on detection */
 static struct Scsi_Host *aha1542_hw_init(struct scsi_host_template *tpnt, struct device *pdev, int indx)
 {
@@ -897,37 +931,8 @@ static struct Scsi_Host *aha1542_hw_init(struct scsi_host_template *tpnt, struct
 
 			base_io = bases[indx];
 
-			/* Set the Bus on/off-times as not to ruin floppy performance */
-			{
-				u8 oncmd[] = {CMD_BUSON_TIME, 7};
-				u8 offcmd[] = {CMD_BUSOFF_TIME, 5};
+			aha1542_set_bus_times(indx);
 
-				if (setup_called[indx]) {
-					oncmd[1] = setup_buson[indx];
-					offcmd[1] = setup_busoff[indx];
-				}
-				aha1542_intr_reset(base_io);
-				aha1542_out(base_io, oncmd, 2);
-				if (!wait_mask(INTRFLAGS(base_io), INTRMASK, HACC, 0, 0))
-					goto fail;
-				aha1542_intr_reset(base_io);
-				aha1542_out(base_io, offcmd, 2);
-				if (!wait_mask(INTRFLAGS(base_io), INTRMASK, HACC, 0, 0))
-					goto fail;
-				if (setup_dmaspeed[indx] >= 0) {
-					u8 dmacmd[] = {CMD_DMASPEED, 0};
-					dmacmd[1] = setup_dmaspeed[indx];
-					aha1542_intr_reset(base_io);
-					aha1542_out(base_io, dmacmd, 2);
-					if (!wait_mask(INTRFLAGS(base_io), INTRMASK, HACC, 0, 0))
-						goto fail;
-				}
-				while (0) {
-fail:
-					printk(KERN_ERR "aha1542_detect: setting bus on/off-time failed\n");
-				}
-				aha1542_intr_reset(base_io);
-			}
 			if (aha1542_query(base_io, &trans))
 				goto unregister;
 
-- 
Ondrej Zary

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]
  Powered by Linux