From patchwork Wed Nov 1 16:01:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 117728 Delivered-To: patch@linaro.org Received: by 10.80.245.45 with SMTP id t42csp943362edm; Wed, 1 Nov 2017 09:02:44 -0700 (PDT) X-Google-Smtp-Source: ABhQp+SuiqElyB+QBjABoAZjXc/NBddZGlUK1tR/EfsJJaHmGG57U43zMyDdXhRbeZ+ZnjBpGhli X-Received: by 10.84.193.129 with SMTP id f1mr80549pld.248.1509552164707; Wed, 01 Nov 2017 09:02:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509552164; cv=none; d=google.com; s=arc-20160816; b=QJ1siV8A6g5KuXXM4UXWvGGyGdQ/z7wacMPPfy/8qvu9dlAD+qqWqnZmR40KvlsM4U 06JURxGDcgahDIPDPYtWikVfrdgKSPFnC3Dh4ERDSt3sxiWMR5x86Z78RiL9ajX524ZR uDT29XgzbfcSn94KjiTgL2HhPWNt9WNfWyZFeMz0inWoQKY4OIkrwZUefYqpcDuORK5Q 5bPNaSYcXCeRfSHjhHHcqof/djExL505N8Dvk16Ks6DyVtb4DleAZvKM2p6M28U1NxWf oL2R9dIIIZwK62yvhkQcGjFfau5OOB0tvKSpcMf5BJ3dWAi5bRENEhsH+pzSdbrqJpJw T9JQ== 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=J70be5HlON5/VezMpW2Jp6qK4C0ObTDBEmIPaSvzi9w=; b=Jg5/eg6CddZFAbcINTkTQBeKZIaUMVpzwiXw9QB8D4nwJOwTtuBJ5WvbZ+ISFW+Q3s xn18krvku7auyd9T6TQMgzkhjeIg9NzjdQucTNA6j6W/MyByZ8q+TlZoDsxkuCdEeaBv mrekGVoXKT7lJCqz/7UMvkdjzFDogEpSY0P0fAyl+rQnWR1fZpOOHT4N1D6wWU+Qtboy ADovvFJv02mUI2XWdbqc17afJXc5pviYDzNW0KENG9o8lQj7gXFSSpoHzKcgmHcWMO5Z XPLqmbBgMgwfXbF+K5TyROccfXLHFy9UYeJhaVeEJK1ZJJ+0IKnjD2lm5OAaK9q9WzA4 +TUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=BiEncLkz; 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 s10si1283937pgp.531.2017.11.01.09.02.44; Wed, 01 Nov 2017 09:02:44 -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=BiEncLkz; 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 S933035AbdKAQCm (ORCPT + 26 others); Wed, 1 Nov 2017 12:02:42 -0400 Received: from conuserg-10.nifty.com ([210.131.2.77]:20728 "EHLO conuserg-10.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932392AbdKAQCl (ORCPT ); Wed, 1 Nov 2017 12:02:41 -0400 X-Greylist: delayed 716 seconds by postgrey-1.27 at vger.kernel.org; Wed, 01 Nov 2017 12:02:41 EDT 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 vA1G24g6014889; Thu, 2 Nov 2017 01:02:05 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-10.nifty.com vA1G24g6014889 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1509552125; bh=J70be5HlON5/VezMpW2Jp6qK4C0ObTDBEmIPaSvzi9w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BiEncLkzvwr3IPWfW/DHzN8Bq0sljUUm3qDgMF8+4GS/ob4oTGXboBucNlfiPuft0 w4KkBW/AMAByVHI3Gm1dmLXahPbBeoWnYvD8/PreuMl28mCTfWLW/oln5ejpCqDNEm pIG9nRmpQrM0Qk5yC3G4CmE4qnqLUNQM3bnvalsAvPOJ3SMm+l+HzMxghr3GMz7py7 35FZq2CbTET2YCkqllqBaPUCeG7s/WwiUfSmFqv6kAEPp34Meofp5BuSsqgrjvp8Z+ I8+Ak0CVaIbLXXo9nN2b7Hl7KiCpb4wA1cupxZXcJWbxSFBxaffieqC1e4dPkW5yVf zyL+7tOb/HfDA== X-Nifty-SrcIP: [125.199.20.195] From: Masahiro Yamada To: linux-usb@vger.kernel.org Cc: Masahiro Yamada , Greg Kroah-Hartman , Alan Stern , linux-kernel@vger.kernel.org Subject: [PATCH v2 2/2] usb: ohci-platform: use reset array API Date: Thu, 2 Nov 2017 01:01:59 +0900 Message-Id: <1509552119-23816-2-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1509552119-23816-1-git-send-email-yamada.masahiro@socionext.com> References: <1509552119-23816-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 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/ohci-platform.c | 37 +++++++++++++++---------------------- 1 file changed, 15 insertions(+), 22 deletions(-) -- 2.7.4 diff --git a/drivers/usb/host/ohci-platform.c b/drivers/usb/host/ohci-platform.c index 61fe2b9..05ebde6 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,17 @@ 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)) { + err = PTR_ERR(priv->resets); + goto err_put_clks; } + + err = reset_control_deassert(priv->resets); + if (err) + goto err_put_clks; } if (pdata->big_endian_desc) @@ -279,8 +274,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 +292,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 +300,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]);