Re: [net-next PATCH 05/19] net: dsa: qca8k: move read switch id function in qca8k_setup

From: Vladimir Oltean
Date: Sun Nov 21 2021 - 13:34:18 EST


On Fri, Nov 19, 2021 at 02:08:59AM +0100, Ansuel Smith wrote:
> On Fri, Nov 19, 2021 at 03:03:05AM +0200, Vladimir Oltean wrote:
> > On Wed, Nov 17, 2021 at 10:04:37PM +0100, Ansuel Smith wrote:
> > > Move read_switch_id function in qca8k_setup in preparation for regmap
> > > conversion. Sw probe should NOT contain function that depends on reading
> > > from switch regs.
> >
> > It shouldn't? Why? We have plenty of switch drivers that use regmap in
> > the probe function.
> >
>
> The initial idea was to make a shared probe function. (when the ipq40xx
> code will be proposed)
> Currently the regmap is init in the setup function so we can both
> move the switch id to setup or move regmap to probe.
> What should be better in your opinion?

Either one is fine, but it seems a bit backwards to call
dsa_register_switch() only to find out later, during the ->setup()
callback, that you're in fact talking to a potato. So from that point of
view maybe you could keep the device id check in ->probe, and therefore
also move the regmap initialization there.