linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ondrej Zary <linux@zary.sk>
To: Damien Le Moal <damien.lemoal@opensource.wdc.com>
Cc: Christoph Hellwig <hch@lst.de>,
	Sergey Shtylyov <s.shtylyov@omp.ru>, Jens Axboe <axboe@kernel.dk>,
	Tim Waugh <tim@cyberelk.net>,
	linux-block@vger.kernel.org, linux-parport@lists.infradead.org,
	linux-ide@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 16/18] pata_parport: remove scratch parameter from test_proto()
Date: Wed, 15 Feb 2023 00:00:08 +0100	[thread overview]
Message-ID: <20230214230010.20318-17-linux@zary.sk> (raw)
In-Reply-To: <20230214230010.20318-1-linux@zary.sk>

Don't pass around a pointer to scratch buffer. Use local buffers in
protocols that need it.

Signed-off-by: Ondrej Zary <linux@zary.sk>
---
 drivers/ata/pata_parport/bpck.c         |  2 +-
 drivers/ata/pata_parport/epat.c         |  3 ++-
 drivers/ata/pata_parport/epia.c         |  3 ++-
 drivers/ata/pata_parport/friq.c         |  3 ++-
 drivers/ata/pata_parport/frpw.c         |  3 ++-
 drivers/ata/pata_parport/pata_parport.c | 23 +++++++++++------------
 include/linux/pata_parport.h            |  2 +-
 7 files changed, 21 insertions(+), 18 deletions(-)

diff --git a/drivers/ata/pata_parport/bpck.c b/drivers/ata/pata_parport/bpck.c
index 2072e291fd16..ecb98bf0e6de 100644
--- a/drivers/ata/pata_parport/bpck.c
+++ b/drivers/ata/pata_parport/bpck.c
@@ -274,7 +274,7 @@ static void bpck_force_spp(struct pi_adapter *pi)
 
 #define TEST_LEN  16
 
-static int bpck_test_proto(struct pi_adapter *pi, char *scratch)
+static int bpck_test_proto(struct pi_adapter *pi)
 
 {	int i, e, l, h, om;
 	char buf[TEST_LEN];
diff --git a/drivers/ata/pata_parport/epat.c b/drivers/ata/pata_parport/epat.c
index da3398941f81..26d1b6d438bc 100644
--- a/drivers/ata/pata_parport/epat.c
+++ b/drivers/ata/pata_parport/epat.c
@@ -246,10 +246,11 @@ static void epat_disconnect(struct pi_adapter *pi)
 	w2(pi->saved_r2);
 }
 
-static int epat_test_proto(struct pi_adapter *pi, char *scratch)
+static int epat_test_proto(struct pi_adapter *pi)
 
 {       int     k, j, f, cc;
 	int	e[2] = {0,0};
+	char scratch[512];
 
         epat_connect(pi);
 	cc = RR(0xd);
diff --git a/drivers/ata/pata_parport/epia.c b/drivers/ata/pata_parport/epia.c
index a83685ed9dde..101a0d9f1aa6 100644
--- a/drivers/ata/pata_parport/epia.c
+++ b/drivers/ata/pata_parport/epia.c
@@ -232,10 +232,11 @@ static void epia_write_block(struct pi_adapter *pi, char *buf, int count)
 
 }
 
