From patchwork Sun Dec 31 11:58:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcin Wojtas X-Patchwork-Id: 10138101 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 C738C603EE for ; Sun, 31 Dec 2017 12:00:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B098228718 for ; Sun, 31 Dec 2017 12:00:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A4E9B28844; Sun, 31 Dec 2017 12:00:47 +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=unavailable 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 25FD628718 for ; Sun, 31 Dec 2017 12:00:47 +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=rjcduYlBOpVbrLN1yJwqiR855K Co7IEs9AQVMHfBmWi4pc3ij87CBcBfQTiYyDLaMwqXrCPqyIX4DN/za/FsfgKi4ANLCv3LExQgqv+ aAKG/A+IirVsNgP4fO1SaoMKiXJksfuLPj/KfAcZRTCz4pubxe73ESEPnMDTMweslAmjq094loX6v QYhvO4pP5D4TAXtqrHYFOKJR+HfnnmaY3PgeDBwiYLQkwbxpYpfs5fo5MSRpidioozmHbIem/1xdL sEftkWQMIBAMK6VE7ierr4V7uTfbbmQwIxzNvgwrrq4zZ64xlMqHrt4K3Nex3gZt5Nwb3LoAggSxi Q/oimdzA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1eVcID-0001CI-My; Sun, 31 Dec 2017 12:00:41 +0000 Received: from mail-lf0-x242.google.com ([2a00:1450:4010:c07::242]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eVcGh-0007qw-Ru for linux-arm-kernel@lists.infradead.org; Sun, 31 Dec 2017 11:59:09 +0000 Received: by mail-lf0-x242.google.com with SMTP id h140so1022357lfg.1 for ; Sun, 31 Dec 2017 03:58:57 -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=VAkoICC90FJF9qQGyglNRrmGJrBPLe7DQGEIa5kjRt2H7h7OK5w6Oavs0Y+II9JzOA N6YpOegY3udbDVfeyHZCdq3/hEZQDWLLzxOjfujlAfeAVbUAtJAx5aPIjtW17jAmvtMy PBowIAWSNIwmNE98bh0tpNt1VOjRtVY82kNprFOPJSnPctPwd2agd50MnAu77hyi6/LW p4DsGRIsemPiY9P21sqTG7KDtY04CKWn0exRwUbbMbdg7ucObs7HJ5JVdytqx6dljGES xaFs/Y5kPrf0rDYz1JeJvQo0q35ciSSUrX4Bjt33SQl/w49Le0/kUs0JYzHvKfCFvrhk xxzg== 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=uBrTZpac8QfpYKFsVZJ8nKYEK6NWfofD1puPhoQiVRvC+G+/tjDUv9q3IICXif8+zU qjT6bjP2TxcyXMgzhP3CSEJCk55dsxnbxuyxYcvJzHIzVZwJuzvDT57h8DTME9SMNxUn FgWe54amIdW3MRuN5cHZ75szeQpdK8K7Y7ae+wRaFlHonfs116nL3+jHXdIcO7dgVsdE OjRTr+/2eDK3duBTTlJ86prqsCrKKCOvQczGWvpcwFFgiYR7dlnPNpsbknXMJxRVH9bJ vtH4rOp1YLcr4CDZPrQoCFjbe30eTKiphTPpwhftqdh6lW1aPF5FqkrdbDODn9cqTy9b U2vw== X-Gm-Message-State: AKGB3mJ/ftzg3K4ae3Qj4e+sJ/O8WNCjXcKxuEa/nD0qnRgD4bn7CQZX tMySdAAiw6WmjOeGGGLJ6l2JgQ== X-Google-Smtp-Source: ACJfBouN5s5A5VwUFxumBWQbquurB+WyQ+7nIEA0qBZA1ptQoDwxrAn4/E25EnMFxbd6+FXAd6Ekgw== X-Received: by 10.46.14.9 with SMTP id 9mr25023108ljo.148.1514721535770; Sun, 31 Dec 2017 03:58:55 -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 f10sm8646298lff.56.2017.12.31.03.58.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 31 Dec 2017 03:58:55 -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 Subject: [net-next: PATCH v2 3/5] net: mvpp2: simplify maintaining enabled ports' list Date: Sun, 31 Dec 2017 12:58:38 +0100 Message-Id: <1514721520-18964-4-git-send-email-mw@semihalf.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1514721520-18964-1-git-send-email-mw@semihalf.com> References: <1514721520-18964-1-git-send-email-mw@semihalf.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171231_035907_928769_0F29B41A X-CRM114-Status: GOOD ( 14.43 ) 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, graeme.gregory@linaro.org, ard.biesheuvel@linaro.org, jaz@semihalf.com, antoine.tenart@free-electrons.com, rafael.j.wysocki@intel.com, linux@armlinux.org.uk, 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