From 35faff569fc02750b6581180b10645d253afa10b Mon Sep 17 00:00:00 2001 From: Ioana Ciornei Date: Wed, 22 Jul 2026 02:15:58 +0300 Subject: [PATCH] soc: fsl: guts: add a central fsl_guts_read() function Add a central fsl_guts_read() function which will take into account the endianness that was already determined. No point is duplicating the if-else statement each time we need to read a DCFG register. Signed-off-by: Ioana Ciornei Signed-off-by: Vladimir Oltean Link: https://lore.kernel.org/r/20260721231603.67865-5-vladimir.oltean@nxp.com Signed-off-by: Christophe Leroy (CS GROUP) --- drivers/soc/fsl/guts.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/soc/fsl/guts.c b/drivers/soc/fsl/guts.c index bb65b62ed805..8e5c3cae811e 100644 --- a/drivers/soc/fsl/guts.c +++ b/drivers/soc/fsl/guts.c @@ -111,6 +111,14 @@ static struct fsl_soc_guts { bool little_endian; } soc; +static unsigned int fsl_guts_read(const void __iomem *reg) +{ + if (soc.little_endian) + return ioread32(reg); + + return ioread32be(reg); +} + static const struct fsl_soc_die_attr *fsl_soc_die_match( u32 svr, const struct fsl_soc_die_attr *matches) { @@ -209,10 +217,7 @@ static int __init fsl_guts_init(void) } soc.little_endian = of_property_read_bool(np, "little-endian"); - if (soc.little_endian) - svr = ioread32(&soc.dcfg_ccsr->svr); - else - svr = ioread32be(&soc.dcfg_ccsr->svr); + svr = fsl_guts_read(&soc.dcfg_ccsr->svr); of_node_put(np); /* Register soc device */