Skip to content

Commit 2c139e7

Browse files
committed
ide: checkpatch.pl fixes for ide-timing.h
Also fix placement of comments in ide_timing_compute() while at it. There should be no functional changes caused by this patch (md5sum was verified to be the same before/after the patch). Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com> Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
1 parent bd887f7 commit 2c139e7

1 file changed

Lines changed: 48 additions & 45 deletions

File tree

‎drivers/ide/ide-timing.h‎

Lines changed: 48 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33

44
/*
55
* Copyright (c) 1999-2001 Vojtech Pavlik
6-
*/
7-
8-
/*
6+
*
97
* This program is free software; you can redistribute it and/or modify
108
* it under the terms of the GNU General Public License as published by
119
* the Free Software Foundation; either version 2 of the License, or
@@ -32,7 +30,7 @@
3230
* PIO 0-5, MWDMA 0-2 and UDMA 0-6 timings (in nanoseconds).
3331
* These were taken from ATA/ATAPI-6 standard, rev 0a, except
3432
* for PIO 5, which is a nonstandard extension and UDMA6, which
35-
* is currently supported only by Maxtor drives.
33+
* is currently supported only by Maxtor drives.
3634
*/
3735

3836
static struct ide_timing ide_timing[] = {
@@ -67,10 +65,11 @@ static struct ide_timing ide_timing[] = {
6765
{ 0xff }
6866
};
6967

70-
#define ENOUGH(v,unit) (((v)-1)/(unit)+1)
71-
#define EZ(v,unit) ((v)?ENOUGH(v,unit):0)
68+
#define ENOUGH(v, unit) (((v) - 1) / (unit) + 1)
69+
#define EZ(v, unit) ((v) ? ENOUGH(v, unit) : 0)
7270

73-
static void ide_timing_quantize(struct ide_timing *t, struct ide_timing *q, int T, int UT)
71+
static void ide_timing_quantize(struct ide_timing *t, struct ide_timing *q,
72+
int T, int UT)
7473
{
7574
q->setup = EZ(t->setup * 1000, T);
7675
q->act8b = EZ(t->act8b * 1000, T);
@@ -82,16 +81,25 @@ static void ide_timing_quantize(struct ide_timing *t, struct ide_timing *q, int
8281
q->udma = EZ(t->udma * 1000, UT);
8382
}
8483

85-
static void ide_timing_merge(struct ide_timing *a, struct ide_timing *b, struct ide_timing *m, unsigned int what)
84+
static void ide_timing_merge(struct ide_timing *a, struct ide_timing *b,
85+
struct ide_timing *m, unsigned int what)
8686
{
87-
if (what & IDE_TIMING_SETUP ) m->setup = max(a->setup, b->setup);
88-
if (what & IDE_TIMING_ACT8B ) m->act8b = max(a->act8b, b->act8b);
89-
if (what & IDE_TIMING_REC8B ) m->rec8b = max(a->rec8b, b->rec8b);
90-
if (what & IDE_TIMING_CYC8B ) m->cyc8b = max(a->cyc8b, b->cyc8b);
91-
if (what & IDE_TIMING_ACTIVE ) m->active = max(a->active, b->active);
92-
if (what & IDE_TIMING_RECOVER) m->recover = max(a->recover, b->recover);
93-
if (what & IDE_TIMING_CYCLE ) m->cycle = max(a->cycle, b->cycle);
94-
if (what & IDE_TIMING_UDMA ) m->udma = max(a->udma, b->udma);
87+
if (what & IDE_TIMING_SETUP)
88+
m->setup = max(a->setup, b->setup);
89+
if (what & IDE_TIMING_ACT8B)
90+
m->act8b = max(a->act8b, b->act8b);
91+
if (what & IDE_TIMING_REC8B)
92+
m->rec8b = max(a->rec8b, b->rec8b);
93+
if (what & IDE_TIMING_CYC8B)
94+
m->cyc8b = max(a->cyc8b, b->cyc8b);
95+
if (what & IDE_TIMING_ACTIVE)
96+
m->active = max(a->active, b->active);
97+
if (what & IDE_TIMING_RECOVER)
98+
m->recover = max(a->recover, b->recover);
99+
if (what & IDE_TIMING_CYCLE)
100+
m->cycle = max(a->cycle, b->cycle);
101+
if (what & IDE_TIMING_UDMA)
102+
m->udma = max(a->udma, b->udma);
95103
}
96104

97105
static struct ide_timing *ide_timing_find_mode(u8 speed)
@@ -101,7 +109,7 @@ static struct ide_timing *ide_timing_find_mode(u8 speed)
101109
for (t = ide_timing; t->mode != speed; t++)
102110
if (t->mode == 0xff)
103111
return NULL;
104-
return t;
112+
return t;
105113
}
106114

107115
static int ide_timing_compute(ide_drive_t *drive, u8 speed,
@@ -110,24 +118,22 @@ static int ide_timing_compute(ide_drive_t *drive, u8 speed,
110118
struct hd_driveid *id = drive->id;
111119
struct ide_timing *s, p;
112120

113-
/*
114-
* Find the mode.
115-
*/
116-
117-
if (!(s = ide_timing_find_mode(speed)))
121+
/*
122+
* Find the mode.
123+
*/
124+
s = ide_timing_find_mode(speed);
125+
if (s == NULL)
118126
return -EINVAL;
119127

120-
/*
121-
* Copy the timing from the table.
122-
*/
123-
128+
/*
129+
* Copy the timing from the table.
130+
*/
124131
*t = *s;
125132

126-
/*
127-
* If the drive is an EIDE drive, it can tell us it needs extended
128-
* PIO/MWDMA cycle timing.
129-
*/
130-
133+
/*
134+
* If the drive is an EIDE drive, it can tell us it needs extended
135+
* PIO/MWDMA cycle timing.
136+
*/
131137
if (id && id->field_valid & 2) { /* EIDE drive */
132138

133139
memset(&p, 0, sizeof(p));
@@ -142,28 +148,25 @@ static int ide_timing_compute(ide_drive_t *drive, u8 speed,
142148
ide_timing_merge(&p, t, t, IDE_TIMING_CYCLE | IDE_TIMING_CYC8B);
143149
}
144150

145-
/*
146-
* Convert the timing to bus clock counts.
147-
*/
148-
151+
/*
152+
* Convert the timing to bus clock counts.
153+
*/
149154
ide_timing_quantize(t, t, T, UT);
150155

151-
/*
152-
* Even in DMA/UDMA modes we still use PIO access for IDENTIFY, S.M.A.R.T
153-
* and some other commands. We have to ensure that the DMA cycle timing is
154-
* slower/equal than the fastest PIO timing.
155-
*/
156-
156+
/*
157+
* Even in DMA/UDMA modes we still use PIO access for IDENTIFY,
158+
* S.M.A.R.T and some other commands. We have to ensure that the
159+
* DMA cycle timing is slower/equal than the fastest PIO timing.
160+
*/
157161
if (speed >= XFER_SW_DMA_0) {
158162
u8 pio = ide_get_best_pio_mode(drive, 255, 5);
159163
ide_timing_compute(drive, XFER_PIO_0 + pio, &p, T, UT);
160164
ide_timing_merge(&p, t, t, IDE_TIMING_ALL);
161165
}
162166

163-
/*
164-
* Lengthen active & recovery time so that cycle time is correct.
165-
*/
166-
167+
/*
168+
* Lengthen active & recovery time so that cycle time is correct.
169+
*/
167170
if (t->act8b + t->rec8b < t->cyc8b) {
168171
t->act8b += (t->cyc8b - (t->act8b + t->rec8b)) / 2;
169172
t->rec8b = t->cyc8b - t->act8b;

0 commit comments

Comments
 (0)