Linux-Wireless Archive mirror
 help / color / mirror / Atom feed
From: "Alexis Lothoré" <alexis.lothore@bootlin.com>
To: Ajay Singh <ajay.kathat@microchip.com>,
	 Claudiu Beznea <claudiu.beznea@tuxon.dev>,
	Kalle Valo <kvalo@kernel.org>
Cc: "Thomas Petazzoni" <thomas.petazzoni@bootlin.com>,
	linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org,
	"Heiko Thiery" <Heiko.Thiery@kontron.com>,
	"Alexis Lothoré" <alexis.lothore@bootlin.com>
Subject: [PATCH v2 1/6] wifi: wilc1000: set net device registration as last step during interface creation
Date: Tue, 14 May 2024 17:51:19 +0200	[thread overview]
Message-ID: <20240514-mac_addr_at_probe-v2-1-afef09f1cd10@bootlin.com> (raw)
In-Reply-To: <20240514-mac_addr_at_probe-v2-0-afef09f1cd10@bootlin.com>

net device registration is currently done in wilc_netdev_ifc_init but
other initialization operations are still done after this registration.
Since net device is assumed to be usable right after registration, it
should be the very last step of initialization.

Move netdev registration at the very end of wilc_netdev_ifc_init to let
this function completely initialize netdevice before registering it.

Signed-off-by: Alexis Lothoré <alexis.lothore@bootlin.com>
---
 drivers/net/wireless/microchip/wilc1000/netdev.c | 31 ++++++++++++------------
 1 file changed, 16 insertions(+), 15 deletions(-)

diff --git a/drivers/net/wireless/microchip/wilc1000/netdev.c b/drivers/net/wireless/microchip/wilc1000/netdev.c
index 73f56f7b002b..acc9b9a64552 100644
--- a/drivers/net/wireless/microchip/wilc1000/netdev.c
+++ b/drivers/net/wireless/microchip/wilc1000/netdev.c
@@ -965,16 +965,6 @@ struct wilc_vif *wilc_netdev_ifc_init(struct wilc *wl, const char *name,
 	vif->priv.wdev.iftype = type;
 	vif->priv.dev = ndev;
 
-	if (rtnl_locked)
-		ret = cfg80211_register_netdevice(ndev);
-	else
-		ret = register_netdev(ndev);
-
-	if (ret) {
-		ret = -EFAULT;
-		goto error;
-	}
-
 	ndev->needs_free_netdev = true;
 	vif->iftype = vif_type;
 	vif->idx = wilc_get_available_idx(wl);
@@ -985,13 +975,24 @@ struct wilc_vif *wilc_netdev_ifc_init(struct wilc *wl, const char *name,
 	mutex_unlock(&wl->vif_mutex);
 	synchronize_rcu();
 
-	return vif;
-
-error:
 	if (rtnl_locked)
-		cfg80211_unregister_netdevice(ndev);
+		ret = cfg80211_register_netdevice(ndev);
 	else
-		unregister_netdev(ndev);
+		ret = register_netdev(ndev);
+
+	if (ret) {
+		ret = -EFAULT;
+		goto error_remove_vif;
+	}
+
+	return vif;
+
+error_remove_vif:
+	mutex_lock(&wl->vif_mutex);
+	list_del_rcu(&vif->list);
+	wl->vif_num -= 1;
+	mutex_unlock(&wl->vif_mutex);
+	synchronize_rcu();
 	free_netdev(ndev);
 	return ERR_PTR(ret);
 }

-- 
2.44.0


  reply	other threads:[~2024-05-14 15:51 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-14 15:51 [PATCH v2 0/6] wifi: wilc1000: fix default mac address Alexis Lothoré
2024-05-14 15:51 ` Alexis Lothoré [this message]
2024-05-17  8:02   ` [PATCH v2 1/6] wifi: wilc1000: set net device registration as last step during interface creation Kalle Valo
2024-05-14 15:51 ` [PATCH v2 2/6] wifi: wilc1000: register net device only after bus being fully initialized Alexis Lothoré
2024-05-14 15:51 ` [PATCH v2 3/6] wifi: wilc1000: set wilc_set_mac_address parameter as const Alexis Lothoré
2024-05-14 15:51 ` [PATCH v2 4/6] wifi: wilc1000: add function to read mac address from eFuse Alexis Lothoré
2024-05-14 15:51 ` [PATCH v2 5/6] wifi: wilc1000: make sdio deinit function really deinit the sdio card Alexis Lothoré
2024-05-14 15:51 ` [PATCH v2 6/6] wifi: wilc1000: read MAC address from fuse at probe Alexis Lothoré

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240514-mac_addr_at_probe-v2-1-afef09f1cd10@bootlin.com \
    --to=alexis.lothore@bootlin.com \
    --cc=Heiko.Thiery@kontron.com \
    --cc=ajay.kathat@microchip.com \
    --cc=claudiu.beznea@tuxon.dev \
    --cc=kvalo@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=thomas.petazzoni@bootlin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).