ata: pata_parport: remove scratch parameter from test_proto()
authorOndrej Zary <linux@zary.sk>
Sat, 18 Feb 2023 22:01:36 +0000 (23:01 +0100)
committerDamien Le Moal <damien.lemoal@opensource.wdc.com>
Thu, 23 Mar 2023 01:29:25 +0000 (10:29 +0900)
Don't pass around a pointer to scratch buffer. Use local buffers in
protocols that need it.

Reviewed-by: Sergey Shtylyov <s.shtylyov@omp.ru>
Signed-off-by: Ondrej Zary <linux@zary.sk>
Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
drivers/ata/pata_parport/bpck.c
drivers/ata/pata_parport/epat.c
drivers/ata/pata_parport/epia.c
drivers/ata/pata_parport/friq.c
drivers/ata/pata_parport/frpw.c
drivers/ata/pata_parport/pata_parport.c
include/linux/pata_parport.h

index 2072e291fd16894deb59b2e1e604f395200c8c6b..ecb98bf0e6deb3ac926a847461a0875e1e925304 100644 (file)
@@ -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];
index 4877b39ed04cd1b75197042819c4c56a56870807..609614b2c69e7a89252a44edba8aabf0d7450821 100644 (file)
@@ -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);
index e7401351463a548693662f8eef005dbb846ce152..970532619aeb52c179da2664400f0a47b6204e37 100644 (file)
@@ -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++) {
index df15b210f355bbd3f64385efc7bb0988adbc7f83..1888e8bcb8843ace688fefca78aaad238b8b57c2 100644 (file)
@@ -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 */
index 0d4e84806350004f2376034a251609622f8980a9..484b5b9d31eba2e8a1a8ec0a60f3bb27794ad145 100644 (file)
@@ -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;
index c855937889517735c7fc79313ba438f478a67ab3..b6499f2160da8b3012228f9ba8d7355b30db40f9 100644 (file)
@@ -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)
@@ -420,7 +420,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;
@@ -473,7 +472,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;
        }
index e45bb18960032f8fcc4107b53da5cc97e9451155..bbfa4e63ee85901025d2644e6adfd6d08bff0270 100644 (file)
@@ -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);