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: 10032249 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 5EA79603B4 for ; Mon, 30 Oct 2017 09:36:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5225F28802 for ; Mon, 30 Oct 2017 09:36:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4624B28807; Mon, 30 Oct 2017 09:36:34 +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 CCAD428802 for ; Mon, 30 Oct 2017 09:36:33 +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: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:In-Reply-To: References:List-Owner; bh=F5oRRZXyqWxIxg8rzv9/FcnGJaVBizyCmkxhoZ4gHKo=; b=ilI dIScSvVGMKAeuBPiYA1csm+vzSspg2ejAET2L64vNlRzF+Qwqp2rNM12gZSY48GZYcRfrYIajXbSD BBzc8lF2XCYG2nBwdjA8bb7bpRQ2ZZBOQFi1S7NUkk/E3Vy+Av4nfnl4lmM+Ootf+cAkWnWPwAmMw InW3WSF+u+4syN1uFROtqlQzEeoN2ukAAo+ItAKXPoKFweP84pg59wdCuTIZ6Osr+/B59O7zFd+Nh vUOyXmTFYfm5/zPpqnAS0z+4lYOgZ2prQ941SlySkNH++sQdK9tNMcY0ujJMaSz48PN5Df/PRmrbA ww8nvxdv1tOATfg+Ami+VNL+S3xdumw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1e96Ug-0005Rj-GX; Mon, 30 Oct 2017 09:36:30 +0000 Received: from conuserg-07.nifty.com ([210.131.2.74]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1e96Ub-0005PP-JD for linux-arm-kernel@lists.infradead.org; Mon, 30 Oct 2017 09:36:28 +0000 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 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171030_023625_879185_B76E3D2B X-CRM114-Status: GOOD ( 11.20 ) 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: Greg Kroah-Hartman , linux-kernel@vger.kernel.org, Tony Prisk , Masahiro Yamada , Alan Stern , linux-arm-kernel@lists.infradead.org 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 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(-) 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]);