Skip to content

Commit bd91cbf

Browse files
committed
ata: pata_parport: Fix friq module code indentation and style
Fix 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. Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
1 parent 6b42711 commit bd91cbf

1 file changed

Lines changed: 150 additions & 142 deletions

File tree

  • drivers/ata/pata_parport

drivers/ata/pata_parport/friq.c

Lines changed: 150 additions & 142 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,23 @@
1-
/*
2-
friq.c (c) 1998 Grant R. Guenther <grant@torque.net>
3-
Under the terms of the GNU General Public License
4-
5-
friq.c is a low-level protocol driver for the Freecom "IQ"
6-
parallel port IDE adapter. Early versions of this adapter
7-
use the 'frpw' protocol.
8-
9-
Freecom uses this adapter in a battery powered external
10-
CD-ROM drive. It is also used in LS-120 drives by
11-
Maxell and Panasonic, and other devices.
12-
13-
The battery powered drive requires software support to
14-
control the power to the drive. This module enables the
15-
drive power when the high level driver (pcd) is loaded
16-
and disables it when the module is unloaded. Note, if
17-
the friq module is built in to the kernel, the power
18-
will never be switched off, so other means should be
19-
used to conserve battery power.
20-
21-
*/
1+
// SPDX-License-Identifier: GPL-2.0-or-later
2+
/*
3+
* (c) 1998 Grant R. Guenther <grant@torque.net>
4+
*
5+
* friq.c is a low-level protocol driver for the Freecom "IQ"
6+
* parallel port IDE adapter. Early versions of this adapter
7+
* use the 'frpw' protocol.
8+
*
9+
* Freecom uses this adapter in a battery powered external
10+
* CD-ROM drive. It is also used in LS-120 drives by
11+
* Maxell and Panasonic, and other devices.
12+
*
13+
* The battery powered drive requires software support to
14+
* control the power to the drive. This module enables the
15+
* drive power when the high level driver (pcd) is loaded
16+
* and disables it when the module is unloaded. Note, if
17+
* the friq module is built in to the kernel, the power
18+
* will never be switched off, so other means should be
19+
* used to conserve battery power.
20+
*/
2221

2322
#include <linux/module.h>
2423
#include <linux/init.h>
@@ -29,197 +28,206 @@
2928
#include <asm/io.h>
3029
#include "pata_parport.h"
3130

32-
#define CMD(x) w2(4);w0(0xff);w0(0xff);w0(0x73);w0(0x73);\
33-
w0(0xc9);w0(0xc9);w0(0x26);w0(0x26);w0(x);w0(x);
31+
#define CMD(x) \
32+
do { \
33+
w2(4); w0(0xff); w0(0xff); w0(0x73); w0(0x73); \
34+
w0(0xc9); w0(0xc9); w0(0x26); \
35+
w0(0x26); w0(x); w0(x); \
36+
} while (0)
3437

35-
#define j44(l,h) (((l>>4)&0x0f)|(h&0xf0))
38+
#define j44(l, h) (((l >> 4) & 0x0f) | (h & 0xf0))
3639

37-
/* cont = 0 - access the IDE register file
38-
cont = 1 - access the IDE command set
39-
*/
40-
41-
static int cont_map[2] = { 0x08, 0x10 };
40+
/*
41+
* cont = 0 - access the IDE register file
42+
* cont = 1 - access the IDE command set
43+
*/
44+
static int cont_map[2] = { 0x08, 0x10 };
4245

