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]); 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]);