linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* Re: [RESEND][PATCH] SPI: xilinx_spi: Added platform driver and support for DS570
       [not found] <4A366622.2050606@mocean-labs.com>
@ 2009-06-23  5:04 ` Andrew Morton
  0 siblings, 0 replies; only message in thread
From: Andrew Morton @ 2009-06-23  5:04 UTC (permalink / raw)
  To: Richard Röjfors
  Cc: dbrownell, Linux Kernel Mailing List, linuxppc-dev,
	spi-devel-general, Andrei Konovalov, John, Linn


This appears to be a ppc thing, so let's cc that list.  Let's also cc
the driver's author and other contributors.  Please cc these people on
future versions of the patch also.

On Mon, 15 Jun 2009 17:17:54 +0200 Richard R__jfors <richard.rojfors.ext@mocean-labs.com> wrote:

> This patch splits xilinx_spi into three parts, an OF and a platform
> driver and generic part.
> 
> The generic part now also works on X86 and also supports the Xilinx
> SPI IP DS570
> 
>
> ...
>
> +#ifndef CONFIG_PPC
> +#define in_8(addr) ioread8(addr)
> +#define in_be16(addr) ioread16(addr)
> +#define in_be32(addr) ioread32(addr)
> +
> +#define out_8(addr, b) iowrite8(b, addr)
> +#define out_be16(addr, w) iowrite16(w, addr)
> +#define out_be32(addr, l) iowrite32(l, addr)
> +#endif

Why do we need these?

> +#define XSPI_WRITE8(xspi, offs, val) \
> +	do { \
> +		if (xspi->model == XILINX_SPI_MODEL_DS464) \
> +			out_8(xspi->regs + offs, (val) & 0xff); \
> +		else \
> +			XSPI_WRITE32(xspi, offs, val); \
> +	} while (0)
> +
> +#define XSPI_WRITE16(xspi, offs, val) \
> +	do { \
> +		if (xspi->model == XILINX_SPI_MODEL_DS464) \
> +			out_be16(xspi->regs + offs, (val) & 0xffff); \
> +		else \
> +			XSPI_WRITE32(xspi, offs, val); \
> +	} while (0)
> +
> +#define XSPI_WRITE32(xspi, offs, val) \
> +	out_be32(xspi->regs + offs, val)
> +
> +#define XSPI_READ8(xspi, offs) \
> +	(xspi->model == XILINX_SPI_MODEL_DS464) ? \
> +		in_8(xspi->regs + offs) : XSPI_READ32(xspi, offs)
> +
> +#define XSPI_READ16(xspi, offs) \
> +	(xspi->model == XILINX_SPI_MODEL_DS464) ? \
> +	in_be16(xspi->regs + offs) : XSPI_READ32(xspi, offs)
> +
> +#define XSPI_READ32(xspi, offs) \
> +	in_be32(xspi->regs + offs)

I'm seeing no reason why these had to be implemented as macros. 
They're ugly, add considerable code bloat and, because they evaluate
their args multiple times they will fail if passed as expression with
side-effects.

I suggest that they be reimplemented as lower-case, uninlined C functions.

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2009-06-23  5:04 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <4A366622.2050606@mocean-labs.com>
2009-06-23  5:04 ` [RESEND][PATCH] SPI: xilinx_spi: Added platform driver and support for DS570 Andrew Morton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).