From mboxrd@z Thu Jan 1 00:00:00 1970 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,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 C3CB5C10F11 for ; Sat, 13 Apr 2019 16:21:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9318B208E3 for ; Sat, 13 Apr 2019 16:21:24 +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="dJmdDI2p" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727286AbfDMQVW (ORCPT ); Sat, 13 Apr 2019 12:21:22 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:38071 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727191AbfDMQVU (ORCPT ); Sat, 13 Apr 2019 12:21:20 -0400 Received: by mail-wr1-f68.google.com with SMTP id k11so15916168wro.5 for ; Sat, 13 Apr 2019 09:21:19 -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=XHw5hY8oJ/jxx5tF5V2dRWucsc5ZeeB8jBswXgrZGMI=; b=dJmdDI2p3G5Vs1OAXETwnIu4CwW7jx4lT6zIJGjreJCZiG5i5Soss664c45XUyA6WM FaUX4GyFU50aG8OG8lZwTYr8AWDWxpGjfs3Xn1bWjrW3F2keEZZ/61tRtEENOkLx1OBY bKp7QvKnvsyL9PmknwksnADFyryU8KtkKjjsNA4EmfTuclvFDUgsQULhav2vwYAQ8YjS cxv1PyFFSJ9nLSTKbQAmsMQk7W39FRnvqwLwTeypexUW/gOf1QmjQFfPHX0rhEOQfAFh 2jOLIF1nVFjBaui/Kvgjn0X/ewsp3bG8YQaMqcSrtX3/Ok90XONwGLPusEm9Fw6v/iLT bNrg== 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=XHw5hY8oJ/jxx5tF5V2dRWucsc5ZeeB8jBswXgrZGMI=; b=m/YVYj/PjVnUBmO7QvC1mU2AOLZGB8wbyL9y+xz3psbUF41sFJt/XwBt9qOSWAoBZZ iTtdGWaBEh7GVKhgmjoE89rfVetz/3ElAiydspSFat+BEukR+25GKCAMVbBkG6sVV7YB 5rswWM0dElFn/1mI1eStBOdvxQDrF9CcfiHKjRyhrZH+Npz+Cw9q3m0kDS7pClSxvULp Ohh+0lcThrjTy4Tfn9UmdejfZ+Mt58+3b1iTe84i6QALbl7giS31nY53AeElMoS112dq JjZFYf0mq5uoDsFGDoohzsyeBkJ9eRfuTLkx543MHoTBPiyEIcAY5Obq7J66kvDGKYLE WJTw== X-Gm-Message-State: APjAAAVWnXW5Ze8LSu19irLkVitEQcOWB1mHdzz22tyXfLFXEiWfPeC8 jmH98t41SGNttJeVXzHzrQaX9cnuy+s= X-Google-Smtp-Source: APXvYqziUttd9q7qflwubi0qt9MBukJ5Xd/am3HTz0qiHgz6CBzHFRVg2kcPMJNfyKy3G0dLCriExQ== X-Received: by 2002:adf:9427:: with SMTP id 36mr41962509wrq.128.1555172478509; Sat, 13 Apr 2019 09:21:18 -0700 (PDT) Received: from localhost (jirka.pirko.cz. [84.16.102.26]) by smtp.gmail.com with ESMTPSA id x14sm14558261wmj.3.2019.04.13.09.21.18 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 13 Apr 2019 09:21:18 -0700 (PDT) From: Jiri Pirko To: netdev@vger.kernel.org Cc: davem@davemloft.net, mlxsw@mellanox.com, jakub.kicinski@netronome.com Subject: [patch net-next rfc 04/15] netdevsim: put netdevsim bus code into separate file Date: Sat, 13 Apr 2019 18:21:01 +0200 Message-Id: <20190413162112.8203-5-jiri@resnulli.us> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190413162112.8203-1-jiri@resnulli.us> References: <20190413162112.8203-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 --- 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 d9486e05f4ea..eea6162f3886 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