From: "Richard Röjfors" <richard.rojfors@mocean-labs.com>
To: Paul Mundt <lethal@linux-sh.org>
Cc: John Linn <John.Linn@xilinx.com>,
Grant Likely <grant.likely@secretlab.ca>,
spi-devel-general@lists.sourceforge.net,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] spi: xilinx_spi: Fix up I/O routine wrapping bogosity.
Date: Thu, 17 Dec 2009 11:59:51 +0100 [thread overview]
Message-ID: <4B2A0F27.8070906@mocean-labs.com> (raw)
In-Reply-To: <20091216060130.GD31265@linux-sh.org>
Paul Mundt wrote:
> xilinx_spi presently makes some fairly questionable assumptions about I/O
> routines, and attempts to assign ioread32/iowrite32 and friends directly
> to its own internal function pointers. On many platforms these I/O
> routines are macros or wrappers and not actual functions on their own,
> resulting in things like:
>
> ERROR: "ioread32be" [drivers/spi/xilinx_spi.ko] undefined!
> ERROR: "iowrite32be" [drivers/spi/xilinx_spi.ko] undefined!
> ERROR: "iowrite32" [drivers/spi/xilinx_spi.ko] undefined!
> ERROR: "ioread32" [drivers/spi/xilinx_spi.ko] undefined!
>
> If xilinx_spi wants to do this sort of casting, it needs to provide its
> own wrappers for these, or change how it does accesses completely.
>
> I've opted for the first approach, and the attached silly patch does
> that. If someone with the hardware available wants to give the second
> option a try that's ok too. In any event, the current code is broken for
> at least: arm, avr32, blackfin, microblaze, mn10300, and sh.
>
> Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Looks good to me.
Acked-by: Richard Röjfors <richard.rojfors@pelagicore.com>
>
> ---
>
> drivers/spi/xilinx_spi.c | 28 ++++++++++++++++++++++++----
> 1 file changed, 24 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/spi/xilinx_spi.c b/drivers/spi/xilinx_spi.c
> index 9f38637..154e908 100644
> --- a/drivers/spi/xilinx_spi.c
> +++ b/drivers/spi/xilinx_spi.c
> @@ -93,6 +93,26 @@ struct xilinx_spi {
> void (*rx_fn) (struct xilinx_spi *);
> };
>
> +static void xspi_write32(u32 val, void __iomem *addr)
> +{
> + iowrite32(val, addr);
> +}
> +
> +static unsigned int xspi_read32(void __iomem *addr)
> +{
> + return ioread32(addr);
> +}
> +
> +static void xspi_write32_be(u32 val, void __iomem *addr)
> +{
> + iowrite32be(val, addr);
> +}
> +
> +static unsigned int xspi_read32_be(void __iomem *addr)
> +{
> + return ioread32be(addr);
> +}
> +
> static void xspi_tx8(struct xilinx_spi *xspi)
> {
> xspi->write_fn(*xspi->tx_ptr, xspi->regs + XSPI_TXD_OFFSET);
> @@ -374,11 +394,11 @@ struct spi_master *xilinx_spi_init(struct device *dev, struct resource *mem,
> xspi->mem = *mem;
> xspi->irq = irq;
> if (pdata->little_endian) {
> - xspi->read_fn = ioread32;
> - xspi->write_fn = iowrite32;
> + xspi->read_fn = xspi_read32;
> + xspi->write_fn = xspi_write32;
> } else {
> - xspi->read_fn = ioread32be;
> - xspi->write_fn = iowrite32be;
> + xspi->read_fn = xspi_read32_be;
> + xspi->write_fn = xspi_write32_be;
> }
> xspi->bits_per_word = pdata->bits_per_word;
> if (xspi->bits_per_word == 8) {
next prev parent reply other threads:[~2009-12-17 10:59 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-16 6:01 [PATCH] spi: xilinx_spi: Fix up I/O routine wrapping bogosity Paul Mundt
2009-12-17 10:59 ` Richard Röjfors [this message]
[not found] ` <20091216060130.GD31265-M7jkjyW5wf5g9hUCZPvPmw@public.gmane.org>
2009-12-17 17:01 ` Grant Likely
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4B2A0F27.8070906@mocean-labs.com \
--to=richard.rojfors@mocean-labs.com \
--cc=John.Linn@xilinx.com \
--cc=grant.likely@secretlab.ca \
--cc=lethal@linux-sh.org \
--cc=linux-kernel@vger.kernel.org \
--cc=spi-devel-general@lists.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).