From patchwork Wed Nov 1 16:01:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 117729 Delivered-To: patch@linaro.org Received: by 10.80.245.45 with SMTP id t42csp944109edm; Wed, 1 Nov 2017 09:03:23 -0700 (PDT) X-Google-Smtp-Source: ABhQp+TCQDI5DWKiqzrITuAUvWR0mbiiez5O9QRfaHL27a1Sp+LGVrWIEOx0tCPNobiPExnlU/qE X-Received: by 10.84.164.165 with SMTP id w34mr83433pla.308.1509552203137; Wed, 01 Nov 2017 09:03:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509552203; cv=none; d=google.com; s=arc-20160816; b=w9D42w1mv6T8GlXNwIZKalrim4m+LH6gIS5fKPVgvI/araQ92VyepQxJr+r1+zCOTj WtQLR64yIi2nLp4qX/9gTvYxDOIgGOQpLQ/tESl2NfmbLYgLP4bcKA3JuLZcajb5ZPUW EZE3aZpu1sJ4gNbV9aMHc6Oyw81/sMlOYom9jQP8ncJGB5gvuL6MWgCJL3SAc1HDqeT+ Io0vcyJXicOBs6FUIxMLS0uehUOwQnms6vnh958tg3F8WBZEEYcQOj8nICSZmvymBsN6 6xEc4k0nDvUStSKpEktGXHVLW4WpoRFXMKAKyDU9dJ4nnJYuYWPhF3OYgw3lsoL7tdjd 94Qg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter:arc-authentication-results; bh=Y0eE01uFyY13oy4+RdNV2wuirTGWEEKHp02bQR6mDqY=; b=mFfdXBggumIcIH2CgApBV9cfUHVWdueEbsJ+QizV8Urxqj0yd3d70ewf6FaCf/KjPw h82pMHxSy4Jn8+/B7HQoLTjMLBWMCcctD/h3JLHnPIj57rQ4HfDau3BafYJrt90CyHdb 0okt6MlAxVwPuPxbBJ1wU7g8J8jJNFkVBicqyaAWA/6uUIUDc/Bw8gRlWV6Yz4baSv/K TLjGkBLVHl/VixgoqO8bDjdWhFRHGuWd51eqTPZJx9+R7BTqn88NhOCO0rzYFfosbbRT ndiX1jGbwdp3BGfY8dOmGVh0mTYSRyHN4oOQZKoi6wqJWPcL4lxbpMnBYFoYTRkMP8jJ 4Xuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=oNOej+iu; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d9si39950pli.468.2017.11.01.09.03.22; Wed, 01 Nov 2017 09:03:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=oNOej+iu; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933129AbdKAQDU (ORCPT + 26 others); Wed, 1 Nov 2017 12:03:20 -0400 Received: from conuserg-10.nifty.com ([210.131.2.77]:21419 "EHLO conuserg-10.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751402AbdKAQDT (ORCPT ); Wed, 1 Nov 2017 12:03:19 -0400 Received: from grover.sesame (FL1-125-199-20-195.osk.mesh.ad.jp [125.199.20.195]) (authenticated) by conuserg-10.nifty.com with ESMTP id vA1G24g5014889; Thu, 2 Nov 2017 01:02:04 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-10.nifty.com vA1G24g5014889 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1509552125; bh=Y0eE01uFyY13oy4+RdNV2wuirTGWEEKHp02bQR6mDqY=; h=From:To:Cc:Subject:Date:From; b=oNOej+iuX0ff04jevAZwXFNl0+ZBZTn1gag6BRLpHtVBSm4B06q+om/7HJKr8kDbT DTmY/OgwuKwS04WIrWwgN60N/Gs30YN/P+ymZdEx3fcHuF2wUZ5viJ+hhLM8I9FxYj n8UKrJ5pO8R/k5VWtyIPHs5wyOY5U8eU8tZ014ZI9RIlrYrFzNs94DJj5jZ0hd4U5D +5iTGgUG0zsCCTquNoEzR2kOlM1PXNAZoomMR/3Mhtuhc9kATerSuS6hcsTfgSJZS1 SCtot8z60BFYnTqB98CsSRr4VXIXazj+r6bLXP0Kco2pQPqLhSmkBgS3lss9i5vyF9 P+n+PF0KJvQwA== X-Nifty-SrcIP: [125.199.20.195] From: Masahiro Yamada To: linux-usb@vger.kernel.org Cc: Masahiro Yamada , Alan Stern , linux-kernel@vger.kernel.org, Tony Prisk , Greg Kroah-Hartman , linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 1/2] usb: ehci-platform: use reset array API Date: Thu, 2 Nov 2017 01:01:58 +0900 Message-Id: <1509552119-23816-1-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Generic drivers like this need to control arbitrary number of reset lines. Instead of hard-coding the maximum number of resets, use the reset array API. It can manage a bunch of resets behind the scene. Signed-off-by: Masahiro Yamada --- Changes in v2: - Goto err_put_clks when it fails to get reset_control. drivers/usb/host/ehci-platform.c | 35 +++++++++++++---------------------- 1 file changed, 13 insertions(+), 22 deletions(-) -- 2.7.4 Acked-by: Alan Stern diff --git a/drivers/usb/host/ehci-platform.c b/drivers/usb/host/ehci-platform.c index f1908ea..a41acd6 100644 --- a/drivers/usb/host/ehci-platform.c +++ b/drivers/usb/host/ehci-platform.c @@ -40,12 +40,11 @@ #define DRIVER_DESC "EHCI generic platform driver" #define EHCI_MAX_CLKS 4 -#define EHCI_MAX_RSTS 4 #define hcd_to_ehci_priv(h) ((struct ehci_platform_priv *)hcd_to_ehci(h)->priv) struct ehci_platform_priv { struct clk *clks[EHCI_MAX_CLKS]; - struct reset_control *rsts[EHCI_MAX_RSTS]; + struct reset_control *rsts; struct phy **phys; int num_phys; bool reset_on_resume; @@ -151,7 +150,7 @@ static int ehci_platform_probe(struct platform_device *dev) struct usb_ehci_pdata *pdata = dev_get_platdata(&dev->dev); struct ehci_platform_priv *priv; struct ehci_hcd *ehci; - int err, irq, phy_num, clk = 0, rst; + int err, irq, phy_num, clk = 0; if (usb_disabled()) return -ENODEV; @@ -239,22 +238,16 @@ static int ehci_platform_probe(struct platform_device *dev) } } - for (rst = 0; rst < EHCI_MAX_RSTS; rst++) { - priv->rsts[rst] = devm_reset_control_get_shared_by_index( - &dev->dev, rst); - if (IS_ERR(priv->rsts[rst])) { - err = PTR_ERR(priv->rsts[rst]); - if (err == -EPROBE_DEFER) - goto err_reset; - priv->rsts[rst] = NULL; - break; - } - - err = reset_control_deassert(priv->rsts[rst]); - if (err) - goto err_reset; + priv->rsts = devm_reset_control_array_get_optional_shared(&dev->dev); + if (IS_ERR(priv->rsts)) { + err = PTR_ERR(priv->rsts); + goto err_put_clks; } + err = reset_control_deassert(priv->rsts); + if (err) + goto err_put_clks; + if (pdata->big_endian_desc) ehci->big_endian_desc = 1; if (pdata->big_endian_mmio) @@ -310,8 +303,7 @@ static int ehci_platform_probe(struct platform_device *dev) if (pdata->power_off) pdata->power_off(dev); err_reset: - while (--rst >= 0) - reset_control_assert(priv->rsts[rst]); + reset_control_assert(priv->rsts); err_put_clks: while (--clk >= 0) clk_put(priv->clks[clk]); @@ -329,15 +321,14 @@ static int ehci_platform_remove(struct platform_device *dev) struct usb_hcd *hcd = platform_get_drvdata(dev); struct usb_ehci_pdata *pdata = dev_get_platdata(&dev->dev); struct ehci_platform_priv *priv = hcd_to_ehci_priv(hcd); - int clk, rst; + int clk; usb_remove_hcd(hcd); if (pdata->power_off) pdata->power_off(dev); - for (rst = 0; rst < EHCI_MAX_RSTS && priv->rsts[rst]; rst++) - reset_control_assert(priv->rsts[rst]); + reset_control_assert(priv->rsts); for (clk = 0; clk < EHCI_MAX_CLKS && priv->clks[clk]; clk++) clk_put(priv->clks[clk]);