mirror of
https://github.com/torvalds/linux.git
synced 2026-09-22 04:34:03 +02:00
Merge branch 'net-dsa-realtek-use-devm_mutex_init'
Luiz Angelo Daros de Luca says: ==================== net: dsa: realtek: use devm_mutex_init This series fixes mutex teardown in the Realtek DSA drivers. With CONFIG_DEBUG_MUTEXES enabled, mutex_destroy() must be called before the mutex is discarded. Using devm_mutex_init() lets the driver core handle that automatically. The changes are split into individual commits based on the feature that introduced each lock to allow proper backports to stable trees. ==================== Link: https://patch.msgid.link/20260726-realtek_mutext-v2-0-5d62ba998791@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
commit
dd16f1b572
|
|
@ -1988,16 +1988,19 @@ static void rtl8365mb_get_stats64(struct dsa_switch *ds, int port,
|
|||
spin_unlock(&p->stats_lock);
|
||||
}
|
||||
|
||||
static void rtl8365mb_stats_setup(struct realtek_priv *priv)
|
||||
static int rtl8365mb_stats_setup(struct realtek_priv *priv)
|
||||
{
|
||||
struct rtl8365mb *mb = priv->chip_data;
|
||||
struct dsa_switch *ds = &priv->ds;
|
||||
struct dsa_port *dp;
|
||||
int ret;
|
||||
|
||||
/* Per-chip global mutex to protect MIB counter access, since doing
|
||||
* so requires accessing a series of registers in a particular order.
|
||||
*/
|
||||
mutex_init(&mb->mib_lock);
|
||||
ret = devm_mutex_init(priv->dev, &mb->mib_lock);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
dsa_switch_for_each_available_port(dp, ds) {
|
||||
struct rtl8365mb_port *p = &mb->ports[dp->index];
|
||||
|
|
@ -2010,6 +2013,8 @@ static void rtl8365mb_stats_setup(struct realtek_priv *priv)
|
|||
*/
|
||||
INIT_DELAYED_WORK(&p->mib_work, rtl8365mb_stats_poll);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void rtl8365mb_stats_teardown(struct realtek_priv *priv)
|
||||
|
|
@ -2567,7 +2572,12 @@ static int rtl8365mb_setup(struct dsa_switch *ds)
|
|||
}
|
||||
|
||||
/* Start statistics counter polling */
|
||||
rtl8365mb_stats_setup(priv);
|
||||
ret = rtl8365mb_stats_setup(priv);
|
||||
if (ret) {
|
||||
dev_err(priv->dev, "failed to setup stats: %pe\n",
|
||||
ERR_PTR(ret));
|
||||
goto out_teardown_irq;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -156,9 +156,17 @@ rtl83xx_probe(struct device *dev,
|
|||
if (!priv)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
mutex_init(&priv->map_lock);
|
||||
mutex_init(&priv->vlan_lock);
|
||||
mutex_init(&priv->l2_lock);
|
||||
ret = devm_mutex_init(dev, &priv->map_lock);
|
||||
if (ret)
|
||||
return ERR_PTR(ret);
|
||||
|
||||
ret = devm_mutex_init(dev, &priv->vlan_lock);
|
||||
if (ret)
|
||||
return ERR_PTR(ret);
|
||||
|
||||
ret = devm_mutex_init(dev, &priv->l2_lock);
|
||||
if (ret)
|
||||
return ERR_PTR(ret);
|
||||
|
||||
rc.lock_arg = priv;
|
||||
priv->map = devm_regmap_init(dev, NULL, priv, &rc);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user