From patchwork Sat Sep 25 11:22:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leon Romanovsky X-Patchwork-Id: 12517427 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6ACC3C433F5 for ; Sat, 25 Sep 2021 11:24:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 50C9A61284 for ; Sat, 25 Sep 2021 11:24:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245697AbhIYL0M (ORCPT ); Sat, 25 Sep 2021 07:26:12 -0400 Received: from mail.kernel.org ([198.145.29.99]:56468 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245428AbhIYLZg (ORCPT ); Sat, 25 Sep 2021 07:25:36 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 002256128A; Sat, 25 Sep 2021 11:24:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1632569041; bh=Cl3NV1NYQWAcpVSM6GygwU59q/PE56ay+2A5k8m+/J0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BFN1GH5Yf1Hsh8UTT6arSQ8EKwmk0uMdcSCGgM/dgkyj3ocPsN9Vib6wa5dZd1Vwz u8rLDRoYW6di1kveNeOMohk6xPKcEvcce/XHpWBXbVjOIlFhpzFhJHHK+3QOzz2Zr9 UPBq95GV2ADYPAzc6L51cg9xLwD9Le8xe4Vc4UqonE/62LqGC9UUMf9agd++VJIEnk 1BjNKGV/rp1lfPh2q4rxGAM52rDVmF/gwCAivI1rzyB7FhJa0oKEDBVXsd+6pTJ0ZD KPsnfCNXWwdH+x7un/bTHw9zKjbfqAmmcjpTdlnAKXgf/Elqbq1UnyzIKCBdF0jyOH RvSInpbsT4LUg== From: Leon Romanovsky To: "David S . Miller" , Jakub Kicinski Cc: Leon Romanovsky , Alexandre Belloni , Andrew Lunn , Ariel Elior , Bin Luo , Claudiu Manoil , Coiby Xu , Derek Chickles , drivers@pensando.io, Felix Manlunas , Florian Fainelli , Geetha sowjanya , Greg Kroah-Hartman , GR-everest-linux-l2@marvell.com, GR-Linux-NIC-Dev@marvell.com, hariprasad , Ido Schimmel , Intel Corporation , intel-wired-lan@lists.osuosl.org, Ioana Ciornei , Jerin Jacob , Jesse Brandeburg , Jiri Pirko , Jonathan Lemon , Linu Cherian , linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org, linux-rdma@vger.kernel.org, linux-staging@lists.linux.dev, Loic Poulain , Manish Chopra , M Chetan Kumar , Michael Chan , Michael Guralnik , netdev@vger.kernel.org, oss-drivers@corigine.com, Richard Cochran , Saeed Mahameed , Satanand Burla , Sergey Ryazanov , Shannon Nelson , Simon Horman , Subbaraya Sundeep , Sunil Goutham , Taras Chornyi , Tariq Toukan , Tony Nguyen , UNGLinuxDriver@microchip.com, Vadym Kochan , Vivien Didelot , Vladimir Oltean Subject: [PATCH net-next v1 17/21] netdevsim: Move devlink registration to be last devlink command Date: Sat, 25 Sep 2021 14:22:57 +0300 Message-Id: <87822c7b4f20182c37758a2c0b9bb84a0a3edaf8.1632565508.git.leonro@nvidia.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org From: Leon Romanovsky This change prevents from users to access device before devlink is fully configured. Signed-off-by: Leon Romanovsky --- drivers/net/netdevsim/dev.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/net/netdevsim/dev.c b/drivers/net/netdevsim/dev.c index b2214bc9efe2..cb6645012a30 100644 --- a/drivers/net/netdevsim/dev.c +++ b/drivers/net/netdevsim/dev.c @@ -1470,7 +1470,6 @@ int nsim_dev_probe(struct nsim_bus_dev *nsim_bus_dev) if (err) goto err_devlink_free; - devlink_register(devlink); err = devlink_params_register(devlink, nsim_devlink_params, ARRAY_SIZE(nsim_devlink_params)); if (err) @@ -1511,9 +1510,9 @@ int nsim_dev_probe(struct nsim_bus_dev *nsim_bus_dev) if (err) goto err_psample_exit; - devlink_params_publish(devlink); - devlink_reload_enable(devlink); nsim_dev->esw_mode = DEVLINK_ESWITCH_MODE_LEGACY; + devlink_register(devlink); + devlink_reload_enable(devlink); return 0; err_psample_exit: @@ -1534,7 +1533,6 @@ int nsim_dev_probe(struct nsim_bus_dev *nsim_bus_dev) devlink_params_unregister(devlink, nsim_devlink_params, ARRAY_SIZE(nsim_devlink_params)); err_dl_unregister: - devlink_unregister(devlink); devlink_resources_unregister(devlink, NULL); err_devlink_free: devlink_free(devlink); @@ -1569,6 +1567,7 @@ void nsim_dev_remove(struct nsim_bus_dev *nsim_bus_dev) struct devlink *devlink = priv_to_devlink(nsim_dev); devlink_reload_disable(devlink); + devlink_unregister(devlink); nsim_dev_reload_destroy(nsim_dev); @@ -1576,7 +1575,6 @@ void nsim_dev_remove(struct nsim_bus_dev *nsim_bus_dev) nsim_dev_debugfs_exit(nsim_dev); devlink_params_unregister(devlink, nsim_devlink_params, ARRAY_SIZE(nsim_devlink_params)); - devlink_unregister(devlink); devlink_resources_unregister(devlink, NULL); devlink_free(devlink); }