mbox series

[net-next,0/2] net: dsa: realtek: Introduce realtek_common, load variants on demand

Message ID 20231117235140.1178-1-luizluca@gmail.com (mailing list archive)
Headers show
Series net: dsa: realtek: Introduce realtek_common, load variants on demand | expand

Message

Luiz Angelo Daros de Luca Nov. 17, 2023, 11:49 p.m. UTC
The current driver comprises two interface modules (SMI and MDIO) and
two family/variant modules (RTL8365MB and RTL8366RB). While the
interface modules are independent and can be loaded only when necessary,
the symbols from variant modules are utilized by interface modules. This
requires loading all enabled variants simultaneously or disabling them
at build time. This approach, although simple, does not scale well,
particularly with the addition of more switch variants (e.g., RTL8366B),
resulting in loaded but unused modules.

This patch series refactors the Realtek DSA switch code by introducing a
common module shared by all existing interfaces (SMI or MDIO) and switch
variant modules (RTL8365MB and RTL8366RB). The common module primarily
contains parts of the probe code common to both interfaces, with the
possibility of incorporating more bits from variants in the future.

The relationship between interfaces and variant modules is also
modified. Variant modules now register themselves in realtek_common
using the compatible string as the key, which is also added as the
module alias. When an interface module probes a device, it utilizes the
matching string to both request the module, loading it if necessary, and
obtain the required variant reference.

Tested with a RTL8367S (RTL8365MB) using MDIO interface and a RTL8366RB
(RTL8366) with SMI interface.

Regards,

Luiz

--

Changelog:

RFC->v1
- Drop the reset-controller patches. It will be submitted in a different
  series.
- Renamed 'var' to 'variant'
- Used 'compatible' as MODULE_ALIAS; avoided static module names in
  macros
- Dropped tmp variable in realtek_variant_get()
- realtek_variant_get() now exclusively uses the compatible string
- Removed clk_delay, cmd_{read,write) from realtek_priv as they are
  already in realtek_variant
- Moved mdc/mdio from realtek_common_probe() to realtek_smi_probe()
- Moved module_realtek_variant() macro to realtek-common.h
- module_realtek_variant() now also generates MODULE_ALIAS()
- Avoided repeating error code with dev_err_probe()
- Removed unused realtek_variant.info
- Used realtek_common_(un)lock() in chip variant modules

Comments

Luiz Angelo Daros de Luca Nov. 17, 2023, 11:57 p.m. UTC | #1
Sorry, I used the wrong prefix. It is missing PATCH. I'll fix it in a
v2 after the first round of reviews.
Jakub Kicinski Nov. 18, 2023, 12:44 a.m. UTC | #2
On Fri, 17 Nov 2023 20:57:34 -0300 Luiz Angelo Daros de Luca wrote:
> Sorry, I used the wrong prefix. It is missing PATCH.

That's fine, patchwork gobbled it up as is, no need to repost.