Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.0 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4768CC10F0E for ; Thu, 18 Apr 2019 14:06:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 14886217FA for ; Thu, 18 Apr 2019 14:06:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=resnulli-us.20150623.gappssmtp.com header.i=@resnulli-us.20150623.gappssmtp.com header.b="GaXIVB9T" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388253AbfDROG1 (ORCPT ); Thu, 18 Apr 2019 10:06:27 -0400 Received: from mail-wm1-f68.google.com ([209.85.128.68]:51771 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389290AbfDROGX (ORCPT ); Thu, 18 Apr 2019 10:06:23 -0400 Received: by mail-wm1-f68.google.com with SMTP id 4so2928500wmf.1 for ; Thu, 18 Apr 2019 07:06:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=resnulli-us.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=1gl2ExjipI+FNpMZvPxbqUS7nQGLxjtJeq37Sy5rja0=; b=GaXIVB9TCqnUkm+Ph4Z5x4A3rA20YzLQK7OAxRiOEJYmMO0CDl/38wdHP9+5ouLEJl usTlulsx5UoG1BIjX7TE0IVEUu33U4eizX25YlpFLGMZIsB2Z5+TFFIyF/xlRgXwLJa4 ud/7XOI7PulRHz6qg85PwLJILbEWxEfe0Tua9zMMwmaidFOA9pTj5NM1xt9+0NDkF2bw yfNduyHbbQ5PR5hxVXCcYJxdWTwIciJHZEqsOom9d3W8CwbhfLvKO5MOgGC+ehe1w0HB FilMkVF7K6X8f2XD0zCya4kp3+8dLKogkifSl07vZ7TaI6Xma5jh1nh84iHPLttDZZA2 s7tg== 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; bh=1gl2ExjipI+FNpMZvPxbqUS7nQGLxjtJeq37Sy5rja0=; b=jCzLZTek5zHCSH+D1tl1VtdW4TuHCmRWgpSuTcYZ+U0tajoGQCbpN2tD11DJEfU/Wf +JSIDZMbhJGmRLrO1QJOqnxHtv8jXmFYHoQQtPeK/fz8kGgtpFdZBzf/MDoMpD7KyJpc +kdQwX4XpsjGRwaeX9jHDKbabMqjMUujJf3MsjGmfxPjHd3LVAISMpxz0IWFmzdFiKQ8 7Y6sCeHNvLqZxpqkk3HYK0xtGVCfimmPwuukWoIvBdumyVOSGnpwQxsIEjhRoRHJgVJO nMnEeRYnKf0tIta8YODyI9E5Uqb0iMZgqS0EnsSTac7QXeJbQz3bAmCbPBYwRHtcGqk9 nXEw== X-Gm-Message-State: APjAAAUPGXjRVPQyY8uE1hDP/+8ruIP91rVh98m4KU1mS5GFT3XuvpH7 QAlQklwI9H+F4qzVJ4YWqA/3J/eP1JE= X-Google-Smtp-Source: APXvYqzP4UouJALUr0nNzq7FZYI1WgLvmiuEz+3qe7VTH4ZiJhxjPbNebr6WL17mHeM1ykizcDIjtg== X-Received: by 2002:a1c:4102:: with SMTP id o2mr3112796wma.91.1555596381549; Thu, 18 Apr 2019 07:06:21 -0700 (PDT) Received: from localhost (jirka.pirko.cz. [84.16.102.26]) by smtp.gmail.com with ESMTPSA id a22sm2574546wmj.44.2019.04.18.07.06.21 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 18 Apr 2019 07:06:21 -0700 (PDT) From: Jiri Pirko To: netdev@vger.kernel.org Cc: davem@davemloft.net, mlxsw@mellanox.com, jakub.kicinski@netronome.com, dsahern@gmail.com Subject: [patch net-next 04/15] netdevsim: put netdevsim bus code into separate file Date: Thu, 18 Apr 2019 16:06:03 +0200 Message-Id: <20190418140614.3973-5-jiri@resnulli.us> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190418140614.3973-1-jiri@resnulli.us> References: <20190418140614.3973-1-jiri@resnulli.us> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Jiri Pirko As the code related to netdevsim bus is going to get bigger, move the existing code to a separate file. Signed-off-by: Jiri Pirko --- rfc->v1: - rebased --- drivers/net/netdevsim/Makefile | 2 +- drivers/net/netdevsim/bus.c | 24 ++++++++++++++++++++++++ drivers/net/netdevsim/netdev.c | 18 ++++++------------ drivers/net/netdevsim/netdevsim.h | 7 +++++++ 4 files changed, 38 insertions(+), 13 deletions(-) create mode 100644 drivers/net/netdevsim/bus.c diff --git a/drivers/net/netdevsim/Makefile b/drivers/net/netdevsim/Makefile index a72dec8e179c..ab7e2c42088f 100644 --- a/drivers/net/netdevsim/Makefile +++ b/drivers/net/netdevsim/Makefile @@ -3,7 +3,7 @@ obj-$(CONFIG_NETDEVSIM) += netdevsim.o netdevsim-objs := \ - netdev.o dev.o fib.o sdev.o + netdev.o dev.o fib.o sdev.o bus.o ifeq ($(CONFIG_BPF_SYSCALL),y) netdevsim-objs += \ diff --git a/drivers/net/netdevsim/bus.c b/drivers/net/netdevsim/bus.c new file mode 100644 index 000000000000..26b866b72afc --- /dev/null +++ b/drivers/net/netdevsim/bus.c @@ -0,0 +1,24 @@ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright (C) 2017 Netronome Systems, Inc. + * Copyright (C) 2019 Mellanox Technologies. All rights reserved + */ + +#include + +#include "netdevsim.h" + +struct bus_type nsim_bus = { + .name = DRV_NAME, + .dev_name = DRV_NAME, + .num_vf = nsim_num_vf, +}; + +int nsim_bus_init(void) +{ + return bus_register(&nsim_bus); +} + +void nsim_bus_exit(void) +{ + bus_unregister(&nsim_bus); +} diff --git a/drivers/net/netdevsim/netdev.c b/drivers/net/netdevsim/netdev.c index 31fc6564d181..7bc0da8cc10d 100644 --- a/drivers/net/netdevsim/netdev.c +++ b/drivers/net/netdevsim/netdev.c @@ -42,19 +42,13 @@ struct nsim_vf_config { static struct dentry *nsim_ddir; -static int nsim_num_vf(struct device *dev) +int nsim_num_vf(struct device *dev) { struct netdevsim *ns = to_nsim(dev); return ns->num_vfs; } -static struct bus_type nsim_bus = { - .name = DRV_NAME, - .dev_name = DRV_NAME, - .num_vf = nsim_num_vf, -}; - static int nsim_vfs_enable(struct netdevsim *ns, unsigned int num_vfs) { ns->vfconfigs = kcalloc(num_vfs, sizeof(struct nsim_vf_config), @@ -544,18 +538,18 @@ static int __init nsim_module_init(void) if (err) goto err_debugfs_destroy; - err = bus_register(&nsim_bus); + err = nsim_bus_init(); if (err) goto err_sdev_exit; err = rtnl_link_register(&nsim_link_ops); if (err) - goto err_unreg_bus; + goto err_bus_exit; return 0; -err_unreg_bus: - bus_unregister(&nsim_bus); +err_bus_exit: + nsim_bus_exit(); err_sdev_exit: nsim_sdev_exit(); err_debugfs_destroy: @@ -566,7 +560,7 @@ static int __init nsim_module_init(void) static void __exit nsim_module_exit(void) { rtnl_link_unregister(&nsim_link_ops); - bus_unregister(&nsim_bus); + nsim_bus_exit(); nsim_sdev_exit(); debugfs_remove_recursive(nsim_ddir); } diff --git a/drivers/net/netdevsim/netdevsim.h b/drivers/net/netdevsim/netdevsim.h index 23d19b461873..7a144aa7965a 100644 --- a/drivers/net/netdevsim/netdevsim.h +++ b/drivers/net/netdevsim/netdevsim.h @@ -188,3 +188,10 @@ static inline struct netdevsim *to_nsim(struct device *ptr) { return container_of(ptr, struct netdevsim, dev); } + +int nsim_num_vf(struct device *dev); + +extern struct bus_type nsim_bus; + +int nsim_bus_init(void); +void nsim_bus_exit(void); -- 2.17.2