From patchwork Mon Sep 28 12:57:37 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kishon Vijay Abraham I X-Patchwork-Id: 7277281 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id A28F49F36A for ; Mon, 28 Sep 2015 12:58:37 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B10A820767 for ; Mon, 28 Sep 2015 12:58:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4AF482076D for ; Mon, 28 Sep 2015 12:58:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933169AbbI1M6Q (ORCPT ); Mon, 28 Sep 2015 08:58:16 -0400 Received: from devils.ext.ti.com ([198.47.26.153]:57481 "EHLO devils.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933547AbbI1M5s (ORCPT ); Mon, 28 Sep 2015 08:57:48 -0400 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id t8SCvlQx011783; Mon, 28 Sep 2015 07:57:47 -0500 Received: from DLEE71.ent.ti.com (dlee71.ent.ti.com [157.170.170.114]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id t8SCvllE016162; Mon, 28 Sep 2015 07:57:47 -0500 Received: from dflp32.itg.ti.com (10.64.6.15) by DLEE71.ent.ti.com (157.170.170.114) with Microsoft SMTP Server id 14.3.224.2; Mon, 28 Sep 2015 07:57:47 -0500 Received: from a0393678ub.india.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id t8SCvf8S030418; Mon, 28 Sep 2015 07:57:45 -0500 From: Kishon Vijay Abraham I To: CC: , , , , , Subject: [RFC PATCH 1/2] pci: host: pci-dra7xx: use "num-lanes" property to find phy count Date: Mon, 28 Sep 2015 18:27:37 +0530 Message-ID: <1443445058-643-2-git-send-email-kishon@ti.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1443445058-643-1-git-send-email-kishon@ti.com> References: <1443445058-643-1-git-send-email-kishon@ti.com> MIME-Version: 1.0 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP use "num-lanes" property to find phy count instead of the number phy-names property. Signed-off-by: Kishon Vijay Abraham I --- drivers/pci/host/pci-dra7xx.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/drivers/pci/host/pci-dra7xx.c b/drivers/pci/host/pci-dra7xx.c index 199e29a..e15b2e2 100644 --- a/drivers/pci/host/pci-dra7xx.c +++ b/drivers/pci/host/pci-dra7xx.c @@ -66,7 +66,7 @@ struct dra7xx_pcie { void __iomem *base; struct phy **phy; - int phy_count; + int lanes; struct device *dev; struct pcie_port pp; }; @@ -328,7 +328,7 @@ static int __init dra7xx_pcie_probe(struct platform_device *pdev) int ret; int irq; int i; - int phy_count; + u32 lanes; struct phy **phy; void __iomem *base; struct resource *res; @@ -362,17 +362,16 @@ static int __init dra7xx_pcie_probe(struct platform_device *pdev) if (!base) return -ENOMEM; - phy_count = of_property_count_strings(np, "phy-names"); - if (phy_count < 0) { - dev_err(dev, "unable to find the strings\n"); - return phy_count; + if (of_property_read_u32(np, "num-lanes", &lanes)) { + dev_err(dev, "Failed to parse the number of lanes\n"); + return -EINVAL; } - phy = devm_kzalloc(dev, sizeof(*phy) * phy_count, GFP_KERNEL); + phy = devm_kzalloc(dev, sizeof(*phy) * lanes, GFP_KERNEL); if (!phy) return -ENOMEM; - for (i = 0; i < phy_count; i++) { + for (i = 0; i < lanes; i++) { snprintf(name, sizeof(name), "pcie-phy%d", i); phy[i] = devm_phy_get(dev, name); if (IS_ERR(phy[i])) @@ -392,7 +391,7 @@ static int __init dra7xx_pcie_probe(struct platform_device *pdev) dra7xx->base = base; dra7xx->phy = phy; dra7xx->dev = dev; - dra7xx->phy_count = phy_count; + dra7xx->lanes = lanes; pm_runtime_enable(dev); ret = pm_runtime_get_sync(dev); @@ -449,7 +448,7 @@ static int __exit dra7xx_pcie_remove(struct platform_device *pdev) struct dra7xx_pcie *dra7xx = platform_get_drvdata(pdev); struct pcie_port *pp = &dra7xx->pp; struct device *dev = &pdev->dev; - int count = dra7xx->phy_count; + int count = dra7xx->lanes; if (pp->irq_domain) irq_domain_remove(pp->irq_domain); @@ -495,7 +494,7 @@ static int dra7xx_pcie_resume(struct device *dev) static int dra7xx_pcie_suspend_noirq(struct device *dev) { struct dra7xx_pcie *dra7xx = dev_get_drvdata(dev); - int count = dra7xx->phy_count; + int count = dra7xx->lanes; while (count--) { phy_power_off(dra7xx->phy[count]); @@ -508,7 +507,7 @@ static int dra7xx_pcie_suspend_noirq(struct device *dev) static int dra7xx_pcie_resume_noirq(struct device *dev) { struct dra7xx_pcie *dra7xx = dev_get_drvdata(dev); - int phy_count = dra7xx->phy_count; + int phy_count = dra7xx->lanes; int ret; int i;