Re: [RFC 4/4] m68k: coldfire: fix non-standard readX()/writeX() functions

From: Frank Li

Date: Wed May 06 2026 - 12:19:22 EST


On Thu, May 07, 2026 at 12:26:48AM +1000, Greg Ungerer wrote:
> From: Greg Ungerer <gerg@xxxxxxxxxxxxxx>
>
> Remove the local ColdFire definitions of readb()/readw()/readl() and
> writeb()/writew()/writel() and use the asm-generic versions of them.
>
> The implementation of the readX()/writeX() family of IO access functions
> is non-standard on ColdFire platforms. They either return big-endian (that
> is native endian) data, or on platforms with PCI bus support check the
> supplied address and return either big or little endian data based on that
> check. This is non-standard, they are expected to always return
> little-endian byte ordered data. Unfortunately this behavior also means
> that ioreadX()/iowroteX() and their big-endian counter parts
> ioreadXbe()/iowriteXbe() are currently broken because they are implemented
> using the readX()/writeX() functions.
>
> The change to use the asm-generic versions of readX()/writeX() itself is
> quite strait forward, just remove the ColdFire local versions of them. But
> this of course has implications for any remaining drivers that use any of
> these IO access functions. A number of drivers can be independently fixed,
> before this final fix to readX()/writeX() for ColdFire. A small number of
> drivers cannot easily be independently fixed and remain in a working
> state. Those drivers are fixed here as well:
>
> drivers/dma/mcf-edma-main.c
> Supports big-endian access by setting the big-endian flag of
> the drivers struct fsl_edma_engine. But locally should be using
> ioread32be() and iowrite32be() instead of ioread32() and iowrite32().
>
> drivers/net/can/flexcan/flexcan-core.c
> Setting the driver quirks flag for big-endian access will force
> driver to use correct access functions.
>
> drivers/spi/spi-fsl-dspi.c
> Setting the regmap format_endian flags to use native endian will
> force driver to use appropriate big or little endian access on
> whatever platform it is built for.
>
> These drivers have only been compile tested.
>
> Signed-off-by: Greg Ungerer <gerg@xxxxxxxxxxxxxx>
> ---
> arch/m68k/include/asm/io_no.h | 68 +++-----------------------
> drivers/dma/mcf-edma-main.c | 14 +++---

Suppose it is correct, but I have not such platform to test it. it should
be correct if disassembly code is the same at access register.

Frank

>