Commit baa6f0f8 authored by Ondrej Zary's avatar Ondrej Zary Committed by Damien Le Moal

ata: pata_parport-bpck6: remove mode from struct ppc_storage

introduce mode_map[] that maps bpck6 modes to ppc6 modes and use it to
replace mode in ppc_storage
Signed-off-by: default avatarOndrej Zary <linux@zary.sk>
Reviewed-by: default avatarSergey Shtylyov <s.shtylyov@omp.ru>
Signed-off-by: default avatarDamien Le Moal <damien.lemoal@opensource.wdc.com>
parent f5031656
...@@ -43,22 +43,8 @@ static void bpck6_read_block(struct pi_adapter *pi, char *buf, int len) ...@@ -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) static void bpck6_connect(struct pi_adapter *pi)
{ {
struct ppc_storage *ppc = (void *)(pi->private);
dev_dbg(&pi->dev, "connect\n"); 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_open(pi);
ppc6_wr_extout(pi, 0x3); ppc6_wr_extout(pi, 0x3);
} }
...@@ -85,13 +71,13 @@ static int bpck6_test_port(struct pi_adapter *pi) /* check for 8-bit port */ ...@@ -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) static int bpck6_probe_unit(struct pi_adapter *pi)
{ {
struct ppc_storage *ppc = (void *)(pi->private); int out, saved_mode;
int out;
dev_dbg(&pi->dev, "PROBE UNIT %x on port:%x\n", pi->unit, pi->port); dev_dbg(&pi->dev, "PROBE UNIT %x on port:%x\n", pi->unit, pi->port);
saved_mode = pi->mode;
/*LOWER DOWN TO UNIDIRECTIONAL*/ /*LOWER DOWN TO UNIDIRECTIONAL*/
ppc->mode = 1; pi->mode = 0;
out = ppc6_open(pi); out = ppc6_open(pi);
...@@ -101,11 +87,13 @@ static int bpck6_probe_unit(struct pi_adapter *pi) ...@@ -101,11 +87,13 @@ static int bpck6_probe_unit(struct pi_adapter *pi)
{ {
ppc6_close(pi); ppc6_close(pi);
dev_dbg(&pi->dev, "leaving probe\n"); dev_dbg(&pi->dev, "leaving probe\n");
pi->mode = saved_mode;
return(1); return(1);
} }
else else
{ {
dev_dbg(&pi->dev, "Failed open\n"); dev_dbg(&pi->dev, "Failed open\n");
pi->mode = saved_mode;
return(0); return(0);
} }
} }
......
...@@ -65,14 +65,6 @@ ...@@ -65,14 +65,6 @@
//*************************************************************************** //***************************************************************************
struct ppc_storage { 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 ppc_flags;
u8 cur_ctrl; // current control port contents u8 cur_ctrl; // current control port contents
}; };
...@@ -115,6 +107,9 @@ static void ppc6_close(struct pi_adapter *pi); ...@@ -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) static int ppc6_select(struct pi_adapter *pi)
{ {
struct ppc_storage *ppc = (void *)(pi->private); struct ppc_storage *ppc = (void *)(pi->private);
...@@ -151,10 +146,10 @@ static int ppc6_select(struct pi_adapter *pi) ...@@ -151,10 +146,10 @@ static int ppc6_select(struct pi_adapter *pi)
outb(ppc->cur_ctrl, pi->port + 2); outb(ppc->cur_ctrl, pi->port + 2);
i = ppc->mode & 0x0C; i = mode_map[pi->mode] & 0x0C;
if (i == 0) if (i == 0)
i = (ppc->mode & 2) | 1; i = (mode_map[pi->mode] & 2) | 1;
outb(i, pi->port); outb(i, pi->port);
...@@ -205,7 +200,7 @@ static int ppc6_select(struct pi_adapter *pi) ...@@ -205,7 +200,7 @@ static int ppc6_select(struct pi_adapter *pi)
static void ppc6_deselect(struct pi_adapter *pi) static void ppc6_deselect(struct pi_adapter *pi)
{ {
struct ppc_storage *ppc = (void *)(pi->private); struct ppc_storage *ppc = (void *)(pi->private);
if (ppc->mode & 4) // EPP if (mode_map[pi->mode] & 4) // EPP
ppc->cur_ctrl |= port_init; ppc->cur_ctrl |= port_init;
else // PPC/ECP else // PPC/ECP
ppc->cur_ctrl |= port_sel; ppc->cur_ctrl |= port_sel;
...@@ -224,7 +219,7 @@ static void ppc6_deselect(struct pi_adapter *pi) ...@@ -224,7 +219,7 @@ static void ppc6_deselect(struct pi_adapter *pi)
static void ppc6_send_cmd(struct pi_adapter *pi, u8 cmd) static void ppc6_send_cmd(struct pi_adapter *pi, u8 cmd)
{ {
struct ppc_storage *ppc = (void *)(pi->private); struct ppc_storage *ppc = (void *)(pi->private);
switch(ppc->mode) switch (mode_map[pi->mode])
{ {
case PPCMODE_UNI_SW : case PPCMODE_UNI_SW :
case PPCMODE_UNI_FW : case PPCMODE_UNI_FW :
...@@ -256,7 +251,7 @@ static void ppc6_send_cmd(struct pi_adapter *pi, u8 cmd) ...@@ -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) static void ppc6_wr_data_byte(struct pi_adapter *pi, u8 data)
{ {
struct ppc_storage *ppc = (void *)(pi->private); struct ppc_storage *ppc = (void *)(pi->private);
switch(ppc->mode) switch (mode_map[pi->mode])
{ {
case PPCMODE_UNI_SW : case PPCMODE_UNI_SW :
case PPCMODE_UNI_FW : case PPCMODE_UNI_FW :
...@@ -290,7 +285,7 @@ static u8 ppc6_rd_data_byte(struct pi_adapter *pi) ...@@ -290,7 +285,7 @@ static u8 ppc6_rd_data_byte(struct pi_adapter *pi)
struct ppc_storage *ppc = (void *)(pi->private); struct ppc_storage *ppc = (void *)(pi->private);
u8 data = 0; u8 data = 0;
switch(ppc->mode) switch (mode_map[pi->mode])
{ {
case PPCMODE_UNI_SW : case PPCMODE_UNI_SW :
case PPCMODE_UNI_FW : case PPCMODE_UNI_FW :
...@@ -380,7 +375,7 @@ static void ppc6_wr_port(struct pi_adapter *pi, u8 port, u8 data) ...@@ -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) static void ppc6_rd_data_blk(struct pi_adapter *pi, u8 *data, long count)
{ {
struct ppc_storage *ppc = (void *)(pi->private); struct ppc_storage *ppc = (void *)(pi->private);
switch(ppc->mode) switch (mode_map[pi->mode])
{ {
case PPCMODE_UNI_SW : case PPCMODE_UNI_SW :
case PPCMODE_UNI_FW : case PPCMODE_UNI_FW :
...@@ -531,7 +526,7 @@ static void ppc6_wait_for_fifo(struct pi_adapter *pi) ...@@ -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) static void ppc6_wr_data_blk(struct pi_adapter *pi, u8 *data, long count)
{ {
struct ppc_storage *ppc = (void *)(pi->private); struct ppc_storage *ppc = (void *)(pi->private);
switch(ppc->mode) switch (mode_map[pi->mode])
{ {
case PPCMODE_UNI_SW : case PPCMODE_UNI_SW :
case PPCMODE_BI_SW : case PPCMODE_BI_SW :
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment