Subject: Re: [spi-devel-general] [PATCH] Adapt spi_mpc83xx SPI driver for 832x

From: David Brownell <[email-masked]>
Date: Fri, 22 Dec 2006 16:57:11 -0800

On Wednesday 13 December 2006 4:13 pm, Joakim Tjernlund wrote:
>
> > The problem I have with this patch is that it has too much 
> > #ifdeffery.  If
> 
> Too much? There is only 2 of them.

But it's the wrong kind of  #ifdeffery, and that's avoidable.

> > > (possibly this can be reduced by adding more logic to the 
> > > tx_buf/rx_buf functions)
> > > not to mention what will happen when support for reversed 
> > > bit order is added.
> > 
> > Sure enough, sounds ugly.  But cpu_is_xxx() macros, combined 
> > with GCC dead
> > code elimination will strip out functions that are unused, so 
> > that e.g.
> > 
> > 	if (cpu_is_mpc834x())
> > 		fn = mpc834x_spi_tx_buf_u16;
> > 	else if (cpu_is_mpc832x())
> > 		fn = mpc832x_spi_tx_buf_u16;
> > 
> > would only link one of them unless the kernel supports both SOCs.  And
> > without in-driver #ifdeffery.
> 
> Hmm, I can't find any cpu_is_xxx macros/functions. I guess the
> infrastructure isn't there yet?

So it would seem.    At least for PPC.  I noticed the patch from
Kumar Gala, which takes an alternate approach based on parameters
passed through platform_data ... that works too, in terms of
code being cleaner.

- Dave