Skip to content

Commit 012f205

Browse files
committed
ata: pata_parport: Fix on20 module code indentation and style
Fix 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. Signed-off-by: Damien Le Moal <[email protected]>
1 parent ece68db commit 012f205

File tree

1 file changed

+82
-67
lines changed
  • drivers/ata/pata_parport

1 file changed

+82
-67
lines changed

drivers/ata/pata_parport/on20.c

Lines changed: 82 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
/*
2-
on20.c (c) 1996-8 Grant R. Guenther <[email protected]>
3-
Under the terms of the GNU General Public License.
4-
5-
on20.c is a low-level protocol driver for the
6-
Onspec 90c20 parallel to IDE adapter.
7-
*/
1+
// SPDX-License-Identifier: GPL-2.0-or-later
2+
/*
3+
* (c) 1996-1998 Grant R. Guenther <[email protected]>
4+
*
5+
* on20.c is a low-level protocol driver for the
6+
* Onspec 90c20 parallel to IDE adapter.
7+
*/
88

99
#include <linux/module.h>
1010
#include <linux/init.h>
@@ -15,99 +15,114 @@
1515
#include <asm/io.h>
1616
#include "pata_parport.h"
1717

18-
#define op(f) w2(4);w0(f);w2(5);w2(0xd);w2(5);w2(0xd);w2(5);w2(4);
19-
#define vl(v) w2(4);w0(v);w2(5);w2(7);w2(5);w2(4);
20-
21-
#define j44(a,b) (((a>>4)&0x0f)|(b&0xf0))
22-
23-
/* cont = 0 - access the IDE register file
24-
cont = 1 - access the IDE command set
25-
*/
26-
27-
static int on20_read_regr(struct pi_adapter *pi, int cont, int regr)
28-
29-
{ int h,l, r ;
18+
#define op(f) \
19+
do { \
20+
w2(4); w0(f); w2(5); w2(0xd); \
21+
w2(5); w2(0xd); w2(5); w2(4); \
22+
} while (0)
3023

31-
r = (regr<<2) + 1 + cont;
24+
#define vl(v) \
25+
do { \
26+
w2(4); w0(v); w2(5); \
27+
w2(7); w2(5); w2(4); \
28+
} while (0)
3229

33-
op(1); vl(r); op(0);
30+
#define j44(a, b) (((a >> 4) & 0x0f) | (b & 0xf0))
3431

35-
switch (pi->mode) {
36-
37-
case 0: w2(4); w2(6); l = r1();
38-
w2(4); w2(6); h = r1();
39-
w2(4); w2(6); w2(4); w2(6); w2(4);
40-
return j44(l,h);
41-
42-
case 1: w2(4); w2(0x26); r = r0();
43-
w2(4); w2(0x26); w2(4);
44-
return r;
32+
/*
33+
* cont = 0 - access the IDE register file
34+
* cont = 1 - access the IDE command set
35+
*/
4536

37+
static int on20_read_regr(struct pi_adapter *pi, int cont, int regr)
38+
{
39+
int h, l, r;
40+
41+
r = (regr << 2) + 1 + cont;
42+
43+
op(1); vl(r); op(0);
44+
45+
switch (pi->mode) {
46+
case 0:
47+
w2(4); w2(6); l = r1();
48+
w2(4); w2(6); h = r1();
49+
w2(4); w2(6); w2(4); w2(6); w2(4);
50+
return j44(l, h);
51+
case 1:
52+
w2(4); w2(0x26); r = r0();
53+
w2(4); w2(0x26); w2(4);
54+
return r;
4655
}
56+
4757
return -1;
48-
}
58+
}
4959

5060
static void on20_write_regr(struct pi_adapter *pi, int cont, int regr, int val)
61+
{
62+
int r = (regr << 2) + 1 + cont;
5163

52-
{ int r;
53-
54-
r = (regr<<2) + 1 + cont;
55-
56-
op(1); vl(r);
57-
op(0); vl(val);
64+
op(1); vl(r);
65+
op(0); vl(val);
5866
op(0); vl(val);
5967
}
6068

6169
static void on20_connect(struct pi_adapter *pi)
62-
63-
{ pi->saved_r0 = r0();
64-
pi->saved_r2 = r2();
65-
66-
w2(4);w0(0);w2(0xc);w2(4);w2(6);w2(4);w2(6);w2(4);
67-
if (pi->mode) { op(2); vl(8); op(2); vl(9); }
68-
else { op(2); vl(0); op(2); vl(8); }
70+
{
71+
pi->saved_r0 = r0();
72+
pi->saved_r2 = r2();
73+
74+
w2(4); w0(0); w2(0xc); w2(4); w2(6); w2(4); w2(6); w2(4);
75+
if (pi->mode) {
76+
op(2); vl(8); op(2); vl(9);
77+
} else {
78+
op(2); vl(0); op(2); vl(8);
79+
}
6980
}
7081

7182
static void on20_disconnect(struct pi_adapter *pi)
72-
73-
{ w2(4);w0(7);w2(4);w2(0xc);w2(4);
74-
w0(pi->saved_r0);
75-
w2(pi->saved_r2);
76-
}
83+
{
84+
w2(4); w0(7); w2(4); w2(0xc); w2(4);
85+
w0(pi->saved_r0);
86+
w2(pi->saved_r2);
87+
}
7788

7889
static void on20_read_block(struct pi_adapter *pi, char *buf, int count)
79-
80-
{ int k, l, h;
90+
{
91+
int k, l, h;
8192

8293
op(1); vl(1); op(0);
8394

84-
for (k=0;k<count;k++)
85-
if (pi->mode) {
86-
w2(4); w2(0x26); buf[k] = r0();
87-
} else {
88-
w2(6); l = r1(); w2(4);
89-
w2(6); h = r1(); w2(4);
90-
buf[k] = j44(l,h);
91-
}
95+
for (k = 0; k < count; k++) {
96+
if (pi->mode) {
97+
w2(4); w2(0x26); buf[k] = r0();
98+
} else {
99+
w2(6); l = r1(); w2(4);
100+
w2(6); h = r1(); w2(4);
101+
buf[k] = j44(l, h);
102+
}
103+
}
92104
w2(4);
93105
}
94106

95107
static void on20_write_block(struct pi_adapter *pi, char *buf, int count)
96-
97-
{ int k;
108+
{
109+
int k;
98110

99111
op(1); vl(1); op(0);
100112

101-
for (k=0;k<count;k++) { w2(5); w0(buf[k]); w2(7); }
113+
for (k = 0; k < count; k++) {
114+
w2(5); w0(buf[k]); w2(7);
115+
}
102116
w2(4);
103117
}
104118

105119
static void on20_log_adapter(struct pi_adapter *pi)
120+
{
121+
char *mode_string[2] = { "4-bit", "8-bit" };
106122

107-
{ char *mode_string[2] = {"4-bit","8-bit"};
108-
109-
dev_info(&pi->dev, "OnSpec 90c20 at 0x%x, mode %d (%s), delay %d\n",
110-
pi->port, pi->mode, mode_string[pi->mode], pi->delay);
123+
dev_info(&pi->dev,
124+
"OnSpec 90c20 at 0x%x, mode %d (%s), delay %d\n",
125+
pi->port, pi->mode, mode_string[pi->mode], pi->delay);
111126
}
112127

113128
static struct pi_protocol on20 = {

0 commit comments

Comments
 (0)