* [PATCH] Use "safe" Linux min() macro in Linux 2.2, 2.4
@ 2002-10-06 23:00 Chris Rankin
2002-10-07 9:44 ` Takashi Iwai
0 siblings, 1 reply; 2+ messages in thread
From: Chris Rankin @ 2002-10-06 23:00 UTC (permalink / raw)
To: alsa-devel; +Cc: perex
Hi,
I have modified the SoundScape (proto-)driver to use the typesafe Linux min() macro, defining
the macro if it hasn't been declared already. (This is compatibility for Linux 2.2.) In fact, it turns
out that both min() and ARRAY_SIZE() are declared in include/linux/kernel.h and so I suppose
that both these macros are candidates for putting in adriver.h instead.
Cheers,
Chris
Index: alsa-driver/isa/sscape.c
===================================================================
RCS file: /cvsroot/alsa/alsa-driver/isa/sscape.c,v
retrieving revision 1.6
diff -u -u -r1.6 sscape.c
--- alsa-driver/isa/sscape.c 4 Oct 2002 12:45:16 -0000 1.6
+++ alsa-driver/isa/sscape.c 6 Oct 2002 22:55:41 -0000
@@ -72,6 +72,18 @@
# define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
#endif
+#ifndef min
+ /*
+ * This macro copied from the include/linux/kernel.h file
+ * for compatibility with earlier kernels.
+ */
+# define min(x,y) ({ \
+ const typeof(x) _x = (x); \
+ const typeof(y) _y = (y); \
+ (void) (&_x == &_y); \
+ _x < _y ? _x : _y; })
+#endif
+
#define MPU401_IO(i) ((i) + 0)
#define MIDI_DATA_IO(i) ((i) + 0)
#define MIDI_CTRL_IO(i) ((i) + 1)
@@ -435,8 +447,8 @@
* Upload a byte-stream into the SoundScape using DMA channel A.
*/
static int upload_dma_data(struct soundscape *s,
- const unsigned char *data, unsigned long size,
- unsigned long dmasize)
+ const unsigned char *data, unsigned long size,
+ unsigned long dmasize)
{
unsigned long flags;
struct dmabuf dma;
@@ -471,7 +483,7 @@
while (size != 0) {
unsigned long len;
- len = size < dma.size ? size : dma.size;
+ len = min(size, dma.size);
/*
* Remember that the data that we want to DMA
@@ -517,7 +529,7 @@
ret = -EAGAIN;
}
- _release_dma:
+ _release_dma:
/*
* NOTE!!! We are NOT holding any spinlocks at this point !!!
*/
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] Use "safe" Linux min() macro in Linux 2.2, 2.4
2002-10-06 23:00 [PATCH] Use "safe" Linux min() macro in Linux 2.2, 2.4 Chris Rankin
@ 2002-10-07 9:44 ` Takashi Iwai
0 siblings, 0 replies; 2+ messages in thread
From: Takashi Iwai @ 2002-10-07 9:44 UTC (permalink / raw)
To: Chris Rankin; +Cc: alsa-devel, perex
At Mon, 7 Oct 2002 00:00:33 +0100 (BST),
Chris Rankin wrote:
>
> Hi,
>
> I have modified the SoundScape (proto-)driver to use the typesafe Linux min() macro, defining
> the macro if it hasn't been declared already. (This is compatibility for Linux 2.2.) In fact, it turns
> out that both min() and ARRAY_SIZE() are declared in include/linux/kernel.h and so I suppose
> that both these macros are candidates for putting in adriver.h instead.
ah, regarding min(), i already replaced it with a simple if statement
for 2.2 kernel at friday, because there is only one place it's used.
yes, the macros should go into adriver.h.
once when these macro are there, i'll take the original code back.
thanks,
Takashi
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2002-10-07 9:44 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-10-06 23:00 [PATCH] Use "safe" Linux min() macro in Linux 2.2, 2.4 Chris Rankin
2002-10-07 9:44 ` Takashi Iwai
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.