From patchwork Thu Jan 18 12:31:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcin Wojtas X-Patchwork-Id: 10173091 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 54A28603B5 for ; Thu, 18 Jan 2018 12:33:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8097227C0B for ; Thu, 18 Jan 2018 12:33:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7042E27CF3; Thu, 18 Jan 2018 12:33:51 +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 E0F1D27C0B for ; Thu, 18 Jan 2018 12:33:50 +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=iMhmZyVCum6MyvbzZZKynaEgOy e+faao5Vj43QoaluIhHgNOATOmW+W4D4MXG0a/cT6sbZ+3cmQzyfvtEMPg8YXF+IMprXP5BY2+wWn aOBQyZmxZQKV+OERoUQBZYBrv6dJMsU+VNyTCt+m/TRY0bryluV7eOVQqF+fIKgdDUNVwItXPfoIN UR8tu1L1aQL1bcHLxM4XhAcwGlQXzwAjZ1sTrgZLTSTQWgOXjbLW7Kjc8Nee3vTCkn+RzfNV6VoyQ jHe+kuzvxqWGIA2BDvcJtcjvz/nVio1Y+QvtTt6Lt5jwU/eZbJ7qDXqBs/34L5+HuBxGJX1PE0UxF MruocYrA==; 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 1ec9O7-0002Ym-3N; Thu, 18 Jan 2018 12:33:47 +0000 Received: from mail-lf0-x244.google.com ([2a00:1450:4010:c07::244]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1ec9Ma-0000kN-Tf for linux-arm-kernel@lists.infradead.org; Thu, 18 Jan 2018 12:32:20 +0000 Received: by mail-lf0-x244.google.com with SMTP id f3so26450505lfe.4 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=S5yiJaW4+OSYILPrVtf36yGcGLlP1AL/Fq80gyDl46Sr0cdldlMwrBtbfKKmKLFybl bYXbi9/9ChXMv4n42MvQkKIhfUQ8a37istlLXl2yIHGpVDAnGbQErRrBDcNMstlm22Xs BoRtSg1JOGlF6Y0gn92InPOMNAYIWXtl2vUkpstPit4YnTmVXNhT4oWHxu4IqDlFwMFN IWsGzIJXHmyAfNx2I/Bv3IKeDZiNKms6p7P2/T+NdwvTMv60NNTuCbeFRnqWPVzJyRnA j278GqkKVER/tlziHIqNxqWxApIkf3LPHD+Zh/VcFprb2lOciZEG9r1lR90QRg3Yem/d 1x3A== X-Gm-Message-State: AKwxytdILA27CjaAVezsHVXxg5YOf/qWQOksxDv6sz4qjowQyvB60lg0 1Id7mGKm26odUvU62NXZCt8xJw== X-Google-Smtp-Source: ACJfBotEbT6enu4uJiSvYlAnVGs6gsm2dwwmiu39JkFMfO1+ssqyV5xIzEeol4Gb0+kKl4yq9Zr4Ug== 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 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> 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