mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 6/8] drivers-edac-i3000 replace macros with functions
@ 2007-10-19 19:18 dougthompson
  2007-10-19 21:11 ` Andrew Morton
  0 siblings, 1 reply; 4+ messages in thread
From: dougthompson @ 2007-10-19 19:18 UTC (permalink / raw)
  To: dougthompson, alan, linux-kernel, akpm

From: Jason Uhlenkott <juhlenko@akamai.com>

Replace function-like macros with functions.

Signed-off-by: Jason Uhlenkott <juhlenko@akamai.com>
CC:     Alan Cox <alan@lxorguk.ukuu.org.uk
Signed-off-by: Doug Thompson <dougthompson@xmission.com>
---

 drivers/edac/i3000_edac.c |   50 ++++++++++++++++++++++++++++++++--------------
 1 files changed, 35 insertions(+), 15 deletions(-)

Index: edac/drivers/edac/i3000_edac.c
===================================================================
--- edac.orig/drivers/edac/i3000_edac.c	2007-09-05 18:01:44.404999805 -0700
+++ edac/drivers/edac/i3000_edac.c	2007-09-05 18:03:06.859573940 -0700
@@ -42,11 +42,23 @@
 				 * 0     Error channel 0/1
 				 */
 #define I3000_DEAP_GRAIN 		(1 << 7)
-#define I3000_DEAP_PFN(edeap, deap)	((((edeap) & 1) << (32 - PAGE_SHIFT)) \
-					| ((deap) >> PAGE_SHIFT))
-#define I3000_DEAP_OFFSET(deap)		((deap) & ~(I3000_DEAP_GRAIN-1) & \
-					~PAGE_MASK)
-#define I3000_DEAP_CHANNEL(deap)	((deap) & 1)
+
+static inline unsigned long deap_pfn(u8 edeap, u32 deap)
+{
+	deap >>= PAGE_SHIFT;
+	deap |= (edeap & 1) << (32 - PAGE_SHIFT);
+	return deap;
+}
+
+static inline unsigned long deap_offset(u32 deap)
+{
+	return deap & ~(I3000_DEAP_GRAIN - 1) & ~PAGE_MASK;
+}
+
+static inline int deap_channel(u32 deap)
+{
+	return deap & 1;
+}
 
 #define I3000_DERRSYN	0x5c	/* DRAM Error Syndrome (8b)
 				 *
@@ -116,8 +128,16 @@
 				 *     Others: reserved
 				 */
 #define I3000_C1DRA	0x188	/* Channel 1 DRAM Rank Attribute (8b x 2) */
-#define ODD_RANK_ATTRIB(dra)	(((dra) & 0x70) >> 4)
-#define EVEN_RANK_ATTRIB(dra)	((dra) & 0x07)
+
+static inline unsigned char odd_rank_attrib(unsigned char dra)
+{
+	return (dra & 0x70) >> 4;
+}
+
+static inline unsigned char even_rank_attrib(unsigned char dra)
+{
+	return dra & 0x07;
+}
 
 #define I3000_C0DRC0	0x120	/* DRAM Controller Mode 0 (32b)
 				 *
@@ -206,8 +226,8 @@
 				struct i3000_error_info *info,
 				int handle_errors)
 {
-	int row, multi_chan;
-	int pfn, offset, channel;
+	int row, multi_chan, channel;
+	unsigned long pfn, offset;
 
 	multi_chan = mci->csrows[0].nr_channels - 1;
 
@@ -222,9 +242,9 @@
 		info->errsts = info->errsts2;
 	}
 
-	pfn = I3000_DEAP_PFN(info->edeap, info->deap);
-	offset = I3000_DEAP_OFFSET(info->deap);
-	channel = I3000_DEAP_CHANNEL(info->deap);
+	pfn = deap_pfn(info->edeap, info->deap);
+	offset = deap_offset(info->deap);
+	channel = deap_channel(info->deap);
 
 	row = edac_mc_find_csrow_by_page(mci, pfn);
 
@@ -258,9 +278,9 @@
 	 * we're not interleaved.
 	 */
 	for (i = 0; i < I3000_RANKS_PER_CHANNEL / 2; i++)
-		if (ODD_RANK_ATTRIB(c0dra[i]) != ODD_RANK_ATTRIB(c1dra[i]) ||
-			EVEN_RANK_ATTRIB(c0dra[i]) !=
-						EVEN_RANK_ATTRIB(c1dra[i]))
+		if (odd_rank_attrib(c0dra[i]) != odd_rank_attrib(c1dra[i]) ||
+			even_rank_attrib(c0dra[i]) !=
+						even_rank_attrib(c1dra[i]))
 			return 0;
 
 	/*

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

* Re: [PATCH 6/8] drivers-edac-i3000 replace macros with functions
  2007-10-19 19:18 [PATCH 6/8] drivers-edac-i3000 replace macros with functions dougthompson
@ 2007-10-19 21:11 ` Andrew Morton
  2007-10-19 23:58   ` Doug Thompson
  2007-10-20  0:13   ` Jason Uhlenkott
  0 siblings, 2 replies; 4+ messages in thread
