From patchwork Wed Jan 17 16:55:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcin Wojtas X-Patchwork-Id: 10170151 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 96D5F603B5 for ; Wed, 17 Jan 2018 16:56:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 84A1728533 for ; Wed, 17 Jan 2018 16:56:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 789A22859E; Wed, 17 Jan 2018 16:56:54 +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 DC85728533 for ; Wed, 17 Jan 2018 16:56:53 +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=TidFniSvT7t8itQwD+BTtpieLF Xyj357zfGtfG3uMOUe+ruacinFBw0CpF6SMOOXAUQPKhdNgdz/S5JWjfIQRoAUtQavx+TGcbnLW94 sLFYl3qilNV9VpMAFPMDg3QQTR5PVXH2DDgD47SPzNfAchepKfWGPVQNGJwzemSRqI7fdBhP+0TXR KnN/0RhcUN01ciefogbNiZOtCL9EoGn2HYim0MIAdhDoTeXF2EZQYJQ5naO3PjPvgqPZaQ0lMtfKY Hwhzi3EsNAEgQ8sQooZ0e9SRdEnt0+9iE2X6Uy5K/QXekbwEF0xaLWzxb/LfbjkdIMW/ejkvd8r32 R7QnQcGA==; 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 1ebr18-0006Hi-BL; Wed, 17 Jan 2018 16:56:50 +0000 Received: from mail-lf0-x241.google.com ([2a00:1450:4010:c07::241]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1ebr0X-0005h5-Ds for linux-arm-kernel@lists.infradead.org; Wed, 17 Jan 2018 16:56:14 +0000 Received: by mail-lf0-x241.google.com with SMTP id t79so7486766lfe.3 for ; Wed, 17 Jan 2018 08:56:08 -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=o+ODlGizZRkhynp+KSUze1biLUXzpvQnvhjxGWQQnU9y1ujLZV7ppnu/iz7tmF3rTO 62DOkj8CBvAGAE7aGlePwKnosY2AhJ2rBpQV8fMGMT2utlA6GA2bRtll9X2MxpeO+ODx 9KZvh9H4HqNvsSPUHKvabbfBOQwf80ewaft/IGHOr+N6jG3xvz+SGzmu3QZR+NpvsEea rQNgEpGaYJmZYu2b+ycRLIH1KeSDn00tIOY/y1Zul4oDa3FxGYQ8UUDSN2hEviovPdIe NMDY5ZKLs+Hyv3mg1s//cBU5E9ZqccyraD8VnN6+ZZEUBHz0T/AXYvjHOd1XGscJGr91 +Mtg== 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=la0IbKhJ/DZiqpeVI5hKyIEKIGkkq97hK6+O+c5rp8sQwiHdDW7xND57G4zGi3Qj3E 6ec7hcdIBtasnmirHanAtTluR4WT5i3FgpT3XyAQnTpc0GWiqF0VB0gGvp9Gio2JEYYx C4EKrqBbFcQ4aElcrWaud8SCID2CXCm82ZyMhMKwR16nEUO2RNlu4X4KZJ6S/9WjspTa xWfQfIoph0GtorezvVFlUcTRzinMZMZC6Vc2hex3X/47OmBiAwcRFwPVyS0COqzQXIky Rq1kDgTqQToAVkhD3B3qrhwYugJhijA0SKp7N2VBg4p+RyvTjcww08jywrsJySwHK4Rx Q/GQ== X-Gm-Message-State: AKwxytfMnF4c6V10GM91Up9SC+OpQw7ZDhN+nN4kKMWGPMiXYJbkfvTi Ibs15FIhJvuREW4UrfJn24M29g== X-Google-Smtp-Source: ACJfBougJbQjrvSiHgZM26TrO0STA0UhTDBP/bsqf7U851frPUfsX9cHaQ8206NfLGRUqpg94FdeVQ== X-Received: by 10.25.167.85 with SMTP id q82mr5748449lfe.112.1516208166233; Wed, 17 Jan 2018 08:56: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 t81sm868347lff.47.2018.01.17.08.56.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 17 Jan 2018 08:56:05 -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 v3 5/7] net: mvpp2: simplify maintaining enabled ports' list Date: Wed, 17 Jan 2018 17:55:44 +0100 Message-Id: <1516208146-4144-6-git-send-email-mw@semihalf.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1516208146-4144-1-git-send-email-mw@semihalf.com> References: <1516208146-4144-1-git-send-email-mw@semihalf.com> 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, tn@semihalf.com, gregory.clement@free-electrons.com, stefanc@marvell.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