Skip to contentSkip to conversation

unify DMA_..BIT_MASK definitions

PATCH In review Borislav Petkov 2 participants 4 messages Sep 17, 2007 DMA mapping helpers

lore
Share & tools
lore
#0 lore raw

cover unify DMA_..BIT_MASK definitions

This patches remove redundant DMA_..BIT_MASK definitions across two drivers. First off, consolidate dma bitmask definitions in the proper header file...

--

include/linux/dma-mapping.h renamed from include/linux/dma-mapping.h.orig +1 -0
Index: 23-rc6/include/linux/dma-mapping.h
===================================================================
@@ -17,6 +17,7 @@
 #define DMA_48BIT_MASK	0x0000ffffffffffffULL
 #define DMA_40BIT_MASK	0x000000ffffffffffULL
 #define DMA_39BIT_MASK	0x0000007fffffffffULL
+#define DMA_35BIT_MASK	0x00000007ffffffffULL
 #define DMA_32BIT_MASK	0x00000000ffffffffULL
 #define DMA_31BIT_MASK	0x000000007fffffffULL
 #define DMA_30BIT_MASK	0x000000003fffffffULL
Signature · 2 lines
Regards/Gruß,
    Boris.
#1 lore raw
Quoted 12 lines · Borislav Petkov

This patches remove redundant DMA_..BIT_MASK definitions across two drivers. First off, consolidate dma bitmask definitions in the proper header file...

--
Index: 23-rc6/include/linux/dma-mapping.h
===================================================================

include/linux/dma-mapping.h line 23

Quoted 7 lines
include/linux/dma-mapping.h renamed from include/linux/dma-mapping.h.orig +1 -0
@@ -17,6 +17,7 @@
 #define DMA_48BIT_MASK	0x0000ffffffffffffULL
 #define DMA_40BIT_MASK	0x000000ffffffffffULL
 #define DMA_39BIT_MASK	0x0000007fffffffffULL
+#define DMA_35BIT_MASK	0x00000007ffffffffULL
 #define DMA_32BIT_MASK	0x00000000ffffffffULL
 #define DMA_31BIT_MASK	0x000000007fffffffULL
 #define DMA_30BIT_MASK	0x000000003fffffffULL

Hm. Wouldn't it be better to define something like

#define DMA_BIT_MASK(x) ((1ull<<(x))-1)

and then define everything in terms of that (or just use it directly and deprecate the DMA_XXBIT_MASK macros)?

J

#2 lore raw
Quoted 23 lines · Jeremy Fitzhardinge
Quoted 12 lines · Borislav Petkov

This patches remove redundant DMA_..BIT_MASK definitions across two drivers. First off, consolidate dma bitmask definitions in the proper header file...

--
Index: 23-rc6/include/linux/dma-mapping.h
===================================================================

include/linux/dma-mapping.h line 23

Quoted 7 lines
include/linux/dma-mapping.h renamed from include/linux/dma-mapping.h.orig +1 -0
@@ -17,6 +17,7 @@
 #define DMA_48BIT_MASK	0x0000ffffffffffffULL
 #define DMA_40BIT_MASK	0x000000ffffffffffULL
 #define DMA_39BIT_MASK	0x0000007fffffffffULL
+#define DMA_35BIT_MASK	0x00000007ffffffffULL
 #define DMA_32BIT_MASK	0x00000000ffffffffULL
 #define DMA_31BIT_MASK	0x000000007fffffffULL
 #define DMA_30BIT_MASK	0x000000003fffffffULL

Hm. Wouldn't it be better to define something like

Quoted 6 lines

#define DMA_BIT_MASK(x) ((1ull<<(x))-1)

and then define everything in terms of that (or just use it directly and deprecate the DMA_XXBIT_MASK macros)?

J

That is more compact, I agree. However, the XXBIT_MASK macros have the better readability, imho. And also, doing

$grep -Prin 'DMA_..BIT_MASK' * | wc -l

returns 383 on the 23-rc6 tree so removing them should be quite the logistical challenge for the kernel janitors :). What do the others think?

Signature · 2 lines
Regards/Gruß,
    Boris.
#3 lore raw
Quoted 8 lines · Borislav Petkov

That is more compact, I agree. However, the XXBIT_MASK macros have the better readability, imho. And also, doing

$grep -Prin 'DMA_..BIT_MASK' * | wc -l

returns 383 on the 23-rc6 tree so removing them should be quite the logistical challenge for the kernel janitors :). What do the others think?

Well, even defining the existing macros in terms of DMA_BIT_MASK would be an improvement. It's certainly not obvious at first glance that 0x00000007ffffffffULL is a correct 35-bit mask - it's something that the compiler is perfectly happy to compute for us.

J