From patchwork Wed Aug 4 15:36:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 491679 Delivered-To: patch@linaro.org Received: by 2002:a05:6638:396:0:0:0:0 with SMTP id y22csp1744444jap; Wed, 4 Aug 2021 08:36:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJywmxMftjb0bSiLqh0vMqITUtwgD9EamMANPaDhJvDrFyG9XLHCNVnlNh16J2iWDarzqERt X-Received: by 2002:aa7:cd71:: with SMTP id ca17mr431389edb.58.1628091398501; Wed, 04 Aug 2021 08:36:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628091398; cv=none; d=google.com; s=arc-20160816; b=JMtJqqnch6VdL3+QHWgb/4xYAxxcCbVkBGJ0KrszcSdVeyC0q9d30OMN8mLbzZ7zBi au3aqmvElLxknUeloRc/yTuecybL/VvHTN/Ny2zwWqx0UfUSjtwb1khJ0Or7SIduaHPc tgrLiNMlXIcXYr2Y1yon1wEmxFWHRyucv10CWDlAHEan+R3S/nbh98QAm4q8tdHnHfZd 7uGnWkQ+KdnddMrwKWD2/u81dnZA6h7wK0hk7IX53yd/ISB89Lh4GgBWjcHITrDSo7Ai uxl4WQzac4Kx4jH374RNGAzTx3Gs7ArXzN1VR17ANtC1NjEStyF+xcox1OEnjQHC7fyh UcJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=fYPy0EiH44k22cfOkFHbddfBvF8NraMV8hju0p8WV3I=; b=Yg650hTyfjcC9d6SdHxM5zQuYm4RZRAz20TSubR/YR991oRAD3rwGWX4kZE9jUamK5 5hr4Id/TAS1walPhHRwe1HawD0+v60ZIgWuIjz35XKl/PE4n4mtyZ0+zKWb1x3CxFfBS Q9ODdIkEzacQsHDpU78/USePhHRO8ET+8j/slVRn3zH7FRdw1aQdhh4XgAWYjBec9e+I qBBroxmt4A0K16TCYAWSeJBHtetdUmVsvEOxIsYWncRyW6kOL1zg4EXa4zCLolVAt6Ed 25grEKO/Tmzn4jVG10XD1HyVHYu8gUpwwQ79SnO0E/vtw/aiFTCGCspYeWghV/TBSrnZ zX+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nfa3a3gi; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id me18si2499859ejb.340.2021.08.04.08.36.38; Wed, 04 Aug 2021 08:36:38 -0700 (PDT) Received-SPF: pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nfa3a3gi; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239151AbhHDPgr (ORCPT + 8 others); Wed, 4 Aug 2021 11:36:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42222 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239099AbhHDPgo (ORCPT ); Wed, 4 Aug 2021 11:36:44 -0400 Received: from mail-il1-x132.google.com (mail-il1-x132.google.com [IPv6:2607:f8b0:4864:20::132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 095ACC0613D5 for ; Wed, 4 Aug 2021 08:36:32 -0700 (PDT) Received: by mail-il1-x132.google.com with SMTP id i9so2032770ilk.9 for ; Wed, 04 Aug 2021 08:36:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=fYPy0EiH44k22cfOkFHbddfBvF8NraMV8hju0p8WV3I=; b=nfa3a3gifGAmzcnPuZcW28cXDmG7gslzHVrpFLibwHKn64pSf5F/fFXAkN5hxytTFh c0t9+UkVdA1SGhzdUZGHw4bKRUh7vheepR4V2huVhnQGjCoMaUISEC37qvUHyLPLcWjZ W64vnSt7ckWVNnG7lG9SI0LODBArDaedcM3lpze2zHX+DVRCAsibwTl9ReYUa28PiqWV BTfrDCUlzG49F3K6xUtadCNjZT61slN9YjELEpkE+okX9aFEx99mGnCrieUQvDVgspeD BVYUIMEFZ+xezpvVatoESVQsGVCq4nGfQz0wiNrWNVRlmaOgIEEiPoUsaPIlgdntuSWM nq/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=fYPy0EiH44k22cfOkFHbddfBvF8NraMV8hju0p8WV3I=; b=p/1E1PjRxJU47rCS556p5zfczfHdMPeMyGvNhcSbeSYiQ4eNMtjN4UkCkQ8N7VGY2p aBif0OvNFBPKcEqOZYZ0TkAAeI42b/rZV5Ywy5Eybo7Hj5Hr7RttHUuQg3y5rYifgSpq u6naswAxqIyi7wXr+7G8VL0M71HlfCZGJILj+vG8e3kArzK7aQ8351+C4Yh0YF9xe93J vQ81Sa38GvfgfVBb/KV+xpgnB1jR3DYpVSCsu76Za0vfNJ07Vs11Gtg9uMiDXSLE/HDQ sJmek+SJBsw6/SPO4dleXrlvLPXkRjSksBFrKMSb2oHrhgdUIj/nSibUn/bUH9Ia0dht qDyg== X-Gm-Message-State: AOAM531RNM7h98w0+IlfPgWI9jkcKwNYpfNqjc+dftAQuIMWKeHirbgo GfZxldMW/IPRjVEz/lBnk9k6Zw== X-Received: by 2002:a92:d088:: with SMTP id h8mr11704ilh.165.1628091391490; Wed, 04 Aug 2021 08:36:31 -0700 (PDT) Received: from presto.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id z11sm1687480ioh.14.2021.08.04.08.36.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Aug 2021 08:36:31 -0700 (PDT) From: Alex Elder To: davem@davemloft.net, kuba@kernel.org Cc: bjorn.andersson@linaro.org, evgreen@chromium.org, cpratapa@codeaurora.org, subashab@codeaurora.org, elder@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 2/6] net: ipa: reorder netdev pointer assignments Date: Wed, 4 Aug 2021 10:36:22 -0500 Message-Id: <20210804153626.1549001-3-elder@linaro.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210804153626.1549001-1-elder@linaro.org> References: <20210804153626.1549001-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Assign the ipa->modem_netdev and endpoint->netdev pointers *before* registering the network device. As soon as the device is registered it can be opened, and by that time we'll want those pointers valid. Similarly, don't make those pointers NULL until *after* the modem network device is unregistered in ipa_modem_stop(). Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_modem.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) -- 2.27.0 diff --git a/drivers/net/ipa/ipa_modem.c b/drivers/net/ipa/ipa_modem.c index 663a610979e70..ad4019e8016ec 100644 --- a/drivers/net/ipa/ipa_modem.c +++ b/drivers/net/ipa/ipa_modem.c @@ -231,13 +231,15 @@ int ipa_modem_start(struct ipa *ipa) SET_NETDEV_DEV(netdev, &ipa->pdev->dev); priv = netdev_priv(netdev); priv->ipa = ipa; + ipa->name_map[IPA_ENDPOINT_AP_MODEM_TX]->netdev = netdev; + ipa->name_map[IPA_ENDPOINT_AP_MODEM_RX]->netdev = netdev; + ipa->modem_netdev = netdev; ret = register_netdev(netdev); - if (!ret) { - ipa->modem_netdev = netdev; - ipa->name_map[IPA_ENDPOINT_AP_MODEM_TX]->netdev = netdev; - ipa->name_map[IPA_ENDPOINT_AP_MODEM_RX]->netdev = netdev; - } else { + if (ret) { + ipa->modem_netdev = NULL; + ipa->name_map[IPA_ENDPOINT_AP_MODEM_RX]->netdev = NULL; + ipa->name_map[IPA_ENDPOINT_AP_MODEM_TX]->netdev = NULL; free_netdev(netdev); } @@ -276,10 +278,10 @@ int ipa_modem_stop(struct ipa *ipa) /* If it was opened, stop it first */ if (netdev->flags & IFF_UP) (void)ipa_stop(netdev); - ipa->name_map[IPA_ENDPOINT_AP_MODEM_RX]->netdev = NULL; - ipa->name_map[IPA_ENDPOINT_AP_MODEM_TX]->netdev = NULL; - ipa->modem_netdev = NULL; unregister_netdev(netdev); + ipa->modem_netdev = NULL; + ipa->name_map[IPA_ENDPOINT_AP_MODEM_RX]->netdev = NULL; + ipa->name_map[IPA_ENDPOINT_AP_MODEM_TX]->netdev = NULL; free_netdev(netdev); }