linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: mw@semihalf.com (Marcin Wojtas)
To: linux-arm-kernel@lists.infradead.org
Subject: [net-next: PATCH v2 3/5] net: mvpp2: simplify maintaining enabled ports' list
Date: Sun, 31 Dec 2017 12:58:38 +0100	[thread overview]
Message-ID: <1514721520-18964-4-git-send-email-mw@semihalf.com> (raw)
In-Reply-To: <1514721520-18964-1-git-send-email-mw@semihalf.com>

'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 <mw@semihalf.com>
---
 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

  parent reply	other threads:[~2017-12-31 11:58 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-31 11:58 [net-next: PATCH v2 0/5] Armada 7k/8k PP2 ACPI support Marcin Wojtas
2017-12-31 11:58 ` [net-next: PATCH v2 1/5] device property: Introduce fwnode_get_mac_address() Marcin Wojtas
2018-01-03 11:27   ` Rafael J. Wysocki
2017-12-31 11:58 ` [net-next: PATCH v2 2/5] device property: Introduce fwnode_get_phy_mode() Marcin Wojtas
2018-01-03 11:27   ` Rafael J. Wysocki
2017-12-31 11:58 ` Marcin Wojtas [this message]
2017-12-31 11:58 ` [net-next: PATCH v2 4/5] net: mvpp2: use device_*/fwnode_* APIs instead of of_* Marcin Wojtas
2017-12-31 19:18   ` Andrew Lunn
2018-01-01 10:04     ` Marcin Wojtas
2017-12-31 11:58 ` [net-next: PATCH v2 5/5] net: mvpp2: enable ACPI support in the driver Marcin Wojtas
2017-12-31 19:23   ` Andrew Lunn
2018-01-01 10:10     ` Marcin Wojtas
2018-01-02 13:33       ` Andrew Lunn
2018-01-02 13:55         ` Marcin Wojtas
2018-01-02 14:08           ` Andrew Lunn
2018-01-02 15:05             ` Marcin Wojtas
2018-01-02 17:22               ` Florian Fainelli
2018-01-03 11:16     ` graeme.gregory at linaro.org
2018-01-03 11:19       ` Marcin Wojtas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1514721520-18964-4-git-send-email-mw@semihalf.com \
    --to=mw@semihalf.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).