[20/32] pata_parport-bpck6: merge ppc6_rd_data_blk into bpck6_read_block

Message ID 20230307224627.28011-21-linux@zary.sk
State New
Headers
Series pata_parport-bpck6: rework bpck6 protocol driver |

Commit Message

Ondrej Zary March 7, 2023, 10:46 p.m. UTC
  ppc6_rd_data_blk is only called by bpck6_read_block. Merge
ppc6_rd_data_blk into bpck6_read_block.

Signed-off-by: Ondrej Zary <linux@zary.sk>
---
 drivers/ata/pata_parport/bpck6.c   | 49 +++++++++++++++-
 drivers/ata/pata_parport/ppc6lnx.c | 91 ------------------------------
 2 files changed, 48 insertions(+), 92 deletions(-)
  

Patch

diff --git a/drivers/ata/pata_parport/bpck6.c b/drivers/ata/pata_parport/bpck6.c
index 1c04fcaba74a..d379603424ff 100644
--- a/drivers/ata/pata_parport/bpck6.c
+++ b/drivers/ata/pata_parport/bpck6.c
@@ -57,7 +57,54 @@  static void bpck6_read_block(struct pi_adapter *pi, char *buf, int len)
 
 	ppc6_send_cmd(pi, CMD_PREFIX_SET | PREFIX_IO16 | PREFIX_BLK);
 	ppc6_send_cmd(pi, ATA_REG_DATA | ACCESS_PORT | ACCESS_READ);
-	ppc6_rd_data_blk(pi, buf, len);
+
+	switch (mode_map[pi->mode]) {
+	case PPCMODE_UNI_SW:
+	case PPCMODE_UNI_FW:
+		while (len) {
+			u8 d;
+
+			parport_frob_control(pi->pardev->port,
+					PARPORT_CONTROL_STROBE,
+					PARPORT_CONTROL_INIT); /* DATA STROBE */
+			d = parport_read_status(pi->pardev->port);
+			d = ((d & 0x80) >> 1) | ((d & 0x38) >> 3);
+			parport_frob_control(pi->pardev->port,
+					PARPORT_CONTROL_STROBE,
+					PARPORT_CONTROL_STROBE);
+			d |= parport_read_status(pi->pardev->port) & 0xB8;
+			*buf++ = d;
+			len--;
+		}
+		break;
+	case PPCMODE_BI_SW:
+	case PPCMODE_BI_FW:
+		parport_data_reverse(pi->pardev->port);
+		while (len) {
+			parport_frob_control(pi->pardev->port,
+				PARPORT_CONTROL_STROBE,
+				PARPORT_CONTROL_STROBE | PARPORT_CONTROL_INIT);
+			*buf++ = parport_read_data(pi->pardev->port);
+			len--;
+		}
+		parport_frob_control(pi->pardev->port, PARPORT_CONTROL_STROBE,
+					0);
+		parport_data_forward(pi->pardev->port);
+		break;
+	case PPCMODE_EPP_BYTE:
+		pi->pardev->port->ops->epp_read_data(pi->pardev->port, buf, len,
+						PARPORT_EPP_FAST_8);
+		break;
+	case PPCMODE_EPP_WORD:
+		pi->pardev->port->ops->epp_read_data(pi->pardev->port, buf, len,
+						PARPORT_EPP_FAST_16);
+		break;
+	case PPCMODE_EPP_DWORD:
+		pi->pardev->port->ops->epp_read_data(pi->pardev->port, buf, len,
+						PARPORT_EPP_FAST_32);
+		break;
+	}
+
 	ppc6_send_cmd(pi, CMD_PREFIX_RESET | PREFIX_IO16 | PREFIX_BLK);
 }
 
diff --git a/drivers/ata/pata_parport/ppc6lnx.c b/drivers/ata/pata_parport/ppc6lnx.c
index d275de3f1ead..679261e19ac5 100644
--- a/drivers/ata/pata_parport/ppc6lnx.c
+++ b/drivers/ata/pata_parport/ppc6lnx.c
@@ -72,7 +72,6 @@  static void ppc6_deselect(struct pi_adapter *pi);
 static void ppc6_send_cmd(struct pi_adapter *pi, u8 cmd);
 static void ppc6_wr_data_byte(struct pi_adapter *pi, u8 data);
 static u8 ppc6_rd_data_byte(struct pi_adapter *pi);
-static void ppc6_rd_data_blk(struct pi_adapter *pi, u8 *data, long count);
 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_extout(struct pi_adapter *pi, u8 regdata);
@@ -284,96 +283,6 @@  static u8 ppc6_rd_data_byte(struct pi_adapter *pi)
 
 //***************************************************************************
 
-static void ppc6_rd_data_blk(struct pi_adapter *pi, u8 *data, long count)
-{
-	switch (mode_map[pi->mode])
-	{
-		case PPCMODE_UNI_SW :
-		case PPCMODE_UNI_FW :
-		{
-			while(count)
-			{
-				u8 d;
-
-				parport_frob_control(pi->pardev->port,
-					PARPORT_CONTROL_STROBE, PARPORT_CONTROL_INIT);
-
-				// DELAY
-
-				d = parport_read_status(pi->pardev->port);
-
-				d = ((d & 0x80) >> 1) | ((d & 0x38) >> 3);
-
-				parport_frob_control(pi->pardev->port,
-					PARPORT_CONTROL_STROBE, PARPORT_CONTROL_STROBE);
-
-				// DELAY
-
-				d |= parport_read_status(pi->pardev->port) & 0xB8;
-
-				*data++ = d;
-				count--;
-			}
-
-			break;
-		}
-
-		case PPCMODE_BI_SW :
-		case PPCMODE_BI_FW :
-		{
-			parport_data_reverse(pi->pardev->port);
-
-			while(count)
-			{
-				parport_frob_control(pi->pardev->port, PARPORT_CONTROL_STROBE,
-					PARPORT_CONTROL_STROBE | PARPORT_CONTROL_INIT);
-
-				*data++ = parport_read_data(pi->pardev->port);
-				count--;
-			}
-
-			parport_frob_control(pi->pardev->port, PARPORT_CONTROL_STROBE, 0);
-
-			parport_data_forward(pi->pardev->port);
-
-			break;
-		}
-
-		case PPCMODE_EPP_BYTE :
-		{
-			// DELAY
-
-			pi->pardev->port->ops->epp_read_data(pi->pardev->port,
-					data, count, PARPORT_EPP_FAST_8);
-
-			break;
-		}
-
-		case PPCMODE_EPP_WORD :
-		{
-			// DELAY
-
-			pi->pardev->port->ops->epp_read_data(pi->pardev->port,
-					data, count, PARPORT_EPP_FAST_16);
-
-			break;
-		}
-
-		case PPCMODE_EPP_DWORD :
-		{
-			// DELAY
-
-			pi->pardev->port->ops->epp_read_data(pi->pardev->port,
-					data, count, PARPORT_EPP_FAST_32);
-
-			break;
-		}
-	}
-
-}
-
-//***************************************************************************
-
 static void ppc6_wait_for_fifo(struct pi_adapter *pi)
 {
 	int i;