On Sat, 8 Mar 2025, Philippe Mathieu-Daudé wrote:
> While little endianness is the default, ome controllers
Typo, ome -> some.
Regards,
BALATON Zoltan
> might be only implemented in big endianness.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> hw/sd/sdhci.c | 18 ++++--------------
> 1 file changed, 4 insertions(+), 14 deletions(-)
>
> diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c
> index ae485f90dfe..a2e7162e289 100644
> --- a/hw/sd/sdhci.c
> +++ b/hw/sd/sdhci.c
> @@ -1444,20 +1444,10 @@ void sdhci_common_realize(SDHCIState *s, Error **errp)
> SDHCIClass *sc = SYSBUS_SDHCI_GET_CLASS(s);
> const char *class_name = object_get_typename(OBJECT(s));
>
> - s->io_ops = sc->io_ops ?: &sdhci_mmio_le_ops;
> - switch (s->endianness) {
> - case DEVICE_LITTLE_ENDIAN:
> - /* s->io_ops is little endian by default */
> - break;
> - case DEVICE_BIG_ENDIAN:
> - if (s->io_ops != &sdhci_mmio_le_ops) {
> - error_setg(errp, "SD controller doesn't support big endianness");
> - return;
> - }
> - s->io_ops = &sdhci_mmio_be_ops;
> - break;
> - default:
> - error_setg(errp, "Incorrect endianness");
> + s->io_ops = sc->io_ops ?: (s->endianness == DEVICE_BIG_ENDIAN ?
> + &sdhci_mmio_be_ops : &sdhci_mmio_le_ops);
> + if (s->io_ops->endianness != s->endianness) {
> + error_setg(errp, "Invalid endianness for SD controller");
> return;
> }
>
>