Cleanup pata_parport protocol drivers
Damien Le Moal
maintainercover Cleanup pata_parport protocol drivers
Cleanup the code of the pata_parport protocol drivers to avoid warnings from smatch and other static code checkers. No functional changes are introduced.
Damien Le Moal (13):
ata: pata_parport: Fix aten module code indentation and style
ata: pata_parport: Fix bpck6 module code indentation and style
ata: pata_parport: Fix comm module code indentation and style
ata: pata_parport: Fix dstr module code indentation and style
ata: pata_parport: Fix epat module code indentation and style
ata: pata_parport: Fix epia module code indentation and style
ata: pata_parport: Fix fit2 module code indentation and style
ata: pata_parport: Fix fit3 module code indentation and style
ata: pata_parport: Fix friq module code indentation and style
ata: pata_parport: Fix kbic module code indentation and style
ata: pata_parport: Fix ktti module code indentation and style
ata: pata_parport: Fix on20 module code indentation and style
ata: pata_parport: Fix on26 module code indentation and style
drivers/ata/pata_parport/aten.c | 103 +++---- drivers/ata/pata_parport/bpck6.c | 67 ++--- drivers/ata/pata_parport/comm.c | 238 +++++++++-------- drivers/ata/pata_parport/dstr.c | 285 +++++++++++--------- drivers/ata/pata_parport/epat.c | 320 ++++++++++++---------- drivers/ata/pata_parport/epia.c | 442 ++++++++++++++++--------------- drivers/ata/pata_parport/fit2.c | 131 +++++---- drivers/ata/pata_parport/fit3.c | 206 +++++++------- drivers/ata/pata_parport/friq.c | 292 ++++++++++---------- drivers/ata/pata_parport/kbic.c | 314 +++++++++++----------- drivers/ata/pata_parport/ktti.c | 85 +++--- drivers/ata/pata_parport/on20.c | 149 ++++++----- drivers/ata/pata_parport/on26.c | 414 +++++++++++++++-------------- 13 files changed, 1591 insertions(+), 1455 deletions(-)
Signature · 1 line
2.40.1
Damien Le Moal
maintainerPATCH 1/13 ata: pata_parport: Fix aten module code indentation and style
Fix the header, indentation and coding style in the aten pata parport protocol module to suppress warnings from smatch and other static code analyzers.
No functional changes.
--- drivers/ata/pata_parport/aten.c | 103 ++++++++++++++++---------------- 1 file changed, 53 insertions(+), 50 deletions(-)
drivers/ata/pata_parport/aten.c +53 -50
@@ -1,13 +1,12 @@ -/* -aten.c (c) 1997-8 Grant R. Guenther <[email protected]> -Under the terms of the GNU General Public License. - -aten.c is a low-level protocol driver for the ATEN EH-100 -parallel port adapter. The EH-100 supports 4-bit and 8-bit -modes only. There is also an EH-132 which supports EPP mode -transfers. The EH-132 is not yet supported. - -*/ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* (c) 1997-8 Grant R. Guenther <[email protected]> +* +* aten.c is a low-level protocol driver for the ATEN EH-100 +* parallel port adapter. The EH-100 supports 4-bit and 8-bit +* modes only. There is also an EH-132 which supports EPP mode +* transfers. The EH-132 is not yet supported. +*/ #include <linux/module.h> #include <linux/init.h>
@@ -20,36 +19,36 @@#define j44 (a,b) ((((a>>4)&0x0f)|(b&0xf0))^0x88) -/* cont = 0 - access the IDE register file -cont = 1 - access the IDE command set -*/ - +/* +* cont = 0 - access the IDE register file +* cont = 1 - access the IDE command set +*/ static int cont_map[2 ] = {0x08 ,0x20 };static void aten_write_regr (struct pi_adapter *pi,int cont,int regr,int val) - -{int r; - - r = regr + cont_map[cont] +0x80 ; +{ +int r = regr + cont_map[cont] +0x80 ;w0 (r);w2 (0xe );w2 (6 );w0 (val);w2 (7 );w2 (6 );w2 (0xc ); }static int aten_read_regr (struct pi_adapter *pi,int cont,int regr) +{ +int a, b, r; -{int a, b, r; - - r = regr + cont_map[cont] +0x40 ; + r = regr + cont_map[cont] +0x40 ;switch (pi->mode) { -case 0 :w0 (r);w2 (0xe );w2 (6 ); +case 0 : +w0 (r);w2 (0xe );w2 (6 );w2 (7 );w2 (6 );w2 (0 ); a =r1 ();w0 (0x10 ); b =r1 ();w2 (0xc );return j44 (a,b); -case 1 : r |=0x10 ; -w0 (r);w2 (0xe );w2 (6 );w0 (0xff ); +case 1 : + r |=0x10 ; +w0 (r);w2 (0xe );w2 (6 );w0 (0xff );w2 (0x27 );w2 (0x26 );w2 (0x20 ); a =r0 ();w2 (0x26 );w2 (0xc );
@@ -59,27 +58,30 @@ static int aten_read_regr(struct pi_adapter *pi, int cont, int regr) }static void aten_read_block (struct pi_adapter *pi,char *buf,int count) - -{int k, a, b, c, d; +{ +int k, a, b, c, d;switch (pi->mode) { -case 0 :w0 (0x48 );w2 (0xe );w2 (6 ); -for (k=0 ;k<count/2 ;k++) { +case 0 : +w0 (0x48 );w2 (0xe );w2 (6 ); +for (k =0 ; k < count /2 ; k++) {w2 (7 );w2 (6 );w2 (2 ); a =r1 ();w0 (0x58 ); b =r1 ();w2 (0 ); d =r1 ();w0 (0x48 ); c =r1 (); - buf[2 *k] =j44 (c,d); - buf[2 *k+1 ] =j44 (a,b); + buf[2 * k] =j44 (c, d); + buf[2 * k +1 ] =j44 (a, b); }w2 (0xc );break ; -case 1 :w0 (0x58 );w2 (0xe );w2 (6 ); -for (k=0 ;k<count/2 ;k++) { +case 1 : +w0 (0x58 );w2 (0xe );w2 (6 ); +for (k =0 ; k < count /2 ; k++) {w2 (0x27 );w2 (0x26 );w2 (0x22 ); a =r0 ();w2 (0x20 ); b =r0 (); - buf[2 *k] = b; buf[2 *k+1 ] = a; + buf[2 * k] = b; + buf[2 * k +1 ] = a; }w2 (0x26 );w2 (0xc );break ;
@@ -87,36 +89,37 @@ static void aten_read_block(struct pi_adapter *pi, char *buf, int count) }static void aten_write_block (struct pi_adapter *pi,char *buf,int count) - -{int k; +{ +int k;w0 (0x88 );w2 (0xe );w2 (6 ); -for (k=0 ;k<count/2 ;k++) { -w0 (buf[2 *k+1 ]);w2 (0xe );w2 (6 ); -w0 (buf[2 *k]);w2 (7 );w2 (6 ); +for (k =0 ; k < count /2 ; k++) { +w0 (buf[2 * k +1 ]);w2 (0xe );w2 (6 ); +w0 (buf[2 * k]);w2 (7 );w2 (6 ); }w2 (0xc ); }static void aten_connect (struct pi_adapter *pi) - -{ pi->saved_r0 =r0 (); - pi->saved_r2 =r2 (); -w2 (0xc ); +{ + pi->saved_r0 =r0 (); + pi->saved_r2 =r2 (); +w2 (0xc ); }static void aten_disconnect (struct pi_adapter *pi) - -{w0 (pi->saved_r0); -w2 (pi->saved_r2); -} +{ +w0 (pi->saved_r0); +w2 (pi->saved_r2); +}static void aten_log_adapter (struct pi_adapter *pi) +{ +char *mode_string[2 ] = {"4-bit" ,"8-bit" }; -{char *mode_string[2 ] = {"4-bit" ,"8-bit" }; - -dev_info (&pi->dev,"ATEN EH-100 at 0x%x, mode %d (%s), delay %d\n" , - pi->port, pi->mode, mode_string[pi->mode], pi->delay); +dev_info (&pi->dev, +"ATEN EH-100 at 0x%x, mode %d (%s), delay %d\n" , + pi->port, pi->mode, mode_string[pi->mode], pi->delay); }static struct pi_protocol aten = {
Signature · 1 line
2.40.1
Damien Le Moal
maintainerPATCH 2/13 ata: pata_parport: Fix bpck6 module code indentation and style
In reply to Damien Le MoalFix the header, indentation and coding style in the bpck6 pata parport protocol module to suppress warnings from smatch and other static code analyzers.
No functional changes.
--- drivers/ata/pata_parport/bpck6.c | 67 +++++++++++++++++--------------- 1 file changed, 35 insertions(+), 32 deletions(-)
drivers/ata/pata_parport/bpck6.c +35 -32
@@ -1,15 +1,13 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* -backpack.c (c) 2001 Micro Solutions Inc. -Released under the terms of the GNU General Public license - -backpack.c is a low-level protocol driver for the Micro Solutions -"BACKPACK" parallel port IDE adapter -(Works on Series 6 drives) - -Written by: Ken Hahn ([email protected]) -Clive Turvey ([email protected]) - -*/ +* (c) 2001 Micro Solutions Inc. +* +* backpack.c is a low-level protocol driver for the Micro Solutions +* "BACKPACK" parallel port IDE adapter (works on Series 6 drives). +* +* Written by: Ken Hahn ([email protected]) +* Clive Turvey ([email protected]) +*/ #include <linux/module.h> #include <linux/init.h>
@@ -326,11 +324,14 @@ static int bpck6_open(struct pi_adapter *pi)if (j != k) goto fail; -if (i &4 )// EPP +if (i &4 ) { +/* EPP */ parport_frob_control (pi->pardev->port,PARPORT_CONTROL_SELECT |PARPORT_CONTROL_INIT ,0 ); -else // PPC/ECP + }else { +/* PPC/ECP */ parport_frob_control (pi->pardev->port,PARPORT_CONTROL_SELECT ,0 ); + } pi->private =0 ;
@@ -347,17 +348,20 @@ static int bpck6_open(struct pi_adapter *pi)parport_write_control (pi->pardev->port, pi->saved_r2);parport_write_data (pi->pardev->port, pi->saved_r0); -return 0 ;// FAIL +return 0 ; }static void bpck6_deselect (struct pi_adapter *pi) { -if (mode_map[pi->mode] &4 )// EPP +if (mode_map[pi->mode] &4 ) { +/* EPP */ parport_frob_control (pi->pardev->port,PARPORT_CONTROL_INIT , -PARPORT_CONTROL_INIT ); -else // PPC/ECP +PARPORT_CONTROL_INIT ); + }else { +/* PPC/ECP */ parport_frob_control (pi->pardev->port,PARPORT_CONTROL_SELECT , -PARPORT_CONTROL_SELECT ); +PARPORT_CONTROL_SELECT ); + }parport_write_data (pi->pardev->port, pi->saved_r0); parport_write_control(pi->pardev->port,
@@ -386,7 +390,8 @@ static void bpck6_disconnect(struct pi_adapter *pi)bpck6_deselect (pi); } -static int bpck6_test_port (struct pi_adapter *pi)/* check for 8-bit port */ +/* check for 8-bit port */ +static int bpck6_test_port (struct pi_adapter *pi) {dev_dbg (&pi->dev,"PARPORT indicates modes=%x for lp=0x%lx\n" , pi->pardev->port->modes, pi->pardev->port->base);
@@ -413,28 +418,26 @@ static int bpck6_probe_unit(struct pi_adapter *pi)dev_dbg (&pi->dev,"ppc_open returned %2x\n" , out); -if (out) - { +if (out) {bpck6_deselect (pi);dev_dbg (&pi->dev,"leaving probe\n" ); pi->mode = saved_mode; -return (1 ); +return 1 ; } -else - { -dev_dbg (&pi->dev,"Failed open\n" ); - pi->mode = saved_mode; -return (0 ); - } + +dev_dbg (&pi->dev,"Failed open\n" ); + pi->mode = saved_mode; + +return 0 ; }static void bpck6_log_adapter (struct pi_adapter *pi) { -char *mode_string[5 ]= - {"4-bit" ,"8-bit" ,"EPP-8" ,"EPP-16" ,"EPP-32" }; +char *mode_string[5 ] = {"4-bit" ,"8-bit" ,"EPP-8" ,"EPP-16" ,"EPP-32" }; -dev_info (&pi->dev,"Micro Solutions BACKPACK Drive unit %d at 0x%x, mode:%d (%s), delay %d\n" , - pi->unit, pi->port, pi->mode, mode_string[pi->mode], pi->delay); +dev_info (&pi->dev, +"Micro Solutions BACKPACK Drive unit %d at 0x%x, mode:%d (%s), delay %d\n" , + pi->unit, pi->port, pi->mode, mode_string[pi->mode], pi->delay); }static struct pi_protocol bpck6 = {
Signature · 1 line
2.40.1
Damien Le Moal
maintainerPATCH 3/13 ata: pata_parport: Fix comm module code indentation and style
In reply to Damien Le MoalFix the header, indentation and coding style in the comm pata parport protocol module to suppress warnings from smatch and other static code analyzers.
No functional changes.
--- drivers/ata/pata_parport/comm.c | 238 ++++++++++++++++---------------- 1 file changed, 122 insertions(+), 116 deletions(-)
drivers/ata/pata_parport/comm.c +122 -116
@@ -1,12 +1,11 @@ -/* -comm.c (c) 1997-8 Grant R. Guenther <[email protected]> -Under the terms of the GNU General Public License. - -comm.c is a low-level protocol driver for some older models -of the DataStor "Commuter" parallel to IDE adapter. Some of -the parallel port devices marketed by Arista currently -use this adapter. -*/ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* (c) 1997-1998 Grant R. Guenther <[email protected]> +* +* comm.c is a low-level protocol driver for some older models of the DataStor +* "Commuter" parallel to IDE adapter. Some of the parallel port devices +* marketed by Arista currently use this adapter. +*/ #include <linux/module.h> #include <linux/init.h>
@@ -17,165 +16,172 @@#include <asm/io.h> #include "pata_parport.h" -/* mode codes: 0 nybble reads, 8-bit writes -1 8-bit reads and writes -2 8-bit EPP mode -*/ +/* +* mode codes: 0 nybble reads, 8-bit writes +* 1 8-bit reads and writes +* 2 8-bit EPP mode +*/ -#define j44 (a,b) (((a>>3)&0x0f)|((b<<1)&0xf0)) +#define j44 (a, b) (((a >> 3) & 0x0f) | ((b << 1) & 0xf0))#define P1 w2(5);w2(0xd);w2(0xd);w2(5);w2(4);#define P2 w2(5);w2(7);w2(7);w2(5);w2(4); -/* cont = 0 - access the IDE register file -cont = 1 - access the IDE command set -*/ - +/* +* cont = 0 - access the IDE register file +* cont = 1 - access the IDE command set +*/ static int cont_map[2 ] = {0x08 ,0x10 };static int comm_read_regr (struct pi_adapter *pi,int cont,int regr) - -{int l, h, r; +{ +int l, h, r; r = regr + cont_map[cont]; -switch (pi->mode) { +switch (pi->mode) { +case 0 : +w0 (r);P1 ;w0 (0 ); +w2 (6 ); l =r1 ();w0 (0x80 ); h =r1 ();w2 (4 ); +return j44 (l, h); -case 0 :w0 (r);P1 ;w0 (0 ); -w2 (6 ); l =r1 ();w0 (0x80 ); h =r1 ();w2 (4 ); -return j44 (l,h); - -case 1 :w0 (r+0x20 );P1 ; -w0 (0 );w2 (0x26 ); h =r0 ();w2 (4 ); -return h; +case 1 : +w0 (r+0x20 );P1 ; +w0 (0 );w2 (0x26 ); h =r0 ();w2 (4 ); +return h;case 2 :case 3 : -case 4 :w3 (r+0x20 ); (void )r1 (); -w2 (0x24 ); h =r4 ();w2 (4 ); -return h; +case 4 : +w3 (r+0x20 ); (void )r1 (); +w2 (0x24 ); h =r4 ();w2 (4 ); +return h; + } - } -return -1 ; -} +return -1 ; +}static void comm_write_regr (struct pi_adapter *pi,int cont,int regr,int val) +{ +int r = regr + cont_map[cont]; -{int r; - - r = regr + cont_map[cont]; - -switch (pi->mode) { - -case 0 : -case 1 :w0 (r);P1 ;w0 (val);P2 ; +switch (pi->mode) { +case 0 : +case 1 : +w0 (r);P1 ;w0 (val);P2 ;break ; -case 2 :case 3 : -case 4 :w3 (r); (void )r1 ();w4 (val); -break ; - } +case 4 : +w3 (r); (void )r1 ();w4 (val); +break ; + } }static void comm_connect (struct pi_adapter *pi) - -{ pi->saved_r0 =r0 (); - pi->saved_r2 =r2 (); -w2 (4 );w0 (0xff );w2 (6 ); -w2 (4 );w0 (0xaa );w2 (6 ); -w2 (4 );w0 (0x00 );w2 (6 ); -w2 (4 );w0 (0x87 );w2 (6 ); -w2 (4 );w0 (0xe0 );w2 (0xc );w2 (0xc );w2 (4 ); +{ + pi->saved_r0 =r0 (); + pi->saved_r2 =r2 (); +w2 (4 );w0 (0xff );w2 (6 ); +w2 (4 );w0 (0xaa );w2 (6 ); +w2 (4 );w0 (0x00 );w2 (6 ); +w2 (4 );w0 (0x87 );w2 (6 ); +w2 (4 );w0 (0xe0 );w2 (0xc );w2 (0xc );w2 (4 ); }static void comm_disconnect (struct pi_adapter *pi) -{w2 (0 );w2 (0 );w2 (0 );w2 (4 ); +{ +w2 (0 );w2 (0 );w2 (0 );w2 (4 );w0 (pi->saved_r0); -w2 (pi->saved_r2); -} +w2 (pi->saved_r2); +}static void comm_read_block (struct pi_adapter *pi,char *buf,int count) - -{int i, l, h; - -switch (pi->mode) { - -case 0 :w0 (0x48 );P1 ; -for (i=0 ;i<count;i++) { -w0 (0 );w2 (6 ); l =r1 (); -w0 (0x80 ); h =r1 ();w2 (4 ); - buf[i] =j44 (l,h); - } -break ; - -case 1 :w0 (0x68 );P1 ;w0 (0 ); -for (i=0 ;i<count;i++) { -w2 (0x26 ); buf[i] =r0 ();w2 (0x24 ); - } +{ +int i, l, h; + +switch (pi->mode) { +case 0 : +w0 (0x48 );P1 ; +for (i =0 ; i < count; i++) { +w0 (0 );w2 (6 ); l =r1 (); +w0 (0x80 ); h =r1 ();w2 (4 ); + buf[i] =j44 (l, h); + } +break ; +case 1 : +w0 (0x68 );P1 ;w0 (0 ); +for (i =0 ; i < count; i++) { +w2 (0x26 ); + buf[i] =r0 (); +w2 (0x24 ); + }w2 (4 );break ; - -case 2 :w3 (0x68 ); (void )r1 ();w2 (0x24 ); -for (i=0 ;i<count;i++) buf[i] =r4 (); +case 2 : +w3 (0x68 ); (void )r1 ();w2 (0x24 ); +for (i =0 ; i < count; i++) + buf[i] =r4 (); +w2 (4 ); +break ; +case 3 : +w3 (0x68 ); (void )r1 ();w2 (0x24 ); +for (i =0 ; i < count /2 ; i++) + ((u16 *)buf)[i] =r4w (); +w2 (4 ); +break ; +case 4 : +w3 (0x68 ); (void )r1 ();w2 (0x24 ); +for (i =0 ; i < count /4 ; i++) + ((u32 *)buf)[i] =r4l ();w2 (4 );break ; - -case 3 :w3 (0x68 ); (void )r1 ();w2 (0x24 ); -for (i=0 ;i<count/2 ;i++) ((u16 *)buf)[i] =r4w (); -w2 (4 ); -break ; - -case 4 :w3 (0x68 ); (void )r1 ();w2 (0x24 ); -for (i=0 ;i<count/4 ;i++) ((u32 *)buf)[i] =r4l (); -w2 (4 ); -break ; - } }/* NB: Watch out for the byte swapped writes ! */ -static void comm_write_block (struct pi_adapter *pi,char *buf,int count) - -{int k; - -switch (pi->mode) { - -case 0 : -case 1 :w0 (0x68 );P1 ; -for (k=0 ;k<count;k++) { -w2 (5 );w0 (buf[k^1 ]);w2 (7 ); - } -w2 (5 );w2 (4 ); -break ; - -case 2 :w3 (0x48 ); (void )r1 (); -for (k=0 ;k<count;k++)w4 (buf[k^1 ]); -break ; - -case 3 :w3 (0x48 ); (void )r1 (); +{ +int k; + +switch (pi->mode) { +case 0 : +case 1 : +w0 (0x68 );P1 ; +for (k =0 ; k < count; k++) { +w2 (5 ); +w0 (buf[k ^1 ]); +w2 (7 ); + } +w2 (5 );w2 (4 ); +break ; +case 2 : +w3 (0x48 ); (void )r1 (); +for (k =0 ; k < count; k++) +w4 (buf[k ^1 ]); +break ; +case 3 : +w3 (0x48 ); (void )r1 ();for (k =0 ; k < count /2 ; k++)w4w (swab16 (((u16 *)buf)[k])); -break ; - -case 4 :w3 (0x48 ); (void )r1 (); +break ; +case 4 : +w3 (0x48 ); (void )r1 ();for (k =0 ; k < count /4 ; k++)w4l (swab16 (((u16 *)buf)[2 * k]) |swab16 (((u16 *)buf)[2 * k +1 ]) <<16 ); -break ; - - +break ; } }static void comm_log_adapter (struct pi_adapter *pi) -{char *mode_string[5 ] = {"4-bit" ,"8-bit" ,"EPP-8" ,"EPP-16" ,"EPP-32" }; +{char *mode_string[5 ] = {"4-bit" ,"8-bit" ,"EPP-8" ,"EPP-16" ,"EPP-32" }; -dev_info (&pi->dev,"DataStor Commuter at 0x%x, mode %d (%s), delay %d\n" , - pi->port, pi->mode, mode_string[pi->mode], pi->delay); +dev_info (&pi->dev, +"DataStor Commuter at 0x%x, mode %d (%s), delay %d\n" , + pi->port, pi->mode, mode_string[pi->mode], pi->delay); }static struct pi_protocol comm = {
Signature · 1 line
2.40.1
Damien Le Moal
maintainerPATCH 4/13 ata: pata_parport: Fix dstr module code indentation and style
In reply to Damien Le MoalFix the header, indentation and coding style in the dstr pata parport protocol module to suppress warnings from smatch and other static code analyzers.
No functional changes.
--- drivers/ata/pata_parport/dstr.c | 285 +++++++++++++++++--------------- 1 file changed, 154 insertions(+), 131 deletions(-)
drivers/ata/pata_parport/dstr.c +154 -131
@@ -1,11 +1,10 @@ -/* -dstr.c (c) 1997-8 Grant R. Guenther <[email protected]> -Under the terms of the GNU General Public License. - -dstr.c is a low-level protocol driver for the -DataStor EP2000 parallel to IDE adapter chip. - -*/ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* (c) 1997-1998 Grant R. Guenther <[email protected]> +* +* dstr.c is a low-level protocol driver for the DataStor EP2000 parallel +* to IDE adapter chip. +*/ #include <linux/module.h> #include <linux/init.h>
@@ -16,178 +15,202 @@#include <asm/io.h> #include "pata_parport.h" -/* mode codes: 0 nybble reads, 8-bit writes -1 8-bit reads and writes -2 8-bit EPP mode -3 EPP-16 -4 EPP-32 -*/ +/* +* mode codes: 0 nybble reads, 8-bit writes +* 1 8-bit reads and writes +* 2 8-bit EPP mode +* 3 EPP-16 +* 4 EPP-32 +*/ -#define j44 (a,b) (((a>>3)&0x07)|((~a>>4)&0x08)|((b<<1)&0x70)|((~b)&0x80)) +#define j44 (a, b) (((a >> 3) & 0x07) | ((~a >> 4) & 0x08) | \ + ((b << 1) & 0x70) | ((~b) & 0x80))#define P1 w2(5);w2(0xd);w2(5);w2(4);#define P2 w2(5);w2(7);w2(5);w2(4);#define P3 w2(6);w2(4);w2(6);w2(4); -/* cont = 0 - access the IDE register file -cont = 1 - access the IDE command set -*/ - +/* +* cont = 0 - access the IDE register file +* cont = 1 - access the IDE command set +*/ static int cont_map[2 ] = {0x20 ,0x40 };static int dstr_read_regr (struct pi_adapter *pi,int cont,int regr) +{ +int a, b, r; -{int a, b, r; - - r = regr + cont_map[cont]; + r = regr + cont_map[cont];w0 (0x81 );P1 ; -if (pi->mode) {w0 (0x11 ); }else {w0 (1 ); } +if (pi->mode) +w0 (0x11 ); +else +w0 (1 );P2 ;w0 (r);P1 ; -switch (pi->mode) { - -case 0 :w2 (6 ); a =r1 ();w2 (4 );w2 (6 ); b =r1 ();w2 (4 ); -return j44 (a,b); - -case 1 :w0 (0 );w2 (0x26 ); a =r0 ();w2 (4 ); -return a; - +switch (pi->mode) { +case 0 : +w2 (6 ); a =r1 ();w2 (4 );w2 (6 ); b =r1 ();w2 (4 ); +return j44 (a, b); +case 1 : +w0 (0 );w2 (0x26 ); a =r0 ();w2 (4 ); +return a;case 2 :case 3 : -case 4 :w2 (0x24 ); a =r4 ();w2 (4 ); -return a; +case 4 : +w2 (0x24 ); a =r4 ();w2 (4 ); +return a; + } - } -return -1 ; -} +return -1 ; +}static void dstr_write_regr (struct pi_adapter *pi,int cont,int regr,int val) +{ +int r = regr + cont_map[cont]; -{int r; - - r = regr + cont_map[cont]; - -w0 (0x81 );P1 ; -if (pi->mode >=2 ) {w0 (0x11 ); }else {w0 (1 ); } +w0 (0x81 );P1 ; +if (pi->mode >=2 ) +w0 (0x11 ); +else +w0 (1 );P2 ;w0 (r);P1 ; - -switch (pi->mode) { -case 0 : -case 1 :w0 (val);w2 (5 );w2 (7 );w2 (5 );w2 (4 ); +switch (pi->mode) { +case 0 : +case 1 : +w0 (val);w2 (5 );w2 (7 );w2 (5 );w2 (4 );break ; -case 2 :case 3 : -case 4 :w4 (val); -break ; - } +case 4 : +w4 (val); +break ; + } } -#define CCP (x) w0(0xff);w2(0xc);w2(4);\ - w0(0xaa);w0(0x55);w0(0);w0(0xff);w0(0x87);w0(0x78);\ - w0(x);w2(5);w2(4); +#define CCP (x) \ + do { \ + w0(0xff); w2(0xc); w2(4); \ + w0(0xaa); w0(0x55); w0(0); w0(0xff); \ + w0(0x87); w0(0x78); \ + w0(x); w2(5); w2(4); \ + } while (0)static void dstr_connect (struct pi_adapter *pi) - -{ pi->saved_r0 =r0 (); - pi->saved_r2 =r2 (); -w2 (4 );CCP (0xe0 );w0 (0xff ); +{ + pi->saved_r0 =r0 (); + pi->saved_r2 =r2 (); +w2 (4 );CCP (0xe0 );w0 (0xff ); }static void dstr_disconnect (struct pi_adapter *pi) - -{CCP (0x30 ); -w0 (pi->saved_r0); -w2 (pi->saved_r2); -} +{ +CCP (0x30 ); +w0 (pi->saved_r0); +w2 (pi->saved_r2); +}static void dstr_read_block (struct pi_adapter *pi,char *buf,int count) - -{int k, a, b; +{ +int k, a, b;w0 (0x81 );P1 ; -if (pi->mode) {w0 (0x19 ); }else {w0 (9 ); } +if (pi->mode) +w0 (0x19 ); +else +w0 (9 );P2 ;w0 (0x82 );P1 ;P3 ;w0 (0x20 );P1 ; -switch (pi->mode) { - -case 0 :for (k=0 ;k<count;k++) { -w2 (6 ); a =r1 ();w2 (4 ); -w2 (6 ); b =r1 ();w2 (4 ); - buf[k] =j44 (a,b); - } -break ; - -case 1 :w0 (0 ); -for (k=0 ;k<count;k++) { -w2 (0x26 ); buf[k] =r0 ();w2 (0x24 ); - } -w2 (4 ); -break ; - -case 2 :w2 (0x24 ); -for (k=0 ;k<count;k++) buf[k] =r4 (); -w2 (4 ); -break ; - -case 3 :w2 (0x24 ); -for (k=0 ;k<count/2 ;k++) ((u16 *)buf)[k] =r4w (); -w2 (4 ); -break ; - -case 4 :w2 (0x24 ); -for (k=0 ;k<count/4 ;k++) ((u32 *)buf)[k] =r4l (); -w2 (4 ); -break ; - - } +switch (pi->mode) { +case 0 : +for (k =0 ; k < count; k++) { +w2 (6 ); a =r1 ();w2 (4 ); +w2 (6 ); b =r1 ();w2 (4 ); + buf[k] =j44 (a, b); + } +break ; +case 1 : +w0 (0 ); +for (k =0 ; k < count; k++) { +w2 (0x26 ); + buf[k] =r0 (); +w2 (0x24 ); + } +w2 (4 ); +break ; +case 2 : +w2 (0x24 ); +for (k =0 ; k < count; k++) + buf[k] =r4 (); +w2 (4 ); +break ; +case 3 : +w2 (0x24 ); +for (k =0 ; k < count /2 ; k++) + ((u16 *)buf)[k] =r4w (); +w2 (4 ); +break ; +case 4 : +w2 (0x24 ); +for (k =0 ; k < count /4 ; k++) + ((u32 *)buf)[k] =r4l (); +w2 (4 ); +break ; + } }static void dstr_write_block (struct pi_adapter *pi,char *buf,int count) +{ +int k; -{int k; - -w0 (0x81 );P1 ; -if (pi->mode) {w0 (0x19 ); }else {w0 (9 ); } -P2 ;w0 (0x82 );P1 ;P3 ;w0 (0x20 );P1 ; - -switch (pi->mode) { - -case 0 : -case 1 :for (k=0 ;k<count;k++) { -w2 (5 );w0 (buf[k]);w2 (7 ); - } -w2 (5 );w2 (4 ); -break ; +w0 (0x81 );P1 ; +if (pi->mode) +w0 (0x19 ); +else +w0 (9 ); +P2 ;w0 (0x82 );P1 ;P3 ;w0 (0x20 );P1 ; -case 2 :w2 (0xc5 ); -for (k=0 ;k<count;k++)w4 (buf[k]); +switch (pi->mode) { +case 0 : +case 1 : +for (k =0 ; k < count; k++) { +w2 (5 ); +w0 (buf[k]); +w2 (7 ); + } +w2 (5 );w2 (4 ); +break ; +case 2 : +w2 (0xc5 ); +for (k =0 ; k < count; k++) +w4 (buf[k]);w2 (0xc4 ); -break ; - -case 3 :w2 (0xc5 ); -for (k=0 ;k<count/2 ;k++)w4w (((u16 *)buf)[k]); -w2 (0xc4 ); -break ; - -case 4 :w2 (0xc5 ); -for (k=0 ;k<count/4 ;k++)w4l (((u32 *)buf)[k]); -w2 (0xc4 ); -break ; - - } +break ; +case 3 : +w2 (0xc5 ); +for (k =0 ; k < count /2 ; k++) +w4w (((u16 *)buf)[k]); +w2 (0xc4 ); +break ; +case 4 : +w2 (0xc5 ); +for (k =0 ; k < count /4 ; k++) +w4l (((u32 *)buf)[k]); +w2 (0xc4 ); +break ; + } } -static void dstr_log_adapter (struct pi_adapter *pi) -{char *mode_string[5 ] = {"4-bit" ,"8-bit" ,"EPP-8" , -"EPP-16" ,"EPP-32" }; +{ +char *mode_string[5 ] = {"4-bit" ,"8-bit" ,"EPP-8" ,"EPP-16" ,"EPP-32" }; -dev_info (&pi->dev,"DataStor EP2000 at 0x%x, mode %d (%s), delay %d\n" , - pi->port, pi->mode, mode_string[pi->mode], pi->delay); +dev_info (&pi->dev, +"DataStor EP2000 at 0x%x, mode %d (%s), delay %d\n" , + pi->port, pi->mode, mode_string[pi->mode], pi->delay); }static struct pi_protocol dstr = {
Signature · 1 line
2.40.1
Damien Le Moal
maintainerPATCH 5/13 ata: pata_parport: Fix epat module code indentation and style
In reply to Damien Le MoalFix the header, indentation and coding style in the epat pata parport protocol module to suppress warnings from smatch and other static code analyzers.
No functional changes.
--- drivers/ata/pata_parport/epat.c | 320 ++++++++++++++++++-------------- 1 file changed, 178 insertions(+), 142 deletions(-)
drivers/ata/pata_parport/epat.c +178 -142
@@ -1,13 +1,12 @@ -/* -epat.c (c) 1997-8 Grant R. Guenther <[email protected]> -Under the terms of the GNU General Public License. - -This is the low level protocol driver for the EPAT parallel -to IDE adapter from Shuttle Technologies. This adapter is -used in many popular parallel port disk products such as the -SyQuest EZ drives, the Avatar Shark and the Imation SuperDisk. -- */ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* (c) 1997-1998 Grant R. Guenther <[email protected]> +* +* This is the low level protocol driver for the EPAT parallel +* to IDE adapter from Shuttle Technologies. This adapter is +* used in many popular parallel port disk products such as the +* SyQuest EZ drives, the Avatar Shark and the Imation SuperDisk. +*/ #include <linux/module.h> #include <linux/init.h>
@@ -18,276 +17,313 @@#include <asm/io.h> #include "pata_parport.h" -#define j44 (a,b) (((a>>4)&0x0f)+(b&0xf0)) -#define j53 (a,b) (((a>>3)&0x1f)+((b<<4)&0xe0)) +#define j44 (a, b) (((a >> 4) & 0x0f) + (b & 0xf0)) +#define j53 (a, b) (((a >> 3) & 0x1f) + ((b << 4) & 0xe0))static int epatc8;module_param (epatc8, int,0 ); -MODULE_PARM_DESC (epatc8,"support for the Shuttle EP1284 chip, " -"used in any recent Imation SuperDisk (LS-120) drive." ); - -/* cont = 0 IDE register file -cont = 1 IDE control registers -cont = 2 internal EPAT registers -*/ - +MODULE_PARM_DESC (epatc8, +"support for the Shuttle EP1284 chip, " +"used in any recent Imation SuperDisk (LS-120) drive." ); + +/* +* cont = 0 IDE register file +* cont = 1 IDE control registers +* cont = 2 internal EPAT registers +*/ static int cont_map[3 ] = {0x18 ,0x10 ,0 };static void epat_write_regr (struct pi_adapter *pi,int cont,int regr,int val) - -{int r; - - r = regr + cont_map[cont]; +{ +int r = regr + cont_map[cont];switch (pi->mode) { -case 0 :case 1 : -case 2 :w0 (0x60 +r);w2 (1 );w0 (val);w2 (4 ); +case 2 : +w0 (0x60 +r);w2 (1 );w0 (val);w2 (4 );break ; -case 3 :case 4 : -case 5 :w3 (0x40 +r);w4 (val); +case 5 : +w3 (0x40 +r);w4 (val);break ; - } }static int epat_read_regr (struct pi_adapter *pi,int cont,int regr) - -{int a, b, r; +{ +int a, b, r; r = regr + cont_map[cont];switch (pi->mode) { -case 0 :w0 (r);w2 (1 );w2 (3 ); +case 0 : +w0 (r);w2 (1 );w2 (3 ); a =r1 ();w2 (4 ); b =r1 (); -return j44 (a,b); - -case 1 :w0 (0x40 +r);w2 (1 );w2 (4 ); +return j44 (a, b); +case 1 : +w0 (0x40 +r);w2 (1 );w2 (4 ); a =r1 (); b =r2 ();w0 (0xff ); -return j53 (a,b); - -case 2 :w0 (0x20 +r);w2 (1 );w2 (0x25 ); +return j53 (a, b); +case 2 : +w0 (0x20 +r);w2 (1 );w2 (0x25 ); a =r0 ();w2 (4 );return a; -case 3 :case 4 : -case 5 :w3 (r);w2 (0x24 ); a =r4 ();w2 (4 ); +case 5 : +w3 (r);w2 (0x24 ); a =r4 ();w2 (4 );return a; - } +return -1 ;/* never gets here */ }static void epat_read_block (struct pi_adapter *pi,char *buf,int count) - -{int k, ph, a, b; +{ +int k, ph, a, b;switch (pi->mode) { -case 0 :w0 (7 );w2 (1 );w2 (3 );w0 (0xff ); +case 0 : +w0 (7 );w2 (1 );w2 (3 );w0 (0xff ); ph =0 ; -for (k=0 ;k<count;k++) { -if (k == count-1 )w0 (0xfd ); -w2 (6 +ph); a =r1 (); -if (a &8 ) b = a; -else {w2 (4 +ph); b =r1 (); } - buf[k] =j44 (a,b); +for (k =0 ; k < count; k++) { +if (k == count-1 ) +w0 (0xfd ); +w2 (6 + ph); a =r1 (); +if (a &8 ) { + b = a; + }else { +w2 (4 +ph); b =r1 (); + } + buf[k] =j44 (a, b); ph =1 - ph; }w0 (0 );w2 (4 );break ; -case 1 :w0 (0x47 );w2 (1 );w2 (5 );w0 (0xff ); +case 1 : +w0 (0x47 );w2 (1 );w2 (5 );w0 (0xff ); ph =0 ; -for (k=0 ;k<count;k++) { -if (k == count-1 )w0 (0xfd ); -w2 (4 +ph); +for (k =0 ; k < count; k++) { +if (k == count -1 ) +w0 (0xfd ); +w2 (4 + ph); a =r1 (); b =r2 (); - buf[k] =j53 (a,b); + buf[k] =j53 (a, b); ph =1 - ph; }w0 (0 );w2 (4 );break ; -case 2 :w0 (0x27 );w2 (1 );w2 (0x25 );w0 (0 ); +case 2 : +w0 (0x27 );w2 (1 );w2 (0x25 );w0 (0 ); ph =0 ; -for (k=0 ;k<count-1 ;k++) { -w2 (0x24 +ph); +for (k =0 ; k < count -1 ; k++) { +w2 (0x24 + ph); buf[k] =r0 (); ph =1 - ph; } -w2 (0x26 );w2 (0x27 ); buf[count-1 ] =r0 (); +w2 (0x26 );w2 (0x27 ); + buf[count -1 ] =r0 ();w2 (0x25 );w2 (4 );break ; -case 3 :w3 (0x80 );w2 (0x24 ); -for (k=0 ;k<count-1 ;k++) buf[k] =r4 (); -w2 (4 );w3 (0xa0 );w2 (0x24 ); buf[count-1 ] =r4 (); +case 3 : +w3 (0x80 );w2 (0x24 ); +for (k =0 ; k < count -1 ; k++) + buf[k] =r4 (); +w2 (4 );w3 (0xa0 );w2 (0x24 ); + buf[count -1 ] =r4 ();w2 (4 );break ; -case 4 :w3 (0x80 );w2 (0x24 ); -for (k=0 ;k<(count/2 )-1 ;k++) ((u16 *)buf)[k] =r4w (); - buf[count-2 ] =r4 (); -w2 (4 );w3 (0xa0 );w2 (0x24 ); buf[count-1 ] =r4 (); +case 4 : +w3 (0x80 );w2 (0x24 ); +for (k =0 ; k < count /2 -1 ; k++) + ((u16 *)buf)[k] =r4w (); + buf[count -2 ] =r4 (); +w2 (4 );w3 (0xa0 );w2 (0x24 ); + buf[count -1 ] =r4 ();w2 (4 );break ; -case 5 :w3 (0x80 );w2 (0x24 ); -for (k=0 ;k<(count/4 )-1 ;k++) ((u32 *)buf)[k] =r4l (); -for (k=count-4 ;k<count-1 ;k++) buf[k] =r4 (); -w2 (4 );w3 (0xa0 );w2 (0x24 ); buf[count-1 ] =r4 (); +case 5 : +w3 (0x80 );w2 (0x24 ); +for (k =0 ; k < count /4 -1 ; k++) + ((u32 *)buf)[k] =r4l (); +for (k = count -4 ; k < count -1 ; k++) + buf[k] =r4 (); +w2 (4 );w3 (0xa0 );w2 (0x24 ); + buf[count -1 ] =r4 ();w2 (4 );break ; - } }static void epat_write_block (struct pi_adapter *pi,char *buf,int count) - -{int ph, k; +{ +int ph, k;switch (pi->mode) { -case 0 :case 1 : -case 2 :w0 (0x67 );w2 (1 );w2 (5 ); +case 2 : +w0 (0x67 );w2 (1 );w2 (5 ); ph =0 ; -for (k=0 ;k<count;k++) { +for (k =0 ; k < count; k++) {w0 (buf[k]); -w2 (4 +ph); +w2 (4 + ph); ph =1 - ph; }w2 (7 );w2 (4 );break ; - -case 3 :w3 (0xc0 ); -for (k=0 ;k<count;k++)w4 (buf[k]); +case 3 : +w3 (0xc0 ); +for (k =0 ; k < count; k++) +w4 (buf[k]);w2 (4 );break ; - -case 4 :w3 (0xc0 ); -for (k=0 ;k<(count/2 );k++)w4w (((u16 *)buf)[k]); +case 4 : +w3 (0xc0 ); +for (k =0 ; k < count /2 ; k++) +w4w (((u16 *)buf)[k]);w2 (4 );break ; - -case 5 :w3 (0xc0 ); -for (k=0 ;k<(count/4 );k++)w4l (((u32 *)buf)[k]); +case 5 : +w3 (0xc0 ); +for (k =0 ; k < count /4 ; k++) +w4l (((u32 *)buf)[k]);w2 (4 );break ; - } }/* these macros access the EPAT registers in native addressing */ -#define WR (r,v) epat_write_regr(pi,2,r,v) -#define RR (r) (epat_read_regr(pi,2,r)) +#define WR (r, v) epat_write_regr(pi, 2, r, v) +#define RR (r) epat_read_regr(pi, 2, r)/* and these access the IDE task file */ -#define WRi (r,v) epat_write_regr(pi,0,r,v) -#define RRi (r) (epat_read_regr(pi,0,r)) +#define WRi (r, v) epat_write_regr(pi, 0, r, v) +#define RRi (r) epat_read_regr(pi, 0, r)/* FIXME: the CPP stuff should be fixed to handle multiple EPATs on a chain */ -#define CPP (x) w2(4);w0(0x22);w0(0xaa);w0(0x55);w0(0);w0(0xff);\ - w0(0x87);w0(0x78);w0(x);w2(4);w2(5);w2(4);w0(0xff); +#define CPP (x) \ + do { \ + w2(4); w0(0x22); w0(0xaa); \ + w0(0x55); w0(0); w0(0xff); \ + w0(0x87); w0(0x78); w0(x); \ + w2(4); w2(5); w2(4); w0(0xff); \ + } while (0)static void epat_connect (struct pi_adapter *pi) - -{ pi->saved_r0 =r0 (); - pi->saved_r2 =r2 (); +{ + pi->saved_r0 =r0 (); + pi->saved_r2 =r2 ();/* Initialize the chip */ CPP (0 );if (epatc8) { -CPP (0x40 );CPP (0xe0 ); -w0 (0 );w2 (1 );w2 (4 ); -WR (0x8 ,0x12 );WR (0xc ,0x14 );WR (0x12 ,0x10 ); -WR (0xe ,0xf );WR (0xf ,4 ); +CPP (0x40 );CPP (0xe0 ); +w0 (0 );w2 (1 );w2 (4 ); +WR (0x8 ,0x12 ); +WR (0xc ,0x14 ); +WR (0x12 ,0x10 ); +WR (0xe ,0xf ); +WR (0xf ,4 );/* WR(0xe,0xa);WR(0xf,4); */ -WR (0xe ,0xd );WR (0xf ,0 ); +WR (0xe ,0xd ); +WR (0xf ,0 );/* CPP(0x30); */ }/* Connect to the chip */ CPP (0xe0 ); -w0 (0 );w2 (1 );w2 (4 );/* Idle into SPP */ +w0 (0 );w2 (1 );w2 (4 );/* Idle into SPP */ if (pi->mode >=3 ) { -w0 (0 );w2 (1 );w2 (4 );w2 (0xc ); -/* Request EPP */ -w0 (0x40 );w2 (6 );w2 (7 );w2 (4 );w2 (0xc );w2 (4 ); +w0 (0 );w2 (1 );w2 (4 );w2 (0xc ); +/* Request EPP */ +w0 (0x40 );w2 (6 );w2 (7 );w2 (4 );w2 (0xc );w2 (4 ); }if (!epatc8) { -WR (8 ,0x10 );WR (0xc ,0x14 );WR (0xa ,0x38 );WR (0x12 ,0x10 ); +WR (8 ,0x10 ); +WR (0xc ,0x14 ); +WR (0xa ,0x38 ); +WR (0x12 ,0x10 ); } }static void epat_disconnect (struct pi_adapter *pi) -{CPP (0x30 ); +{ +CPP (0x30 );w0 (pi->saved_r0);w2 (pi->saved_r2); }static int epat_test_proto (struct pi_adapter *pi) - -{int k, j, f, cc; -int e[2 ] = {0 ,0 }; +{ +int k, j, f, cc; +int e[2 ] = {0 ,0 };char scratch[512 ]; -epat_connect (pi); +epat_connect (pi); cc =RR (0xd );epat_disconnect (pi);epat_connect (pi);for (j=0 ;j<2 ;j++) { -WRi (6 ,0xa0 +j*0x10 ); -for (k=0 ;k<256 ;k++) { -WRi (2 ,k^0xaa ); -WRi (3 ,k^0x55 ); -if (RRi (2 ) != (k^0xaa )) e[j]++; - } - } -epat_disconnect (pi); - - f =0 ; -epat_connect (pi); -WR (0x13 ,1 );WR (0x13 ,0 );WR (0xa ,0x11 ); -epat_read_block (pi,scratch,512 ); - -for (k=0 ;k<256 ;k++) { -if ((scratch[2 *k] &0xff ) != k) f++; -if ((scratch[2 *k+1 ] &0xff ) != (0xff -k)) f++; - } -epat_disconnect (pi); +WRi (6 ,0xa0 + j *0x10 ); +for (k =0 ; k <256 ; k++) { +WRi (2 , k ^0xaa ); +WRi (3 , k ^0x55 ); +if (RRi (2 ) != (k ^0xaa )) + e[j]++; + } + } +epat_disconnect (pi); -dev_dbg (&pi->dev,"epat: port 0x%x, mode %d, ccr %x, test=(%d,%d,%d)\n" , - pi->port, pi->mode, cc, e[0 ], e[1 ], f); - -return (e[0 ] && e[1 ]) || f; + f =0 ; +epat_connect (pi); +WR (0x13 ,1 );WR (0x13 ,0 );WR (0xa ,0x11 ); +epat_read_block (pi, scratch,512 ); + +for (k =0 ; k <256 ; k++) { +if ((scratch[2 * k] &0xff ) != k) + f++; +if ((scratch[2 * k +1 ] &0xff ) !=0xff - k) + f++; + } +epat_disconnect (pi); + +dev_dbg (&pi->dev, +"epat: port 0x%x, mode %d, ccr %x, test=(%d,%d,%d)\n" , + pi->port, pi->mode, cc, e[0 ], e[1 ], f); + +return (e[0 ] && e[1 ]) || f; }static void epat_log_adapter (struct pi_adapter *pi) - -{int ver; -char *mode_string[6 ] = - {"4-bit" ,"5/3" ,"8-bit" ,"EPP-8" ,"EPP-16" ,"EPP-32" }; +{ +int ver; +char *mode_string[6 ] = + {"4-bit" ,"5/3" ,"8-bit" ,"EPP-8" ,"EPP-16" ,"EPP-32" };epat_connect (pi); -WR (0xa ,0x38 );/* read the version code */ - ver =RR (0xb ); -epat_disconnect (pi); +WR (0xa ,0x38 );/* read the version code */ + ver =RR (0xb ); +epat_disconnect (pi); -dev_info (&pi->dev,"Shuttle EPAT chip %x at 0x%x, mode %d (%s), delay %d\n" , +dev_info (&pi->dev, +"Shuttle EPAT chip %x at 0x%x, mode %d (%s), delay %d\n" , ver, pi->port, pi->mode, mode_string[pi->mode], pi->delay); }
Signature · 1 line
2.40.1
Damien Le Moal
maintainerPATCH 6/13 ata: pata_parport: Fix epia module code indentation and style
In reply to Damien Le MoalFix the header, indentation and coding style in the epia pata parport protocol module to suppress warnings from smatch and other static code analyzers.
No functional changes.
--- drivers/ata/pata_parport/epia.c | 442 +++++++++++++++++--------------- 1 file changed, 230 insertions(+), 212 deletions(-)
drivers/ata/pata_parport/epia.c +230 -212
@@ -1,14 +1,13 @@ -/* -epia.c (c) 1997-8 Grant R. Guenther <[email protected]> -Under the terms of the GNU General Public License. - -epia.c is a low-level protocol driver for Shuttle Technologies -EPIA parallel to IDE adapter chip. This device is now obsolete -and has been replaced with the EPAT chip, which is supported -by epat.c, however, some devices based on EPIA are still -available. - -*/ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* (c) 1997-1998 Grant R. Guenther <[email protected]> +* +* epia.c is a low-level protocol driver for Shuttle Technologies +* EPIA parallel to IDE adapter chip. This device is now obsolete +* and has been replaced with the EPAT chip, which is supported +* by epat.c, however, some devices based on EPIA are still +* available. +*/ #include <linux/module.h> #include <linux/init.h>
@@ -19,255 +18,274 @@#include <asm/io.h> #include "pata_parport.h" -/* mode codes: 0 nybble reads on port 1, 8-bit writes -1 5/3 reads on ports 1 & 2, 8-bit writes -2 8-bit reads and writes -3 8-bit EPP mode -4 16-bit EPP -5 32-bit EPP -*/ - -#define j44 (a,b) (((a>>4)&0x0f)+(b&0xf0)) -#define j53 (a,b) (((a>>3)&0x1f)+((b<<4)&0xe0)) - -/* cont = 0 IDE register file -cont = 1 IDE control registers -*/ - +/* +* mode codes: 0 nybble reads on port 1, 8-bit writes +* 1 5/3 reads on ports 1 & 2, 8-bit writes +* 2 8-bit reads and writes +* 3 8-bit EPP mode +* 4 16-bit EPP +* 5 32-bit EPP +*/ + +#define j44 (a, b) (((a >> 4) & 0x0f) + (b & 0xf0)) +#define j53 (a, b) (((a >> 3) & 0x1f) + ((b << 4) & 0xe0)) + +/* +* cont = 0 IDE register file +* cont = 1 IDE control registers +*/ static int cont_map[2 ] = {0 ,0x80 };static int epia_read_regr (struct pi_adapter *pi,int cont,int regr) - -{int a, b, r; +{ +int a, b, r; regr += cont_map[cont]; -switch (pi->mode) { - -case 0 : r = regr^0x39 ; -w0 (r);w2 (1 );w2 (3 );w0 (r); - a =r1 ();w2 (1 ); b =r1 ();w2 (4 ); -return j44 (a,b); - -case 1 : r = regr^0x31 ; -w0 (r);w2 (1 );w0 (r&0x37 ); -w2 (3 );w2 (5 );w0 (r|0xf0 ); - a =r1 (); b =r2 ();w2 (4 ); -return j53 (a,b); - -case 2 : r = regr^0x29 ; -w0 (r);w2 (1 );w2 (0X21 );w2 (0x23 ); - a =r0 ();w2 (4 ); -return a; - +switch (pi->mode) { +case 0 : + r = regr ^0x39 ; +w0 (r);w2 (1 );w2 (3 );w0 (r); + a =r1 ();w2 (1 ); b =r1 ();w2 (4 ); +return j44 (a, b); +case 1 : + r = regr ^0x31 ; +w0 (r);w2 (1 );w0 (r &0x37 ); +w2 (3 );w2 (5 );w0 (r |0xf0 ); + a =r1 (); b =r2 ();w2 (4 ); +return j53 (a, b); +case 2 : + r = regr^0x29 ; +w0 (r);w2 (1 );w2 (0X21 );w2 (0x23 ); + a =r0 ();w2 (4 ); +return a;case 3 :case 4 : -case 5 :w3 (regr);w2 (0x24 ); a =r4 ();w2 (4 ); -return a; +case 5 : +w3 (regr);w2 (0x24 ); a =r4 ();w2 (4 ); +return a; + } - } -return -1 ; -} +return -1 ; +}static void epia_write_regr (struct pi_adapter *pi,int cont,int regr,int val) - -{int r; +{ +int r; regr += cont_map[cont]; -switch (pi->mode) { - -case 0 : -case 1 : -case 2 : r = regr^0x19 ; -w0 (r);w2 (1 );w0 (val);w2 (3 );w2 (4 ); -break ; - +switch (pi->mode) { +case 0 : +case 1 : +case 2 : + r = regr ^0x19 ; +w0 (r);w2 (1 );w0 (val);w2 (3 );w2 (4 ); +break ;case 3 :case 4 : -case 5 : r = regr^0x40 ; -w3 (r);w4 (val);w2 (4 ); -break ; - } +case 5 : + r = regr ^0x40 ; +w3 (r);w4 (val);w2 (4 ); +break ; + } } -#define WR (r,v) epia_write_regr(pi,0,r,v) -#define RR (r) (epia_read_regr(pi,0,r)) - -/* The use of register 0x84 is entirely unclear - it seems to control -some EPP counters ... currently we know about 3 different block -sizes: the standard 512 byte reads and writes, 12 byte writes and -2048 byte reads (the last two being used in the CDrom drivers. -*/ +#define WR (r, v) epia_write_regr(pi, 0, r, v) +#define RR (r) epia_read_regr(pi, 0, r) +/* +* The use of register 0x84 is entirely unclear - it seems to control +* some EPP counters ... currently we know about 3 different block +* sizes: the standard 512 byte reads and writes, 12 byte writes and +* 2048 byte reads (the last two being used in the CDrom drivers. +*/ static void epia_connect (struct pi_adapter *pi) - -{ pi->saved_r0 =r0 (); - pi->saved_r2 =r2 (); - -w2 (4 );w0 (0xa0 );w0 (0x50 );w0 (0xc0 );w0 (0x30 );w0 (0xa0 );w0 (0 ); -w2 (1 );w2 (4 ); -if (pi->mode >=3 ) { -w0 (0xa );w2 (1 );w2 (4 );w0 (0x82 );w2 (4 );w2 (0xc );w2 (4 ); -w2 (0x24 );w2 (0x26 );w2 (4 ); - } -WR (0x86 ,8 ); +{ + pi->saved_r0 =r0 (); + pi->saved_r2 =r2 (); + +w2 (4 );w0 (0xa0 );w0 (0x50 );w0 (0xc0 );w0 (0x30 );w0 (0xa0 );w0 (0 ); +w2 (1 );w2 (4 ); +if (pi->mode >=3 ) { +w0 (0xa );w2 (1 );w2 (4 );w0 (0x82 );w2 (4 );w2 (0xc );w2 (4 ); +w2 (0x24 );w2 (0x26 );w2 (4 ); + } +WR (0x86 ,8 ); }static void epia_disconnect (struct pi_adapter *pi) - -{/* WR(0x84,0x10); */ -w0 (pi->saved_r0); -w2 (1 );w2 (4 ); -w0 (pi->saved_r0); -w2 (pi->saved_r2); -} +{ +/* WR(0x84,0x10); */ +w0 (pi->saved_r0); +w2 (1 );w2 (4 ); +w0 (pi->saved_r0); +w2 (pi->saved_r2); +}static void epia_read_block (struct pi_adapter *pi,char *buf,int count) -{int k, ph, a, b; - -switch (pi->mode) { - -case 0 :w0 (0x81 );w2 (1 );w2 (3 );w0 (0xc1 ); - ph =1 ; -for (k=0 ;k<count;k++) { -w2 (2 +ph); a =r1 (); -w2 (4 +ph); b =r1 (); - buf[k] =j44 (a,b); - ph =1 - ph; - } -w0 (0 );w2 (4 ); -break ; - -case 1 :w0 (0x91 );w2 (1 );w0 (0x10 );w2 (3 ); -w0 (0x51 );w2 (5 );w0 (0xd1 ); - ph =1 ; -for (k=0 ;k<count;k++) { -w2 (4 +ph); - a =r1 (); b =r2 (); - buf[k] =j53 (a,b); - ph =1 - ph; - } -w0 (0 );w2 (4 ); -break ; - -case 2 :w0 (0x89 );w2 (1 );w2 (0x23 );w2 (0x21 ); - ph =1 ; -for (k=0 ;k<count;k++) { -w2 (0x24 +ph); - buf[k] =r0 (); - ph =1 - ph; - } -w2 (6 );w2 (4 ); -break ; - -case 3 :if (count >512 )WR (0x84 ,3 ); +{ +int k, ph, a, b; + +switch (pi->mode) { +case 0 : +w0 (0x81 );w2 (1 );w2 (3 );w0 (0xc1 ); + ph =1 ; +for (k =0 ; k < count; k++) { +w2 (2 +ph); a =r1 (); +w2 (4 +ph); b =r1 (); + buf[k] =j44 (a, b); + ph =1 - ph; + } +w0 (0 );w2 (4 ); +break ; +case 1 : +w0 (0x91 );w2 (1 );w0 (0x10 );w2 (3 ); +w0 (0x51 );w2 (5 );w0 (0xd1 ); + ph =1 ; +for (k =0 ; k < count; k++) { +w2 (4 + ph); + a =r1 (); b =r2 (); + buf[k] =j53 (a, b); + ph =1 - ph; + } +w0 (0 );w2 (4 ); +break ; +case 2 : +w0 (0x89 );w2 (1 );w2 (0x23 );w2 (0x21 ); + ph =1 ; +for (k =0 ; k < count; k++) { +w2 (0x24 + ph); + buf[k] =r0 (); + ph =1 - ph; + } +w2 (6 );w2 (4 ); +break ; +case 3 : +if (count >512 ) +WR (0x84 ,3 );w3 (0 );w2 (0x24 ); -for (k=0 ;k<count;k++) buf[k] =r4 (); -w2 (4 );WR (0x84 ,0 ); -break ; - -case 4 :if (count >512 )WR (0x84 ,3 ); +for (k =0 ; k < count; k++) + buf[k] =r4 (); +w2 (4 );WR (0x84 ,0 ); +break ; +case 4 : +if (count >512 ) +WR (0x84 ,3 );w3 (0 );w2 (0x24 ); -for (k=0 ;k<count/2 ;k++) ((u16 *)buf)[k] =r4w (); -w2 (4 );WR (0x84 ,0 ); -break ; - -case 5 :if (count >512 )WR (0x84 ,3 ); +for (k =0 ; k < count /2 ; k++) + ((u16 *)buf)[k] =r4w (); +w2 (4 );WR (0x84 ,0 ); +break ; +case 5 : +if (count >512 ) +WR (0x84 ,3 );w3 (0 );w2 (0x24 ); -for (k=0 ;k<count/4 ;k++) ((u32 *)buf)[k] =r4l (); -w2 (4 );WR (0x84 ,0 ); -break ; - - } +for (k =0 ; k < count /4 ; k++) + ((u32 *)buf)[k] =r4l (); +w2 (4 );WR (0x84 ,0 ); +break ; + } }static void epia_write_block (struct pi_adapter *pi,char *buf,int count) - -{int ph, k, last, d; - -switch (pi->mode) { - -case 0 : -case 1 : -case 2 :w0 (0xa1 );w2 (1 );w2 (3 );w2 (1 );w2 (5 ); - ph =0 ; last =0x8000 ; -for (k=0 ;k<count;k++) { - d = buf[k]; -if (d != last) { last = d;w0 (d); } -w2 (4 +ph); - ph =1 - ph; - } -w2 (7 );w2 (4 ); -break ; - -case 3 :if (count <512 )WR (0x84 ,1 ); +{ +int ph, k, last, d; + +switch (pi->mode) { +case 0 : +case 1 : +case 2 : +w0 (0xa1 );w2 (1 );w2 (3 );w2 (1 );w2 (5 ); + ph =0 ; last =0x8000 ; +for (k =0 ; k < count; k++) { + d = buf[k]; +if (d != last) { + last = d; +w0 (d); + } +w2 (4 + ph); + ph =1 - ph; + } +w2 (7 );w2 (4 ); +break ; +case 3 : +if (count <512 ) +WR (0x84 ,1 );w3 (0x40 ); -for (k=0 ;k<count;k++)w4 (buf[k]); -if (count <512 )WR (0x84 ,0 ); -break ; - -case 4 :if (count <512 )WR (0x84 ,1 ); +for (k =0 ; k < count; k++) +w4 (buf[k]); +if (count <512 ) +WR (0x84 ,0 ); +break ; +case 4 : +if (count <512 ) +WR (0x84 ,1 );w3 (0x40 ); -for (k=0 ;k<count/2 ;k++)w4w (((u16 *)buf)[k]); -if (count <512 )WR (0x84 ,0 ); -break ; - -case 5 :if (count <512 )WR (0x84 ,1 ); +for (k =0 ; k < count /2 ; k++) +w4w (((u16 *)buf)[k]); +if (count <512 ) +WR (0x84 ,0 ); +break ; +case 5 : +if (count <512 ) +WR (0x84 ,1 );w3 (0x40 ); -for (k=0 ;k<count/4 ;k++)w4l (((u32 *)buf)[k]); -if (count <512 )WR (0x84 ,0 ); -break ; - - } - +for (k =0 ; k < count /4 ; k++) +w4l (((u32 *)buf)[k]); +if (count <512 ) +WR (0x84 ,0 ); +break ; + } }static int epia_test_proto (struct pi_adapter *pi) - -{int j, k, f; -int e[2 ] = {0 ,0 }; +{ +int j, k, f; +int e[2 ] = {0 ,0 };char scratch[512 ]; -epia_connect (pi); -for (j=0 ;j<2 ;j++) { -WR (6 ,0xa0 +j*0x10 ); -for (k=0 ;k<256 ;k++) { -WR (2 ,k^0xaa ); -WR (3 ,k^0x55 ); -if (RR (2 ) != (k^0xaa )) e[j]++; - } -WR (2 ,1 );WR (3 ,1 ); - } -epia_disconnect (pi); - - f =0 ; -epia_connect (pi); -WR (0x84 ,8 ); -epia_read_block (pi,scratch,512 ); -for (k=0 ;k<256 ;k++) { -if ((scratch[2 *k] &0xff ) != ((k+1 ) &0xff )) f++; -if ((scratch[2 *k+1 ] &0xff ) != ((-2 -k) &0xff )) f++; - } -WR (0x84 ,0 ); -epia_disconnect (pi); +epia_connect (pi); +for (j =0 ; j <2 ; j++) { +WR (6 ,0xa0 + j *0x10 ); +for (k =0 ; k <256 ; k++) { +WR (2 , k ^0xaa ); +WR (3 , k ^0x55 ); +if (RR (2 ) != (k ^0xaa )) + e[j]++; + } +WR (2 ,1 );WR (3 ,1 ); + } +epia_disconnect (pi); + + f =0 ; +epia_connect (pi); +WR (0x84 ,8 ); +epia_read_block (pi, scratch,512 ); +for (k =0 ; k <256 ; k++) { +if ((scratch[2 * k] &0xff ) != ((k +1 ) &0xff )) + f++; +if ((scratch[2 * k +1 ] &0xff ) != ((-2 - k) &0xff )) + f++; + } +WR (0x84 ,0 ); +epia_disconnect (pi);dev_dbg (&pi->dev,"epia: port 0x%x, mode %d, test=(%d,%d,%d)\n" , - pi->port, pi->mode, e[0 ], e[1 ], f); - -return (e[0 ] && e[1 ]) || f; + pi->port, pi->mode, e[0 ], e[1 ], f); +return (e[0 ] && e[1 ]) || f; }static void epia_log_adapter (struct pi_adapter *pi) +{ +char *mode[6 ] = {"4-bit" ,"5/3" ,"8-bit" ,"EPP-8" ,"EPP-16" ,"EPP-32" }; -{char *mode_string[6 ] = {"4-bit" ,"5/3" ,"8-bit" , -"EPP-8" ,"EPP-16" ,"EPP-32" }; - -dev_info (&pi->dev,"Shuttle EPIA at 0x%x, mode %d (%s), delay %d\n" , - pi->port, pi->mode, mode_string[pi->mode], pi->delay); +dev_info (&pi->dev, +"Shuttle EPIA at 0x%x, mode %d (%s), delay %d\n" , + pi->port, pi->mode, mode[pi->mode], pi->delay); }static struct pi_protocol epia = {
Signature · 1 line
2.40.1
Damien Le Moal
maintainerPATCH 7/13 ata: pata_parport: Fix fit2 module code indentation and style
In reply to Damien Le MoalFix the header, indentation and coding style in the fit2 pata parport protocol module to suppress warnings from smatch and other static code analyzers.
No functional changes.
--- drivers/ata/pata_parport/fit2.c | 131 ++++++++++++++++---------------- 1 file changed, 64 insertions(+), 67 deletions(-)
drivers/ata/pata_parport/fit2.c +64 -67
@@ -1,17 +1,16 @@ -/* -fit2.c (c) 1998 Grant R. Guenther <[email protected]> -Under the terms of the GNU General Public License. - -fit2.c is a low-level protocol driver for the older version -of the Fidelity International Technology parallel port adapter. -This adapter is used in their TransDisk 2000 and older TransDisk -3000 portable hard-drives. As far as I can tell, this device -supports 4-bit mode _only_. - -Newer models of the FIT products use an enhanced protocol. -The "fit3" protocol module should support current drives. - -*/ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* (c) 1998 Grant R. Guenther <[email protected]> +* +* fit2.c is a low-level protocol driver for the older version +* of the Fidelity International Technology parallel port adapter. +* This adapter is used in their TransDisk 2000 and older TransDisk +* 3000 portable hard-drives. As far as I can tell, this device +* supports 4-bit mode _only_. +* +* Newer models of the FIT products use an enhanced protocol. +* The "fit3" protocol module should support current drives. +*/ #include <linux/module.h> #include <linux/init.h>
@@ -22,99 +21,97 @@#include <asm/io.h> #include "pata_parport.h" -#define j44 (a,b) (((a>>4)&0x0f)|(b&0xf0)) - -/* cont = 0 - access the IDE register file -cont = 1 - access the IDE command set +#define j44 (a, b) (((a >> 4) & 0x0f) | (b & 0xf0)) -NB: The FIT adapter does not appear to use the control registers. -So, we map ALT_STATUS to STATUS and NO-OP writes to the device -control register - this means that IDE reset will not work on these -devices. - -*/ +/* +* cont = 0 - access the IDE register file +* cont = 1 - access the IDE command set +* +* NB: The FIT adapter does not appear to use the control registers. +* So, we map ALT_STATUS to STATUS and NO-OP writes to the device +* control register - this means that IDE reset will not work on these +* devices. +*/ static void fit2_write_regr (struct pi_adapter *pi,int cont,int regr,int val) - -{if (cont ==1 )return ; +{ +if (cont ==1 ) +return ;w2 (0xc );w0 (regr);w2 (4 );w0 (val);w2 (5 );w0 (0 );w2 (4 ); }static int fit2_read_regr (struct pi_adapter *pi,int cont,int regr) - -{int a, b, r; +{ +int a, b, r;if (cont) { -if (regr !=6 )return 0xff ; - r =7 ; - }else r = regr +0x10 ; +if (regr !=6 ) +return 0xff ; + r =7 ; + }else { + r = regr +0x10 ; + } -w2 (0xc );w0 (r);w2 (4 );w2 (5 ); -w0 (0 ); a =r1 (); -w0 (1 ); b =r1 (); +w2 (0xc );w0 (r);w2 (4 );w2 (5 ); +w0 (0 ); a =r1 (); +w0 (1 ); b =r1 ();w2 (4 ); -return j44 (a,b); - +return j44 (a, b); }static void fit2_read_block (struct pi_adapter *pi,char *buf,int count) - -{int k, a, b, c, d; +{ +int k, a, b, c, d;w2 (0xc );w0 (0x10 ); -for (k=0 ;k<count/4 ;k++) { - +for (k =0 ; k < count /4 ; k++) {w2 (4 );w2 (5 );w0 (0 ); a =r1 ();w0 (1 ); b =r1 (); -w0 (3 ); c =r1 ();w0 (2 ); d =r1 (); - buf[4 *k+0 ] =j44 (a,b); - buf[4 *k+1 ] =j44 (d,c); - -w2 (4 );w2 (5 ); - a =r1 ();w0 (3 ); b =r1 (); -w0 (1 ); c =r1 ();w0 (0 ); d =r1 (); - buf[4 *k+2 ] =j44 (d,c); - buf[4 *k+3 ] =j44 (a,b); +w0 (3 ); c =r1 ();w0 (2 ); d =r1 (); + buf[4 * k +0 ] =j44 (a, b); + buf[4 * k +1 ] =j44 (d, c); +w2 (4 );w2 (5 ); + a =r1 ();w0 (3 ); b =r1 (); +w0 (1 ); c =r1 ();w0 (0 ); d =r1 (); + buf[4 * k +2 ] =j44 (d, c); + buf[4 * k +3 ] =j44 (a, b); }w2 (4 ); - }static void fit2_write_block (struct pi_adapter *pi,char *buf,int count) +{ +int k; -{int k; - - -w2 (0xc );w0 (0 ); -for (k=0 ;k<count/2 ;k++) { -w2 (4 );w0 (buf[2 *k]); -w2 (5 );w0 (buf[2 *k+1 ]); +w2 (0xc );w0 (0 ); +for (k =0 ; k < count /2 ; k++) { +w2 (4 );w0 (buf[2 * k]); +w2 (5 );w0 (buf[2 * k +1 ]); }w2 (4 ); }static void fit2_connect (struct pi_adapter *pi) - -{ pi->saved_r0 =r0 (); - pi->saved_r2 =r2 (); -w2 (0xcc ); +{ + pi->saved_r0 =r0 (); + pi->saved_r2 =r2 (); +w2 (0xcc ); }static void fit2_disconnect (struct pi_adapter *pi) - -{w0 (pi->saved_r0); -w2 (pi->saved_r2); -} +{ +w0 (pi->saved_r0); +w2 (pi->saved_r2); +}static void fit2_log_adapter (struct pi_adapter *pi) - {dev_info (&pi->dev,"FIT 2000 adapter at 0x%x, delay %d\n" , - pi->port, pi->delay); + pi->port, pi->delay); }
Signature · 1 line
2.40.1
Damien Le Moal
maintainerPATCH 8/13 ata: pata_parport: Fix fit3 module code indentation and style
In reply to Damien Le MoalFix the header, indentation and coding style in the fit3 pata parport protocol module to suppress warnings from smatch and other static code analyzers.
No functional changes.
--- drivers/ata/pata_parport/fit3.c | 206 ++++++++++++++++---------------- 1 file changed, 104 insertions(+), 102 deletions(-)
drivers/ata/pata_parport/fit3.c +104 -102
@@ -1,21 +1,20 @@ -/* -fit3.c (c) 1998 Grant R. Guenther <[email protected]> -Under the terms of the GNU General Public License. - -fit3.c is a low-level protocol driver for newer models -of the Fidelity International Technology parallel port adapter. -This adapter is used in their TransDisk 3000 portable -hard-drives, as well as CD-ROM, PD-CD and other devices. - -The TD-2000 and certain older devices use a different protocol. -Try the fit2 protocol module with them. - -NB: The FIT adapters do not appear to support the control -registers. So, we map ALT_STATUS to STATUS and NO-OP writes -to the device control register - this means that IDE reset -will not work on these devices. - -*/ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* (c) 1998 Grant R. Guenther <[email protected]> +* +* fit3.c is a low-level protocol driver for newer models +* of the Fidelity International Technology parallel port adapter. +* This adapter is used in their TransDisk 3000 portable +* hard-drives, as well as CD-ROM, PD-CD and other devices. +* +* The TD-2000 and certain older devices use a different protocol. +* Try the fit2 protocol module with them. +* +* NB: The FIT adapters do not appear to support the control +* registers. So, we map ALT_STATUS to STATUS and NO-OP writes +* to the device control register - this means that IDE reset +* will not work on these devices. +*/ #include <linux/module.h> #include <linux/init.h>
@@ -26,152 +25,155 @@#include <asm/io.h> #include "pata_parport.h" -#define j44 (a,b) (((a>>3)&0x0f)|((b<<1)&0xf0)) - -#define w7 (byte) {out_p(7,byte);} -#define r7 () (in_p(7) & 0xff) +#define j44 (a, b) (((a >> 3) & 0x0f) | ((b << 1) & 0xf0)) -/* cont = 0 - access the IDE register file -cont = 1 - access the IDE command set +#define w7 (byte) out_p(7, byte) +#define r7 () (in_p(7) & 0xff) -*/ +/* +* cont = 0 - access the IDE register file +* cont = 1 - access the IDE command set +*/ static void fit3_write_regr (struct pi_adapter *pi,int cont,int regr,int val) - -{if (cont ==1 )return ; +{ +if (cont ==1 ) +return ;switch (pi->mode) { -case 0 : -case 1 :w2 (0xc );w0 (regr);w2 (0x8 );w2 (0xc ); -w0 (val);w2 (0xd ); +case 1 : +w2 (0xc );w0 (regr);w2 (0x8 );w2 (0xc ); +w0 (val);w2 (0xd );w0 (0 );w2 (0xc );break ; - -case 2 :w2 (0xc );w0 (regr);w2 (0x8 );w2 (0xc ); +case 2 : +w2 (0xc );w0 (regr);w2 (0x8 );w2 (0xc );w4 (val);w4 (0 );w2 (0xc );break ; - } }static int fit3_read_regr (struct pi_adapter *pi,int cont,int regr) - -{int a, b; +{ +int a, b;if (cont) { -if (regr !=6 )return 0xff ; - regr =7 ; - } +if (regr !=6 ) +return 0xff ; + regr =7 ; + }switch (pi->mode) { - -case 0 :w2 (0xc );w0 (regr +0x10 );w2 (0x8 );w2 (0xc ); +case 0 : +w2 (0xc );w0 (regr +0x10 );w2 (0x8 );w2 (0xc );w2 (0xd ); a =r1 (); -w2 (0xf ); b =r1 (); +w2 (0xf ); b =r1 ();w2 (0xc ); -return j44 (a,b); - -case 1 :w2 (0xc );w0 (regr +0x90 );w2 (0x8 );w2 (0xc ); -w2 (0xec );w2 (0xee );w2 (0xef ); a =r0 (); +return j44 (a, b); +case 1 : +w2 (0xc );w0 (regr +0x90 );w2 (0x8 );w2 (0xc ); +w2 (0xec );w2 (0xee );w2 (0xef ); a =r0 ();w2 (0xc );return a; - -case 2 :w2 (0xc );w0 (regr +0x90 );w2 (0x8 );w2 (0xc ); -w2 (0xec ); - a =r4 (); b =r4 (); +case 2 : +w2 (0xc );w0 (regr +0x90 );w2 (0x8 );w2 (0xc ); +w2 (0xec ); + a =r4 (); b =r4 ();w2 (0xc );return a; - } -return -1 ; +return -1 ; }static void fit3_read_block (struct pi_adapter *pi,char *buf,int count) - -{int k, a, b, c, d; +{ +int k, a, b, c, d;switch (pi->mode) { - -case 0 :w2 (0xc );w0 (0x10 );w2 (0x8 );w2 (0xc ); -for (k=0 ;k<count/2 ;k++) { -w2 (0xd ); a =r1 (); -w2 (0xf ); b =r1 (); -w2 (0xc ); c =r1 (); -w2 (0xe ); d =r1 (); - buf[2 *k ] =j44 (a,b); - buf[2 *k+1 ] =j44 (c,d); +case 0 : +w2 (0xc );w0 (0x10 );w2 (0x8 );w2 (0xc ); +for (k =0 ; k < count /2 ; k++) { +w2 (0xd ); a =r1 (); +w2 (0xf ); b =r1 (); +w2 (0xc ); c =r1 (); +w2 (0xe ); d =r1 (); + buf[2 * k] =j44 (a, b); + buf[2 * k +1 ] =j44 (c, d); }w2 (0xc );break ; - -case 1 :w2 (0xc );w0 (0x90 );w2 (0x8 );w2 (0xc ); +case 1 : +w2 (0xc );w0 (0x90 );w2 (0x8 );w2 (0xc );w2 (0xec );w2 (0xee ); -for (k=0 ;k<count/2 ;k++) { -w2 (0xef ); a =r0 (); -w2 (0xee ); b =r0 (); - buf[2 *k ] = a; - buf[2 *k+1 ] = b; +for (k =0 ; k < count /2 ; k++) { +w2 (0xef ); a =r0 (); +w2 (0xee ); b =r0 (); + buf[2 * k] = a; + buf[2 * k +1 ] = b; } -w2 (0xec ); +w2 (0xec );w2 (0xc );break ; - -case 2 :w2 (0xc );w0 (0x90 );w2 (0x8 );w2 (0xc ); -w2 (0xec ); -for (k=0 ;k<count;k++) buf[k] =r4 (); -w2 (0xc ); +case 2 : +w2 (0xc );w0 (0x90 );w2 (0x8 );w2 (0xc ); +w2 (0xec ); +for (k =0 ; k < count; k++) + buf[k] =r4 (); +w2 (0xc );break ; - } }static void fit3_write_block (struct pi_adapter *pi,char *buf,int count) +{ +int k; -{int k; - -switch (pi->mode) { - +switch (pi->mode) {case 0 : -case 1 :w2 (0xc );w0 (0 );w2 (0x8 );w2 (0xc ); -for (k=0 ;k<count/2 ;k++) { -w0 (buf[2 *k ]);w2 (0xd ); -w0 (buf[2 *k+1 ]);w2 (0xc ); +case 1 : +w2 (0xc );w0 (0 );w2 (0x8 );w2 (0xc ); +for (k =0 ; k < count /2 ; k++) { +w0 (buf[2 * k]);w2 (0xd ); +w0 (buf[2 * k +1 ]);w2 (0xc ); }break ; - -case 2 :w2 (0xc );w0 (0 );w2 (0x8 );w2 (0xc ); -for (k=0 ;k<count;k++)w4 (buf[k]); -w2 (0xc ); +case 2 : +w2 (0xc );w0 (0 );w2 (0x8 );w2 (0xc ); +for (k =0 ; k < count; k++) +w4 (buf[k]); +w2 (0xc );break ; } }static void fit3_connect (struct pi_adapter *pi) - -{ pi->saved_r0 =r0 (); - pi->saved_r2 =r2 (); +{ + pi->saved_r0 =r0 (); + pi->saved_r2 =r2 ();w2 (0xc );w0 (0 );w2 (0xa ); -if (pi->mode ==2 ) { -w2 (0xc );w0 (0x9 );w2 (0x8 );w2 (0xc ); - } +if (pi->mode ==2 ) { +w2 (0xc );w0 (0x9 ); +w2 (0x8 );w2 (0xc ); + } }static void fit3_disconnect (struct pi_adapter *pi) - -{w2 (0xc );w0 (0xa );w2 (0x8 );w2 (0xc ); +{ +w2 (0xc );w0 (0xa );w2 (0x8 );w2 (0xc );w0 (pi->saved_r0); -w2 (pi->saved_r2); -} +w2 (pi->saved_r2); +}static void fit3_log_adapter (struct pi_adapter *pi) +{ +char *mode_string[3 ] = {"4-bit" ,"8-bit" ,"EPP" }; -{char *mode_string[3 ] = {"4-bit" ,"8-bit" ,"EPP" }; - -dev_info (&pi->dev,"FIT 3000 adapter at 0x%x, mode %d (%s), delay %d\n" , - pi->port, pi->mode, mode_string[pi->mode], pi->delay); +dev_info (&pi->dev, +"FIT 3000 adapter at 0x%x, mode %d (%s), delay %d\n" , + pi->port, pi->mode, mode_string[pi->mode], pi->delay); }static struct pi_protocol fit3 = {
Signature · 1 line
2.40.1
Damien Le Moal
maintainerPATCH 9/13 ata: pata_parport: Fix friq module code indentation and style
In reply to Damien Le MoalFix the header, indentation and coding style in the friq pata parport protocol module to suppress warnings from smatch and other static code analyzers.
No functional changes.
--- drivers/ata/pata_parport/friq.c | 292 ++++++++++++++++---------------- 1 file changed, 150 insertions(+), 142 deletions(-)
drivers/ata/pata_parport/friq.c +150 -142
@@ -1,24 +1,23 @@ -/* -friq.c (c) 1998 Grant R. Guenther <[email protected]> -Under the terms of the GNU General Public License - -friq.c is a low-level protocol driver for the Freecom "IQ" -parallel port IDE adapter. Early versions of this adapter -use the 'frpw' protocol. -- Freecom uses this adapter in a battery powered external -CD-ROM drive. It is also used in LS-120 drives by -Maxell and Panasonic, and other devices. - -The battery powered drive requires software support to -control the power to the drive. This module enables the -drive power when the high level driver (pcd) is loaded -and disables it when the module is unloaded. Note, if -the friq module is built in to the kernel, the power -will never be switched off, so other means should be -used to conserve battery power. - -*/ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* (c) 1998 Grant R. Guenther <[email protected]> +* +* friq.c is a low-level protocol driver for the Freecom "IQ" +* parallel port IDE adapter. Early versions of this adapter +* use the 'frpw' protocol. +* +* Freecom uses this adapter in a battery powered external +* CD-ROM drive. It is also used in LS-120 drives by +* Maxell and Panasonic, and other devices. +* +* The battery powered drive requires software support to +* control the power to the drive. This module enables the +* drive power when the high level driver (pcd) is loaded +* and disables it when the module is unloaded. Note, if +* the friq module is built in to the kernel, the power +* will never be switched off, so other means should be +* used to conserve battery power. +*/ #include <linux/module.h> #include <linux/init.h>
@@ -29,197 +28,206 @@#include <asm/io.h> #include "pata_parport.h" -#define CMD (x) w2(4);w0(0xff);w0(0xff);w0(0x73);w0(0x73);\ - w0(0xc9);w0(0xc9);w0(0x26);w0(0x26);w0(x);w0(x); +#define CMD (x) \ + do { \ + w2(4); w0(0xff); w0(0xff); w0(0x73); w0(0x73); \ + w0(0xc9); w0(0xc9); w0(0x26); \ + w0(0x26); w0(x); w0(x); \ + } while (0) -#define j44 (l,h) (((l>>4)&0x0f)|(h&0xf0)) +#define j44 (l, h) (((l >> 4) & 0x0f) | (h & 0xf0)) -/* cont = 0 - access the IDE register file -cont = 1 - access the IDE command set -*/ - -static int cont_map[2 ] = {0x08 ,0x10 }; +/* +* cont = 0 - access the IDE register file +* cont = 1 - access the IDE command set +*/ +static int cont_map[2 ] = {0x08 ,0x10 };static int friq_read_regr (struct pi_adapter *pi,int cont,int regr) - -{int h,l,r; +{ +int h, l, r; r = regr + cont_map[cont];CMD (r);w2 (6 ); l =r1 ();w2 (4 ); h =r1 (); -w2 (4 ); - -return j44 (l,h); +w2 (4 ); +return j44 (l, h); }static void friq_write_regr (struct pi_adapter *pi,int cont,int regr,int val) - -{int r; - - r = regr + cont_map[cont]; +{ +int r = regr + cont_map[cont];CMD (r);w0 (val); -w2 (5 );w2 (7 );w2 (5 );w2 (4 ); +w2 (5 );w2 (7 );w2 (5 );w2 (4 ); }static void friq_read_block_int (struct pi_adapter *pi,char *buf,int count,int regr) +{ +int h, l, k, ph; -{int h, l, k, ph; - -switch (pi->mode) { - -case 0 :CMD (regr); -for (k=0 ;k<count;k++) { -w2 (6 ); l =r1 (); -w2 (4 ); h =r1 (); - buf[k] =j44 (l,h); - } -w2 (4 ); -break ; - -case 1 : ph =2 ; -CMD (regr+0xc0 ); -w0 (0xff ); -for (k=0 ;k<count;k++) { -w2 (0xa4 + ph); - buf[k] =r0 (); - ph =2 - ph; - } -w2 (0xac );w2 (0xa4 );w2 (4 ); -break ; - -case 2 :CMD (regr+0x80 ); -for (k=0 ;k<count-2 ;k++) buf[k] =r4 (); +switch (pi->mode) { +case 0 : +CMD (regr); +for (k =0 ; k < count; k++) { +w2 (6 ); l =r1 (); +w2 (4 ); h =r1 (); + buf[k] =j44 (l, h); + } +w2 (4 ); +break ; +case 1 : + ph =2 ; +CMD (regr +0xc0 ); +w0 (0xff ); +for (k =0 ; k < count; k++) { +w2 (0xa4 + ph); + buf[k] =r0 (); + ph =2 - ph; + } +w2 (0xac );w2 (0xa4 );w2 (4 ); +break ; +case 2 : +CMD (regr +0x80 ); +for (k =0 ; k < count -2 ; k++) + buf[k] =r4 ();w2 (0xac );w2 (0xa4 ); - buf[count-2 ] =r4 (); - buf[count-1 ] =r4 (); + buf[count -2 ] =r4 (); + buf[count -1 ] =r4 ();w2 (4 );break ; - -case 3 :CMD (regr+0x80 ); -for (k=0 ;k<(count/2 )-1 ;k++) ((u16 *)buf)[k] =r4w (); -w2 (0xac );w2 (0xa4 ); - buf[count-2 ] =r4 (); - buf[count-1 ] =r4 (); -w2 (4 ); -break ; - -case 4 :CMD (regr+0x80 ); -for (k=0 ;k<(count/4 )-1 ;k++) ((u32 *)buf)[k] =r4l (); - buf[count-4 ] =r4 (); - buf[count-3 ] =r4 (); -w2 (0xac );w2 (0xa4 ); - buf[count-2 ] =r4 (); - buf[count-1 ] =r4 (); -w2 (4 ); -break ; - - } +case 3 : +CMD (regr +0x80 ); +for (k =0 ; k < count /2 -1 ; k++) + ((u16 *)buf)[k] =r4w (); +w2 (0xac );w2 (0xa4 ); + buf[count -2 ] =r4 (); + buf[count -1 ] =r4 (); +w2 (4 ); +break ; +case 4 : +CMD (regr +0x80 ); +for (k =0 ; k < count /4 -1 ; k++) + ((u32 *)buf)[k] =r4l (); + buf[count -4 ] =r4 (); + buf[count -3 ] =r4 (); +w2 (0xac );w2 (0xa4 ); + buf[count -2 ] =r4 (); + buf[count -1 ] =r4 (); +w2 (4 ); +break ; + } }static void friq_read_block (struct pi_adapter *pi,char *buf,int count) - -{friq_read_block_int (pi,buf,count,0x08 ); +{ +friq_read_block_int (pi, buf, count,0x08 ); }static void friq_write_block (struct pi_adapter *pi,char *buf,int count) - -{int k; - -switch (pi->mode) { +{ +int k; +switch (pi->mode) {case 0 : -case 1 :CMD (8 );w2 (5 ); -for (k=0 ;k<count;k++) { +case 1 : +CMD (8 );w2 (5 ); +for (k =0 ; k < count; k++) {w0 (buf[k]); -w2 (7 );w2 (5 ); +w2 (7 );w2 (5 ); }w2 (4 );break ; - -case 2 :CMD (0xc8 );w2 (5 ); -for (k=0 ;k<count;k++)w4 (buf[k]); +case 2 : +CMD (0xc8 );w2 (5 ); +for (k =0 ; k < count; k++) +w4 (buf[k]); +w2 (4 ); +break ; +case 3 : +CMD (0xc8 );w2 (5 ); +for (k =0 ; k < count /2 ; k++) +w4w (((u16 *)buf)[k]); +w2 (4 ); +break ; +case 4 : +CMD (0xc8 );w2 (5 ); +for (k =0 ; k < count /4 ; k++) +w4l (((u32 *)buf)[k]);w2 (4 );break ; - -case 3 :CMD (0xc8 );w2 (5 ); -for (k=0 ;k<count/2 ;k++)w4w (((u16 *)buf)[k]); -w2 (4 ); -break ; - -case 4 :CMD (0xc8 );w2 (5 ); -for (k=0 ;k<count/4 ;k++)w4l (((u32 *)buf)[k]); -w2 (4 ); -break ; - } +} }static void friq_connect (struct pi_adapter *pi) - -{ pi->saved_r0 =r0 (); - pi->saved_r2 =r2 (); +{ + pi->saved_r0 =r0 (); + pi->saved_r2 =r2 ();w2 (4 ); }static void friq_disconnect (struct pi_adapter *pi) - -{CMD (0x20 ); +{ +CMD (0x20 );w0 (pi->saved_r0); -w2 (pi->saved_r2); -} +w2 (pi->saved_r2); +}static int friq_test_proto (struct pi_adapter *pi) - -{int j, k, r; -int e[2 ] = {0 ,0 }; +{ +int j, k, r; +int e[2 ] = {0 ,0 };char scratch[512 ]; - pi->saved_r0 =r0 (); + pi->saved_r0 =r0 ();w0 (0xff );udelay (20 );CMD (0x3d );/* turn the power on */ udelay (500 );w0 (pi->saved_r0);friq_connect (pi); -for (j=0 ;j<2 ;j++) { -friq_write_regr (pi,0 ,6 ,0xa0 +j*0x10 ); -for (k=0 ;k<256 ;k++) { -friq_write_regr (pi,0 ,2 ,k^0xaa ); -friq_write_regr (pi,0 ,3 ,k^0x55 ); -if (friq_read_regr (pi,0 ,2 ) != (k^0xaa )) e[j]++; - } - } +for (j =0 ; j <2 ; j++) { +friq_write_regr (pi,0 ,6 ,0xa0 + j *0x10 ); +for (k =0 ; k <256 ; k++) { +friq_write_regr (pi,0 ,2 , k ^0xaa ); +friq_write_regr (pi,0 ,3 , k ^0x55 ); +if (friq_read_regr (pi,0 ,2 ) != (k ^0xaa )) + e[j]++; + } + }friq_disconnect (pi);friq_connect (pi); -friq_read_block_int (pi,scratch,512 ,0x10 ); - r =0 ; -for (k=0 ;k<128 ;k++)if (scratch[k] != k) r++; +friq_read_block_int (pi, scratch,512 ,0x10 ); + r =0 ; +for (k =0 ; k <128 ; k++) { +if (scratch[k] != k) + r++; + }friq_disconnect (pi); -dev_dbg (&pi->dev,"friq: port 0x%x, mode %d, test=(%d,%d,%d)\n" , - pi->port, pi->mode, e[0 ], e[1 ], r); +dev_dbg (&pi->dev, +"friq: port 0x%x, mode %d, test=(%d,%d,%d)\n" , + pi->port, pi->mode, e[0 ], e[1 ], r); -return (r || (e[0 ] && e[1 ])); +return r || (e[0 ] && e[1 ]); } -static void friq_log_adapter (struct pi_adapter *pi) +{ +char *mode_string[6 ] = {"4-bit" ,"8-bit" ,"EPP-8" ,"EPP-16" ,"EPP-32" }; -{char *mode_string[6 ] = {"4-bit" ,"8-bit" , -"EPP-8" ,"EPP-16" ,"EPP-32" }; - -dev_info (&pi->dev,"Freecom IQ ASIC-2 adapter at 0x%x, mode %d (%s), delay %d\n" , - pi->port, pi->mode, mode_string[pi->mode], pi->delay); +dev_info (&pi->dev, +"Freecom IQ ASIC-2 adapter at 0x%x, mode %d (%s), delay %d\n" , + pi->port, pi->mode, mode_string[pi->mode], pi->delay); pi->private =1 ;friq_connect (pi);CMD (0x9e );/* disable sleep timer */ friq_disconnect (pi); - }static void friq_release_proto (struct pi_adapter *pi)
Signature · 1 line
2.40.1
Damien Le Moal
maintainerPATCH 10/13 ata: pata_parport: Fix kbic module code indentation and style
In reply to Damien Le MoalFix the header, indentation and coding style in the kbic pata parport protocol module to suppress warnings from smatch and other static code analyzers.
No functional changes.
--- drivers/ata/pata_parport/kbic.c | 314 ++++++++++++++++---------------- 1 file changed, 162 insertions(+), 152 deletions(-)
drivers/ata/pata_parport/kbic.c +162 -152
@@ -1,16 +1,15 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* -kbic.c (c) 1997-8 Grant R. Guenther <[email protected]> -Under the terms of the GNU General Public License. - -This is a low-level driver for the KBIC-951A and KBIC-971A -parallel to IDE adapter chips from KingByte Information Systems. - -The chips are almost identical, however, the wakeup code -required for the 971A interferes with the correct operation of -the 951A, so this driver registers itself twice, once for -each chip. - -*/ +* (c) 1997-1998 Grant R. Guenther <[email protected]> +* +* This is a low-level driver for the KBIC-951A and KBIC-971A +* parallel to IDE adapter chips from KingByte Information Systems. +* +* The chips are almost identical, however, the wakeup code +* required for the 971A interferes with the correct operation of +* the 951A, so this driver registers itself twice, once for +* each chip. +*/ #include <linux/module.h> #include <linux/init.h>
@@ -21,212 +20,223 @@#include <asm/io.h> #include "pata_parport.h" -#define r12w () (delay_p,inw(pi->port+1)&0xffff) +#define r12w () (delay_p, inw(pi->port + 1) & 0xffff) -#define j44 (a,b) ((((a>>4)&0x0f)|(b&0xf0))^0x88) -#define j53 (w) (((w>>3)&0x1f)|((w>>4)&0xe0)) +#define j44 (a, b) ((((a >> 4) & 0x0f) | (b & 0xf0)) ^ 0x88) +#define j53 (w) (((w >> 3) & 0x1f) | ((w >> 4) & 0xe0)) -/* cont = 0 - access the IDE register file -cont = 1 - access the IDE command set -*/ - -static int cont_map[2 ] = {0x80 ,0x40 }; +/* +* cont = 0 - access the IDE register file +* cont = 1 - access the IDE command set +*/ +static int cont_map[2 ] = {0x80 ,0x40 };static int kbic_read_regr (struct pi_adapter *pi,int cont,int regr) +{ +int a, b, s; -{int a, b, s; - - s = cont_map[cont]; + s = cont_map[cont];switch (pi->mode) { - -case 0 :w0 (regr|0x18 |s);w2 (4 );w2 (6 );w2 (4 );w2 (1 );w0 (8 ); - a =r1 ();w0 (0x28 ); b =r1 ();w2 (4 ); -return j44 (a,b); - -case 1 :w0 (regr|0x38 |s);w2 (4 );w2 (6 );w2 (4 );w2 (5 );w0 (8 ); +case 0 : +w0 (regr |0x18 | s);w2 (4 );w2 (6 );w2 (4 );w2 (1 );w0 (8 ); + a =r1 ();w0 (0x28 ); b =r1 ();w2 (4 ); +return j44 (a, b); +case 1 : +w0 (regr|0x38 | s);w2 (4 );w2 (6 );w2 (4 );w2 (5 );w0 (8 ); a =r12w ();w2 (4 );return j53 (a); - -case 2 :w0 (regr|0x08 |s);w2 (4 );w2 (6 );w2 (4 );w2 (0xa5 );w2 (0xa1 ); +case 2 : +w0 (regr |0x08 | s);w2 (4 );w2 (6 );w2 (4 );w2 (0xa5 );w2 (0xa1 ); a =r0 ();w2 (4 ); -return a; - +return a;case 3 :case 4 : -case 5 :w0 (0x20 |s);w2 (4 );w2 (6 );w2 (4 );w3 (regr); +case 5 : +w0 (0x20 | s);w2 (4 );w2 (6 );w2 (4 );w3 (regr); a =r4 (); b =r4 ();w2 (4 );w2 (0 );w2 (4 );return a; - } +return -1 ; -} +}static void kbic_write_regr (struct pi_adapter *pi,int cont,int regr,int val) +{ +int s = cont_map[cont]; -{int s; - - s = cont_map[cont]; - -switch (pi->mode) { - -case 0 : -case 1 : -case 2 :w0 (regr|0x10 |s);w2 (4 );w2 (6 );w2 (4 ); +switch (pi->mode) { +case 0 : +case 1 : +case 2 : +w0 (regr |0x10 | s);w2 (4 );w2 (6 );w2 (4 );w0 (val);w2 (5 );w2 (4 );break ; -case 3 :case 4 : -case 5 :w0 (0x20 |s);w2 (4 );w2 (6 );w2 (4 );w3 (regr); +case 5 : +w0 (0x20 | s);w2 (4 );w2 (6 );w2 (4 );w3 (regr);w4 (val);w4 (val);w2 (4 );w2 (0 );w2 (4 ); -break ; - +break ; } }static void k951_connect (struct pi_adapter *pi) - -{ pi->saved_r0 =r0 (); - pi->saved_r2 =r2 (); -w2 (4 ); +{ + pi->saved_r0 =r0 (); + pi->saved_r2 =r2 (); +w2 (4 ); }static void k951_disconnect (struct pi_adapter *pi) - -{w0 (pi->saved_r0); -w2 (pi->saved_r2); +{ +w0 (pi->saved_r0); +w2 (pi->saved_r2); } -#define CCP (x) w2(0xc4);w0(0xaa);w0(0x55);w0(0);w0(0xff);w0(0x87);\ - w0(0x78);w0(x);w2(0xc5);w2(0xc4);w0(0xff); +#define CCP (x) \ + do { \ + w2(0xc4); w0(0xaa); w0(0x55); \ + w0(0); w0(0xff); w0(0x87); \ + w0(0x78); w0(x); w2(0xc5); \ + w2(0xc4); w0(0xff); \ + } while (0)static void k971_connect (struct pi_adapter *pi) - -{ pi->saved_r0 =r0 (); - pi->saved_r2 =r2 (); +{ + pi->saved_r0 =r0 (); + pi->saved_r2 =r2 ();CCP (0x20 ); -w2 (4 ); +w2 (4 ); }static void k971_disconnect (struct pi_adapter *pi) - -{CCP (0x30 ); +{ +CCP (0x30 );w0 (pi->saved_r0); -w2 (pi->saved_r2); +w2 (pi->saved_r2); } -/* counts must be congruent to 0 MOD 4, but all known applications -have this property. -*/ - +/* +* count must be congruent to 0 MOD 4, but all known applications +*have this property. +*/ static void kbic_read_block (struct pi_adapter *pi,char *buf,int count) +{ +int k, a, b; -{int k, a, b; - -switch (pi->mode) { - -case 0 :w0 (0x98 );w2 (4 );w2 (6 );w2 (4 ); -for (k=0 ;k<count/2 ;k++) { -w2 (1 );w0 (8 ); a =r1 (); -w0 (0x28 ); b =r1 (); - buf[2 *k] =j44 (a,b); -w2 (5 ); b =r1 (); -w0 (8 ); a =r1 (); - buf[2 *k+1 ] =j44 (a,b); +switch (pi->mode) { +case 0 : +w0 (0x98 );w2 (4 );w2 (6 );w2 (4 ); +for (k =0 ; k < count /2 ; k++) { +w2 (1 );w0 (8 ); + a =r1 (); +w0 (0x28 ); + b =r1 (); + buf[2 * k] =j44 (a, b); +w2 (5 ); + b =r1 (); +w0 (8 ); + a =r1 (); + buf[2 * k +1 ] =j44 (a, b);w2 (4 ); - } -break ; - -case 1 :w0 (0xb8 );w2 (4 );w2 (6 );w2 (4 ); -for (k=0 ;k<count/4 ;k++) { -w0 (0xb8 ); -w2 (4 );w2 (5 ); -w0 (8 ); buf[4 *k] =j53 (r12w ()); -w0 (0xb8 ); buf[4 *k+1 ] =j53 (r12w ()); + } +break ; +case 1 : +w0 (0xb8 );w2 (4 );w2 (6 );w2 (4 ); +for (k =0 ; k < count /4 ; k++) { +w0 (0xb8 );w2 (4 );w2 (5 ); - buf[4 *k+3 ] =j53 (r12w ()); -w0 (8 ); buf[4 *k+2 ] =j53 (r12w ()); - } -w2 (4 ); -break ; - -case 2 :w0 (0x88 );w2 (4 );w2 (6 );w2 (4 ); -for (k=0 ;k<count/2 ;k++) { -w2 (0xa0 );w2 (0xa1 ); buf[2 *k] =r0 (); -w2 (0xa5 ); buf[2 *k+1 ] =r0 (); - } -w2 (4 ); -break ; - -case 3 :w0 (0xa0 );w2 (4 );w2 (6 );w2 (4 );w3 (0 ); -for (k=0 ;k<count;k++) buf[k] =r4 (); -w2 (4 );w2 (0 );w2 (4 ); -break ; - -case 4 :w0 (0xa0 );w2 (4 );w2 (6 );w2 (4 );w3 (0 ); -for (k=0 ;k<count/2 ;k++) ((u16 *)buf)[k] =r4w (); -w2 (4 );w2 (0 );w2 (4 ); -break ; - -case 5 :w0 (0xa0 );w2 (4 );w2 (6 );w2 (4 );w3 (0 ); -for (k=0 ;k<count/4 ;k++) ((u32 *)buf)[k] =r4l (); -w2 (4 );w2 (0 );w2 (4 ); -break ; - - - } +w0 (8 ); + buf[4 * k] =j53 (r12w ()); +w0 (0xb8 ); + buf[4 * k +1 ] =j53 (r12w ()); +w2 (4 );w2 (5 ); + buf[4 * k +3 ] =j53 (r12w ()); +w0 (8 ); + buf[4 * k +2 ] =j53 (r12w ()); + } +w2 (4 ); +break ; +case 2 : +w0 (0x88 );w2 (4 );w2 (6 );w2 (4 ); +for (k =0 ; k < count /2 ; k++) { +w2 (0xa0 );w2 (0xa1 ); + buf[2 * k] =r0 (); +w2 (0xa5 ); + buf[2 * k +1 ] =r0 (); + } +w2 (4 ); +break ; +case 3 : +w0 (0xa0 );w2 (4 );w2 (6 );w2 (4 );w3 (0 ); +for (k =0 ; k < count; k++) + buf[k] =r4 (); +w2 (4 );w2 (0 );w2 (4 ); +break ; +case 4 : +w0 (0xa0 );w2 (4 );w2 (6 );w2 (4 );w3 (0 ); +for (k =0 ; k < count /2 ; k++) + ((u16 *)buf)[k] =r4w (); +w2 (4 );w2 (0 );w2 (4 ); +break ; +case 5 : +w0 (0xa0 );w2 (4 );w2 (6 );w2 (4 );w3 (0 ); +for (k =0 ; k < count /4 ; k++) + ((u32 *)buf)[k] =r4l (); +w2 (4 );w2 (0 );w2 (4 ); +break ; + } }static void kbic_write_block (struct pi_adapter *pi,char *buf,int count) +{ +int k; -{int k; - -switch (pi->mode) { - -case 0 : -case 1 : -case 2 :w0 (0x90 );w2 (4 );w2 (6 );w2 (4 ); -for (k=0 ;k<count/2 ;k++) { -w0 (buf[2 *k+1 ]);w2 (0 );w2 (4 ); -w0 (buf[2 *k]);w2 (5 );w2 (4 ); +switch (pi->mode) { +case 0 : +case 1 : +case 2 : +w0 (0x90 );w2 (4 );w2 (6 );w2 (4 ); +for (k =0 ; k < count /2 ; k++) { +w0 (buf[2 * k +1 ]); +w2 (0 );w2 (4 ); +w0 (buf[2 * k]); +w2 (5 );w2 (4 ); }break ; - -case 3 :w0 (0xa0 );w2 (4 );w2 (6 );w2 (4 );w3 (0 ); -for (k=0 ;k<count/2 ;k++) { -w4 (buf[2 *k+1 ]); -w4 (buf[2 *k]); - } +case 3 : +w0 (0xa0 );w2 (4 );w2 (6 );w2 (4 );w3 (0 ); +for (k =0 ; k < count /2 ; k++) { +w4 (buf[2 * k +1 ]); +w4 (buf[2 * k]); + }w2 (4 );w2 (0 );w2 (4 );break ; - -case 4 :w0 (0xa0 );w2 (4 );w2 (6 );w2 (4 );w3 (0 ); +case 4 : +w0 (0xa0 );w2 (4 );w2 (6 );w2 (4 );w3 (0 );for (k =0 ; k < count /2 ; k++)w4w (swab16 (((u16 *)buf)[k])); -w2 (4 );w2 (0 );w2 (4 ); -break ; - -case 5 :w0 (0xa0 );w2 (4 );w2 (6 );w2 (4 );w3 (0 ); +w2 (4 );w2 (0 );w2 (4 ); +break ; +case 5 : +w0 (0xa0 );w2 (4 );w2 (6 );w2 (4 );w3 (0 );for (k =0 ; k < count /4 ; k++)w4l (swab16 (((u16 *)buf)[2 * k]) |swab16 (((u16 *)buf)[2 * k +1 ]) <<16 ); -w2 (4 );w2 (0 );w2 (4 ); -break ; - - } - +w2 (4 );w2 (0 );w2 (4 ); +break ; + } }static void kbic_log_adapter (struct pi_adapter *pi,char *chip) - -{char *mode_string[6 ] = {"4-bit" ,"5/3" ,"8-bit" , -"EPP-8" ,"EPP_16" ,"EPP-32" }; +{ +char *mode[6 ] = {"4-bit" ,"5/3" ,"8-bit" ,"EPP-8" ,"EPP_16" ,"EPP-32" };dev_info (&pi->dev,"KingByte %s at 0x%x, mode %d (%s), delay %d\n" , - chip, pi->port, pi->mode, mode_string[pi->mode], pi->delay); + chip, pi->port, pi->mode, mode[pi->mode], pi->delay); }static void k951_log_adapter (struct pi_adapter *pi)
Signature · 1 line
2.40.1
Damien Le Moal
maintainerPATCH 11/13 ata: pata_parport: Fix ktti module code indentation and style
In reply to Damien Le MoalFix the header, indentation and coding style in the ktti pata parport protocol module to suppress warnings from smatch and other static code analyzers.
No functional changes.
--- drivers/ata/pata_parport/ktti.c | 85 ++++++++++++++++----------------- 1 file changed, 40 insertions(+), 45 deletions(-)
drivers/ata/pata_parport/ktti.c +40 -45
@@ -1,12 +1,11 @@ -/* -ktti.c (c) 1998 Grant R. Guenther <[email protected]> -Under the terms of the GNU General Public License. - -ktti.c is a low-level protocol driver for the KT Technology -parallel port adapter. This adapter is used in the "PHd" -portable hard-drives. As far as I can tell, this device -supports 4-bit mode _only_. - +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* (c) 1998 Grant R. Guenther <[email protected]> +* +* ktti.c is a low-level protocol driver for the KT Technology +* parallel port adapter. This adapter is used in the "PHd" +* portable hard-drives. As far as I can tell, this device +* supports 4-bit mode _only_. */ #include <linux/module.h>
@@ -18,80 +17,76 @@#include <asm/io.h> #include "pata_parport.h" -#define j44 (a,b) (((a>>4)&0x0f)|(b&0xf0)) +#define j44 (a, b) (((a >> 4) & 0x0f) | (b & 0xf0)) -/* cont = 0 - access the IDE register file -cont = 1 - access the IDE command set -*/ - -static int cont_map[2 ] = {0x10 ,0x08 }; +/* +* cont = 0 - access the IDE register file +* cont = 1 - access the IDE command set +*/ +static int cont_map[2 ] = {0x10 ,0x08 };static void ktti_write_regr (struct pi_adapter *pi,int cont,int regr,int val) +{ +int r = regr + cont_map[cont]; -{int r; - - r = regr + cont_map[cont]; - -w0 (r);w2 (0xb );w2 (0xa );w2 (3 );w2 (6 ); +w0 (r);w2 (0xb );w2 (0xa );w2 (3 );w2 (6 );w0 (val);w2 (3 );w0 (0 );w2 (6 );w2 (0xb ); }static int ktti_read_regr (struct pi_adapter *pi,int cont,int regr) - -{int a, b, r; +{ +int a, b, r; r = regr + cont_map[cont]; -w0 (r);w2 (0xb );w2 (0xa );w2 (9 );w2 (0xc );w2 (9 ); +w0 (r);w2 (0xb );w2 (0xa );w2 (9 );w2 (0xc );w2 (9 ); a =r1 ();w2 (0xc ); b =r1 ();w2 (9 );w2 (0xc );w2 (9 ); -return j44 (a,b); - +return j44 (a, b); }static void ktti_read_block (struct pi_adapter *pi,char *buf,int count) +{ +int k, a, b; -{int k, a, b; - -for (k=0 ;k<count/2 ;k++) { +for (k =0 ; k < count /2 ; k++) {w0 (0x10 );w2 (0xb );w2 (0xa );w2 (9 );w2 (0xc );w2 (9 ); a =r1 ();w2 (0xc ); b =r1 ();w2 (9 ); - buf[2 *k] =j44 (a,b); + buf[2 *k] =j44 (a, b); a =r1 ();w2 (0xc ); b =r1 ();w2 (9 ); - buf[2 *k+1 ] =j44 (a,b); + buf[2 *k+1 ] =j44 (a, b); } }static void ktti_write_block (struct pi_adapter *pi,char *buf,int count) +{ +int k; -{int k; - -for (k=0 ;k<count/2 ;k++) { +for (k =0 ; k < count /2 ; k++) {w0 (0x10 );w2 (0xb );w2 (0xa );w2 (3 );w2 (6 ); -w0 (buf[2 *k]);w2 (3 ); -w0 (buf[2 *k+1 ]);w2 (6 ); +w0 (buf[2 * k]);w2 (3 ); +w0 (buf[2 * k +1 ]);w2 (6 );w2 (0xb ); } }static void ktti_connect (struct pi_adapter *pi) - -{ pi->saved_r0 =r0 (); - pi->saved_r2 =r2 (); -w2 (0xb );w2 (0xa );w0 (0 );w2 (3 );w2 (6 ); +{ + pi->saved_r0 =r0 (); + pi->saved_r2 =r2 (); +w2 (0xb );w2 (0xa );w0 (0 );w2 (3 );w2 (6 ); }static void ktti_disconnect (struct pi_adapter *pi) - -{w2 (0xb );w2 (0xa );w0 (0xa0 );w2 (3 );w2 (4 ); +{ +w2 (0xb );w2 (0xa );w0 (0xa0 );w2 (3 );w2 (4 );w0 (pi->saved_r0); -w2 (pi->saved_r2); -} +w2 (pi->saved_r2); +}static void ktti_log_adapter (struct pi_adapter *pi) - {dev_info (&pi->dev,"KT adapter at 0x%x, delay %d\n" , - pi->port, pi->delay); + pi->port, pi->delay); }static struct pi_protocol ktti = {
Signature · 1 line
2.40.1
Damien Le Moal
maintainerPATCH 12/13 ata: pata_parport: Fix on20 module code indentation and style
In reply to Damien Le MoalFix the header, indentation and coding style in the on20 pata parport protocol module to suppress warnings from smatch and other static code analyzers.
No functional changes.
--- drivers/ata/pata_parport/on20.c | 149 ++++++++++++++++++-------------- 1 file changed, 82 insertions(+), 67 deletions(-)
drivers/ata/pata_parport/on20.c +82 -67
@@ -1,10 +1,10 @@ -/* -on20.c (c) 1996-8 Grant R. Guenther <[email protected]> -Under the terms of the GNU General Public License. - -on20.c is a low-level protocol driver for the -Onspec 90c20 parallel to IDE adapter. -*/ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* (c) 1996-1998 Grant R. Guenther <[email protected]> +* +* on20.c is a low-level protocol driver for the +* Onspec 90c20 parallel to IDE adapter. +*/ #include <linux/module.h> #include <linux/init.h>
@@ -15,99 +15,114 @@#include <asm/io.h> #include "pata_parport.h" -#define op (f) w2(4);w0(f);w2(5);w2(0xd);w2(5);w2(0xd);w2(5);w2(4); -#define vl (v) w2(4);w0(v);w2(5);w2(7);w2(5);w2(4); - -#define j44 (a,b) (((a>>4)&0x0f)|(b&0xf0)) - -/* cont = 0 - access the IDE register file -cont = 1 - access the IDE command set -*/ - -static int on20_read_regr (struct pi_adapter *pi,int cont,int regr) - -{int h,l, r ; +#define op (f) \ + do { \ + w2(4); w0(f); w2(5); w2(0xd); \ + w2(5); w2(0xd); w2(5); w2(4); \ + } while (0) - r = (regr<<2 ) +1 + cont; +#define vl (v) \ + do { \ + w2(4); w0(v); w2(5); \ + w2(7); w2(5); w2(4); \ + } while (0) -op (1 );vl (r);op (0 ); +#define j44 (a, b) (((a >> 4) & 0x0f) | (b & 0xf0)) -switch (pi->mode) { - -case 0 :w2 (4 );w2 (6 ); l =r1 (); -w2 (4 );w2 (6 ); h =r1 (); -w2 (4 );w2 (6 );w2 (4 );w2 (6 );w2 (4 ); -return j44 (l,h); - -case 1 :w2 (4 );w2 (0x26 ); r =r0 (); -w2 (4 );w2 (0x26 );w2 (4 ); -return r; +/* +* cont = 0 - access the IDE register file +* cont = 1 - access the IDE command set +*/ +static int on20_read_regr (struct pi_adapter *pi,int cont,int regr) +{ +int h, l, r; + + r = (regr <<2 ) +1 + cont; + +op (1 );vl (r);op (0 ); + +switch (pi->mode) { +case 0 : +w2 (4 );w2 (6 ); l =r1 (); +w2 (4 );w2 (6 ); h =r1 (); +w2 (4 );w2 (6 );w2 (4 );w2 (6 );w2 (4 ); +return j44 (l, h); +case 1 : +w2 (4 );w2 (0x26 ); r =r0 (); +w2 (4 );w2 (0x26 );w2 (4 ); +return r; } +return -1 ; -} +}static void on20_write_regr (struct pi_adapter *pi,int cont,int regr,int val) +{ +int r = (regr <<2 ) +1 + cont; -{int r; - - r = (regr<<2 ) +1 + cont; - -op (1 );vl (r); -op (0 );vl (val); +op (1 );vl (r); +op (0 );vl (val);op (0 );vl (val); }static void on20_connect (struct pi_adapter *pi) - -{ pi->saved_r0 =r0 (); - pi->saved_r2 =r2 (); - -w2 (4 );w0 (0 );w2 (0xc );w2 (4 );w2 (6 );w2 (4 );w2 (6 );w2 (4 ); -if (pi->mode) {op (2 );vl (8 );op (2 );vl (9 ); } -else {op (2 );vl (0 );op (2 );vl (8 ); } +{ + pi->saved_r0 =r0 (); + pi->saved_r2 =r2 (); + +w2 (4 );w0 (0 );w2 (0xc );w2 (4 );w2 (6 );w2 (4 );w2 (6 );w2 (4 ); +if (pi->mode) { +op (2 );vl (8 );op (2 );vl (9 ); + }else { +op (2 );vl (0 );op (2 );vl (8 ); + } }static void on20_disconnect (struct pi_adapter *pi) - -{w2 (4 );w0 (7 );w2 (4 );w2 (0xc );w2 (4 ); -w0 (pi->saved_r0); -w2 (pi->saved_r2); -} +{ +w2 (4 );w0 (7 );w2 (4 );w2 (0xc );w2 (4 ); +w0 (pi->saved_r0); +w2 (pi->saved_r2); +}static void on20_read_block (struct pi_adapter *pi,char *buf,int count) - -{int k, l, h; +{ +int k, l, h;op (1 );vl (1 );op (0 ); -for (k=0 ;k<count;k++) -if (pi->mode) { -w2 (4 );w2 (0x26 ); buf[k] =r0 (); - }else { -w2 (6 ); l =r1 ();w2 (4 ); -w2 (6 ); h =r1 ();w2 (4 ); - buf[k] =j44 (l,h); - } +for (k =0 ; k < count; k++) { +if (pi->mode) { +w2 (4 );w2 (0x26 ); buf[k] =r0 (); + }else { +w2 (6 ); l =r1 ();w2 (4 ); +w2 (6 ); h =r1 ();w2 (4 ); + buf[k] =j44 (l, h); + } + }w2 (4 ); }static void on20_write_block (struct pi_adapter *pi,char *buf,int count) - -{int k; +{ +int k;op (1 );vl (1 );op (0 ); -for (k=0 ;k<count;k++) {w2 (5 );w0 (buf[k]);w2 (7 ); } +for (k =0 ; k < count; k++) { +w2 (5 );w0 (buf[k]);w2 (7 ); + }w2 (4 ); }static void on20_log_adapter (struct pi_adapter *pi) +{ +char *mode_string[2 ] = {"4-bit" ,"8-bit" }; -{char *mode_string[2 ] = {"4-bit" ,"8-bit" }; - -dev_info (&pi->dev,"OnSpec 90c20 at 0x%x, mode %d (%s), delay %d\n" , - pi->port, pi->mode, mode_string[pi->mode], pi->delay); +dev_info (&pi->dev, +"OnSpec 90c20 at 0x%x, mode %d (%s), delay %d\n" , + pi->port, pi->mode, mode_string[pi->mode], pi->delay); }static struct pi_protocol on20 = {
Signature · 1 line
2.40.1
Damien Le Moal
maintainerPATCH 13/13 ata: pata_parport: Fix on26 module code indentation and style
In reply to Damien Le MoalFix the header, indentation and coding style in the on26 pata parport protocol module to suppress warnings from smatch and other static code analyzers.
No functional changes.
--- drivers/ata/pata_parport/on26.c | 414 +++++++++++++++++--------------- 1 file changed, 217 insertions(+), 197 deletions(-)
drivers/ata/pata_parport/on26.c +217 -197
@@ -1,11 +1,10 @@ -/* -on26.c (c) 1997-8 Grant R. Guenther <[email protected]> -Under the terms of the GNU General Public License. - -on26.c is a low-level protocol driver for the -OnSpec 90c26 parallel to IDE adapter chip. - -*/ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* (c) 1997-1998 Grant R. Guenther <[email protected]> +* +* on26.c is a low-level protocol driver for the +* OnSpec 90c26 parallel to IDE adapter chip. +*/ #include <linux/module.h> #include <linux/init.h>
@@ -16,260 +15,281 @@#include <asm/io.h> #include "pata_parport.h" -/* mode codes: 0 nybble reads, 8-bit writes -1 8-bit reads and writes -2 8-bit EPP mode -3 EPP-16 -4 EPP-32 -*/ +/* +* mode codes: 0 nybble reads, 8-bit writes +* 1 8-bit reads and writes +* 2 8-bit EPP mode +* 3 EPP-16 +* 4 EPP-32 +*/ -#define j44 (a,b) (((a>>4)&0x0f)|(b&0xf0)) +#define j44 (a, b) (((a >> 4) & 0x0f) | (b & 0xf0)) -#define P1 w2(5);w2(0xd);w2(5);w2(0xd);w2(5);w2(4); -#define P2 w2(5);w2(7);w2(5);w2(4); +#define P1 \ + do { \ + w2(5); w2(0xd); w2(5); w2(0xd); w2(5); w2(4); \ + } while (0) -/* cont = 0 - access the IDE register file -cont = 1 - access the IDE command set -*/ - -static int on26_read_regr (struct pi_adapter *pi,int cont,int regr) +#define P2 \ + do { \ + w2(5); w2(7); w2(5); w2(4); \ + } while (0) -{int a, b, r; +/* +* cont = 0 - access the IDE register file +* cont = 1 - access the IDE command set +*/ - r = (regr<<2 ) +1 + cont; +static int on26_read_regr (struct pi_adapter *pi,int cont,int regr) +{ +int a, b, r; -switch (pi->mode) { + r = (regr <<2 ) +1 + cont; -case 0 :w0 (1 );P1 ;w0 (r);P2 ;w0 (0 );P1 ; +switch (pi->mode) { +case 0 : +w0 (1 );P1 ;w0 (r);P2 ;w0 (0 );P1 ;w2 (6 ); a =r1 ();w2 (4 );w2 (6 ); b =r1 ();w2 (4 );w2 (6 );w2 (4 );w2 (6 );w2 (4 ); -return j44 (a,b); - -case 1 :w0 (1 );P1 ;w0 (r);P2 ;w0 (0 );P1 ; +return j44 (a, b); +case 1 : +w0 (1 );P1 ;w0 (r);P2 ;w0 (0 );P1 ;w2 (0x26 ); a =r0 ();w2 (4 );w2 (0x26 );w2 (4 ); -return a; - +return a;case 2 :case 3 : -case 4 :w3 (1 );w3 (1 );w2 (5 );w4 (r);w2 (4 ); +case 4 : +w3 (1 );w3 (1 );w2 (5 );w4 (r);w2 (4 );w3 (0 );w3 (0 );w2 (0x24 ); a =r4 ();w2 (4 );w2 (0x24 ); (void )r4 ();w2 (4 ); -return a; +return a; + } - } -return -1 ; -} +return -1 ; +}static void on26_write_regr (struct pi_adapter *pi,int cont,int regr,int val) +{ +int r = (regr <<2 ) +1 + cont; -{int r; - - r = (regr<<2 ) +1 + cont; - -switch (pi->mode) { - -case 0 : -case 1 :w0 (1 );P1 ;w0 (r);P2 ;w0 (0 );P1 ; +switch (pi->mode) { +case 0 : +case 1 : +w0 (1 );P1 ;w0 (r);P2 ;w0 (0 );P1 ;w0 (val);P2 ;w0 (val);P2 ;break ; -case 2 :case 3 : -case 4 :w3 (1 );w3 (1 );w2 (5 );w4 (r);w2 (4 ); -w3 (0 );w3 (0 ); +case 4 : +w3 (1 );w3 (1 );w2 (5 );w4 (r);w2 (4 ); +w3 (0 );w3 (0 );w2 (5 );w4 (val);w2 (4 );w2 (5 );w4 (val);w2 (4 ); -break ; - } +break ; + } } -#define CCP (x) w0(0xfe);w0(0xaa);w0(0x55);w0(0);w0(0xff);\ - w0(0x87);w0(0x78);w0(x);w2(4);w2(5);w2(4);w0(0xff); +#define CCP (x) \ + do { \ + w0(0xfe); w0(0xaa); w0(0x55); w0(0); \ + w0(0xff); w0(0x87); w0(0x78); w0(x); \ + w2(4); w2(5); w2(4); w0(0xff); \ + } while (0)static void on26_connect (struct pi_adapter *pi) - -{int x; +{ +int x; pi->saved_r0 =r0 (); - pi->saved_r2 =r2 (); + pi->saved_r2 =r2 (); -CCP (0x20 ); - x =8 ;if (pi->mode) x =9 ; +CCP (0x20 ); +if (pi->mode) + x =9 ; +else + x =8 ;w0 (2 );P1 ;w0 (8 );P2 ;w0 (2 );P1 ;w0 (x);P2 ; }static void on26_disconnect (struct pi_adapter *pi) - -{if (pi->mode >=2 ) {w3 (4 );w3 (4 );w3 (4 );w3 (4 ); } -else {w0 (4 );P1 ;w0 (4 );P1 ; } +{ +if (pi->mode >=2 ) { +w3 (4 );w3 (4 );w3 (4 );w3 (4 ); + }else { +w0 (4 );P1 ;w0 (4 );P1 ; + }CCP (0x30 ); -w0 (pi->saved_r0); -w2 (pi->saved_r2); -} +w0 (pi->saved_r0); +w2 (pi->saved_r2); +}#define RESET_WAIT 200 -static int on26_test_port (struct pi_adapter *pi)/* hard reset */ +/* hard reset */ +static int on26_test_port (struct pi_adapter *pi) +{ +int i, m, d, x =0 , y =0 ; -{int i, m, d, x=0 , y=0 ; - - pi->saved_r0 =r0 (); - pi->saved_r2 =r2 (); - - d = pi->delay; - m = pi->mode; - pi->delay =5 ; - pi->mode =0 ; - -w2 (0xc ); - -CCP (0x30 );CCP (0 ); - -w0 (0xfe );w0 (0xaa );w0 (0x55 );w0 (0 );w0 (0xff ); - i = ((r1 () &0xf0 ) <<4 );w0 (0x87 ); - i |= (r1 () &0xf0 );w0 (0x78 ); -w0 (0x20 );w2 (4 );w2 (5 ); - i |= ((r1 () &0xf0 ) >>4 ); -w2 (4 );w0 (0xff ); - -if (i ==0xb5f ) { - -w0 (2 );P1 ;w0 (0 );P2 ; -w0 (3 );P1 ;w0 (0 );P2 ; -w0 (2 );P1 ;w0 (8 );P2 ;udelay (100 ); -w0 (2 );P1 ;w0 (0xa );P2 ;udelay (100 ); -w0 (2 );P1 ;w0 (8 );P2 ;udelay (1000 ); - -on26_write_regr (pi,0 ,6 ,0xa0 ); - -for (i=0 ;i<RESET_WAIT ;i++) { -on26_write_regr (pi,0 ,6 ,0xa0 ); - x =on26_read_regr (pi,0 ,7 ); -on26_write_regr (pi,0 ,6 ,0xb0 ); - y =on26_read_regr (pi,0 ,7 ); -if (!((x&0x80 )||(y&0x80 )))break ; -mdelay (100 ); - } - -if (i ==RESET_WAIT ) -dev_err (&pi->dev,"on26: Device reset failed (%x,%x)\n" , x, y); - -w0 (4 );P1 ;w0 (4 );P1 ; - } + pi->saved_r0 =r0 (); + pi->saved_r2 =r2 (); + + d = pi->delay; + m = pi->mode; + pi->delay =5 ; + pi->mode =0 ; + +w2 (0xc ); + +CCP (0x30 );CCP (0 ); + +w0 (0xfe );w0 (0xaa );w0 (0x55 );w0 (0 );w0 (0xff ); + i = ((r1 () &0xf0 ) <<4 );w0 (0x87 ); + i |= (r1 () &0xf0 );w0 (0x78 ); +w0 (0x20 );w2 (4 );w2 (5 ); + i |= ((r1 () &0xf0 ) >>4 ); +w2 (4 );w0 (0xff ); + +if (i ==0xb5f ) { +w0 (2 );P1 ;w0 (0 );P2 ; +w0 (3 );P1 ;w0 (0 );P2 ; +w0 (2 );P1 ;w0 (8 );P2 ;udelay (100 ); +w0 (2 );P1 ;w0 (0xa );P2 ;udelay (100 ); +w0 (2 );P1 ;w0 (8 );P2 ;udelay (1000 ); + +on26_write_regr (pi,0 ,6 ,0xa0 ); + +for (i =0 ; i <RESET_WAIT ; i++) { +on26_write_regr (pi,0 ,6 ,0xa0 ); + x =on26_read_regr (pi,0 ,7 ); +on26_write_regr (pi,0 ,6 ,0xb0 ); + y =on26_read_regr (pi,0 ,7 ); +if (!((x &0x80 ) || (y &0x80 ))) +break ; +mdelay (100 ); + } + +if (i ==RESET_WAIT ) +dev_err (&pi->dev, +"on26: Device reset failed (%x,%x)\n" , x, y); + +w0 (4 );P1 ;w0 (4 );P1 ; + } -CCP (0x30 ); +CCP (0x30 ); - pi->delay = d; - pi->mode = m; -w0 (pi->saved_r0); -w2 (pi->saved_r2); + pi->delay = d; + pi->mode = m; +w0 (pi->saved_r0); +w2 (pi->saved_r2); -return 5 ; +return 5 ; } -static void on26_read_block (struct pi_adapter *pi,char *buf,int count) +{ +int k, a, b; -{int k, a, b; - -switch (pi->mode) { - -case 0 :w0 (1 );P1 ;w0 (1 );P2 ;w0 (2 );P1 ;w0 (0x18 );P2 ;w0 (0 );P1 ; +switch (pi->mode) { +case 0 : +w0 (1 );P1 ;w0 (1 );P2 ;w0 (2 );P1 ;w0 (0x18 );P2 ;w0 (0 );P1 ;udelay (10 ); -for (k=0 ;k<count;k++) { -w2 (6 ); a =r1 (); -w2 (4 ); b =r1 (); - buf[k] =j44 (a,b); - } -w0 (2 );P1 ;w0 (8 );P2 ; -break ; - -case 1 :w0 (1 );P1 ;w0 (1 );P2 ;w0 (2 );P1 ;w0 (0x19 );P2 ;w0 (0 );P1 ; +for (k =0 ; k < count; k++) { +w2 (6 ); a =r1 (); +w2 (4 ); b =r1 (); + buf[k] =j44 (a, b); + } +w0 (2 );P1 ;w0 (8 );P2 ; +break ; +case 1 : +w0 (1 );P1 ;w0 (1 );P2 ;w0 (2 );P1 ;w0 (0x19 );P2 ;w0 (0 );P1 ; +udelay (10 ); +for (k =0 ; k < count /2 ; k++) { +w2 (0x26 ); buf[2 * k] =r0 (); +w2 (0x24 ); buf[2 * k +1 ] =r0 (); + } +w0 (2 );P1 ;w0 (9 );P2 ; +break ; +case 2 : +w3 (1 );w3 (1 );w2 (5 );w4 (1 );w2 (4 ); +w3 (0 );w3 (0 );w2 (0x24 ); +udelay (10 ); +for (k =0 ; k < count; k++) + buf[k] =r4 (); +w2 (4 ); +break ; +case 3 : +w3 (1 );w3 (1 );w2 (5 );w4 (1 );w2 (4 ); +w3 (0 );w3 (0 );w2 (0x24 );udelay (10 ); -for (k=0 ;k<count/2 ;k++) { -w2 (0x26 ); buf[2 *k] =r0 (); -w2 (0x24 ); buf[2 *k+1 ] =r0 (); - } -w0 (2 );P1 ;w0 (9 );P2 ; -break ; - -case 2 :w3 (1 );w3 (1 );w2 (5 );w4 (1 );w2 (4 ); +for (k =0 ; k < count /2 ; k++) + ((u16 *)buf)[k] =r4w (); +w2 (4 ); +break ; +case 4 : +w3 (1 );w3 (1 );w2 (5 );w4 (1 );w2 (4 );w3 (0 );w3 (0 );w2 (0x24 );udelay (10 ); -for (k=0 ;k<count;k++) buf[k] =r4 (); -w2 (4 ); -break ; - -case 3 :w3 (1 );w3 (1 );w2 (5 );w4 (1 );w2 (4 ); -w3 (0 );w3 (0 );w2 (0x24 ); -udelay (10 ); -for (k=0 ;k<count/2 ;k++) ((u16 *)buf)[k] =r4w (); -w2 (4 ); -break ; - -case 4 :w3 (1 );w3 (1 );w2 (5 );w4 (1 );w2 (4 ); -w3 (0 );w3 (0 );w2 (0x24 ); -udelay (10 ); -for (k=0 ;k<count/4 ;k++) ((u32 *)buf)[k] =r4l (); -w2 (4 ); -break ; - - } +for (k =0 ; k < count /4 ; k++) + ((u32 *)buf)[k] =r4l (); +w2 (4 ); +break ; + } }static void on26_write_block (struct pi_adapter *pi,char *buf,int count) - -{int k; - -switch (pi->mode) { - -case 0 : -case 1 :w0 (1 );P1 ;w0 (1 );P2 ; -w0 (2 );P1 ;w0 (0x18 +pi->mode);P2 ;w0 (0 );P1 ; +{ +int k; + +switch (pi->mode) { +case 0 : +case 1 : +w0 (1 );P1 ;w0 (1 );P2 ; +w0 (2 );P1 ;w0 (0x18 + pi->mode);P2 ;w0 (0 );P1 ;udelay (10 ); -for (k=0 ;k<count/2 ;k++) { -w2 (5 );w0 (buf[2 *k]); -w2 (7 );w0 (buf[2 *k+1 ]); - } -w2 (5 );w2 (4 ); -w0 (2 );P1 ;w0 (8 +pi->mode);P2 ; -break ; - -case 2 :w3 (1 );w3 (1 );w2 (5 );w4 (1 );w2 (4 ); +for (k =0 ; k < count /2 ; k++) { +w2 (5 );w0 (buf[2 * k]); +w2 (7 );w0 (buf[2 * k +1 ]); + } +w2 (5 );w2 (4 ); +w0 (2 );P1 ;w0 (8 + pi->mode);P2 ; +break ; +case 2 : +w3 (1 );w3 (1 );w2 (5 );w4 (1 );w2 (4 );w3 (0 );w3 (0 );w2 (0xc5 );udelay (10 ); -for (k=0 ;k<count;k++)w4 (buf[k]); +for (k =0 ; k < count; k++) +w4 (buf[k]);w2 (0xc4 ); -break ; - -case 3 :w3 (1 );w3 (1 );w2 (5 );w4 (1 );w2 (4 ); -w3 (0 );w3 (0 );w2 (0xc5 ); -udelay (10 ); -for (k=0 ;k<count/2 ;k++)w4w (((u16 *)buf)[k]); -w2 (0xc4 ); -break ; - -case 4 :w3 (1 );w3 (1 );w2 (5 );w4 (1 );w2 (4 ); -w3 (0 );w3 (0 );w2 (0xc5 ); -udelay (10 ); -for (k=0 ;k<count/4 ;k++)w4l (((u32 *)buf)[k]); -w2 (0xc4 ); -break ; - - } - +break ; +case 3 : +w3 (1 );w3 (1 );w2 (5 );w4 (1 );w2 (4 ); +w3 (0 );w3 (0 );w2 (0xc5 ); +udelay (10 ); +for (k =0 ; k < count /2 ; k++) +w4w (((u16 *)buf)[k]); +w2 (0xc4 ); +break ; +case 4 : +w3 (1 );w3 (1 );w2 (5 );w4 (1 );w2 (4 ); +w3 (0 );w3 (0 );w2 (0xc5 ); +udelay (10 ); +for (k =0 ; k < count /4 ; k++) +w4l (((u32 *)buf)[k]); +w2 (0xc4 ); +break ; + } }static void on26_log_adapter (struct pi_adapter *pi) +{ +char *mode_string[5 ] = {"4-bit" ,"8-bit" ,"EPP-8" ,"EPP-16" ,"EPP-32" }; -{char *mode_string[5 ] = {"4-bit" ,"8-bit" ,"EPP-8" , -"EPP-16" ,"EPP-32" }; - -dev_info (&pi->dev,"OnSpec 90c26 at 0x%x, mode %d (%s), delay %d\n" , - pi->port, pi->mode, mode_string[pi->mode], pi->delay); +dev_info (&pi->dev, +"OnSpec 90c26 at 0x%x, mode %d (%s), delay %d\n" , + pi->port, pi->mode, mode_string[pi->mode], pi->delay); }static struct pi_protocol on26 = {
Signature · 1 line
2.40.1