Received: by 10.223.164.202 with SMTP id h10csp865225wrb; Mon, 6 Nov 2017 17:40:10 -0800 (PST) X-Google-Smtp-Source: ABhQp+SYw4d/i3gfKJ2ZznJFCUUcjK8F9NWyKd5GTSlCb14LNud0j6Xbu3hnFBXNeq3CNkeaW4ZE X-Received: by 10.101.73.136 with SMTP id r8mr17170530pgs.411.1510018810432; Mon, 06 Nov 2017 17:40:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510018810; cv=none; d=google.com; s=arc-20160816; b=ubxJH1ZCnOyVNqGdGJhURxpyByEA9kIit2DGp+81SoXSbH2K++L3CufFE1pUxzXfom OiPzUvTgOYhsfLkcTYn53Hw7cAgLHz3ftrtwXQ/3MwTx8HFEBG4rwwH7pSx8guQHGnJv t5VUPmNmLwy75PvSwoTdwkeV59MtRK87jfJN+kWJiMOGalyw017JgFplFXEuNklu4aCO o8MkfD3oHRA/rve9RRptqvp7c/cBJSePuLgXfZZv4D2PMwYvLuE2QPb96WZBsyDIItfu lKf7zw0VYaAIBaxXqHSJaZjRdA0WOANv921njafklhlDKDZV2fdSM+dMrSjkxS+Ha73b Pw6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=FGp+MeOmsXdZG7mRJ1d2pXbEy73uvpWY1A10PBA8QLM=; b=1BAiAiMKix86aIyAzQRzrvSN50Fz63n7ov4ATZkR93vuBPBnkYahDSMZEtI+OkPFOa ImR8MUd72A19+8tx+Bv+42UrjMuvLFXfTjY2BqxldMUzAbkG1n6ftkouYL+3Bhi/Fhzz c00wLphQq0c+ASXG0Pl6LOD2WqsmErJ1QFGdgoqJf8w189BM+iEUje0AQ1+sYG/ie5CM K9t8zNjbdjHnRgtoJOHYBcwEeqO2RiOR2G0XVOk4kBhJkcc3F2lXZZNMy3uYO+U1QOjO 3A2l4zbPFtMXDrvrTbzMsxIxP6XxVelqxGiXScL7Hn7NiAR8jdAVRpD5BRIUBq1xoGUf u48Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n123si67990pgn.35.2017.11.06.17.39.57; Mon, 06 Nov 2017 17:40:10 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753539AbdKFVPM (ORCPT + 95 others); Mon, 6 Nov 2017 16:15:12 -0500 Received: from mail.savoirfairelinux.com ([208.88.110.44]:55104 "EHLO mail.savoirfairelinux.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753488AbdKFVMR (ORCPT ); Mon, 6 Nov 2017 16:12:17 -0500 Received: from localhost (localhost [127.0.0.1]) by mail.savoirfairelinux.com (Postfix) with ESMTP id E0E569C2F16; Mon, 6 Nov 2017 16:12:16 -0500 (EST) Received: from mail.savoirfairelinux.com ([127.0.0.1]) by localhost (mail.savoirfairelinux.com [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id iTC0nHAHBdXy; Mon, 6 Nov 2017 16:12:16 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by mail.savoirfairelinux.com (Postfix) with ESMTP id 25F089C1A91; Mon, 6 Nov 2017 16:12:16 -0500 (EST) X-Virus-Scanned: amavisd-new at mail.savoirfairelinux.com Received: from mail.savoirfairelinux.com ([127.0.0.1]) by localhost (mail.savoirfairelinux.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 3HSVbSn3VIpE; Mon, 6 Nov 2017 16:12:16 -0500 (EST) Received: from weeman.mtl.sfl (unknown [192.168.49.104]) by mail.savoirfairelinux.com (Postfix) with ESMTPSA id ED4809C2F0C; Mon, 6 Nov 2017 16:12:15 -0500 (EST) From: Vivien Didelot To: netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel@savoirfairelinux.com, "David S. Miller" , Florian Fainelli , Andrew Lunn , Vivien Didelot Subject: [PATCH net-next 04/11] net: dsa: setup and teardown tree Date: Mon, 6 Nov 2017 16:11:46 -0500 Message-Id: <20171106211153.26529-5-vivien.didelot@savoirfairelinux.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20171106211153.26529-1-vivien.didelot@savoirfairelinux.com> References: <20171106211153.26529-1-vivien.didelot@savoirfairelinux.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This commit provides better scope for the DSA tree setup and teardown functions. It renames the "applied" bool to "setup" and print a message when the tree is setup, as it is done during teardown. At the same time, check dst->setup in dsa_tree_setup, where it is set to true. Signed-off-by: Vivien Didelot --- include/net/dsa.h | 2 +- net/dsa/dsa2.c | 32 ++++++++++++++++++-------------- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/include/net/dsa.h b/include/net/dsa.h index 2a8613b5a23d..6c239257309b 100644 --- a/include/net/dsa.h +++ b/include/net/dsa.h @@ -122,7 +122,7 @@ struct dsa_switch_tree { struct kref refcount; /* Has this tree been applied to the hardware? */ - bool applied; + bool setup; /* * Configuration data for the platform device that owns diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c index c9b50339fcac..1a8df0a177b5 100644 --- a/net/dsa/dsa2.c +++ b/net/dsa/dsa2.c @@ -486,12 +486,18 @@ static void dsa_tree_teardown_master(struct dsa_switch_tree *dst) return dsa_master_teardown(master); } -static int dsa_dst_apply(struct dsa_switch_tree *dst) +static int dsa_tree_setup(struct dsa_switch_tree *dst) { struct dsa_switch *ds; u32 index; int err; + if (dst->setup) { + pr_err("DSA: tree %d already setup! Disjoint trees?\n", + dst->index); + return -EEXIST; + } + err = dsa_tree_setup_default_cpu(dst); if (err) return err; @@ -510,17 +516,19 @@ static int dsa_dst_apply(struct dsa_switch_tree *dst) if (err) return err; - dst->applied = true; + dst->setup = true; + + pr_info("DSA: tree %d setup\n", dst->index); return 0; } -static void dsa_dst_unapply(struct dsa_switch_tree *dst) +static void dsa_tree_teardown(struct dsa_switch_tree *dst) { struct dsa_switch *ds; u32 index; - if (!dst->applied) + if (!dst->setup) return; dsa_tree_teardown_master(dst); @@ -535,8 +543,9 @@ static void dsa_dst_unapply(struct dsa_switch_tree *dst) dsa_tree_teardown_default_cpu(dst); - pr_info("DSA: tree %d unapplied\n", dst->index); - dst->applied = false; + pr_info("DSA: tree %d torn down\n", dst->index); + + dst->setup = false; } static void dsa_tree_remove_switch(struct dsa_switch_tree *dst, @@ -794,14 +803,9 @@ static int _dsa_register_switch(struct dsa_switch *ds) if (err == 1) return 0; - if (dst->applied) { - pr_info("DSA: Disjoint trees?\n"); - return -EINVAL; - } - - err = dsa_dst_apply(dst); + err = dsa_tree_setup(dst); if (err) { - dsa_dst_unapply(dst); + dsa_tree_teardown(dst); goto out_del_dst; } @@ -852,7 +856,7 @@ static void _dsa_unregister_switch(struct dsa_switch *ds) struct dsa_switch_tree *dst = ds->dst; unsigned int index = ds->index; - dsa_dst_unapply(dst); + dsa_tree_teardown(dst); dsa_tree_remove_switch(dst, index); } -- 2.14.3 From 1583367621464884608@xxx Tue Nov 07 01:10:34 +0000 2017 X-GM-THRID: 1583362042608495125 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread