[PATCH 08/32] pata_parport-bpck6: remove mode from struct ppc_storage

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

 



introduce mode_map[] that maps bpck6 modes to ppc6 modes and use it to
replace mode in ppc_storage

Signed-off-by: Ondrej Zary <linux@xxxxxxx>
---
 drivers/ata/pata_parport/bpck6.c   | 22 +++++-----------------
 drivers/ata/pata_parport/ppc6lnx.c | 27 +++++++++++----------------
 2 files changed, 16 insertions(+), 33 deletions(-)

diff --git a/drivers/ata/pata_parport/bpck6.c b/drivers/ata/pata_parport/bpck6.c
index 176bf456c698..fe97d1dee51c 100644
--- a/drivers/ata/pata_parport/bpck6.c
+++ b/drivers/ata/pata_parport/bpck6.c
@@ -43,22 +43,8 @@ static void bpck6_read_block(struct pi_adapter *pi, char *buf, int len)
 
 static void bpck6_connect(struct pi_adapter *pi)
 {
-	struct ppc_storage *ppc = (void *)(pi->private);
 	dev_dbg(&pi->dev, "connect\n");
 
-	if(pi->mode >=2)
-  	{
-		ppc->mode = 4+pi->mode-2;
-	}
-	else if(pi->mode==1)
-	{
-		ppc->mode = 3;
-	}
-	else
-	{
-		ppc->mode = 1;
-	}
-
 	ppc6_open(pi);
 	ppc6_wr_extout(pi, 0x3);
 }
@@ -85,13 +71,13 @@ static int bpck6_test_port(struct pi_adapter *pi)   /* check for 8-bit port */
 
 static int bpck6_probe_unit(struct pi_adapter *pi)
 {
-	struct ppc_storage *ppc = (void *)(pi->private);
-	int out;
+	int out, saved_mode;
 
 	dev_dbg(&pi->dev, "PROBE UNIT %x on port:%x\n", pi->unit, pi->port);
 
+	saved_mode = pi->mode;
 	/*LOWER DOWN TO UNIDIRECTIONAL*/
-	ppc->mode = 1;
+	pi->mode = 0;
 
 	out = ppc6_open(pi);
 
@@ -101,11 +87,13 @@ static int bpck6_probe_unit(struct pi_adapter *pi)
  	{
 		ppc6_close(pi);
 		dev_dbg(&pi->dev, "leaving probe\n");
+		pi->mode = saved_mode;
                return(1);
 	}
   	else
   	{
 		dev_dbg(&pi->dev, "Failed open\n");
+		pi->mode = saved_mode;
     		return(0);
   	}
 }
diff --git a/drivers/ata/pata_parport/ppc6lnx.c b/drivers/ata/pata_parport/ppc6lnx.c
index 7ea8e8a31aeb..75f9748d8de5 100644
--- a/drivers/ata/pata_parport/ppc6lnx.c
+++ b/drivers/ata/pata_parport/ppc6lnx.c
@@ -65,14 +65,6 @@
 //***************************************************************************
 
 struct ppc_storage {
-	u8	mode;						// operating mode
-					// 0 = PPC Uni SW
-					// 1 = PPC Uni FW
-					// 2 = PPC Bi SW
-					// 3 = PPC Bi FW
-					// 4 = EPP Byte
-					// 5 = EPP Word
-					// 6 = EPP Dword
 	u8	ppc_flags;
 	u8	cur_ctrl;				// current control port contents
 };
@@ -115,6 +107,9 @@ static void ppc6_close(struct pi_adapter *pi);
 
 //***************************************************************************
 
+int mode_map[] = { PPCMODE_UNI_FW, PPCMODE_BI_FW, PPCMODE_EPP_BYTE,
+		   PPCMODE_EPP_WORD, PPCMODE_EPP_DWORD };
+
 static int ppc6_select(struct pi_adapter *pi)
 {
 	struct ppc_storage *ppc = (void *)(pi->private);
@@ -151,10 +146,10 @@ static int ppc6_select(struct pi_adapter *pi)
 
 	outb(ppc->cur_ctrl, pi->port + 2);
 
-	i = ppc->mode & 0x0C;
+	i = mode_map[pi->mode] & 0x0C;
 
 	if (i == 0)
-		i = (ppc->mode & 2) | 1;
+		i = (mode_map[pi->mode] & 2) | 1;
 
 	outb(i, pi->port);
 
@@ -205,7 +200,7 @@ static int ppc6_select(struct pi_adapter *pi)
 static void ppc6_deselect(struct pi_adapter *pi)
 {
 	struct ppc_storage *ppc = (void *)(pi->private);
-	if (ppc->mode & 4)	// EPP
+	if (mode_map[pi->mode] & 4)	// EPP
 		ppc->cur_ctrl |= port_init;
 	else								// PPC/ECP
 		ppc->cur_ctrl |= port_sel;
@@ -224,7 +219,7 @@ static void ppc6_deselect(struct pi_adapter *pi)
 static void ppc6_send_cmd(struct pi_adapter *pi, u8 cmd)
 {
 	struct ppc_storage *ppc = (void *)(pi->private);
-	switch(ppc->mode)
+	switch (mode_map[pi->mode])
 	{
 		case PPCMODE_UNI_SW :
 		case PPCMODE_UNI_FW :
@@ -256,7 +251,7 @@ static void ppc6_send_cmd(struct pi_adapter *pi, u8 cmd)
 static void ppc6_wr_data_byte(struct pi_adapter *pi, u8 data)
 {
 	struct ppc_storage *ppc = (void *)(pi->private);
-	switch(ppc->mode)
+	switch (mode_map[pi->mode])
 	{
 		case PPCMODE_UNI_SW :
 		case PPCMODE_UNI_FW :
@@ -290,7 +285,7 @@ static u8 ppc6_rd_data_byte(struct pi_adapter *pi)
 	struct ppc_storage *ppc = (void *)(pi->private);
 	u8 data = 0;
 
-	switch(ppc->mode)
+	switch (mode_map[pi->mode])
 	{
 		case PPCMODE_UNI_SW :
 		case PPCMODE_UNI_FW :
@@ -380,7 +375,7 @@ static void ppc6_wr_port(struct pi_adapter *pi, u8 port, u8 data)
 static void ppc6_rd_data_blk(struct pi_adapter *pi, u8 *data, long count)
 {
 	struct ppc_storage *ppc = (void *)(pi->private);
-	switch(ppc->mode)
+	switch (mode_map[pi->mode])
 	{
 		case PPCMODE_UNI_SW :
 		case PPCMODE_UNI_FW :
@@ -531,7 +526,7 @@ static void ppc6_wait_for_fifo(struct pi_adapter *pi)
 static void ppc6_wr_data_blk(struct pi_adapter *pi, u8 *data, long count)
 {
 	struct ppc_storage *ppc = (void *)(pi->private);
-	switch(ppc->mode)
+	switch (mode_map[pi->mode])
 	{
 		case PPCMODE_UNI_SW :
 		case PPCMODE_BI_SW :
-- 
Ondrej Zary




[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux