From patchwork Wed Dec 23 12:56:36 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Lunn X-Patchwork-Id: 560535 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 6D6B6140BE9 for ; Wed, 23 Dec 2015 23:59:49 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932953AbbLWM7j (ORCPT ); Wed, 23 Dec 2015 07:59:39 -0500 Received: from vps0.lunn.ch ([178.209.37.122]:48751 "EHLO vps0.lunn.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757177AbbLWM6O (ORCPT ); Wed, 23 Dec 2015 07:58:14 -0500 Received: from andrew by vps0.lunn.ch with local (Exim 4.80) (envelope-from ) id 1aBiyh-0005S2-Ef; Wed, 23 Dec 2015 13:57:15 +0100 From: Andrew Lunn To: Florian Fainelli , narmstrong@baylibre.com, vivien.didelot@savoirfairelinux.com Cc: netdev , Andrew Lunn Subject: [PATCH RFC 22/28] net: dsa: Setup the switches after all have been probed Date: Wed, 23 Dec 2015 13:56:36 +0100 Message-Id: <1450875402-20740-23-git-send-email-andrew@lunn.ch> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1450875402-20740-1-git-send-email-andrew@lunn.ch> References: <1450875402-20740-1-git-send-email-andrew@lunn.ch> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Some switches register themselves with DSA, which others are probed by DSA itself. Move the setup call to after all switches have been successfully probed. Signed-off-by: Andrew Lunn --- net/dsa/dsa.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c index 2c1f50561343..fbb8fc852a3b 100644 --- a/net/dsa/dsa.c +++ b/net/dsa/dsa.c @@ -382,7 +382,6 @@ dsa_switch_setup(struct dsa_switch_tree *dst, int index, struct dsa_chip_data *pd = dst->pd->chip + index; struct dsa_switch_driver *drv; struct dsa_switch *ds; - int ret; char *name; /* @@ -412,10 +411,6 @@ dsa_switch_setup(struct dsa_switch_tree *dst, int index, ds->tag_protocol = drv->tag_protocol; ds->master_dev = host_dev; - ret = dsa_switch_setup_one(ds, parent); - if (ret) - return ERR_PTR(ret); - return ds; } @@ -827,22 +822,28 @@ static inline void dsa_of_remove(struct device *dev, static int dsa_setup_dst(struct dsa_switch_tree *dst, struct net_device *dev, struct device *parent) { - int i; + int i, ret; unsigned configured = 0; + struct dsa_switch *ds; struct dsa_platform_data *pd = dst->pd; dst->cpu_switch = -1; dst->cpu_port = -1; for (i = 0; i < pd->nr_chips; i++) { - struct dsa_switch *ds; - ds = dsa_switch_setup(dst, i, parent, pd->chip[i].host_dev); if (IS_ERR(ds)) { netdev_err(dev, "[%d]: couldn't create dsa switch instance (error %ld)\n", i, PTR_ERR(ds)); continue; } + } + + for (i = 0; i < pd->nr_chips; i++) { + ds = dst->ds[i]; + ret = dsa_switch_setup_one(ds, parent); + if (ret) + return ret; dst->ds[i] = ds;