mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Paolo Pisati <p.pisati@gmail.com>
To: Sergey Shtylyov <s.shtylyov@omp.ru>, Damien Le Moal <dlemoal@kernel.org>
Cc: linux-m68k@lists.linux-m68k.org, linux-ide@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH] ata: pata_buddha: pata_gayle: consolidate .sff_data_xfer around libata::ata_sff_data_xfer()
Date: Tue,  4 Jun 2024 18:22:17 +0200	[thread overview]
Message-ID: <20240604162217.484789-1-p.pisati@gmail.com> (raw)

pata_buddha_data_xfer(), pata_gayle_data_xfer() and ata_sff_data_xfer() are the
same function, consolidate around libata::ata_sff_data_xfer().

Signed-off-by: Paolo Pisati <p.pisati@gmail.com>
---
 drivers/ata/pata_buddha.c | 40 ++-------------------------------------
 drivers/ata/pata_gayle.c  | 40 ++-------------------------------------
 2 files changed, 4 insertions(+), 76 deletions(-)

diff --git a/drivers/ata/pata_buddha.c b/drivers/ata/pata_buddha.c
index c36ee991d5e5..234278eb26e1 100644
--- a/drivers/ata/pata_buddha.c
+++ b/drivers/ata/pata_buddha.c
@@ -60,42 +60,6 @@ static const struct scsi_host_template pata_buddha_sht = {
 	ATA_PIO_SHT(DRV_NAME),
 };
 
-/* FIXME: is this needed? */
-static unsigned int pata_buddha_data_xfer(struct ata_queued_cmd *qc,
-					 unsigned char *buf,
-					 unsigned int buflen, int rw)
-{
-	struct ata_device *dev = qc->dev;
-	struct ata_port *ap = dev->link->ap;
-	void __iomem *data_addr = ap->ioaddr.data_addr;
-	unsigned int words = buflen >> 1;
-
-	/* Transfer multiple of 2 bytes */
-	if (rw == READ)
-		raw_insw((u16 *)data_addr, (u16 *)buf, words);
-	else
-		raw_outsw((u16 *)data_addr, (u16 *)buf, words);
-
-	/* Transfer trailing byte, if any. */
-	if (unlikely(buflen & 0x01)) {
-		unsigned char pad[2] = { };
-
-		/* Point buf to the tail of buffer */
-		buf += buflen - 1;
-
-		if (rw == READ) {
-			raw_insw((u16 *)data_addr, (u16 *)pad, 1);
-			*buf = pad[0];
-		} else {
-			pad[0] = *buf;
-			raw_outsw((u16 *)data_addr, (u16 *)pad, 1);
-		}
-		words++;
-	}
-
-	return words << 1;
-}
-
 /*
  * Provide our own set_mode() as we don't want to change anything that has
  * already been configured..
@@ -131,7 +95,7 @@ static void pata_xsurf_irq_clear(struct ata_port *ap)
 
 static struct ata_port_operations pata_buddha_ops = {
 	.inherits	= &ata_sff_port_ops,
-	.sff_data_xfer	= pata_buddha_data_xfer,
+	.sff_data_xfer	= ata_sff_data_xfer,
 	.sff_irq_check	= pata_buddha_irq_check,
 	.cable_detect	= ata_cable_unknown,
 	.set_mode	= pata_buddha_set_mode,
@@ -139,7 +103,7 @@ static struct ata_port_operations pata_buddha_ops = {
 
 static struct ata_port_operations pata_xsurf_ops = {
 	.inherits	= &ata_sff_port_ops,
-	.sff_data_xfer	= pata_buddha_data_xfer,
+	.sff_data_xfer	= ata_sff_data_xfer,
 	.sff_irq_check	= pata_buddha_irq_check,
 	.sff_irq_clear	= pata_xsurf_irq_clear,
 	.cable_detect	= ata_cable_unknown,
diff --git a/drivers/ata/pata_gayle.c b/drivers/ata/pata_gayle.c
index 3bdbe2b65a2b..febffc36a18f 100644
--- a/drivers/ata/pata_gayle.c
+++ b/drivers/ata/pata_gayle.c
@@ -38,42 +38,6 @@ static const struct scsi_host_template pata_gayle_sht = {
 	ATA_PIO_SHT(DRV_NAME),
 };
 
-/* FIXME: is this needed? */
-static unsigned int pata_gayle_data_xfer(struct ata_queued_cmd *qc,
-					 unsigned char *buf,
-					 unsigned int buflen, int rw)
-{
-	struct ata_device *dev = qc->dev;
-	struct ata_port *ap = dev->link->ap;
-	void __iomem *data_addr = ap->ioaddr.data_addr;
-	unsigned int words = buflen >> 1;
-
-	/* Transfer multiple of 2 bytes */
-	if (rw == READ)
-		raw_insw((u16 *)data_addr, (u16 *)buf, words);
-	else
-		raw_outsw((u16 *)data_addr, (u16 *)buf, words);
-
-	/* Transfer trailing byte, if any. */
-	if (unlikely(buflen & 0x01)) {
-		unsigned char pad[2] = { };
-
-		/* Point buf to the tail of buffer */
-		buf += buflen - 1;
-
-		if (rw == READ) {
-			raw_insw((u16 *)data_addr, (u16 *)pad, 1);
-			*buf = pad[0];
-		} else {
-			pad[0] = *buf;
-			raw_outsw((u16 *)data_addr, (u16 *)pad, 1);
-		}
-		words++;
-	}
-
-	return words << 1;
-}
-
 /*
  * Provide our own set_mode() as we don't want to change anything that has
  * already been configured..
@@ -110,7 +74,7 @@ static void pata_gayle_irq_clear(struct ata_port *ap)
 
 static struct ata_port_operations pata_gayle_a1200_ops = {
 	.inherits	= &ata_sff_port_ops,
-	.sff_data_xfer	= pata_gayle_data_xfer,
+	.sff_data_xfer	= ata_sff_data_xfer,
 	.sff_irq_check	= pata_gayle_irq_check,
 	.sff_irq_clear	= pata_gayle_irq_clear,
 	.cable_detect	= ata_cable_unknown,
@@ -119,7 +83,7 @@ static struct ata_port_operations pata_gayle_a1200_ops = {
 
 static struct ata_port_operations pata_gayle_a4000_ops = {
 	.inherits	= &ata_sff_port_ops,
-	.sff_data_xfer	= pata_gayle_data_xfer,
+	.sff_data_xfer	= ata_sff_data_xfer,
 	.cable_detect	= ata_cable_unknown,
 	.set_mode	= pata_gayle_set_mode,
 };
-- 
2.34.1


             reply	other threads:[~2024-06-04 16:22 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-04 16:22 Paolo Pisati [this message]
2024-06-04 20:17 ` Sergey Shtylyov
2024-06-04 20:29 ` Niklas Cassel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240604162217.484789-1-p.pisati@gmail.com \
    --to=p.pisati@gmail.com \
    --cc=dlemoal@kernel.org \
    --cc=linux-ide@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-m68k@lists.linux-m68k.org \
    --cc=s.shtylyov@omp.ru \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome