From patchwork Fri Mar 16 09:10:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manu Gautam X-Patchwork-Id: 10286683 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 ECC0160386 for ; Fri, 16 Mar 2018 09:11:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E78F728DEA for ; Fri, 16 Mar 2018 09:11:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DC17B28DEC; Fri, 16 Mar 2018 09:11:37 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 659A528DEB for ; Fri, 16 Mar 2018 09:11:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752421AbeCPJLV (ORCPT ); Fri, 16 Mar 2018 05:11:21 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:59532 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750847AbeCPJLT (ORCPT ); Fri, 16 Mar 2018 05:11:19 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 6921760C64; Fri, 16 Mar 2018 09:11:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1521191479; bh=XOlot3QcEVzxAdTRESb+WG7XMr1rVim9kISJs9qR95w=; h=From:To:Cc:Subject:Date:From; b=hAEoMLJJk5lefG7DIg0iRFAsTVrqxCt0jChwDA4DxVN2pAQThNEdaEwzXfxYNjky9 u9vVtJJPzoVaj+xhJS520AUnkxfQQygdwPndIw6cj8sSjBxaPhP9bz2gKqVj9Ten8q u1obUF8WpFCUpBbhQd4GERYXQfToUfir86VpJ9FM= Received: from mgautam-linux.qualcomm.com (blr-c-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.19.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: mgautam@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 52AA860590; Fri, 16 Mar 2018 09:11:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1521191478; bh=XOlot3QcEVzxAdTRESb+WG7XMr1rVim9kISJs9qR95w=; h=From:To:Cc:Subject:Date:From; b=I8YD5bKNuTDJhDPAlvLGOzQEgEy+9sSr7uffimE/rcNV/hAIu33GiJVMFJ4WCVQOg ux/hpAPNdtSMPeFs8bbXHtrKj9QPc5zGRd+6gVKiJVIK0buQBvqWMxoDEuB6ax91LV ZxPlk0qa5zhihczx/5fflDh9F8omlya9mJBI4+Ks= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 52AA860590 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=mgautam@codeaurora.org From: Manu Gautam To: Kishon Vijay Abraham I Cc: linux-arm-msm@vger.kernel.org, Manu Gautam , linux-kernel@vger.kernel.org (open list:GENERIC PHY FRAMEWORK) Subject: [PATCH] phy: core: Allow phy_pm_runtime_xxx API calls with NULL phy Date: Fri, 16 Mar 2018 14:40:51 +0530 Message-Id: <1521191452-30089-1-git-send-email-mgautam@codeaurora.org> X-Mailer: git-send-email 1.9.1 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP phy_init() and phy_exit() calls, and phy_power_on() and phy_power_off() already accept NULL as valid PHY refernece and act as NOP. Extend same concept to phy runtime_pm APIs to keep drivers (e.g. dwc3) code simple while dealing with optional PHYs. Signed-off-by: Manu Gautam --- drivers/phy/phy-core.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c index 09ac8af..48b9615 100644 --- a/drivers/phy/phy-core.c +++ b/drivers/phy/phy-core.c @@ -153,6 +153,9 @@ int phy_pm_runtime_get(struct phy *phy) { int ret; + if (!phy) + return 0; + if (!pm_runtime_enabled(&phy->dev)) return -ENOTSUPP; @@ -168,6 +171,9 @@ int phy_pm_runtime_get_sync(struct phy *phy) { int ret; + if (!phy) + return 0; + if (!pm_runtime_enabled(&phy->dev)) return -ENOTSUPP; @@ -181,6 +187,9 @@ int phy_pm_runtime_get_sync(struct phy *phy) int phy_pm_runtime_put(struct phy *phy) { + if (!phy) + return 0; + if (!pm_runtime_enabled(&phy->dev)) return -ENOTSUPP; @@ -190,6 +199,9 @@ int phy_pm_runtime_put(struct phy *phy) int phy_pm_runtime_put_sync(struct phy *phy) { + if (!phy) + return 0; + if (!pm_runtime_enabled(&phy->dev)) return -ENOTSUPP; @@ -199,6 +211,9 @@ int phy_pm_runtime_put_sync(struct phy *phy) void phy_pm_runtime_allow(struct phy *phy) { + if (!phy) + return 0; + if (!pm_runtime_enabled(&phy->dev)) return; @@ -208,6 +223,9 @@ void phy_pm_runtime_allow(struct phy *phy) void phy_pm_runtime_forbid(struct phy *phy) { + if (!phy) + return 0; + if (!pm_runtime_enabled(&phy->dev)) return;