4346
static int friq_read_regr(struct pi_adapter *pi, int cont, int regr)
44-
45-
{ int h,l,r;
47+
{
48+
int h, l, r;
4649

4750
r = regr + cont_map[cont];
4851

4952
CMD(r);
5053
w2(6); l = r1();
5154
w2(4); h = r1();
52-
w2(4);
53-
54-
return j44(l,h);
55+
w2(4);
5556

57+
return j44(l, h);
5658
}
5759

5860
static void friq_write_regr(struct pi_adapter *pi, int cont, int regr, int val)
59-
60-
{ int r;
61-
62-
r = regr + cont_map[cont];
61+
{
62+
int r = regr + cont_map[cont];
6363

6464
CMD(r);
6565
w0(val);
66-
w2(5);w2(7);w2(5);w2(4);
66+
w2(5); w2(7); w2(5); w2(4);
6767
}
6868

6969
static void friq_read_block_int(struct pi_adapter *pi, char *buf, int count, int regr)
70+
{
71+
int h, l, k, ph;
7072

71-
{ int h, l, k, ph;
72-
73-
switch(pi->mode) {
74-
75-
case 0: CMD(regr);
76-
for (k=0;k<count;k++) {
77-
w2(6); l = r1();
78-
w2(4); h = r1();
79-
buf[k] = j44(l,h);
80-
}
81-
w2(4);
82-
break;
83-
84-
case 1: ph = 2;
85-
CMD(regr+0xc0);
86-
w0(0xff);
87-
for (k=0;k<count;k++) {
88-
w2(0xa4 + ph);
89-
buf[k] = r0();
90-
ph = 2 - ph;
91-
}
92-
w2(0xac); w2(0xa4); w2(4);
93-
break;
94-
95-
case 2: CMD(regr+0x80);
96-
for (k=0;k<count-2;k++) buf[k] = r4();
73+
switch (pi->mode) {
74+
case 0:
75+
CMD(regr);
76+
for (k = 0; k < count; k++) {
77+
w2(6); l = r1();
78+
w2(4); h = r1();
79+
buf[k] = j44(l, h);
80+
}
81+
w2(4);
82+
break;
83+
case 1:
84+
ph = 2;
85+
CMD(regr + 0xc0);
86+
w0(0xff);
87+
for (k = 0; k < count; k++) {
88+
w2(0xa4 + ph);
89+
buf[k] = r0();
90+
ph = 2 - ph;
91+
}
92+
w2(0xac); w2(0xa4); w2(4);
93+
break;
94+
case 2:
95+
CMD(regr + 0x80);
96+
for (k = 0; k < count - 2; k++)
97+
buf[k] = r4();
9798
w2(0xac); w2(0xa4);
98-
buf[count-2] = r4();
99-
buf[count-1] = r4();
99+
buf[count - 2] = r4();
100+
buf[count - 1] = r4();
100101
w2(4);
101102
break;
102-
103-
case 3: CMD(regr+0x80);
104-
for (k=0;k<(count/2)-1;k++) ((u16 *)buf)[k] = r4w();
105-
w2(0xac); w2(0xa4);
106-
buf[count-2] = r4();
107-
buf[count-1] = r4();
108-
w2(4);
109-
break;
110-
111-
case 4: CMD(regr+0x80);
112-
for (k=0;k<(count/4)-1;k++) ((u32 *)buf)[k] = r4l();
113-
buf[count-4] = r4();
114-
buf[count-3] = r4();
115-
w2(0xac); w2(0xa4);
116-
buf[count-2] = r4();
117-
buf[count-1] = r4();
118-
w2(4);
119-
break;
120-
121-
}
103+
case 3:
104+
CMD(regr + 0x80);
105+
for (k = 0; k < count / 2 - 1; k++)
106+
((u16 *)buf)[k] = r4w();
107+
w2(0xac); w2(0xa4);
108+
buf[count - 2] = r4();
109+
buf[count - 1] = r4();
110+
w2(4);
111+
break;
112+
case 4:
113+
CMD(regr + 0x80);
114+
for (k = 0; k < count / 4 - 1; k++)
115+
((u32 *)buf)[k] = r4l();
116+
buf[count - 4] = r4();
117+
buf[count - 3] = r4();
118+
w2(0xac); w2(0xa4);
119+
buf[count - 2] = r4();
120+
buf[count - 1] = r4();
121+
w2(4);
122+
break;
123+
}
122124
}
123125

124126
static void friq_read_block(struct pi_adapter *pi, char *buf, int count)
125-
126-
{ friq_read_block_int(pi,buf,count,0x08);
127+
{
128+
friq_read_block_int(pi, buf, count, 0x08);
127129
}
128130

129131
static void friq_write_block(struct pi_adapter *pi, char *buf, int count)
130-
131-
{ int k;
132-
133-
switch(pi->mode) {
132+
{
133+
int k;
134134

135+
switch (pi->mode) {
135136
case 0:
136-
case 1: CMD(8); w2(5);
137-
for (k=0;k<count;k++) {
137+
case 1:
138+
CMD(8); w2(5);
139+
for (k = 0; k < count; k++) {
138140
w0(buf[k]);
139-
w2(7);w2(5);
141+
w2(7); w2(5);
140142
}
141143
w2(4);
142144
break;
143-
144-
case 2: CMD(0xc8); w2(5);
145-
for (k=0;k<count;k++) w4(buf[k]);
145+
case 2:
146+
CMD(0xc8); w2(5);
147+
for (k = 0; k < count; k++)
148+
w4(buf[k]);
149+
w2(4);
150+
break;
151+
case 3:
152+
CMD(0xc8); w2(5);
153+
for (k = 0; k < count / 2; k++)
154+
w4w(((u16 *)buf)[k]);
155+
w2(4);
156+
break;
157+
case 4:
158+
CMD(0xc8); w2(5);
159+
for (k = 0; k < count / 4; k++)
160+
w4l(((u32 *)buf)[k]);
146161
w2(4);
147162
break;
148-
149-
case 3: CMD(0xc8); w2(5);
150-
for (k=0;k<count/2;k++) w4w(((u16 *)buf)[k]);
151-
w2(4);
152-
break;
153-
154-
case 4: CMD(0xc8); w2(5);
155-
for (k=0;k<count/4;k++) w4l(((u32 *)buf)[k]);
156-
w2(4);
157-
break;
158-
}
163+
}
159164
}
160165

161166
static void friq_connect(struct pi_adapter *pi)
162-
163-
{ pi->saved_r0 = r0();
164-
pi->saved_r2 = r2();
167+
{
168+
pi->saved_r0 = r0();
169+
pi->saved_r2 = r2();
165170
w2(4);
166171
}
167172

168173
static void friq_disconnect(struct pi_adapter *pi)
169-
170-
{ CMD(0x20);
174+
{
175+
CMD(0x20);
171176
w0(pi->saved_r0);
172-
w2(pi->saved_r2);
173-
}
177+
w2(pi->saved_r2);
178+
}
174179

175180
static int friq_test_proto(struct pi_adapter *pi)
176-
177-
{ int j, k, r;
178-
int e[2] = {0,0};
181+
{
182+
int j, k, r;
183+
int e[2] = { 0, 0 };
179184
char scratch[512];
180185

181-
pi->saved_r0 = r0();
186+
pi->saved_r0 = r0();
182187
w0(0xff); udelay(20); CMD(0x3d); /* turn the power on */
183188
udelay(500);
184189
w0(pi->saved_r0);
185190

186191
friq_connect(pi);
187-
for (j=0;j<2;j++) {
188-
friq_write_regr(pi,0,6,0xa0+j*0x10);
189-
for (k=0;k<256;k++) {
190-
friq_write_regr(pi,0,2,k^0xaa);
191-
friq_write_regr(pi,0,3,k^0x55);
192-
if (friq_read_regr(pi,0,2) != (k^0xaa)) e[j]++;
193-
}
194-
}
192+
for (j = 0; j < 2; j++) {
193+
friq_write_regr(pi, 0, 6, 0xa0 + j * 0x10);
194+
for (k = 0; k < 256; k++) {
195+
friq_write_regr(pi, 0, 2, k ^ 0xaa);
196+
friq_write_regr(pi, 0, 3, k ^ 0x55);
197+
if (friq_read_regr(pi, 0, 2) != (k ^ 0xaa))
198+
e[j]++;
199+
}
200+
}
195201
friq_disconnect(pi);
196202

197203
friq_connect(pi);
198-
friq_read_block_int(pi,scratch,512,0x10);
199-
r = 0;
200-
for (k=0;k<128;k++) if (scratch[k] != k) r++;
204+
friq_read_block_int(pi, scratch, 512, 0x10);
205+
r = 0;
206+
for (k = 0; k < 128; k++) {
207+
if (scratch[k] != k)
208+
r++;
209+
}
201210
friq_disconnect(pi);
202211

203-
dev_dbg(&pi->dev, "friq: port 0x%x, mode %d, test=(%d,%d,%d)\n",
204-
pi->port, pi->mode, e[0], e[1], r);
212+
dev_dbg(&pi->dev,
213+
"friq: port 0x%x, mode %d, test=(%d,%d,%d)\n",
214+
pi->port, pi->mode, e[0], e[1], r);
205215

206-
return (r || (e[0] && e[1]));
216+
return r || (e[0] && e[1]);
207217
}
208218

209-
210219
static void friq_log_adapter(struct pi_adapter *pi)
220+
{
221+
char *mode_string[6] = { "4-bit", "8-bit", "EPP-8", "EPP-16", "EPP-32"};
211222

212-
{ char *mode_string[6] = {"4-bit","8-bit",
213-
"EPP-8","EPP-16","EPP-32"};
214-
215-
dev_info(&pi->dev, "Freecom IQ ASIC-2 adapter at 0x%x, mode %d (%s), delay %d\n",
216-
pi->port, pi->mode, mode_string[pi->mode], pi->delay);
223+
dev_info(&pi->dev,
224+
"Freecom IQ ASIC-2 adapter at 0x%x, mode %d (%s), delay %d\n",
225+
pi->port, pi->mode, mode_string[pi->mode], pi->delay);
217226

218227
pi->private = 1;
219228
friq_connect(pi);
220229
CMD(0x9e); /* disable sleep timer */
221230
friq_disconnect(pi);
222-
223231
}
224232

225233
static void friq_release_proto(struct pi_adapter *pi)

0 commit comments

Comments
 (0)