From: Andrew Morton @ 2007-10-19 21:11 UTC (permalink / raw)
  To: dougthompson; +Cc: dougthompson, alan, linux-kernel

On Fri, 19 Oct 2007 13:18:23 -0600
dougthompson@xmission.com wrote:

> +static inline unsigned long deap_pfn(u8 edeap, u32 deap)
> +{
> +	deap >>= PAGE_SHIFT;
> +	deap |= (edeap & 1) << (32 - PAGE_SHIFT);
> +	return deap;
> +}
> +
> +static inline unsigned long deap_offset(u32 deap)
> +{
> +	return deap & ~(I3000_DEAP_GRAIN - 1) & ~PAGE_MASK;
> +}
> +

The types here look a bit confused.  Implicit conversions of
u32s into unsigned longs.

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

* Re: [PATCH 6/8] drivers-edac-i3000 replace macros with functions
  2007-10-19 21:11 ` Andrew Morton
@ 2007-10-19 23:58   ` Doug Thompson
  2007-10-20  0:13   ` Jason Uhlenkott
  1 sibling, 0 replies; 4+ messages in thread
From: Doug Thompson @ 2007-10-19 23:58 UTC (permalink / raw)
  To: Andrew Morton, juhlenko; +Cc: dougthompson, alan, linux-kernel

Jason,

Can you provide some information on this?

doug t


--- Andrew Morton <akpm@linux-foundation.org> wrote:

> On Fri, 19 Oct 2007 13:18:23 -0600
> dougthompson@xmission.com wrote:
> 
> > +static inline unsigned long deap_pfn(u8 edeap, u32 deap)
> > +{
> > +	deap >>= PAGE_SHIFT;
> > +	deap |= (edeap & 1) << (32 - PAGE_SHIFT);
> > +	return deap;
> > +}
> > +
> > +static inline unsigned long deap_offset(u32 deap)
> > +{
> > +	return deap & ~(I3000_DEAP_GRAIN - 1) & ~PAGE_MASK;
> > +}
> > +
> 
> The types here look a bit confused.  Implicit conversions of
> u32s into unsigned longs.
> 


W1DUG

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

* Re: [PATCH 6/8] drivers-edac-i3000 replace macros with functions
  2007-10-19 21:11 ` Andrew Morton
  2007-10-19 23:58   ` Doug Thompson
@ 2007-10-20  0:13   ` Jason Uhlenkott
  1 sibling, 0 replies; 4+ messages in thread
From: Jason Uhlenkott @ 2007-10-20  0:13 UTC (permalink / raw)
  To: Andrew Morton; +Cc: dougthompson, alan, linux-kernel

On Fri, Oct 19, 2007 at 14:11:18 -0700, Andrew Morton wrote:
> On Fri, 19 Oct 2007 13:18:23 -0600
> dougthompson@xmission.com wrote:
> 
> > +static inline unsigned long deap_pfn(u8 edeap, u32 deap)
> > +{
> > +	deap >>= PAGE_SHIFT;
> > +	deap |= (edeap & 1) << (32 - PAGE_SHIFT);
> > +	return deap;
> > +}
> > +
> > +static inline unsigned long deap_offset(u32 deap)
> > +{
> > +	return deap & ~(I3000_DEAP_GRAIN - 1) & ~PAGE_MASK;
> > +}
> > +
> 
> The types here look a bit confused.  Implicit conversions of
> u32s into unsigned longs.

That's deliberate, though perhaps not as clear as it could have been:
We're calculating a pfn and an offset which are logically unsigned
longs (and treated as such by the higher level edac code where they
ultimately get passed) from some bits in config space registers which
are u8/u32.

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

end of thread, other threads:[~2007-10-20  0:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-10-19 19:18 [PATCH 6/8] drivers-edac-i3000 replace macros with functions dougthompson
2007-10-19 21:11 ` Andrew Morton
2007-10-19 23:58   ` Doug Thompson
2007-10-20  0:13   ` Jason Uhlenkott

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

all inboxes | Powered by JetHome®