From patchwork Mon Oct 30 09:35:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 117456 Delivered-To: patch@linaro.org Received: by 10.80.245.45 with SMTP id t42csp2428074edm; Mon, 30 Oct 2017 02:36:45 -0700 (PDT) X-Google-Smtp-Source: ABhQp+RfOOCy8GF6uRhEqFP3k1T3qd9XbNeJhyFES5URX3NDqe+XZiytsS5ilJNwq2NmIYd6j6ZV X-Received: by 10.98.247.4 with SMTP id h4mr8339824pfi.16.1509356205492; Mon, 30 Oct 2017 02:36:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509356205; cv=none; d=google.com; s=arc-20160816; b=WIP9kOvltN8hAnuFJaBn7GGk1GmOv6kHNm4tEziFFVdJmvDSglFYKB0r1UiK0oR0Op dUoO1AUwOxnOwKGzmB7+6VMn8ChRcwhVerrH4sIbcNKHHTTcdYns++o4gwkPiDeJ+DtF FGqSvN0/zcSoonaI4GnjcJrkrgPd3TCs2afMxlH43BkiJf6iBEW+1T4oD72q1UDpCsZE dteWHPswsaXRx6AqnbnMSfEfbsg8z8BmdQyKg7CDoift24gwXDiJ+3dSKbZPimkKBnkr W0WeUe/abAzxfs+I79zdR+0uBJLIgv4QuCWE6E9KVekWvYFda1DXC+HaPlhNMTRJ3hqv rUiA== 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=xm+dONKMlTnTtgAQUrrzOV/khhqGdnaRlMZO9yFEiMk=; b=NUb0/2/P48W8JK6levw+R9AocEA7UVBE87QnB4Z2uBXmWroeLqEU4i0zo1klUcNxXu F4/n/zLjT4byouaGV4OutKjAURRJxBIYmlCZehmKpdUMsqbBk4opvo8ekcPcMfwqxdLU xcUdcbBg+IOpF5gO6VZXdavcvH3+D2trDPVN34AVhyUDpZyuQ0QDxqzez6rvvwUKZD1M WObEjyzhJRGIDH/zum4lhMl5NJXztqW2aDq3Ke2ud4U4MBbvAdyBiID5B4/SyKf7n6X1 T68hpvMmxJDDChQZjU+6NHuzHmPuWlGrowPuzaD7AmbRtQEVTDwyasJIOVYrkgl3h5g6 179Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=n6iQTAyO; 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 s12si9692783pgc.765.2017.10.30.02.36.45; Mon, 30 Oct 2017 02:36:45 -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=n6iQTAyO; 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 S932279AbdJ3Jgn (ORCPT + 27 others); Mon, 30 Oct 2017 05:36:43 -0400 Received: from conuserg-07.nifty.com ([210.131.2.74]:63032 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751732AbdJ3Jgm (ORCPT ); Mon, 30 Oct 2017 05:36:42 -0400 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-07.nifty.com with ESMTP id v9U9ZagU015048; Mon, 30 Oct 2017 18:35:36 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com v9U9ZagU015048 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1509356137; bh=xm+dONKMlTnTtgAQUrrzOV/khhqGdnaRlMZO9yFEiMk=; h=From:To:Cc:Subject:Date:From; b=n6iQTAyOCGByx3uaC62+AaGUSMcY9+nCFaKE7dan9mON4AGVgfYTyRXrehNqkPZHw tZXWkUohT+jw+z/1T6Y4nlz40YFQwjV5QlabZWUR6rILaZ0sAgn8GNtvzwelsiZdu+ 0oS0Rhmoivd/MvUmTGS9e9un7/V2fWWqKnXvdy2eINvlC9/2ox2yGUZ6BvTrtBYUts U1x1Z9UVqaMFp2Y+Dkjbn/FSbElAz0Xq14tbJkxOJ7m9M36J4abJKfi2oY4HisZINY rtC97oS4PjFXnsYMPLIxZDL54CCAJ+vobHkwqZ33gWsu4iBvq2ju399ifnJwWecokl sLHccMjFL2PfA== X-Nifty-SrcIP: [153.142.97.92] 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 1/2] usb: ehci-platform: use reset array API Date: Mon, 30 Oct 2017 18:35:19 +0900 Message-Id: <1509356120-21473-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 numbers 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 --- drivers/usb/host/ehci-platform.c | 33 +++++++++++---------------------- 1 file changed, 11 insertions(+), 22 deletions(-) -- 2.7.4 diff --git a/drivers/usb/host/ehci-platform.c b/drivers/usb/host/ehci-platform.c index f1908ea..64fd643 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,21 +238,13 @@ 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; - } + priv->rsts = devm_reset_control_array_get_optional_shared(&dev->dev); + if (IS_ERR(priv->rsts)) + return PTR_ERR(priv->rsts); - err = reset_control_deassert(priv->rsts[rst]); - if (err) - goto err_reset; - } + err = reset_control_deassert(priv->rsts); + if (err) + goto err_put_clks; if (pdata->big_endian_desc) ehci->big_endian_desc = 1; @@ -310,8 +301,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 +319,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]);