linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vojtech Pavlik <vojtech@suse.cz>
To: Clemens Buchacher <drizzd@aon.at>, B.Zolnierkiewicz@elka.pw.edu.pl
Cc: Linux-ide list <linux-ide@vger.kernel.org>,
	kernel janitors list <kernel-janitors@lists.osdl.org>
Subject: [Kernel-janitors] Re: [patch] MIN/MAX in ide-timing.h
Date: Thu, 29 Jul 2004 16:48:09 +0200	[thread overview]
Message-ID: <20040729144809.GP19452@ucw.cz> (raw)
In-Reply-To: <20040710224329.GF1991@moley.homelinux.net>

[-- Attachment #1: Type: text/plain, Size: 2723 bytes --]

On Sun, Jul 11, 2004 at 12:43:29AM +0200, Clemens Buchacher wrote:

> On Sat, Jul 10, 2004 at 04:03:37PM +0200, Vojtech Pavlik wrote:
> > How about if you used the "min_t" and "max_t" macros inside FIT? That
> > could help get rid of the casts completely (assuming the second and
> > third parameters to FIT are expected to be constants).
> 
> Yes, that's better. It reduces the necessary changes to a minimum.

Bartolomiej, please apply this patch. Thanks.

diff -Nur a/drivers/ide/ide-timing.h b/drivers/ide/ide-timing.h
--- a/drivers/ide/ide-timing.h	2004-07-11 00:27:38 +02:00
+++ b/drivers/ide/ide-timing.h	2004-07-11 00:27:01 +02:00
@@ -27,6 +27,7 @@
  * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic
  */
 
+#include <linux/kernel.h>
 #include <linux/hdreg.h>
 
 #define XFER_PIO_5		0x0d
@@ -96,11 +97,9 @@
 #define IDE_TIMING_UDMA		0x80
 #define IDE_TIMING_ALL		0xff
 
-#define MIN(a,b)	((a)<(b)?(a):(b))
-#define MAX(a,b)	((a)>(b)?(a):(b))
-#define FIT(v,min,max)	MAX(MIN(v,max),min)
-#define ENOUGH(v,unit)	(((v)-1)/(unit)+1)
-#define EZ(v,unit)	((v)?ENOUGH(v,unit):0)
+#define FIT(v,vmin,vmax)	max_t(short,min_t(short,v,vmax),vmin)
+#define ENOUGH(v,unit)		(((v)-1)/(unit)+1)
+#define EZ(v,unit)		((v)?ENOUGH(v,unit):0)
 
 #define XFER_MODE	0xf0
 #define XFER_UDMA_133	0x48
@@ -188,14 +187,14 @@
 
 static void ide_timing_merge(struct ide_timing *a, struct ide_timing *b, struct ide_timing *m, unsigned int what)
 {
-	if (what & IDE_TIMING_SETUP  ) m->setup   = MAX(a->setup,   b->setup);
-	if (what & IDE_TIMING_ACT8B  ) m->act8b   = MAX(a->act8b,   b->act8b);
-	if (what & IDE_TIMING_REC8B  ) m->rec8b   = MAX(a->rec8b,   b->rec8b);
-	if (what & IDE_TIMING_CYC8B  ) m->cyc8b   = MAX(a->cyc8b,   b->cyc8b);
-	if (what & IDE_TIMING_ACTIVE ) m->active  = MAX(a->active,  b->active);
-	if (what & IDE_TIMING_RECOVER) m->recover = MAX(a->recover, b->recover);
-	if (what & IDE_TIMING_CYCLE  ) m->cycle   = MAX(a->cycle,   b->cycle);
-	if (what & IDE_TIMING_UDMA   ) m->udma    = MAX(a->udma,    b->udma);
+	if (what & IDE_TIMING_SETUP  ) m->setup   = max(a->setup,   b->setup);
+	if (what & IDE_TIMING_ACT8B  ) m->act8b   = max(a->act8b,   b->act8b);
+	if (what & IDE_TIMING_REC8B  ) m->rec8b   = max(a->rec8b,   b->rec8b);
+	if (what & IDE_TIMING_CYC8B  ) m->cyc8b   = max(a->cyc8b,   b->cyc8b);
+	if (what & IDE_TIMING_ACTIVE ) m->active  = max(a->active,  b->active);
+	if (what & IDE_TIMING_RECOVER) m->recover = max(a->recover, b->recover);
+	if (what & IDE_TIMING_CYCLE  ) m->cycle   = max(a->cycle,   b->cycle);
+	if (what & IDE_TIMING_UDMA   ) m->udma    = max(a->udma,    b->udma);
 }
 
 static struct ide_timing* ide_timing_find_mode(short speed)

--  
Vojtech Pavlik
SuSE Labs, SuSE CR

[-- Attachment #2: Type: text/plain, Size: 167 bytes --]

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
http://lists.osdl.org/mailman/listinfo/kernel-janitors

      reply	other threads:[~2004-07-29 14:48 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-07-08 18:18 [patch] MIN/MAX in ide-timing.h Clemens Buchacher
2004-07-10 13:55 ` [Kernel-janitors] " Luiz Fernando N. Capitulino
2004-07-11  9:12   ` Clemens Buchacher
2004-07-11 13:09     ` Luiz Fernando N. Capitulino
2004-07-10 14:03 ` Vojtech Pavlik
2004-07-10 22:43   ` Clemens Buchacher
2004-07-29 14:48     ` Vojtech Pavlik [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040729144809.GP19452@ucw.cz \
    --to=vojtech@suse.cz \
    --cc=B.Zolnierkiewicz@elka.pw.edu.pl \
    --cc=drizzd@aon.at \
    --cc=kernel-janitors@lists.osdl.org \
    --cc=linux-ide@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).