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=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 9BB52C4321B for ; Thu, 25 Apr 2019 14:00:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8309920717 for ; Thu, 25 Apr 2019 14:00:08 +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="ujT5TGI9" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728622AbfDYOAG (ORCPT ); Thu, 25 Apr 2019 10:00:06 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:34719 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728327AbfDYOAE (ORCPT ); Thu, 25 Apr 2019 10:00:04 -0400 Received: by mail-wr1-f68.google.com with SMTP id c6so24808183wrm.1 for ; Thu, 25 Apr 2019 07:00:03 -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=ujT5TGI908AQ6qSvtBj7e7PNF1aHRmEDexMRyGMWWeSnkR/WUB1B4QupwAnWbwTUAo AALdLG1wWwcC7NUNoHTuHumtmjxt+p6oA1tVepYS9AxXNWqHPoF51rSVzDPXMiOWHmYx zcJFVpUgxgjcKuWg8xvxKq0riG7VoCv7QTcpY2txGrWoHU2Lszf/It9lXYEfNiqRlfTp 1P3NqAfgMfIt7e1pPjcSyzgabBDkolUTklIKHxAra/bghU/EvqxoDaTrZluunBIPJI2K 9C09Q7sfJHmUYPQ0mSwUQjHinvCEnh80tDO10/PrKpqjLNdleGEof5zyuihhxh+CAE91 ZBAA== 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=pF8iwQnF9X+5mV2Isrec+l9PUJJwHNkAMpbIj3ljXb5TO10eXO3bjjih+gYW4tVxYg kbS0KhziDut9vzh97yJv+Saxeph5JdYCfOy8GHU4RuakshjMRW+smuSE+KnS06Ieyqcr PrGmmsHLA2jlb4PZslzghI/s55fGhG7UAOYu/GtkRlutR+JRKPUyNzqDVdU/GifuW4QO tj6N/wAlv7d4DcM84TWApZxwjhBqWwW2cbKzFsEYS+OU2jGnKQk/ycsi5/1PUpHY4GII DzSDa2sRElPkyDvdtdB7oPpDFPQYS0zUtKSSSYVoBacMvbEMed4sLB47bV0TfFBSWv5S h2bw== X-Gm-Message-State: APjAAAUN+wWVCccjFSSsdpjZCJtO+u5w36o0g07qwF1EoKbNFiKLLwfA fg2zKtvcanvpYe4pa9z9B1rGXtbgRQ8= X-Google-Smtp-Source: APXvYqziNDKZlXfhVVS3WQ2fjXgkpKJMWS3ECPP3YWACbj+7dwNaQnHtlZdXMeqLHj8IW1QWJ03dtA== X-Received: by 2002:a5d:6988:: with SMTP id g8mr4729431wru.117.1556200802283; Thu, 25 Apr 2019 07:00:02 -0700 (PDT) Received: from localhost (jirka.pirko.cz. [84.16.102.26]) by smtp.gmail.com with ESMTPSA id t74sm31056662wmt.3.2019.04.25.07.00.01 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 25 Apr 2019 07:00:01 -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 v4 04/16] netdevsim: put netdevsim bus code into separate file Date: Thu, 25 Apr 2019 15:59:44 +0200 Message-Id: <20190425135956.3970-5-jiri@resnulli.us> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190425135956.3970-1-jiri@resnulli.us> References: <20190425135956.3970-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