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]); From patchwork Mon Oct 30 09:35:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 117455 Delivered-To: patch@linaro.org Received: by 10.80.245.45 with SMTP id t42csp2427615edm; Mon, 30 Oct 2017 02:36:06 -0700 (PDT) X-Google-Smtp-Source: ABhQp+SPFKKb/+MemCHYAMxZ2rbgy9bH/kfNIcGKoke2dizYdBAjb89xlr1swWXmNap/+MRs51e9 X-Received: by 10.99.116.89 with SMTP id e25mr7341800pgn.383.1509356166612; Mon, 30 Oct 2017 02:36:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509356166; cv=none; d=google.com; s=arc-20160816; b=oLSw3ZT72D8TKZJtTDdszCDDAiYh8iBnHy0lAvcyge7MwonkuTp4scc+rrOM56yOYv nyNb1hPrRftbMmjpJ01sNIKyqUxqVu9mG5YYfgCnbHCpDSvIxEsnPAPu4TX4Pqdpg4Sj 0i2OIM/UpOe5dEAESI/whA8QNALaK3pr6UBVuczwmca20d/LMg9samVBskUNYitgk6Dz cWn+AbLe/z3JLQBCvNTF6clUtVFyaMp86NNxopQOzxO/w9MJWmr9dK9+acwDId6itBfY h336DSTC5U+3VLnubNvsRhbM/8nMAOtik8/5Mi8ARNCpvvIMgYoL+90PEXJmVjAcUWOO vFDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter :arc-authentication-results; bh=6Mpu5dDJ38CT6DBj73s5qFOQdnl+9NpcRaS03o38ei0=; b=RD/lJwIZtAJ3J5IHQ06yCHYs6bZiiySr57AjhrVv8bzWVaPpBJ1BCzO6zirhF++ONL rF6hx8GKszkI1ZftP3ZJeIwp5JhqrflKeDSKi8bbf29KwCZTP7keYauq2Atq4Vp/60Ay EUxRXnV0IvPlvRAHvehI8TVApHtdtBWBihayeXCaElf0AYhGNFsagBISggVgW01imgPD Azem1hPbC2EbuGo+X8o5AtbPVOKJFNBCGds2uyGgr7kbBDSJ+jaDzOzuWhO07+7vvdEB TV0oHVGDlCJmSY9fjlEqo4VEDN1MYLX6Mfr1P2KL76WoCgH4OzxpS+1NTqCUxMOeVGoE q6Dg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=N3vR5zEC; 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 n187si10511281pfn.50.2017.10.30.02.36.06; Mon, 30 Oct 2017 02:36:06 -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=N3vR5zEC; 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 S1752487AbdJ3JgE (ORCPT + 27 others); Mon, 30 Oct 2017 05:36:04 -0400 Received: from conuserg-07.nifty.com ([210.131.2.74]:61801 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751251AbdJ3JgD (ORCPT ); Mon, 30 Oct 2017 05:36:03 -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 v9U9ZagV015048; Mon, 30 Oct 2017 18:35:37 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com v9U9ZagV015048 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1509356138; bh=6Mpu5dDJ38CT6DBj73s5qFOQdnl+9NpcRaS03o38ei0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=N3vR5zECUrREIOU2miigrgRSzILNI9sxA8QUuT/tgwl2bNNf1fxs1J5S0TaWzjabG 5a+wLk6TFcoRpXiNaP3zFJeUDZ30v/cx4QMpblWwpsc/cZBihS7PBodoe2ch1BO3JS HFS4ymhnpWNZ0X4EwKpi0OR79uIUonKQOrQcFqQ7Xv/WXfsNiGAQfXnKU4KGSm27bN CggNkGIQFBkh9whiy7Pb7w6w6yNAAvgAGOWbv9kY/wqcm2VVw0xanlayZ3VQ31SJ8z 4IMnQrIwTaddH85Lkzpf87RRY9jdXanKjwWy0SDeDXoxINqdnrussB6nGv/mSajd1J Bb+5R1oqMmN3Q== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-usb@vger.kernel.org Cc: Masahiro Yamada , Greg Kroah-Hartman , Alan Stern , linux-kernel@vger.kernel.org Subject: [PATCH 2/2] usb: ohci-platform: use reset array API Date: Mon, 30 Oct 2017 18:35:20 +0900 Message-Id: <1509356120-21473-2-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1509356120-21473-1-git-send-email-yamada.masahiro@socionext.com> References: <1509356120-21473-1-git-send-email-yamada.masahiro@socionext.com> 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/ohci-platform.c | 37 ++++++++++++++----------------------- 1 file changed, 14 insertions(+), 23 deletions(-) -- 2.7.4 diff --git a/drivers/usb/host/ohci-platform.c b/drivers/usb/host/ohci-platform.c index 61fe2b9..cb7e190 100644 --- a/drivers/usb/host/ohci-platform.c +++ b/drivers/usb/host/ohci-platform.c @@ -34,12 +34,11 @@ #define DRIVER_DESC "OHCI generic platform driver" #define OHCI_MAX_CLKS 3 -#define OHCI_MAX_RESETS 2 #define hcd_to_ohci_priv(h) ((struct ohci_platform_priv *)hcd_to_ohci(h)->priv) struct ohci_platform_priv { struct clk *clks[OHCI_MAX_CLKS]; - struct reset_control *resets[OHCI_MAX_RESETS]; + struct reset_control *resets; struct phy **phys; int num_phys; }; @@ -119,7 +118,7 @@ static int ohci_platform_probe(struct platform_device *dev) struct usb_ohci_pdata *pdata = dev_get_platdata(&dev->dev); struct ohci_platform_priv *priv; struct ohci_hcd *ohci; - int err, irq, phy_num, clk = 0, rst = 0; + int err, irq, phy_num, clk = 0; if (usb_disabled()) return -ENODEV; @@ -204,21 +203,15 @@ static int ohci_platform_probe(struct platform_device *dev) break; } } - for (rst = 0; rst < OHCI_MAX_RESETS; rst++) { - priv->resets[rst] = - devm_reset_control_get_shared_by_index( - &dev->dev, rst); - if (IS_ERR(priv->resets[rst])) { - err = PTR_ERR(priv->resets[rst]); - if (err == -EPROBE_DEFER) - goto err_reset; - priv->resets[rst] = NULL; - break; - } - err = reset_control_deassert(priv->resets[rst]); - if (err) - goto err_reset; - } + + priv->resets = devm_reset_control_array_get_optional_shared( + &dev->dev); + if (IS_ERR(priv->resets)) + return PTR_ERR(priv->resets); + + err = reset_control_deassert(priv->resets); + if (err) + goto err_put_clks; } if (pdata->big_endian_desc) @@ -279,8 +272,7 @@ static int ohci_platform_probe(struct platform_device *dev) pdata->power_off(dev); err_reset: pm_runtime_disable(&dev->dev); - while (--rst >= 0) - reset_control_assert(priv->resets[rst]); + reset_control_assert(priv->resets); err_put_clks: while (--clk >= 0) clk_put(priv->clks[clk]); @@ -298,7 +290,7 @@ static int ohci_platform_remove(struct platform_device *dev) struct usb_hcd *hcd = platform_get_drvdata(dev); struct usb_ohci_pdata *pdata = dev_get_platdata(&dev->dev); struct ohci_platform_priv *priv = hcd_to_ohci_priv(hcd); - int clk, rst; + int clk; pm_runtime_get_sync(&dev->dev); usb_remove_hcd(hcd); @@ -306,8 +298,7 @@ static int ohci_platform_remove(struct platform_device *dev) if (pdata->power_off) pdata->power_off(dev); - for (rst = 0; rst < OHCI_MAX_RESETS && priv->resets[rst]; rst++) - reset_control_assert(priv->resets[rst]); + reset_control_assert(priv->resets); for (clk = 0; clk < OHCI_MAX_CLKS && priv->clks[clk]; clk++) clk_put(priv->clks[clk]);