From patchwork Mon Dec 18 09:18:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcin Wojtas X-Patchwork-Id: 10118547 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A66516019C for ; Mon, 18 Dec 2017 09:19:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9C49F28ECC for ; Mon, 18 Dec 2017 09:19:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4418328F01; Mon, 18 Dec 2017 09:19:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id BE13028E5A for ; Mon, 18 Dec 2017 09:19:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=zzvQPQDMiRZfpEd3uP0tm98ijXqcM31F89NuduKh8P8=; b=GOYg0TR2RX6I7pVL0fZfMLmvyt Hu4wjpcdRT7FHCZGHyn7y4ofaVDNJxuSMyzvKRAwTbgZN/YX4jMNCEnZVrW70eTDqhJrV3dh3KzNi Opx51gZemw7rqP2zth1fZNSjuLDGeCWPlA+sIldz4A7/u1TG6QvT+yydJXiayUCpLQE/tibGbYZfy 3AAhCGVRUvzDO0t/WoO33lhQxQYQO99wx0k8Lp2R9SlnHiGxCivZvzQ/Xm2PpMbaGZeclhNY/Xa5J iNt4QHjL1e7riMJ4jRweMc0am8fP4JR4MrPkThe61Zj3q3hpCmO1XxH0BkxRxA/Rx7qMZbHanAhsB m34q8R4g==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1eQra6-00068k-Su; Mon, 18 Dec 2017 09:19:30 +0000 Received: from mail-lf0-x244.google.com ([2a00:1450:4010:c07::244]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1eQrZI-0005Lx-Jj for linux-arm-kernel@lists.infradead.org; Mon, 18 Dec 2017 09:18:50 +0000 Received: by mail-lf0-x244.google.com with SMTP id e30so50856lfb.9 for ; Mon, 18 Dec 2017 01:18:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=oj0JajkqNds/vxCnFWY1cB89VnOimwCruDlOqJl844E=; b=Ci4nCMcXLzTsp9ZzHizkIlmxvOS9pljWCorbjEXCtU5e/cH0tmrmz3FcDchKa/COR5 2cxWqrI6YJ0ThPl887lR417asASQIWc9BtOUK/30TN0jeYv8R4WAM1oudJ3zKKCvOJjQ jY4CzkU0L9pJl045gcSGnzan8b79YbL8X555zPv3cFguN4Eum46BBk0iRUWvFfTq/G7M hk1ynz8kJTWGnp2wP6n2eoUa1eTAHV8XkYnkbsKxcTC72X9YXjRXoyYEXmQig1avS6ej zE/gijUa3ij5J3Ty8728BU3k8/ZSsp7YSFthvzPzl8Y1439+bGmeLolqEsWz2SuZtnOt Zm4A== 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=oj0JajkqNds/vxCnFWY1cB89VnOimwCruDlOqJl844E=; b=NSgYG+dJU/WVEhxwry9AKrttz7A2IOeThb5mv0kmlK3tq0BCxB/kHcjbLjE8n2DDmA ItHX6zlc5MuAwTqxBsj9DeuOP0wXuTvgQJfKJWTs3ic27jDJBm+kTnCUSMrxflej8Fb1 I0Dw5M/fh8OMRv1MkNgA+NSfCEp5nr6o04t1LPjNUpuCl2c4c+mps2q6TAop4PulzoI1 TrBnSkGag0P76dHAeEWSYKkDZhvvC8w+owCH2lqKB4ZwW1npNFEE0WeqP5CXzIVZNHCB cofzICC6iW4R7qRj4RmB6j+iBe6gxXVkfdIaxoZh/8jgS+B6SpU58AINUN6gezwE3mum PzWQ== X-Gm-Message-State: AKGB3mKrLsEX5qS+Qs/YIQ5ZXyD+2exC0POm3Fk/SkL8qx8rCNnPX07K hQtb6gB87VVUgqUm344qT4ea8Q== X-Google-Smtp-Source: ACJfBouFjAXc4cfPQdyiGoxDyHN4FWLYm53e0LBsF9jkIDi6YH7U9lBlN8OQ/EAFquMZcJflRIQ9TA== X-Received: by 10.25.215.167 with SMTP id q39mr10955423lfi.33.1513588699726; Mon, 18 Dec 2017 01:18:19 -0800 (PST) Received: from gilgamesh.semihalf.com (31-172-191-173.noc.fibertech.net.pl. [31.172.191.173]) by smtp.gmail.com with ESMTPSA id r16sm2407186ljd.18.2017.12.18.01.18.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 18 Dec 2017 01:18:19 -0800 (PST) From: Marcin Wojtas To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org Subject: [net-next: PATCH 5/8] net: mvpp2: simplify maintaining enabled ports' list Date: Mon, 18 Dec 2017 10:18:01 +0100 Message-Id: <1513588684-15647-6-git-send-email-mw@semihalf.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1513588684-15647-1-git-send-email-mw@semihalf.com> References: <1513588684-15647-1-git-send-email-mw@semihalf.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171218_011841_732664_55374762 X-CRM114-Status: GOOD ( 14.39 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: thomas.petazzoni@free-electrons.com, andrew@lunn.ch, f.fainelli@gmail.com, linux@arm.linux.org.uk, ard.biesheuvel@linaro.org, jaz@semihalf.com, antoine.tenart@free-electrons.com, rafael.j.wysocki@intel.com, nadavh@marvell.com, neta@marvell.com, ezequiel.garcia@free-electrons.com, tn@semihalf.com, gregory.clement@free-electrons.com, mw@semihalf.com, davem@davemloft.net MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 'port_count' field of the mvpp2 structure holds an overall amount of available ports, based on DT nodes status. In order to be prepared to support other HW description, obtain the value by incrementing it upon each successful port initialization. This allowed for simplifying port indexing in the controller's private array, whose size is now not dynamically allocated, but fixed to MVPP2_MAX_PORTS. This patch simplifies creating and filling list of enabled ports and is a part of the preparation for adding ACPI support in the mvpp2 driver. Signed-off-by: Marcin Wojtas --- drivers/net/ethernet/marvell/mvpp2.c | 32 +++++++------------- 1 file changed, 11 insertions(+), 21 deletions(-) diff --git a/drivers/net/ethernet/marvell/mvpp2.c b/drivers/net/ethernet/marvell/mvpp2.c index a197607..7f42d90 100644 --- a/drivers/net/ethernet/marvell/mvpp2.c +++ b/drivers/net/ethernet/marvell/mvpp2.c @@ -865,7 +865,7 @@ struct mvpp2 { /* List of pointers to port structures */ int port_count; - struct mvpp2_port **port_list; + struct mvpp2_port *port_list[MVPP2_MAX_PORTS]; /* Aggregated TXQs */ struct mvpp2_tx_queue *aggr_txqs; @@ -7741,7 +7741,7 @@ static void mvpp2_port_copy_mac_addr(struct net_device *dev, struct mvpp2 *priv, /* Ports initialization */ static int mvpp2_port_probe(struct platform_device *pdev, struct device_node *port_node, - struct mvpp2 *priv, int index) + struct mvpp2 *priv) { struct device_node *phy_node; struct phy *comphy; @@ -7934,7 +7934,8 @@ static int mvpp2_port_probe(struct platform_device *pdev, } netdev_info(dev, "Using %s mac address %pM\n", mac_from, dev->dev_addr); - priv->port_list[index] = port; + priv->port_list[priv->port_count++] = port; + return 0; err_free_port_pcpu: @@ -8313,28 +8314,17 @@ static int mvpp2_probe(struct platform_device *pdev) goto err_mg_clk; } - priv->port_count = of_get_available_child_count(dn); - if (priv->port_count == 0) { - dev_err(&pdev->dev, "no ports enabled\n"); - err = -ENODEV; - goto err_mg_clk; - } - - priv->port_list = devm_kcalloc(&pdev->dev, priv->port_count, - sizeof(*priv->port_list), - GFP_KERNEL); - if (!priv->port_list) { - err = -ENOMEM; - goto err_mg_clk; - } - /* Initialize ports */ - i = 0; for_each_available_child_of_node(dn, port_node) { - err = mvpp2_port_probe(pdev, port_node, priv, i); + err = mvpp2_port_probe(pdev, port_node, priv); if (err < 0) goto err_port_probe; - i++; + } + + if (priv->port_count == 0) { + dev_err(&pdev->dev, "no ports enabled\n"); + err = -ENODEV; + goto err_mg_clk; } /* Statistics must be gathered regularly because some of them (like