From: Atsushi Nemoto Date: Sun, 2 Nov 2008 20:40:10 +0000 (+0100) Subject: tx4938ide: Avoid underflow on calculation of a wait cycle X-Git-Tag: v2.6.28-rc3~1^2~1 X-Git-Url: http://pilppa.com/gitweb/?a=commitdiff_plain;h=7afa05350c42d8427f2d8f6112b64ab0812f3289;p=linux-2.6-omap-h63xx.git tx4938ide: Avoid underflow on calculation of a wait cycle Make 'wt' variable signed while it can be negative during calculation. Suggested-by: Sergei Shtylyov Signed-off-by: Atsushi Nemoto Cc: sshtylyov@ru.mvista.com Signed-off-by: Bartlomiej Zolnierkiewicz --- diff --git a/drivers/ide/tx4938ide.c b/drivers/ide/tx4938ide.c index 796289cf97e..9120063e8f8 100644 --- a/drivers/ide/tx4938ide.c +++ b/drivers/ide/tx4938ide.c @@ -26,12 +26,13 @@ static void tx4938ide_tune_ebusc(unsigned int ebus_ch, unsigned int sp = (cr >> 4) & 3; unsigned int clock = gbus_clock / (4 - sp); unsigned int cycle = 1000000000 / clock; - unsigned int wt, shwt; + unsigned int shwt; + int wt; /* Minimum DIOx- active time */ wt = DIV_ROUND_UP(t->act8b, cycle) - 2; /* IORDY setup time: 35ns */ - wt = max(wt, DIV_ROUND_UP(35, cycle)); + wt = max_t(int, wt, DIV_ROUND_UP(35, cycle)); /* actual wait-cycle is max(wt & ~1, 1) */ if (wt > 2 && (wt & 1)) wt++;