Received: by 10.223.148.5 with SMTP id 5csp7360715wrq; Thu, 18 Jan 2018 04:38:41 -0800 (PST) X-Google-Smtp-Source: ACJfBosfUcqJs7czp9/DJhR2M1CQ7HRGcN9PVSDlhWl+T2H1MwxVAIbZjda810eGYO5DHSvyhpsD X-Received: by 10.101.67.130 with SMTP id m2mr5860568pgp.301.1516279120950; Thu, 18 Jan 2018 04:38:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516279120; cv=none; d=google.com; s=arc-20160816; b=Q0Q4oshx0OrEtQZe4BIsR32rBuhnzkaIUr1PazLxCyI5vF+A9TMZMIzbR5+6JlUiyd 1S2qWgzRt+T8DjXbYJK2kL/dNrVx0Eqy09otm6WvUiZeq9hBYSnxIPuZtwhevpZUhynj wKQxodWT8jRUup5mVb4QaEbBjPnNTlAZbqRk3cZWcElH1wLWqztXKDR7G4hYH3sNcMHZ Yu1UmC54vg9+EMb4XANwNz9kU1VTAAxAzHkHLPpkhMo4sM0HiOZTiqBXfWgBDtvs+x/N dkYF3or2wBr+6+APCJruHo9TZe4QexQDNQ0xmjLd69lJipYGtU0ripjsyN9jyGGAlSgL 8vqA== 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:dkim-signature:arc-authentication-results; bh=oj0JajkqNds/vxCnFWY1cB89VnOimwCruDlOqJl844E=; b=rntc+L4GWIW/T9N6nKd5VLkukVH+fneCX3UhoBoeEeua+QeYMKRmbIbaLl0mygYh3n S/LdRkNd/bS1IKpB3gxf/JaNgephR72cupYz7HobII4BJfy0iVgzMgXqN1hDXYuGZl0r DhHrwP2LXWa/H34XAgqqzjxQ4ijWToXVG994FK2KCGo8iEGgDVaMagPy3oDmwyPMO84w MvodYxc6prmvTroFh7k1l6GKw1TkprDPvjMKn3Y3jeaYYaKpKFy3iWGI408UM9M201BU qgM8DjBXK1klR17xYGsggYmXuRp/Wv8E/C8dr9A/BXHf6ZLODTcUiAhrSd5/QsHLqvN6 vzMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@semihalf-com.20150623.gappssmtp.com header.s=20150623 header.b=Sok5zZm1; 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 i11si5831792pgq.332.2018.01.18.04.38.26; Thu, 18 Jan 2018 04:38:40 -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; dkim=pass header.i=@semihalf-com.20150623.gappssmtp.com header.s=20150623 header.b=Sok5zZm1; 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 S932474AbeARMc6 (ORCPT + 99 others); Thu, 18 Jan 2018 07:32:58 -0500 Received: from mail-lf0-f66.google.com ([209.85.215.66]:44054 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932269AbeARMcH (ORCPT ); Thu, 18 Jan 2018 07:32:07 -0500 Received: by mail-lf0-f66.google.com with SMTP id w23so26400990lfd.11 for ; Thu, 18 Jan 2018 04:32:07 -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=Sok5zZm1n9pY7p5ysaRzD3Q0GEG24/Mmo9CqU3yXUlQC2jxDfnyLHqVcnPHXNq+kb8 bAXVIvigoBcqulvPlR/A7BNNo8LfbqU20/dCNdxYxb8gciRKWewGY6djBBq7LQ9RQ90p 0JXOAraZUYbibs5IbGq0lIsk97uiiTNOTvqYKYLAKL3cZOCyHEYJHiGIaKmi7gceP8ZG C+mDzECIqJqmrLJb0UEV8UscFqGlJGaTwdBLYh75oU5nmNSlVe34eFgFH50XdLbtm74d iNGtMDoKcmc2bGPJr53bu5jFGvwYw6YTixG7DAO0R21+ub4q7RsuJ3PNmPaZTgme2elF kfjw== 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=bX+vOK9wr6nNv4M++3IcnxiHieH6UIxKk3fkPEh5vWJ+S+NbIAAd2sro9Ovqvh0Ggj XJpa+v1WsEzP398Ry9Tgr6YYc7DP7F47ywvNwgGV4iylYT27ZHK7YG+8fT90P5rEXH9r 4xR3EY/X9Pix+na95uHxDoYBk7zoxv3XNDUZmRHUk15a2ERpafvXjSD6lh6d9xikh+Fh F/n5ony4pqUle8EL5TS50SVMxc2JbdJP9bDPIbNmz0uqVBIGCpNINNSf/zUwVeYueMyt 3BaieurbVye2HkBfXRj/T4XVH9zogDUI24J1MVfzEVI9/8mjZ3aKPL7hV3RMPKj1vey3 QAVw== X-Gm-Message-State: AKwxyteCkxmZ2E541io048qWv0EHaewWPljCmuogNKhrN+myX74EanhT 1tIxEr8loEycTccy1jXNV33RCDiCMgU= X-Received: by 10.46.8.89 with SMTP id g25mr2726915ljd.47.1516278726013; Thu, 18 Jan 2018 04:32:06 -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 s23sm1303906ljs.1.2018.01.18.04.32.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 18 Jan 2018 04:32:04 -0800 (PST) From: Marcin Wojtas To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, linux-acpi@vger.kernel.org Cc: graeme.gregory@linaro.org, davem@davemloft.net, linux@armlinux.org.uk, rafael.j.wysocki@intel.com, andrew@lunn.ch, f.fainelli@gmail.com, antoine.tenart@free-electrons.com, thomas.petazzoni@free-electrons.com, gregory.clement@free-electrons.com, stefanc@marvell.com, nadavh@marvell.com, neta@marvell.com, ard.biesheuvel@linaro.org, mw@semihalf.com, jaz@semihalf.com, tn@semihalf.com Subject: [net-next: PATCH v4 5/7] net: mvpp2: simplify maintaining enabled ports' list Date: Thu, 18 Jan 2018 13:31:42 +0100 Message-Id: <1516278704-17141-6-git-send-email-mw@semihalf.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1516278704-17141-1-git-send-email-mw@semihalf.com> References: <1516278704-17141-1-git-send-email-mw@semihalf.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org '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 -- 2.7.4