• Samuel Holland's avatar
    net: stmmac: dwmac-sun8i: Balance syscon (de)initialization · 9b1e39cf
    Samuel Holland authored
    Previously, sun8i_dwmac_set_syscon was called from a chain of functions
    in several different files:
        sun8i_dwmac_probe
          stmmac_dvr_probe
            stmmac_hw_init
              stmmac_hwif_init
                sun8i_dwmac_setup
                  sun8i_dwmac_set_syscon
    which made the lifetime of the syscon values hard to reason about. Part
    of the problem is that there is no similar platform driver callback from
    stmmac_dvr_remove. As a result, the driver unset the syscon value in
    sun8i_dwmac_exit, but this leaves it uninitialized after a suspend/
    resume cycle. It was also unset a second time (outside sun8i_dwmac_exit)
    in the probe error path.
    
    Move the init to the earliest available place in sun8i_dwmac_probe
    (after stmmac_probe_config_dt, which initializes plat_dat), and the
    deinit to the corresponding position in the cleanup order.
    
    Since priv is not filled in until stmmac_dvr_probe, this requires
    changing the sun8i_dwmac_set_syscon parameters to priv's two relevant
    members.
    
    Fixes: 9f93ac8d ("net-next: stmmac: Add dwmac-sun8i")
    Fixes: 634db83b ("net: stmmac: dwmac-sun8i: Handle integrated/external MDIOs")
    Signed-off-by: default avatarSamuel Holland <samuel@sholland.org>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    9b1e39cf
dwmac-sun8i.c 33.8 KB