From patchwork Tue Mar 20 06:01:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manu Gautam X-Patchwork-Id: 10296459 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 93E13600F6 for ; Tue, 20 Mar 2018 06:02:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8330529524 for ; Tue, 20 Mar 2018 06:02:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7755B2953A; Tue, 20 Mar 2018 06:02:04 +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 CECEA29524 for ; Tue, 20 Mar 2018 06:02:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751320AbeCTGCC (ORCPT ); Tue, 20 Mar 2018 02:02:02 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:60762 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751022AbeCTGCC (ORCPT ); Tue, 20 Mar 2018 02:02:02 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id A059F60C5F; Tue, 20 Mar 2018 06:02:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1521525721; bh=mm6TeliGUDwtR9K8WxlJWKmBJaEgTQDR97OKrKVOrAA=; h=From:To:Cc:Subject:Date:From; b=E2n7YjG+OnWQDsVrUz84JpJHJTZZmZhEI/x8Locxzn4VNtuBCc7Y59klhVXIeqaXc pgx135HjLTi6LHCj0p2GrdcIhSdr2oIjdLYovZdOBWF4CCYjGhGPa5zziI2YP5oghY 2iJODG1n0A/J0jJmVOFEwIdYCwjc3tXkJI5qBu3Q= 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 3AC84603AF; Tue, 20 Mar 2018 06:01:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1521525721; bh=mm6TeliGUDwtR9K8WxlJWKmBJaEgTQDR97OKrKVOrAA=; h=From:To:Cc:Subject:Date:From; b=E2n7YjG+OnWQDsVrUz84JpJHJTZZmZhEI/x8Locxzn4VNtuBCc7Y59klhVXIeqaXc pgx135HjLTi6LHCj0p2GrdcIhSdr2oIjdLYovZdOBWF4CCYjGhGPa5zziI2YP5oghY 2iJODG1n0A/J0jJmVOFEwIdYCwjc3tXkJI5qBu3Q= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 3AC84603AF 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 v2] phy: core: Allow phy_pm_runtime_xxx API calls with NULL phy Date: Tue, 20 Mar 2018 11:31:47 +0530 Message-Id: <1521525707-23927-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 reference 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 --- Changes for v2: - Fixed compilation warning 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 3c31ce5..1fda576 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; + 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; + if (!pm_runtime_enabled(&phy->dev)) return;