From patchwork Tue Oct 7 03:43:05 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoshihiro Shimoda X-Patchwork-Id: 5040581 Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id D9DCCC11AB for ; Tue, 7 Oct 2014 03:43:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0AAAD20172 for ; Tue, 7 Oct 2014 03:43:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1C79D2016C for ; Tue, 7 Oct 2014 03:43:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752654AbaJGDnY (ORCPT ); Mon, 6 Oct 2014 23:43:24 -0400 Received: from relmlor2.renesas.com ([210.160.252.172]:22801 "EHLO relmlie1.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752480AbaJGDnX (ORCPT ); Mon, 6 Oct 2014 23:43:23 -0400 Received: from unknown (HELO relmlir4.idc.renesas.com) ([10.200.68.154]) by relmlie1.idc.renesas.com with ESMTP; 07 Oct 2014 12:43:23 +0900 Received: from relmlac4.idc.renesas.com (relmlac4.idc.renesas.com [10.200.69.24]) by relmlir4.idc.renesas.com (Postfix) with ESMTP id 52E4045A87; Tue, 7 Oct 2014 12:43:23 +0900 (JST) Received: by relmlac4.idc.renesas.com (Postfix, from userid 0) id 3D5A4480A7; Tue, 7 Oct 2014 12:43:23 +0900 (JST) Received: from relmlac4.idc.renesas.com (localhost [127.0.0.1]) by relmlac4.idc.renesas.com (Postfix) with ESMTP id 35751480A6; Tue, 7 Oct 2014 12:43:23 +0900 (JST) Received: from relmlii2.idc.renesas.com [10.200.68.66] by relmlac4.idc.renesas.com with ESMTP id NAB17424; Tue, 7 Oct 2014 12:43:23 +0900 X-IronPort-AV: E=Sophos;i="5.04,666,1406559600"; d="scan'208";a="171817288" Received: from mail-hk1lp0126.outbound.protection.outlook.com (HELO APAC01-HK1-obe.outbound.protection.outlook.com) ([207.46.51.126]) by relmlii2.idc.renesas.com with ESMTP/TLS/AES256-SHA; 07 Oct 2014 12:43:22 +0900 Received: from localhost (211.11.155.147) by SIXPR06MB333.apcprd06.prod.outlook.com (10.141.120.15) with Microsoft SMTP Server (TLS) id 15.0.1044.10; Tue, 7 Oct 2014 03:43:21 +0000 From: Yoshihiro Shimoda To: , CC: , , , Yoshihiro Shimoda Subject: [PATCH v2 2/3] usb: renesas_usbhs: clean up rcar2.c to support a generic PHY Date: Tue, 7 Oct 2014 12:43:05 +0900 Message-ID: <1412653386-5856-3-git-send-email-yoshihiro.shimoda.uh@renesas.com> X-Mailer: git-send-email 1.9.4.msysgit.1 In-Reply-To: <1412653386-5856-1-git-send-email-yoshihiro.shimoda.uh@renesas.com> References: <1412653386-5856-1-git-send-email-yoshihiro.shimoda.uh@renesas.com> MIME-Version: 1.0 X-Originating-IP: [211.11.155.147] X-ClientProxiedBy: SG2PR03CA0041.apcprd03.prod.outlook.com (25.160.233.51) To SIXPR06MB333.apcprd06.prod.outlook.com (10.141.120.15) X-Microsoft-Antispam: UriScan:; X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:;SRVR:SIXPR06MB333; X-Forefront-PRVS: 035748864E X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(6009001)(6069001)(189002)(199003)(19580395003)(101416001)(95666004)(229853001)(64706001)(120916001)(42382002)(46102003)(99396003)(66066001)(78352002)(93916002)(85306004)(76506005)(105586002)(4396001)(33646002)(50466002)(19580405001)(107046002)(48376002)(42186005)(50226001)(76176999)(50986999)(77096002)(20776003)(92566001)(76482002)(97736003)(80022003)(106356001)(92726001)(31966008)(102836001)(87286001)(88136002)(104166001)(85852003)(47776003)(21056001)(89996001)(87976001)(36756003)(77156001)(122386002)(62966002)(40100002)(88662002)(41533002); DIR:OUT; SFP:1102; SCL:1; SRVR:SIXPR06MB333; H:localhost; FPR:; MLV:nov; PTR:InfoNoRecords; MX:0; A:0; LANG:; Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=<>; X-OriginatorOrg: renesas.com Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-5.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY, URIBL_RHS_DOB autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP To support both usb PHY and generic PHY, this patch cleans up rcar2.c. Signed-off-by: Yoshihiro Shimoda --- 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)