From patchwork Wed Sep 30 08:21:12 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 524173 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 79CE414029C for ; Wed, 30 Sep 2015 18:22:29 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754807AbbI3IWL (ORCPT ); Wed, 30 Sep 2015 04:22:11 -0400 Received: from mail-wi0-f170.google.com ([209.85.212.170]:37740 "EHLO mail-wi0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754479AbbI3IVS (ORCPT ); Wed, 30 Sep 2015 04:21:18 -0400 Received: by wicfx3 with SMTP id fx3so49711012wic.0 for ; Wed, 30 Sep 2015 01:21:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:to:cc:from:subject:organization:message-id:date :user-agent:mime-version:content-type:content-transfer-encoding; bh=8Akf7O3YqcdcQi4vr5QBuc2HtxUp/q0N2u8onnVqe5M=; b=E3RsCIkzK1FAPEw/Sq+NFyZwV7Z/MyahZOEdHgzURmsbEqysjiEg2t6Md1+4bbuZRd BkAnoeFyvK8igcB9v+1Uu0sYtRpFbPF89WIrjR7VA2bVJN8JiJ5hnhS84ou1Qmud8hb4 gnvxijtn1GJnmXjEb1ZfK3GIBa2uE3JphxIy5tES//VVsBhm3sfJ8txiqYzySXRVlaBf nF027TsbJzol26MaAROvR8et+3YFoAG5D24gpp4oo7dBoE4gWV/uleAbc/G8Yi2iHszs lwf46E0UVw4R5E9hNQrmDR2enwO+g/Tf5LLcerQUsjdhEbp9Aq1URfl7oxi1qtqA2stS HUVA== X-Gm-Message-State: ALoCoQlEVUCw12GQoN2f47UK9m05CVA52PIURg4DpySsa3AWy5F500VjvJ5VjDMMOr+U2RWxL/rO X-Received: by 10.180.92.230 with SMTP id cp6mr27764769wib.80.1443601277276; Wed, 30 Sep 2015 01:21:17 -0700 (PDT) Received: from [192.168.2.52] (LPoitiers-656-1-62-228.w90-63.abo.wanadoo.fr. [90.63.143.228]) by smtp.gmail.com with ESMTPSA id e6sm28172798wiy.3.2015.09.30.01.21.16 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 30 Sep 2015 01:21:16 -0700 (PDT) To: "David S. Miller" , Jesper Dangaard Brouer Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org From: Neil Armstrong Subject: [RFC PATCH 2/3] net: dsa: complete dsa_switch_destroy calls Organization: Baylibre Message-ID: <560B9B78.1020904@baylibre.com> Date: Wed, 30 Sep 2015 10:21:12 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org When unbinding dsa, complete the dsa_switch_destroy to cleanly destroy and unregister the net and mdio devices. Signed-off-by: Neil Armstrong --- net/dsa/dsa.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c index 98f94c2..0c104af 100644 --- a/net/dsa/dsa.c +++ b/net/dsa/dsa.c @@ -22,6 +22,7 @@ #include #include #include +#include #include "dsa_priv.h" char dsa_driver_version[] = "0.1"; @@ -420,10 +421,51 @@ dsa_switch_setup(struct dsa_switch_tree *dst, int index, static void dsa_switch_destroy(struct dsa_switch *ds) { + struct device_node *port_dn; + struct phy_device *phydev; + struct dsa_chip_data *cd = ds->pd; + int port; + #ifdef CONFIG_NET_DSA_HWMON if (ds->hwmon_dev) hwmon_device_unregister(ds->hwmon_dev); #endif + + /* Disable configuration of the CPU and DSA ports */ + for (port = 0; port < DSA_MAX_PORTS; port++) { + if (!(dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))) + continue; + + port_dn = cd->port_dn[port]; + if (of_phy_is_fixed_link(port_dn)) { + phydev = of_phy_find_device(port_dn); + if (phydev) { + int addr = phydev->addr; + phy_device_free(phydev); + of_node_put(port_dn); + fixed_phy_del(addr); + } + } + } + + /* + * Destroy network devices for physical switch ports. + */ + for (port = 0; port < DSA_MAX_PORTS; port++) { + if (!(ds->phys_port_mask & (1 << port))) + continue; + + if (!ds->ports[port]) + continue; + + unregister_netdev(ds->ports[port]); + free_netdev(ds->ports[port]); + } + + /* + * Do basic unregister. + */ + mdiobus_unregister(ds->slave_mii_bus); } #ifdef CONFIG_PM_SLEEP