[PATCH] bitops kernel-doc: expand macro

Previous thread: Linux v2.6.24-rc1 by Linus Torvalds on Wednesday, October 24, 2007 - 12:19 am. (55 messages)

Next thread: Re: [PATCH] Add eeprom_bad_csum_allow module option to e1000. by speedy on Wednesday, October 24, 2007 - 12:53 am. (1 message)
To: lkml <linux-kernel@...>
Cc: torvalds <torvalds@...>
Date: Wednesday, October 24, 2007 - 1:09 am

From: Randy Dunlap <randy.dunlap@oracle.com>

Can we expand this macro definition, or should I look for a way to
fool^W teach kernel-doc about this?

scripts/kernel-doc says:
Error(linux-2.6.24-rc1//include/asm-x86/bitops_32.h:188): cannot understand prototype: 'test_and_set_bit_lock test_and_set_bit '

Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
---
include/asm-x86/bitops_32.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

--- linux-2.6.24-rc1.orig/include/asm-x86/bitops_32.h
+++ linux-2.6.24-rc1/include/asm-x86/bitops_32.h
@@ -185,7 +185,7 @@ static inline int test_and_set_bit(int n
*
* This is the same as test_and_set_bit on x86
*/
-#define test_and_set_bit_lock test_and_set_bit
+#define test_and_set_bit_lock(nr, addr) test_and_set_bit(nr, addr)

/**
* __test_and_set_bit - Set a bit and return its old value
---
~Randy
-

To: Randy Dunlap <rdunlap@...>
Cc: lkml <linux-kernel@...>, torvalds <torvalds@...>
Date: Wednesday, October 24, 2007 - 4:00 am

Actually, it probably looks a bit nicer like this anyway. If you grep
for it, then you can actually see the parameters...

On third thoughts, an inline function might be the best thing to do,
-

To: Nick Piggin <nickpiggin@...>, <tglx@...>, <mingo@...>, <hpa@...>
Cc: lkml <linux-kernel@...>, torvalds <torvalds@...>, akpm <akpm@...>
Date: Thursday, October 25, 2007 - 12:31 pm

---

From: Randy Dunlap <randy.dunlap@oracle.com>

Use duplicated inline functions for test_and_set_bit_lock() on x86
instead of #define macros, thus avoiding a bad example. This allows
kernel-doc to run cleanly instead of terminating with an error:

Error(linux-2.6.24-rc1//include/asm-x86/bitops_32.h:188): cannot understand prototype: 'test_and_set_bit_lock test_and_set_bit '

Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
---
include/asm-x86/bitops_32.h | 13 +++++++++++--
include/asm-x86/bitops_64.h | 13 +++++++++++--
2 files changed, 22 insertions(+), 4 deletions(-)

--- linux-2.6.24-rc1.orig/include/asm-x86/bitops_32.h
+++ linux-2.6.24-rc1/include/asm-x86/bitops_32.h
@@ -183,9 +183,18 @@ static inline int test_and_set_bit(int n
* @nr: Bit to set
* @addr: Address to count from
*
- * This is the same as test_and_set_bit on x86
+ * This is the same as test_and_set_bit on x86.
*/
-#define test_and_set_bit_lock test_and_set_bit
+static inline int test_and_set_bit_lock(int nr, volatile unsigned long * addr)
+{
+ int oldbit;
+
+ __asm__ __volatile__( LOCK_PREFIX
+ "btsl %2,%1\n\tsbbl %0,%0"
+ :"=r" (oldbit),"+m" (ADDR)
+ :"Ir" (nr) : "memory");
+ return oldbit;
+}

/**
* __test_and_set_bit - Set a bit and return its old value
--- linux-2.6.24-rc1.orig/include/asm-x86/bitops_64.h
+++ linux-2.6.24-rc1/include/asm-x86/bitops_64.h
@@ -173,9 +173,18 @@ static __inline__ int test_and_set_bit(i
* @nr: Bit to set
* @addr: Address to count from
*
- * This is the same as test_and_set_bit on x86
+ * This is the same as test_and_set_bit on x86.
*/
-#define test_and_set_bit_lock test_and_set_bit
+static __inline__ int test_and_set_bit_lock(int nr, volatile void * addr)
+{
+ int oldbit;
+
+ __asm__ __volatile__( LOCK_PREFIX
+ "btsl %2,%1\n\tsbbl %0,%0"
+ :"=r" (oldbit),ADDR
+ :"dIr" (nr) : "memory");
+ return oldbit;
+}

/**
* __test_and_set_bit - Set a bit and return its old value
-

To: Randy Dunlap <rdunlap@...>
Cc: Nick Piggin <nickpiggin@...>, <mingo@...>, <hpa@...>, lkml <linux-kernel@...>, torvalds <torvalds@...>, akpm <akpm@...>
Date: Thursday, October 25, 2007 - 12:42 pm

Hmm, can we simply do

static inline int test_and_set_bit_lock(int nr, volatile unsigned long * addr)
{
return test_and_set_bit(nr, addr);
}

please ?

-

To: Thomas Gleixner <tglx@...>
Cc: Nick Piggin <nickpiggin@...>, <mingo@...>, <hpa@...>, lkml <linux-kernel@...>, torvalds <torvalds@...>, akpm <akpm@...>
Date: Thursday, October 25, 2007 - 12:55 pm

Certainly. That does look better.

---

From: Randy Dunlap <randy.dunlap@oracle.com>

Use duplicated inline functions for test_and_set_bit_lock() on x86
instead of #define macros, thus avoiding a bad example. This allows
kernel-doc to run cleanly instead of terminating with an error:

Error(linux-2.6.24-rc1//include/asm-x86/bitops_32.h:188): cannot understand prototype: 'test_and_set_bit_lock test_and_set_bit '

Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
---
include/asm-x86/bitops_32.h | 7 +++++--
include/asm-x86/bitops_64.h | 7 +++++--
2 files changed, 10 insertions(+), 4 deletions(-)

--- linux-2.6.24-rc1.orig/include/asm-x86/bitops_32.h
+++ linux-2.6.24-rc1/include/asm-x86/bitops_32.h
@@ -183,9 +183,12 @@ static inline int test_and_set_bit(int n
* @nr: Bit to set
* @addr: Address to count from
*
- * This is the same as test_and_set_bit on x86
+ * This is the same as test_and_set_bit on x86.
*/
-#define test_and_set_bit_lock test_and_set_bit
+static inline int test_and_set_bit_lock(int nr, volatile unsigned long * addr)
+{
+ return test_and_set_bit(nr, addr);
+}

/**
* __test_and_set_bit - Set a bit and return its old value
--- linux-2.6.24-rc1.orig/include/asm-x86/bitops_64.h
+++ linux-2.6.24-rc1/include/asm-x86/bitops_64.h
@@ -173,9 +173,12 @@ static __inline__ int test_and_set_bit(i
* @nr: Bit to set
* @addr: Address to count from
*
- * This is the same as test_and_set_bit on x86
+ * This is the same as test_and_set_bit on x86.
*/
-#define test_and_set_bit_lock test_and_set_bit
+static __inline__ int test_and_set_bit_lock(int nr, volatile void * addr)
+{
+ return test_and_set_bit(nr, addr);
+}

/**
* __test_and_set_bit - Set a bit and return its old value
-

To: Randy Dunlap <rdunlap@...>
Cc: Thomas Gleixner <tglx@...>, <mingo@...>, <hpa@...>, lkml <linux-kernel@...>, torvalds <torvalds@...>, akpm <akpm@...>
Date: Thursday, October 25, 2007 - 5:54 pm

-

To: Randy Dunlap <rdunlap@...>
Cc: <tglx@...>, <nickpiggin@...>, <mingo@...>, <hpa@...>, <linux-kernel@...>, <torvalds@...>, Andy Whitcroft <apw@...>
Date: Thursday, October 25, 2007 - 4:48 pm

On Thu, 25 Oct 2007 09:55:40 -0700

mutter.

ERROR: "foo * bar" should be "foo *bar"
#80: FILE: include/asm-x86/bitops_32.h:188:
+static inline int test_and_set_bit_lock(int nr, volatile unsigned long * addr)

WARNING: Use of volatile is usually wrong: see Documentation/volatile-considered-harmful.txt
#80: FILE: include/asm-x86/bitops_32.h:188:
+static inline int test_and_set_bit_lock(int nr, volatile unsigned long * addr)

ERROR: "foo * bar" should be "foo *bar"
#97: FILE: include/asm-x86/bitops_64.h:178:
+static __inline__ int test_and_set_bit_lock(int nr, volatile void * addr)

WARNING: Use of volatile is usually wrong: see Documentation/volatile-considered-harmful.txt
#97: FILE: include/asm-x86/bitops_64.h:178:
+static __inline__ int test_and_set_bit_lock(int nr, volatile void * addr)

total: 2 errors, 2 warnings, 28 lines checked
Your patch has style problems, please review. If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.

We might as well clean stuff up as we're churning the code.

Andy, I thought we were going to whine about __inline__ and __inline, too?
-

To: Andrew Morton <akpm@...>
Cc: Randy Dunlap <rdunlap@...>, <tglx@...>, <nickpiggin@...>, <mingo@...>, <hpa@...>, <linux-kernel@...>, <torvalds@...>
Date: Saturday, October 27, 2007 - 6:43 am

Hmmm, I don't remember that coming up, but I'll add it to the todo. I
am assuming plain 'inline' is preferred over both of these -- yell if
you meant something else.

-apw
-

To: Andy Whitcroft <apw@...>
Cc: Andrew Morton <akpm@...>, Randy Dunlap <rdunlap@...>, <tglx@...>, <nickpiggin@...>, <mingo@...>, <linux-kernel@...>, <torvalds@...>
Date: Saturday, October 27, 2007 - 2:48 pm

Yes, use __inline__ if and only if it is exported to userspace.

-hpa
-

To: Andrew Morton <akpm@...>
Cc: Randy Dunlap <rdunlap@...>, <tglx@...>, <nickpiggin@...>, <mingo@...>, <hpa@...>, <linux-kernel@...>, <torvalds@...>
Date: Saturday, October 27, 2007 - 10:30 am

Ok, this will be in the next release and is in -next.

WARNING: plain inline is preferred over __inline
#4: FILE: tmp/testset-28768.c:1:
+static __inline int foo(void)

-apw
-

To: Andrew Morton <akpm@...>
Cc: <tglx@...>, <nickpiggin@...>, <mingo@...>, <hpa@...>, <linux-kernel@...>, <torvalds@...>, Andy Whitcroft <apw@...>
Date: Thursday, October 25, 2007 - 5:27 pm

[Empty message]
To: Andrew Morton <akpm@...>
Cc: <tglx@...>, <nickpiggin@...>, <mingo@...>, <hpa@...>, <linux-kernel@...>, <torvalds@...>, Andy Whitcroft <apw@...>
Date: Thursday, October 25, 2007 - 5:21 pm

Thomas, can you replace the previous patch with this one?

Usage of __inline__ is fixed in the next patch (after this one).

---

From: Randy Dunlap <randy.dunlap@oracle.com>

Use duplicated inline functions for test_and_set_bit_lock() on x86
instead of #define macros, thus avoiding a bad example. This allows
kernel-doc to run cleanly instead of terminating with an error:

Error(linux-2.6.24-rc1//include/asm-x86/bitops_32.h:188): cannot understand prototype: 'test_and_set_bit_lock test_and_set_bit '

Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
---
include/asm-x86/bitops_32.h | 7 +++++--
include/asm-x86/bitops_64.h | 7 +++++--
2 files changed, 10 insertions(+), 4 deletions(-)

--- linux-2.6.24-rc1.orig/include/asm-x86/bitops_32.h
+++ linux-2.6.24-rc1/include/asm-x86/bitops_32.h
@@ -183,9 +183,12 @@ static inline int test_and_set_bit(int n
* @nr: Bit to set
* @addr: Address to count from
*
- * This is the same as test_and_set_bit on x86
+ * This is the same as test_and_set_bit on x86.
*/
-#define test_and_set_bit_lock test_and_set_bit
+static inline int test_and_set_bit_lock(int nr, volatile unsigned long *addr)
+{
+ return test_and_set_bit(nr, addr);
+}

/**
* __test_and_set_bit - Set a bit and return its old value
--- linux-2.6.24-rc1.orig/include/asm-x86/bitops_64.h
+++ linux-2.6.24-rc1/include/asm-x86/bitops_64.h
@@ -173,9 +173,12 @@ static __inline__ int test_and_set_bit(i
* @nr: Bit to set
* @addr: Address to count from
*
- * This is the same as test_and_set_bit on x86
+ * This is the same as test_and_set_bit on x86.
*/
-#define test_and_set_bit_lock test_and_set_bit
+static __inline__ int test_and_set_bit_lock(int nr, volatile void *addr)
+{
+ return test_and_set_bit(nr, addr);
+}

/**
* __test_and_set_bit - Set a bit and return its old value
-

To: Randy Dunlap <rdunlap@...>
Cc: Andrew Morton <akpm@...>, <nickpiggin@...>, <mingo@...>, <hpa@...>, <linux-kernel@...>, <torvalds@...>, Andy Whitcroft <apw@...>
Date: Thursday, October 25, 2007 - 5:27 pm

Randy,

Sure. Darn, I did not run yours through the usual procedure :)

-

To: Randy Dunlap <rdunlap@...>
Cc: Nick Piggin <nickpiggin@...>, <mingo@...>, <hpa@...>, lkml <linux-kernel@...>, torvalds <torvalds@...>, akpm <akpm@...>
Date: Thursday, October 25, 2007 - 1:05 pm

Yup. Applied, thanks

-

To: Nick Piggin <nickpiggin@...>
Cc: lkml <linux-kernel@...>, torvalds <torvalds@...>
Date: Wednesday, October 24, 2007 - 11:38 am

That's probably best, yes.

---
~Randy
-

Previous thread: Linux v2.6.24-rc1 by Linus Torvalds on Wednesday, October 24, 2007 - 12:19 am. (55 messages)

Next thread: Re: [PATCH] Add eeprom_bad_csum_allow module option to e1000. by speedy on Wednesday, October 24, 2007 - 12:53 am. (1 message)