net: dsa: ocelot: common probing code
authorVladimir Oltean <vladimir.oltean@nxp.com>
Thu, 30 May 2024 16:33:32 +0000 (19:33 +0300)
committerDavid S. Miller <davem@davemloft.net>
Mon, 3 Jun 2024 12:06:16 +0000 (13:06 +0100)
commitefdbee7d07916d994bc0ff0235d00d46fa991b61
tree8cbac6075dc6cc5e9980ee2b19781394cab40b6b
parent4ca54dd96eca57adea961c0e6cca28bf76168429
net: dsa: ocelot: common probing code

Russell King suggested that felix_vsc9959, seville_vsc9953 and
ocelot_ext have a large portion of duplicated init code, which could be
made common [1].

[1]: https://lore.kernel.org/all/Zh1GvcOTXqb7CpQt@shell.armlinux.org.uk/

Here, we take the following common steps:
- "felix" and "ds" structure allocation
- "felix", "ocelot" and "ds" basic structure initialization
- dsa_register_switch() call

and we make a common function out of them.

For every driver except felix_vsc9959, this is also the entire probing
procedure. For felix_vsc9959, we also need to do some PCI-specific
stuff, which can easily be reordered to be done before, and unwound on
failure.

We also have to convert the bus-specific platform_set_drvdata() and
pci_set_drvdata() calls into dev_set_drvdata(). But this should have no
impact on the behavior.

Suggested-by: "Russell King (Oracle)" <linux@armlinux.org.uk>
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Tested-by: Colin Foster <colin.foster@in-advantage.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/dsa/ocelot/felix.c
drivers/net/dsa/ocelot/felix.h
drivers/net/dsa/ocelot/felix_vsc9959.c
drivers/net/dsa/ocelot/ocelot_ext.c
drivers/net/dsa/ocelot/seville_vsc9953.c