blob: a71edb7be693084d10b50ef844f30294ff35c26b [file] [log] [blame]
From 09eb1b9f73d677d10d18039305b9d974e52cc6d5 Mon Sep 17 00:00:00 2001
From: Nicola Fontana <ntd@entidi.it>
Date: Mon, 3 Jun 2024 12:45:48 +0200
Subject: [PATCH] Remove dev_base_lock for linux >= 6.9.0
Kernel commit 1b3ef46cb7f2618cc0b507393220a69810f6da12 removed
`dev_base_lock` from v6.9 onward.
Use the alternate iterator `for_each_netdev_rcu` introduced by commit
c6d14c84566d6b70ad9dc1618db0dec87cca9300 in 2.6.33+.
Upstream: https://gitlab.com/etherlab.org/ethercat/-/commit/95c25b50711ca7e1f990bdcbca8fa713c942ab01
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
---
devices/generic.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/devices/generic.c b/devices/generic.c
index 4d4d9bbd..f30f1e17 100644
--- a/devices/generic.c
+++ b/devices/generic.c
@@ -420,14 +420,14 @@ int __init ec_gen_init_module(void)
INIT_LIST_HEAD(&generic_devices);
INIT_LIST_HEAD(&descs);
- read_lock(&dev_base_lock);
- for_each_netdev(&init_net, netdev) {
+ rcu_read_lock();
+ for_each_netdev_rcu(&init_net, netdev) {
if (netdev->type != ARPHRD_ETHER)
continue;
desc = kmalloc(sizeof(ec_gen_interface_desc_t), GFP_ATOMIC);
if (!desc) {
ret = -ENOMEM;
- read_unlock(&dev_base_lock);
+ rcu_read_unlock();
goto out_err;
}
strncpy(desc->name, netdev->name, IFNAMSIZ);
@@ -436,7 +436,7 @@ int __init ec_gen_init_module(void)
memcpy(desc->dev_addr, netdev->dev_addr, ETH_ALEN);
list_add_tail(&desc->list, &descs);
}
- read_unlock(&dev_base_lock);
+ rcu_read_unlock();
list_for_each_entry_safe(desc, next, &descs, list) {
ret = offer_device(desc);
--
2.45.2