diff options
author | Atsushi Nemoto <anemo@mba.ocn.ne.jp> | 2008-11-02 15:40:10 -0500 |
---|---|---|
committer | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-11-02 15:40:10 -0500 |
commit | 7afa05350c42d8427f2d8f6112b64ab0812f3289 (patch) | |
tree | 07a972ee758fa975dc4f524df6e3f37628938255 /drivers/ide | |
parent | 9d4eb0a33e620a85e36f66cf895d2bea6d556eac (diff) |
tx4938ide: Avoid underflow on calculation of a wait cycle
Make 'wt' variable signed while it can be negative during calculation.
Suggested-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Cc: sshtylyov@ru.mvista.com
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide')
-rw-r--r-- | drivers/ide/tx4938ide.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/ide/tx4938ide.c b/drivers/ide/tx4938ide.c index 796289cf97e0..9120063e8f87 100644 --- a/drivers/ide/tx4938ide.c +++ b/drivers/ide/tx4938ide.c | |||
@@ -26,12 +26,13 @@ static void tx4938ide_tune_ebusc(unsigned int ebus_ch, | |||
26 | unsigned int sp = (cr >> 4) & 3; | 26 | unsigned int sp = (cr >> 4) & 3; |
27 | unsigned int clock = gbus_clock / (4 - sp); | 27 | unsigned int clock = gbus_clock / (4 - sp); |
28 | unsigned int cycle = 1000000000 / clock; | 28 | unsigned int cycle = 1000000000 / clock; |
29 | unsigned int wt, shwt; | 29 | unsigned int shwt; |
30 | int wt; | ||
30 | 31 | ||
31 | /* Minimum DIOx- active time */ | 32 | /* Minimum DIOx- active time */ |
32 | wt = DIV_ROUND_UP(t->act8b, cycle) - 2; | 33 | wt = DIV_ROUND_UP(t->act8b, cycle) - 2; |
33 | /* IORDY setup time: 35ns */ | 34 | /* IORDY setup time: 35ns */ |
34 | wt = max(wt, DIV_ROUND_UP(35, cycle)); | 35 | wt = max_t(int, wt, DIV_ROUND_UP(35, cycle)); |
35 | /* actual wait-cycle is max(wt & ~1, 1) */ | 36 | /* actual wait-cycle is max(wt & ~1, 1) */ |
36 | if (wt > 2 && (wt & 1)) | 37 | if (wt > 2 && (wt & 1)) |
37 | wt++; | 38 | wt++; |