Re: [PATCH v4 1/2] mfd: syscon: Support physical regmap bus

From: Orson Zhai
Date: Wed May 20 2020 - 21:08:52 EST


On Tue, May 19, 2020 at 9:19 PM Arnd Bergmann <arnd@xxxxxxxx> wrote:
>
> On Sat, May 16, 2020 at 12:13 PM Baolin Wang <baolin.wang7@xxxxxxxxx> wrote:
> >
> > Some platforms such as Spreadtrum platform, define a special method to
> > update bits of the registers instead of reading and writing, which means
> > we should use a physical regmap bus to define the reg_update_bits()
> > operation instead of the MMIO regmap bus.
> >
> > Thus add a a __weak function for the syscon driver to allow to register
> > a physical regmap bus to support this new requirement.
> >
> > };
> >
> > +struct regmap * __weak syscon_regmap_init(struct device_node *np,
> > + void __iomem *base,
> > + struct regmap_config *syscon_config)
> > +{
> > + return regmap_init_mmio(NULL, base, syscon_config);
> > +}
> > +
>
> Sorry, I don't think the __weak function is going to help here. I'm not
> sure whether it actually does what you want when both syscon and
> sprd_syscon are loadable modules (I would guess not), but it clearly
> won't work when syscon is built-in and sprd_syscon is a module, and
> even if the module loader knows how to resolve __weak symbols,


I happened to see module.c last week. It seems there's some code to handle
weak symbols by checking about STB_WEAK. But it is not in this case.
When syscon.c is built-in and sprd_syscon is module, this would not
work because the
__weak one has been built into kernel already. Maybe live patch
feature may work it out.
But it seems over expensive to do things like this.

> I would not want to rely on module load ordering to make it behave
> the right way.

Agree. All other sprd modules would must be loaded behind sprd_syscon
and this will not be
handled by modprobe.

Thanks to pointing out this.

Best,
Orson

>
> Arnd