-static int epia_test_proto(struct pi_adapter *pi, char *scratch)
+static int epia_test_proto(struct pi_adapter *pi)
 
 {       int     j, k, f;
 	int	e[2] = {0,0};
+	char scratch[512];
 
         epia_connect(pi);
         for (j=0;j<2;j++) {
diff --git a/drivers/ata/pata_parport/friq.c b/drivers/ata/pata_parport/friq.c
index 7ace1f7eea34..9c4a6487b2a9 100644
--- a/drivers/ata/pata_parport/friq.c
+++ b/drivers/ata/pata_parport/friq.c
@@ -178,10 +178,11 @@ static void friq_disconnect(struct pi_adapter *pi)
         w2(pi->saved_r2);
 } 
 
-static int friq_test_proto(struct pi_adapter *pi, char *scratch)
+static int friq_test_proto(struct pi_adapter *pi)
 
 {       int     j, k, r;
 	int	e[2] = {0,0};
+	char scratch[512];
 
 	pi->saved_r0 = r0();	
 	w0(0xff); udelay(20); CMD(0x3d); /* turn the power on */
diff --git a/drivers/ata/pata_parport/frpw.c b/drivers/ata/pata_parport/frpw.c
index d04a11889066..024b5c0737e0 100644
--- a/drivers/ata/pata_parport/frpw.c
+++ b/drivers/ata/pata_parport/frpw.c
@@ -219,10 +219,11 @@ static int frpw_test_pnp(struct pi_adapter *pi)
    a hack :-(
 */
 
-static int frpw_test_proto(struct pi_adapter *pi, char *scratch)
+static int frpw_test_proto(struct pi_adapter *pi)
 
 {       int     j, k, r;
 	int	e[2] = {0,0};
+	char scratch[512];
 
 	if ((pi->private>>1) != pi->port)
 	   pi->private = frpw_test_pnp(pi) + 2*pi->port;
diff --git a/drivers/ata/pata_parport/pata_parport.c b/drivers/ata/pata_parport/pata_parport.c
index 27aa2419af02..77a3e5a3f062 100644
--- a/drivers/ata/pata_parport/pata_parport.c
+++ b/drivers/ata/pata_parport/pata_parport.c
@@ -276,7 +276,7 @@ static void pi_release(struct pi_adapter *pi)
 	module_put(pi->proto->owner);
 }
 
-static int default_test_proto(struct pi_adapter *pi, char *scratch)
+static int default_test_proto(struct pi_adapter *pi)
 {
 	int j, k;
 	int e[2] = { 0, 0 };
@@ -300,21 +300,21 @@ static int default_test_proto(struct pi_adapter *pi, char *scratch)
 	return e[0] && e[1];	/* not here if both > 0 */
 }
 
-static int pi_test_proto(struct pi_adapter *pi, char *scratch)
+static int pi_test_proto(struct pi_adapter *pi)
 {
 	int res;
 
 	parport_claim_or_block(pi->pardev);
 	if (pi->proto->test_proto)
-		res = pi->proto->test_proto(pi, scratch);
+		res = pi->proto->test_proto(pi);
 	else
-		res = default_test_proto(pi, scratch);
+		res = default_test_proto(pi);
 	parport_release(pi->pardev);
 
 	return res;
 }
 
-static bool pi_probe_mode(struct pi_adapter *pi, int max, char *scratch)
+static bool pi_probe_mode(struct pi_adapter *pi, int max)
 {
 	int best, range;
 
@@ -326,7 +326,7 @@ static bool pi_probe_mode(struct pi_adapter *pi, int max, char *scratch)
 			range = 8;
 		if (range == 8 && pi->port % 8)
 			return false;
-		return !pi_test_proto(pi, scratch);
+		return !pi_test_proto(pi);
 	}
 	best = -1;
 	for (pi->mode = 0; pi->mode < max; pi->mode++) {
@@ -335,14 +335,14 @@ static bool pi_probe_mode(struct pi_adapter *pi, int max, char *scratch)
 			range = 8;
 		if (range == 8 && pi->port % 8)
 			break;
-		if (!pi_test_proto(pi, scratch))
+		if (!pi_test_proto(pi))
 			best = pi->mode;
 	}
 	pi->mode = best;
 	return best > -1;
 }
 
-static bool pi_probe_unit(struct pi_adapter *pi, int unit, char *scratch)
+static bool pi_probe_unit(struct pi_adapter *pi, int unit)
 {
 	int max, s, e;
 
@@ -367,14 +367,14 @@ static bool pi_probe_unit(struct pi_adapter *pi, int unit, char *scratch)
 		for (pi->unit = s; pi->unit < e; pi->unit++) {
 			if (pi->proto->probe_unit(pi)) {
 				parport_release(pi->pardev);
-				return pi_probe_mode(pi, max, scratch);
+				return pi_probe_mode(pi, max);
 			}
 		}
 		parport_release(pi->pardev);
 		return false;
 	}
 
-	return pi_probe_mode(pi, max, scratch);
+	return pi_probe_mode(pi, max);
 }
 
 static void pata_parport_dev_release(struct device *dev)
@@ -419,7 +419,6 @@ static struct pi_adapter *pi_init_one(struct parport *parport,
 			struct pi_protocol *pr, int mode, int unit, int delay)
 {
 	struct pardev_cb par_cb = { };
-	char scratch[512];
 	const struct ata_port_info *ppi[] = { &pata_parport_port_info };
 	struct ata_host *host;
 	struct pi_adapter *pi;
@@ -469,7 +468,7 @@ static struct pi_adapter *pi_init_one(struct parport *parport,
 	if (!pi->pardev)
 		goto out_module_put;
 
-	if (!pi_probe_unit(pi, unit, scratch)) {
+	if (!pi_probe_unit(pi, unit)) {
 		dev_info(&pi->dev, "Adapter not found\n");
 		goto out_unreg_parport;
 	}
diff --git a/include/linux/pata_parport.h b/include/linux/pata_parport.h
index e45bb1896003..bbfa4e63ee85 100644
--- a/include/linux/pata_parport.h
+++ b/include/linux/pata_parport.h
@@ -67,7 +67,7 @@ struct pi_protocol {
 
 	int (*test_port)(struct pi_adapter *pi);
 	int (*probe_unit)(struct pi_adapter *pi);
-	int (*test_proto)(struct pi_adapter *pi, char *scratch);
+	int (*test_proto)(struct pi_adapter *pi);
 	void (*log_adapter)(struct pi_adapter *pi);
 
 	int (*init_proto)(struct pi_adapter *pi);
-- 
Ondrej Zary


  parent reply	other threads:[~2023-02-14 23:01 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-14 22:59 [PATCH v2 0/18] pata_parport: protocol drivers fixes and cleanups Ondrej Zary
2023-02-14 22:59 ` [PATCH 01/18] pata_parport: fix EPAT C7/C8 Kconfig Ondrej Zary
2023-02-15 17:19   ` Sergey Shtylyov
2023-02-14 22:59 ` [PATCH 02/18] pata_parport: probe all units automatically Ondrej Zary
2023-02-14 22:59 ` [PATCH 03/18] pata_parport: Remove pi_swab16 and pi_swab32 Ondrej Zary
2023-02-14 22:59 ` [PATCH 04/18] pata_parport: remove useless printks at module_init of bpck6 Ondrej Zary
2023-02-14 22:59 ` [PATCH 05/18] pata_parport: Introduce module_pata_parport_driver macro Ondrej Zary
2023-02-14 22:59 ` [PATCH 06/18] pata_parport: remove devtype from struct pi_adapter Ondrej Zary
2023-02-14 22:59 ` [PATCH 07/18] pata_parport: remove device " Ondrej Zary
2023-02-14 23:00 ` [PATCH 08/18] pata_parport: remove typedef struct PIA Ondrej Zary
2023-02-14 23:00 ` [PATCH 09/18] pata_parport: remove verbose parameter from log_adapter() Ondrej Zary
2023-02-14 23:00 ` [PATCH 10/18] pata_parport: remove scratch " Ondrej Zary
2023-02-14 23:00 ` [PATCH 11/18] pata_parport: use dev_* instead of printk Ondrej Zary
2023-02-14 23:00 ` [PATCH 12/18] pata_parport: use print_hex_* Ondrej Zary
2023-02-14 23:00 ` [PATCH 13/18] pata_parport: simplify log_adapter prints, remove VERSION defines Ondrej Zary
2023-02-14 23:00 ` [PATCH 14/18] pata_parport: remove bpck6 verbose parameter Ondrej Zary
2023-02-14 23:00 ` [PATCH 15/18] pata_parport: remove verbose parameter from test_proto() Ondrej Zary
2023-02-14 23:00 ` Ondrej Zary [this message]
2023-02-14 23:00 ` [PATCH 17/18] pata_parport: remove obsolete changelogs Ondrej Zary
2023-02-14 23:00 ` [PATCH 18/18] pata_parport: move pata_parport.h to drivers/ata/pata_parport Ondrej Zary
2023-02-14 23:50 ` [PATCH v2 0/18] pata_parport: protocol drivers fixes and cleanups Damien Le Moal
2023-02-15 17:14   ` Sergey Shtylyov
  -- strict thread matches above, loose matches on Subject: below --
2023-02-15 19:45 [PATCH v3 " Ondrej Zary
2023-02-15 19:45 ` [PATCH 16/18] pata_parport: remove scratch parameter from test_proto() Ondrej Zary
2023-02-18 22:01 [PATCH v4 0/18] pata_parport: protocol drivers fixes and cleanups Ondrej Zary
2023-02-18 22:01 ` [PATCH 16/18] pata_parport: remove scratch parameter from test_proto() Ondrej Zary
2023-03-06 17:27 [PATCH RESEND v4 0/18] pata_parport: protocol drivers fixes and cleanups Ondrej Zary
2023-03-06 17:27 ` [PATCH 16/18] pata_parport: remove scratch parameter from test_proto() Ondrej Zary

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=20230214230010.20318-17-linux@zary.sk \
    --to=linux@zary.sk \
    --cc=axboe@kernel.dk \
    --cc=damien.lemoal@opensource.wdc.com \
    --cc=hch@lst.de \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-ide@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-parport@lists.infradead.org \
    --cc=s.shtylyov@omp.ru \
    --cc=tim@cyberelk.net \
    /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;
as well as URLs for NNTP newsgroup(s).