public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] sparc64: Annotate pointers in PeeCeeI.c
@ 2008-10-16  0:15 Harvey Harrison
  2008-10-16  0:23 ` David Miller
  0 siblings, 1 reply; 3+ messages in thread
From: Harvey Harrison @ 2008-10-16  0:15 UTC (permalink / raw)
  To: David Miller; +Cc: sparclinux, LKML, Andrew Morton

This has no functional changes, but annotates the code to make
the endianness more clear.  In addition, removes some of the only
users of cpu_to_le[16|32]p in the kernel.

Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com>
---
 arch/sparc64/lib/PeeCeeI.c |   34 +++++++++++++++++-----------------
 1 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/arch/sparc64/lib/PeeCeeI.c b/arch/sparc64/lib/PeeCeeI.c
index 8b313f1..e609b65 100644
--- a/arch/sparc64/lib/PeeCeeI.c
+++ b/arch/sparc64/lib/PeeCeeI.c
@@ -53,32 +53,32 @@ void outsl(unsigned long __addr, const void *src, unsigned long count)
 
 	if (count) {
 		if ((((u64)src) & 0x3) == 0) {
-			u32 *p = (u32 *)src;
+			__le32 *p = (__le32 *)src;
 			while (count--) {
-				u32 val = cpu_to_le32p(p);
+				u32 val = le32_to_cpup(p);
 				outl(val, addr);
 				p++;
 			}
 		} else {
 			u8 *pb;
-			u16 *ps = (u16 *)src;
+			__le16 *ps = (__le16 *)src;
 			u32 l = 0, l2;
-			u32 *pi;
+			__le32 *pi;
 
 			switch (((u64)src) & 0x3) {
 			case 0x2:
 				count -= 1;
-				l = cpu_to_le16p(ps) << 16;
+				l = le16_to_cpup(ps) << 16;
 				ps++;
-				pi = (u32 *)ps;
+				pi = (__le32 *)ps;
 				while (count--) {
-					l2 = cpu_to_le32p(pi);
+					l2 = le32_to_cpup(pi);
 					pi++;
 					outl(((l >> 16) | (l2 << 16)), addr);
 					l = l2;
 				}
-				ps = (u16 *)pi;
-				l2 = cpu_to_le16p(ps);
+				ps = (__le16 *)pi;
+				l2 = le16_to_cpup(ps);
 				outl(((l >> 16) | (l2 << 16)), addr);
 				break;
 
@@ -86,13 +86,13 @@ void outsl(unsigned long __addr, const void *src, unsigned long count)
 				count -= 1;
 				pb = (u8 *)src;
 				l = (*pb++ << 8);
-				ps = (u16 *)pb;
-				l2 = cpu_to_le16p(ps);
+				ps = (__le16 *)pb;
+				l2 = le16p_to_cpup(ps);
 				ps++;
 				l |= (l2 << 16);
-				pi = (u32 *)ps;
+				pi = (__le32 *)ps;
 				while (count--) {
-					l2 = cpu_to_le32p(pi);
+					l2 = le32_to_cpup(pi);
 					pi++;
 					outl(((l >> 8) | (l2 << 24)), addr);
 					l = l2;
@@ -105,15 +105,15 @@ void outsl(unsigned long __addr, const void *src, unsigned long count)
 				count -= 1;
 				pb = (u8 *)src;
 				l = (*pb++ << 24);
-				pi = (u32 *)pb;
+				pi = (__le32 *)pb;
 				while (count--) {
-					l2 = cpu_to_le32p(pi);
+					l2 = le32_to_cpup(pi);
 					pi++;
 					outl(((l >> 24) | (l2 << 8)), addr);
 					l = l2;
 				}
-				ps = (u16 *)pi;
-				l2 = cpu_to_le16p(ps);
+				ps = (__le16 *)pi;
+				l2 = le16_to_cpup(ps);
 				ps++;
 				pb = (u8 *)ps;
 				l2 |= (*pb << 16);
-- 
1.6.0.2.711.gf1ba4




^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] sparc64: Annotate pointers in PeeCeeI.c
  2008-10-16  0:15 [PATCH] sparc64: Annotate pointers in PeeCeeI.c Harvey Harrison
@ 2008-10-16  0:23 ` David Miller
  2008-10-16  0:32   ` Harvey Harrison
  0 siblings, 1 reply; 3+ messages in thread
From: David Miller @ 2008-10-16  0:23 UTC (permalink / raw)
  To: harvey.harrison; +Cc: sparclinux, linux-kernel, akpm

From: Harvey Harrison <harvey.harrison@gmail.com>
Date: Wed, 15 Oct 2008 17:15:19 -0700

> This has no functional changes, but annotates the code to make
> the endianness more clear.  In addition, removes some of the only
> users of cpu_to_le[16|32]p in the kernel.
> 
> Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com>

Remind me what the problem is with cpu_to_{le,be}*()?

The interface names define a direction, which in this case is
"CPU endianness to BE/LE endianness".  And that is exactly
what is happening in the out*() routines.

This aids comprehension of the code and is quite useful IMHO.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] sparc64: Annotate pointers in PeeCeeI.c
  2008-10-16  0:23 ` David Miller
@ 2008-10-16  0:32   ` Harvey Harrison
  0 siblings, 0 replies; 3+ messages in thread
From: Harvey Harrison @ 2008-10-16  0:32 UTC (permalink / raw)
  To: David Miller; +Cc: sparclinux, linux-kernel, akpm

On Wed, 2008-10-15 at 17:23 -0700, David Miller wrote:
> From: Harvey Harrison <harvey.harrison@gmail.com>
> Date: Wed, 15 Oct 2008 17:15:19 -0700
> 
> > This has no functional changes, but annotates the code to make
> > the endianness more clear.  In addition, removes some of the only
> > users of cpu_to_le[16|32]p in the kernel.
> > 
> > Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com>
> 
> Remind me what the problem is with cpu_to_{le,be}*()?
> 

Nothing inherently wrong with them, other than it seems that nearly
every user (not this one) would be better served using the by-value
versions.

> The interface names define a direction, which in this case is
> "CPU endianness to BE/LE endianness".  And that is exactly
> what is happening in the out*() routines.
> 
> This aids comprehension of the code and is quite useful IMHO.

Yes, and even from that angle I think my patch is more instructive to
understanding the direction, compare for example in the same file
outsw versus outsl which this patch changes.

Harvey




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-10-16  0:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-16  0:15 [PATCH] sparc64: Annotate pointers in PeeCeeI.c Harvey Harrison
2008-10-16  0:23 ` David Miller
2008-10-16  0:32   ` Harvey Harrison

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox