From patchwork Mon Mar 13 09:39:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoshihiro Shimoda X-Patchwork-Id: 9620387 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8C61160244 for ; Mon, 13 Mar 2017 09:41:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7DF12283E7 for ; Mon, 13 Mar 2017 09:41:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 725972843B; Mon, 13 Mar 2017 09:41:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F310D283E7 for ; Mon, 13 Mar 2017 09:41:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750983AbdCMJli (ORCPT ); Mon, 13 Mar 2017 05:41:38 -0400 Received: from relmlor3.renesas.com ([210.160.252.173]:17580 "EHLO relmlie2.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750839AbdCMJlg (ORCPT ); Mon, 13 Mar 2017 05:41:36 -0400 Received: from unknown (HELO relmlir1.idc.renesas.com) ([10.200.68.151]) by relmlie2.idc.renesas.com with ESMTP; 13 Mar 2017 18:41:34 +0900 Received: from relmlac1.idc.renesas.com (relmlac1.idc.renesas.com [10.200.69.21]) by relmlir1.idc.renesas.com (Postfix) with ESMTP id 6478D72AA0; Mon, 13 Mar 2017 18:41:34 +0900 (JST) Received: by relmlac1.idc.renesas.com (Postfix, from userid 0) id 50CAB80030; Mon, 13 Mar 2017 18:41:34 +0900 (JST) Received: from relmlac1.idc.renesas.com (localhost [127.0.0.1]) by relmlac1.idc.renesas.com (Postfix) with ESMTP id 4BDFD8002F; Mon, 13 Mar 2017 18:41:34 +0900 (JST) Received: from relmlii2.idc.renesas.com [10.200.68.66] by relmlac1.idc.renesas.com with ESMTP id UAD21292; Mon, 13 Mar 2017 18:41:34 +0900 X-IronPort-AV: E=Sophos;i="5.36,158,1486393200"; d="scan'208";a="237344364" Received: from mail-hk2apc01lp0207.outbound.protection.outlook.com (HELO APC01-HK2-obe.outbound.protection.outlook.com) ([65.55.88.207]) by relmlii2.idc.renesas.com with ESMTP/TLS/AES256-SHA256; 13 Mar 2017 18:41:33 +0900 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=renesasgroup.onmicrosoft.com; s=selector1-renesas-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=g4mRF6TCyWW984UQf+ooaZVoyaheB9B3AvVSUofu8Ks=; b=UIzU6ZkXcmDir314gRS0BY/JrP5gy5yTp7JVarDaIb+bVfqkenu3kfjH0EsZDWGD2T4oY7GTCHsCxACKN0D6XNkEsbTF5IoxD2di+bgAHQWvyj+oRhy4Y7q7xQ6DxUy+aNBYcawgv2SJuKqWIiKK+BlMgAF3juGB4+KRJq8gk5s= Authentication-Results: ti.com; dkim=none (message not signed) header.d=none; ti.com; dmarc=none action=none header.from=renesas.com; Received: from localhost.localdomain (211.11.155.144) by PS1PR06MB1689.apcprd06.prod.outlook.com (10.167.53.11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.961.17; Mon, 13 Mar 2017 09:41:31 +0000 From: Yoshihiro Shimoda To: CC: , , Yoshihiro Shimoda Subject: [PATCH v2] phy: rcar-gen3-usb2: fix implementation for runtime PM Date: Mon, 13 Mar 2017 18:39:29 +0900 Message-ID: <1489397969-26153-1-git-send-email-yoshihiro.shimoda.uh@renesas.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 X-Originating-IP: [211.11.155.144] X-ClientProxiedBy: OS2PR01CA0030.jpnprd01.prod.outlook.com (10.164.161.140) To PS1PR06MB1689.apcprd06.prod.outlook.com (10.167.53.11) X-MS-Office365-Filtering-Correlation-Id: 5b940b35-573e-458a-b755-08d469f521cc X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(48565401081); SRVR:PS1PR06MB1689; X-Microsoft-Exchange-Diagnostics: 1; PS1PR06MB1689; 3:whQRBg2pPazy4iQP1mLAUr+F4S9FaHCb736w5ztswL6SgaheTmuZbdyEIEZboB+qqNrQlibfq7M30GfPFeVoJ+KiZi3xDbuQwr79wm0E94grmpK/5Hkkkcz41kCMTc83b4jJW3QSlZSlFa5L6y34t6Zv3iXZcvwD9DmvJ4eyBfNpd70aN4jvDaYBdsKGEbVOdaNoOqYBZXYIUxDx2INXzmdUethMRUTwbO4I96NJsLK//xBVXQqpmZtpXhAWtsnF3gqHCs+f4UngzbIwZjWfHxkqPcwk2Pnfr7jJB5PnTCc=; 25:dq1Dizmpd01V6OMLsR/tF7N80hZxzgx1t3YDqtJKhL+1XnIrDmTGpyt57QVn6clvq0jspIudlG2iecOYNai/xtA1/MPdhUB5aIUo9SIDnQ7FumisAEuslJs54xbBAdgJc0LiUMcsMgsMMvedxUFGdwHgO8k1q+JI91XXfoNUydTngXffxINrhF75hQ0ETcRYNTugbaySUOtbKvtN637wBdj/4nhvITJkYswM/QWfKMZxEABfg43o1hTamqGW3E5nbmwjsuWFSh8CnzBeukZn0MKBZ2s0KwlW8hSGYk+NT1d+s2gxVCjPmODUYsU3ayUF7HBvCFZOeyRlNcpeI1+KnmgFcKhjMuOvJvy8y0+hwLSrm6ZOYAf+uglVChv0YCZtfyJz1sEcIaAYOp2+mUmohYwnKKYAl8envYIMyR+OFXCvdeiAkhDBk7uNdsNME3PWn35KADiMgcEjlQ7h5DBZ6w== X-Microsoft-Exchange-Diagnostics: 1; PS1PR06MB1689; 31:bjVvI4mDiij15fbVeWn5mlMChr+V9GVat+SCaJR59dpq0b/r/IPmhkVGNMESfXHsHRzapKroAYlhSxMSKiFnNXMWXkf8cL8sW9vioVUGUWHW7Iz0hrwN/k8PAqmwiqwLxr+bvmPT3qFAFiyTxLD0Iyic8TaONeM2BJWlpJyPmtzaFYzZdFtvh4CdtO7dPH0KhrcoLBJqbULztx7JNWn5O6CRVUPqguMbtAzEa32R4DY=; 20:/3KIgM0PnHbMXOssEZpB0imJnW4HcXwUTq9yuXAVp5C46kEyb1gFAxqPuMiRKl5dBqp4Qrq5E89MkOo6mIzOlRhwPhi1OwI2DW8/UHz0ZT9+S2SHCKP+Sspt7SEBtZIQD3DqvHkjieA/k8NM/DtAM7INOFPk87VhBJaEd+jZaie4g19QEnJ9Q9+Zwztp0p59Y24GuJrpQazSwSkO1UrtFlXwJCIX61QV9G3AClvplKVx82kE4iIBMhnzZv+XPHt9Sg0ea2Of9/yqpCG3yAfQYvCkS4Jc/YzoB7zQFauzldrTKMk4svsI1N6EyoP31jeDn88wtx/Dw9mYOxNoBOF2aUL7dnPODWGsmdMkOPUr4RwzDal/DKC3FV7zM1wa506LzJ3YC0Z26mGxVxUTUaCejrJ+vtqtobk/Lh6UEh5X06wI8xof3E9gEb33b9Cx7PqKS7isQr51fzVBVV0HvqSQmFXNgbsQ5xx4Q9YgvA5bNMwOfh6kLXpK1HQxLjnhOmva X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040375)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046)(6055026)(6041248)(20161123558025)(20161123560025)(20161123562025)(20161123564025)(20161123555025)(6072148); SRVR:PS1PR06MB1689; BCL:0; PCL:0; RULEID:; SRVR:PS1PR06MB1689; X-Microsoft-Exchange-Diagnostics: 1; PS1PR06MB1689; 4:MZeujVy8YyNBbRoWpBVGFUX+J8iyq5IHaekHib4PgPyrP7dqh5SR6kydqsLzhFl3d2BXZjJD9PBtnzTumbYwHkuuEnuUnqUvYbv4QkSrABRCfruoxl3hCWtdWJjJ5Bj3F5TGEXmDMpLggSZ5OYWEwMivsKP+dqOdCexhy7NQdcgnFRkQMNvVs5Ywi8vKOzg05oei114E4OUb7uD0mzV5/2y/7acVklY1tlMVZDFC3ydNJHGRr0ewgIF8U8Ly1+lpeV4NJgGT2N87EPUm6bf1cdVupEWuMgTsiwn207f5D3TeWqT0iZ2+Fo3PhEvGTGZUqbO93L14mSpAQZKG/7lL2x5tRTA8KMhItAyGvqKBJGZ81Ot+syGQwhNgDT4kmjpm7eKYT3pAsBpn3e5EkmCJ3HhUvK1bHDTlkFZaNGB6f2lijlIv8i1ufTGEwCy7upljyUKWe+0GHhisU2rqljLOnYNTxiTHNZ/DqCFGKpiqyngtREGS7QqV1B8AJCW4h7ITiE2Zy7Den/2vqqHRoLBNCFx+ahAQIiIqIjXxhYu5Bl7DWixOp6a9bXbte69mej9/5Ug5ykbdLlcFnGIl4Oxga1W1kbLBzAOYrzwmhzWgfiSm/GChVCYUPK+mU78X5GqJ X-Forefront-PRVS: 0245702D7B X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6069001)(6009001)(39410400002)(39840400002)(39850400002)(39450400003)(39860400002)(23433003)(43544003)(4326008)(81166006)(38730400002)(8676002)(107886003)(47776003)(2351001)(78352004)(42186005)(7736002)(110136004)(305945005)(2906002)(42882006)(6916009)(5660300001)(5003940100001)(53936002)(36756003)(66066001)(230783001)(50226002)(3846002)(6116002)(6512007)(6506006)(54906002)(33646002)(6486002)(50466002)(25786008)(189998001)(50986999)(48376002); DIR:OUT; SFP:1102; SCL:1; SRVR:PS1PR06MB1689; H:localhost.localdomain; FPR:; SPF:None; MLV:ovrnspm; PTR:InfoNoRecords; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; PS1PR06MB1689; 23:3JInfjfjtpkIL4G8oWbjf3HjA/q3C/mhyZHmQD0FK?= =?us-ascii?Q?SUKuHe6kmoMhjZ5H0n4Gvyh8h2uk4KfmTI7EFR6MoV39tSYuRWlE1DN23T9Y?= =?us-ascii?Q?hJfRu6haDawL9E5hEDHl3hfMLPR0btHnghqyqWvGtz6dz3wv1EE7dHr03HiX?= =?us-ascii?Q?ScTfnfys877kKwlT8RTXruGxgESwjpjj5vYvqfJ7G12ytEV2q1p196Kkng/B?= =?us-ascii?Q?KwmH2bGrZjuvxkLA9n4j4+wHREZss9ev0I6w+ehxml1YqLXS8WnrdZAYnPMC?= =?us-ascii?Q?PzS7/g1wiH6ZSvvEOviCUmqRywROAykZM374/zRKXNNA/OqLcH8kkc2YA9C9?= =?us-ascii?Q?q5OBHarodfrJxsIV9WWw3El1nltByJARwhYjJJwozTZ3NQzdybkqc94J2RNu?= =?us-ascii?Q?/aPaKPSncBlVYnjLDOFjlV6i5YuwiJUWYrRQ6ge8JHh9jUi4SPz2GStoLx+c?= =?us-ascii?Q?IFQsjG7RA0P1g9y/jQ9hjI9TLivm9u8dnTi3Tcu6WSjDu8G4ZM2HNicwEWsd?= =?us-ascii?Q?A0ERoBuqjJawKAFhwv3lOJ6T/4vnvj0NsqNl5jUPUIYTQqzo1ew4/+a78JSJ?= =?us-ascii?Q?bKqMBZ2rId6Vp1XMYPbVaYKUom/lXa5tXETAybiIsU4WZ0uJQjlySUMbcHUA?= =?us-ascii?Q?xCdiljyNDeRQC7o+grEHgUsMaNSmsEYX29rgww4pSqFgkwy+6JHySA2mQFJY?= =?us-ascii?Q?e/E1vnUxMJkYzJA/9PedxW2D+MTykdfAvTIAFbCE1ke2GLZqJky3+KyR+ArH?= =?us-ascii?Q?m6mTv2Aqi2QEtqboqrux/WOuYJAGGz+QI8Pg/DlOd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R3gJvaAfM01KrPISrh8GplY7Z/M1Hh/13IK1+k= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; PS1PR06MB1689; 7:U55LDyaFZSDXVQMIR4QK8zr1b9aHmBTM1VHYzDM+/8ruXehDRgDkdjx42KviIQH14HosOwb8fAaWzc9BQFiKOVMXi+p98BAJxh5NkApycC14Rtsr1OZP7jSSvcxu6oa7T0ac5SpEJqkSQrd6otfVykUzbBeQiNcKXBlQkEj6mEf41ZK9iqqSEGc/alvSS2aLSI+9D6pPJ2pjxtVlBC/hntNNGEx37+tySuz2XjgEwBjByH72ltBcH9TXSbxGnOBkk5jH5dyBE6zE3tHxJZQm49VYeSuu0PMWt7DZ+wqkiDmFw1co9Z8sh4bg0T94IpjlP1+xWiqq4OjNBgkkHOuorw==; 20:qyhZ7KUXjFL9iBy9W+OYEl8ZhFC3EQ/agoOMJqARgT7KJWX+JbvDDngigkrBA0NpTLvExI0/iczfR18Q4IfkjMDJRzoBkOfvSaO2syUGTlfkiWls1AanpZTwAvMAv+jHK7gY9wxbOF7M3GvzN8r31UTeHjKUuXad8oOby2HDjVw= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Mar 2017 09:41:31.7144 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: PS1PR06MB1689 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch fixes an issue that this driver doesn't take care of the runtime PM. This code assumed that devm_phy_create() called pm_runtime_enable(dev), but it misunderstood the dev_phy_create()'s specification. This driver should call its own pm_runtime_pm() before dev_phy_create(). Fixes: f3b5a8d9b50d ("phy: rcar-gen3-usb2: Add R-Car Gen3 USB2 PHY driver") Signed-off-by: Yoshihiro Shimoda --- Changes from v1: - revise the commit log (s/the own/its own/) - simplify return code in probe(). drivers/phy/phy-rcar-gen3-usb2.c | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/drivers/phy/phy-rcar-gen3-usb2.c b/drivers/phy/phy-rcar-gen3-usb2.c index afb4d04..54c3429 100644 --- a/drivers/phy/phy-rcar-gen3-usb2.c +++ b/drivers/phy/phy-rcar-gen3-usb2.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -395,7 +396,7 @@ static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev) struct rcar_gen3_chan *channel; struct phy_provider *provider; struct resource *res; - int irq; + int irq, ret = 0; if (!dev->of_node) { dev_err(dev, "This driver needs device tree\n"); @@ -434,17 +435,24 @@ static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev) } } - /* devm_phy_create() will call pm_runtime_enable(dev); */ + /* + * devm_phy_create() will call pm_runtime_enable(&phy->dev); + * And then, phy-core will manage runtime pm for this device. + */ + pm_runtime_enable(dev); channel->phy = devm_phy_create(dev, NULL, &rcar_gen3_phy_usb2_ops); if (IS_ERR(channel->phy)) { dev_err(dev, "Failed to create USB2 PHY\n"); - return PTR_ERR(channel->phy); + ret = PTR_ERR(channel->phy); + goto error; } channel->vbus = devm_regulator_get_optional(dev, "vbus"); if (IS_ERR(channel->vbus)) { - if (PTR_ERR(channel->vbus) == -EPROBE_DEFER) - return PTR_ERR(channel->vbus); + if (PTR_ERR(channel->vbus) == -EPROBE_DEFER) { + ret = PTR_ERR(channel->vbus); + goto error; + } channel->vbus = NULL; } @@ -454,15 +462,22 @@ static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev) provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate); if (IS_ERR(provider)) { dev_err(dev, "Failed to register PHY provider\n"); + ret = PTR_ERR(provider); + goto error; } else if (channel->has_otg) { int ret; ret = device_create_file(dev, &dev_attr_role); if (ret < 0) - return ret; + goto error; } - return PTR_ERR_OR_ZERO(provider); + return 0; + +error: + pm_runtime_disable(dev); + + return ret; } static int rcar_gen3_phy_usb2_remove(struct platform_device *pdev) @@ -472,6 +487,8 @@ static int rcar_gen3_phy_usb2_remove(struct platform_device *pdev) if (channel->has_otg) device_remove_file(&pdev->dev, &dev_attr_role); + pm_runtime_disable(&pdev->dev); + return 0; };