From patchwork Sat Apr 20 10:29:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Pirko X-Patchwork-Id: 1088361 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=resnulli.us Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=resnulli-us.20150623.gappssmtp.com header.i=@resnulli-us.20150623.gappssmtp.com header.b="WnUXdQ+c"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 44mTbz16QQz9s9G for ; Sat, 20 Apr 2019 20:29:35 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727962AbfDTK3d (ORCPT ); Sat, 20 Apr 2019 06:29:33 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:36956 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726893AbfDTK3a (ORCPT ); Sat, 20 Apr 2019 06:29:30 -0400 Received: by mail-wr1-f66.google.com with SMTP id w10so9763020wrm.4 for ; Sat, 20 Apr 2019 03:29:29 -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=WnUXdQ+cC0zCT4QEoXcpzDTdIFDkQI9F/38hWwWjUvXaOBArWIp79sI3ZTO9hQdNP/ V7IHfMahV5YsgQFU9t/TzW4YV2PXRH9Quu0pBlx3IWqGtWV87wV65HvyFoc03AXozbjH lrKDbf1slgDzR2W4h+//YTbCBkSTE0STnlxY/gnB5RJeGAxFUuEHHuqME7gXB4aFcHI5 5gj/e1CVD3O6Io0czFqgRcD3xvOFQ2IHRF5kFJPOEGO5WGkyA89gBhCl1tE8gWNhIjiM um3s+n9/1YKf189CrAz4WKScMIiIkAEvEpdg0+G8OPOWoq2lKyTlVI+75pc3EgMrQMMo BJYA== 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=H7X64HivjGNi/y62nkuimRzA04hckmSojTjn7/htmc4HjqE969vx5liCx3OUAjgJGh xrh3PJxksLnD9lEBROehq5eBlQQzXusgkdp+09zS1oHh8qh6hpLEuDWt43OxjZIvg158 kpoiaBDxCztdKPFQm5YOsqiVIW+Kw36xv8QFATTt3rs8z5gd5N438/SkJE1RBZTrFXLh b5DFtMXUDRXYq6aelPfBz9SZtLiQ8R1i33KXFn92kpSbFOQcF3Yip7A7zOduDPYGkDrb Li4n/kxPhQwe+qF0pecnghm+xRVnzWe0T0tjRLcBDFZ5xPgUKWadvpRVoT82ayP7nLe5 3ecg== X-Gm-Message-State: APjAAAX2i+m9MjkQ6w7OYfecPNCh9U9/gy+ENI8FgtwBimXjOfydiP79 oEtF9VoTxefvMgz8UlV7bpm4/yAlo5g= X-Google-Smtp-Source: APXvYqzrIANg6TkBVaC2MdgTeerMRTLvrCFA+QUIETEgbyCrv8FG4gRBIJ8XEjN8MX0K/wl+DHYR7w== X-Received: by 2002:adf:e309:: with SMTP id b9mr2052459wrj.165.1555756168603; Sat, 20 Apr 2019 03:29:28 -0700 (PDT) Received: from localhost (jirka.pirko.cz. [84.16.102.26]) by smtp.gmail.com with ESMTPSA id w11sm13163805wre.15.2019.04.20.03.29.28 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 20 Apr 2019 03:29:28 -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 v2 04/16] netdevsim: put netdevsim bus code into separate file Date: Sat, 20 Apr 2019 12:29:10 +0200 Message-Id: <20190420102922.6001-5-jiri@resnulli.us> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190420102922.6001-1-jiri@resnulli.us> References: <20190420102922.6001-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);