From patchwork Fri Oct 17 17:16:18 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Balbi X-Patchwork-Id: 38979 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f71.google.com (mail-wg0-f71.google.com [74.125.82.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 84144202DB for ; Fri, 17 Oct 2014 17:19:52 +0000 (UTC) Received: by mail-wg0-f71.google.com with SMTP id y10sf722076wgg.10 for ; Fri, 17 Oct 2014 10:19:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe:content-type; bh=FRUQkNFfdyz7zD7oRaeFfTMvAiSQhGHMqCedXMz+TaY=; b=hxd6IlSRT0luQk6LtKBfT3gU95hAXCaVnZXELZ65enyrPxyDou1skDaFF/fxMXYah9 ekE2+/tDskF1KTYdf52iMz1MLHwSoK/xrB2fqhL5DbtoNq5dht8X9B18GOTN63qs1sXf yMO8lcSJzN0sIti7rWkxUNLct0tDm2OBkQZ4a2p3iHkml2HsImcQn1Vl7eGABxSJ+HsU jZFxhDEipKx9S8u3WSrnXB19pQmwp8xiXCGAEe9od0cBHkzFGq84sg/vCUtEDUD9DQvQ dYjUvs7fzN8FBRXkrDu399QtQ2mIU14B+oYV/UwFq4mnruYn8Igtf/y6XVFq9wo3vNp/ VNZA== X-Gm-Message-State: ALoCoQmFJ6YeEniA2mSvvsnmNZZV1TvMiCan4EiH6T0ahUmSqt1o72Qf9OTJRIisgsyWl8UcBSxn X-Received: by 10.112.225.135 with SMTP id rk7mr1601316lbc.6.1413566391760; Fri, 17 Oct 2014 10:19:51 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.3.132 with SMTP id c4ls257130lac.88.gmail; Fri, 17 Oct 2014 10:19:51 -0700 (PDT) X-Received: by 10.112.73.35 with SMTP id i3mr10251783lbv.75.1413566391619; Fri, 17 Oct 2014 10:19:51 -0700 (PDT) Received: from mail-lb0-f181.google.com (mail-lb0-f181.google.com. [209.85.217.181]) by mx.google.com with ESMTPS id mi5si3006858lbc.61.2014.10.17.10.19.51 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 17 Oct 2014 10:19:51 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.181 as permitted sender) client-ip=209.85.217.181; Received: by mail-lb0-f181.google.com with SMTP id l4so1015755lbv.40 for ; Fri, 17 Oct 2014 10:19:51 -0700 (PDT) X-Received: by 10.112.189.10 with SMTP id ge10mr10139726lbc.23.1413566391545; Fri, 17 Oct 2014 10:19:51 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.84.229 with SMTP id c5csp268382lbz; Fri, 17 Oct 2014 10:19:50 -0700 (PDT) X-Received: by 10.66.66.136 with SMTP id f8mr9789392pat.55.1413566389986; Fri, 17 Oct 2014 10:19:49 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ap1si1616281pbc.152.2014.10.17.10.19.49 for ; Fri, 17 Oct 2014 10:19:49 -0700 (PDT) Received-SPF: none (google.com: linux-usb-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753476AbaJQRRy (ORCPT + 3 others); Fri, 17 Oct 2014 13:17:54 -0400 Received: from comal.ext.ti.com ([198.47.26.152]:55763 "EHLO comal.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753326AbaJQRRr (ORCPT ); Fri, 17 Oct 2014 13:17:47 -0400 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id s9HHHalO011700; Fri, 17 Oct 2014 12:17:36 -0500 Received: from DFLE73.ent.ti.com (dfle73.ent.ti.com [128.247.5.110]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id s9HHHaWU000695; Fri, 17 Oct 2014 12:17:36 -0500 Received: from dflp33.itg.ti.com (10.64.6.16) by DFLE73.ent.ti.com (128.247.5.110) with Microsoft SMTP Server id 14.3.174.1; Fri, 17 Oct 2014 12:17:36 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp33.itg.ti.com (8.14.3/8.13.8) with ESMTP id s9HHHZ1G002881; Fri, 17 Oct 2014 12:17:36 -0500 From: Felipe Balbi To: Linux USB Mailing List CC: Greg KH , , Paul Zimmerman , , , , , , , Yoshihiro Shimoda , Felipe Balbi Subject: [PATCH 11/67] usb: renesas_usbhs: clean up rcar2.c to support a generic PHY Date: Fri, 17 Oct 2014 12:16:18 -0500 Message-ID: <1413566234-13537-12-git-send-email-balbi@ti.com> X-Mailer: git-send-email 2.1.0.GIT In-Reply-To: <1413566234-13537-1-git-send-email-balbi@ti.com> References: <1413566234-13537-1-git-send-email-balbi@ti.com> MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: balbi@ti.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.181 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Yoshihiro Shimoda To support both usb PHY and generic PHY, this patch cleans up rcar2.c. Signed-off-by: Yoshihiro Shimoda Signed-off-by: Felipe Balbi --- drivers/usb/renesas_usbhs/rcar2.c | 48 +++++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/drivers/usb/renesas_usbhs/rcar2.c b/drivers/usb/renesas_usbhs/rcar2.c index f264cad..485b889 100644 --- a/drivers/usb/renesas_usbhs/rcar2.c +++ b/drivers/usb/renesas_usbhs/rcar2.c @@ -20,25 +20,28 @@ static int usbhs_rcar2_hardware_init(struct platform_device *pdev) { struct usbhs_priv *priv = usbhs_pdev_to_priv(pdev); - struct usb_phy *usb_phy; - usb_phy = usb_get_phy_dev(&pdev->dev, 0); - if (IS_ERR(usb_phy)) - return PTR_ERR(usb_phy); + if (IS_ENABLED(CONFIG_USB_PHY)) { + struct usb_phy *usb_phy = usb_get_phy_dev(&pdev->dev, 0); - priv->usb_phy = usb_phy; - return 0; + if (IS_ERR(usb_phy)) + return PTR_ERR(usb_phy); + + priv->usb_phy = usb_phy; + return 0; + } + + return -ENXIO; } static int usbhs_rcar2_hardware_exit(struct platform_device *pdev) { struct usbhs_priv *priv = usbhs_pdev_to_priv(pdev); - if (!priv->usb_phy) - return 0; - - usb_put_phy(priv->usb_phy); - priv->usb_phy = NULL; + if (priv->usb_phy) { + usb_put_phy(priv->usb_phy); + priv->usb_phy = NULL; + } return 0; } @@ -47,21 +50,22 @@ static int usbhs_rcar2_power_ctrl(struct platform_device *pdev, void __iomem *base, int enable) { struct usbhs_priv *priv = usbhs_pdev_to_priv(pdev); + int retval = -ENODEV; - if (!priv->usb_phy) - return -ENODEV; + if (priv->usb_phy) { + if (enable) { + retval = usb_phy_init(priv->usb_phy); - if (enable) { - int retval = usb_phy_init(priv->usb_phy); - - if (!retval) - retval = usb_phy_set_suspend(priv->usb_phy, 0); - return retval; + if (!retval) + retval = usb_phy_set_suspend(priv->usb_phy, 0); + } else { + usb_phy_set_suspend(priv->usb_phy, 1); + usb_phy_shutdown(priv->usb_phy); + retval = 0; + } } - usb_phy_set_suspend(priv->usb_phy, 1); - usb_phy_shutdown(priv->usb_phy); - return 0; + return retval; } static int usbhs_rcar2_get_id(struct platform_device *pdev)