From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4D3B8C3ABBE for ; Tue, 6 May 2025 02:10:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=AcgEeajQp4TNAXjKpFJCQDqJUx/WYga6px046v4RmFQ=; b=12G+CC0dHOi7H7 67gzcbutwQm5h/yo6KNfmtwLvwQhaUT4KBVw0p/T+sOkyOTbHYV5VukzaUevgeeOIoR4XZPchlcYQ kQv//FAO51q1M+zduE83QdryHyhGg63xBWWM94ucDRpx0Mi82EP+KGd2V7dzLHzwzDohDZEj8LsBb DSnE7moyAJkRPgJ06VaAE4YloMff9oXCej0Oj5cLK2HExP81GJZF+ca1t30YEpIfIQwaxe5Zg+kjS 88V1XNiQx8gN22YvbalOP4vCYO1vaQTIosxJ+fpdUWIwZ0cL1MYGOsDg6BsZWbaB/i6rwyXvrlZE7 6CJHDAkG1twClw4DYHKg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1uC7lN-00000009gLt-0CS7; Tue, 06 May 2025 02:10:29 +0000 Received: from nyc.source.kernel.org ([2604:1380:45d1:ec00::3]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1uC4fD-00000008swb-0Sxp for linux-phy@lists.infradead.org; Mon, 05 May 2025 22:51:56 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id CA901A4D17C; Mon, 5 May 2025 22:46:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 37D8FC4CEEE; Mon, 5 May 2025 22:51:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1746485514; bh=NrKHRuMeaILovRsT/haYgQx4xtXO5Kjk1YY4SG2k6zY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rLOUjOPbH16ccgCfLy1tGsajlfejrmMqSVGhz/pyJVDvFXS8sdHkQ37rpofOq0EOp yPLWGzz2yzXcd2/gZVKftaiUnruZWG7uHrmVijfbV0WY2ZcPLlaDhyGf6DQuevTCb5 p1kwbO2N6mWvOuh3Jv724/4YKNBuK0OHHKmvKTQF1D2Ds7OfQ8LslxMLka08o0VZZe aq+SK0EuOjEltEWSsUE/ZKLheTpK0v+Q/sY/Ur/gMdCtmbvCKCTn6KyojPoIzU32Uv BCG1ToOajDd9o3r6IH0bWkhQf7dSlJWP3myGNSeG0f3Q8RNAdgloF/Ph0w3O6oEY09 MA5dvhhoIQsBA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Dmitry Baryshkov , Damon Ding , Vinod Koul , Sasha Levin , kishon@kernel.org, linux-phy@lists.infradead.org Subject: [PATCH AUTOSEL 6.12 355/486] phy: core: don't require set_mode() callback for phy_get_mode() to work Date: Mon, 5 May 2025 18:37:11 -0400 Message-Id: <20250505223922.2682012-355-sashal@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250505223922.2682012-1-sashal@kernel.org> References: <20250505223922.2682012-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.12.26 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250505_155155_217546_DFADE626 X-CRM114-Status: GOOD ( 10.54 ) X-BeenThere: linux-phy@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux Phy Mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-phy" Errors-To: linux-phy-bounces+linux-phy=archiver.kernel.org@lists.infradead.org From: Dmitry Baryshkov [ Upstream commit d58c04e305afbaa9dda7969151f06c4efe2c98b0 ] As reported by Damon Ding, the phy_get_mode() call doesn't work as expected unless the PHY driver has a .set_mode() call. This prompts PHY drivers to have empty stubs for .set_mode() for the sake of being able to get the mode. Make .set_mode() callback truly optional and update PHY's mode even if it there is none. Cc: Damon Ding Link: https://lore.kernel.org/r/96f8310f-93f1-4bcb-8637-137e1159ff83@rock-chips.com Tested-by: Damon Ding Signed-off-by: Dmitry Baryshkov Link: https://lore.kernel.org/r/20250209-phy-fix-set-moe-v2-1-76e248503856@linaro.org Signed-off-by: Vinod Koul Signed-off-by: Sasha Levin --- drivers/phy/phy-core.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c index 413f76e2d1744..e0a6a272f5714 100644 --- a/drivers/phy/phy-core.c +++ b/drivers/phy/phy-core.c @@ -405,13 +405,14 @@ EXPORT_SYMBOL_GPL(phy_power_off); int phy_set_mode_ext(struct phy *phy, enum phy_mode mode, int submode) { - int ret; + int ret = 0; - if (!phy || !phy->ops->set_mode) + if (!phy) return 0; mutex_lock(&phy->mutex); - ret = phy->ops->set_mode(phy, mode, submode); + if (phy->ops->set_mode) + ret = phy->ops->set_mode(phy, mode, submode); if (!ret) phy->attrs.mode = mode; mutex_unlock(&phy->mutex); -- 2.39.5 -- linux-phy mailing list linux-phy@lists.infradead.org https://lists.infradead.org/mailman/listinfo/linux-phy From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3FC5427F74A; Mon, 5 May 2025 22:51:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746485515; cv=none; b=vEHON12XGQbaDsupy2fy9RrCogun4C0txVKFSsBP9Fc0NXcRX2bbQXODpnMPGunBD4QKopmcvyfzZ9RTGeG5rkdrJZbqELUi8cm2C7KymvAlAWl/CZsgM2XgGoXVGqfjpugAvj8aLkHFVHeiFUnBRgVCBAATKzzvo5XVAJSZBMo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746485515; c=relaxed/simple; bh=NrKHRuMeaILovRsT/haYgQx4xtXO5Kjk1YY4SG2k6zY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=gUTRrr3thznjWQ+4pX921CN9s3c2lGDvlR9i5faiQT83xpjD/VLX5CXJfghipJLN0UuUH+U6gXvckdZKdz8rjhHQGzoWD8ff6id66xpcU7e44QiU4RTg+jXXjNfkDk5gv69qwHVesvDSGyss83RsNBoxItX2BUF3P8fW4Ut7gKI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=rLOUjOPb; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="rLOUjOPb" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 37D8FC4CEEE; Mon, 5 May 2025 22:51:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1746485514; bh=NrKHRuMeaILovRsT/haYgQx4xtXO5Kjk1YY4SG2k6zY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rLOUjOPbH16ccgCfLy1tGsajlfejrmMqSVGhz/pyJVDvFXS8sdHkQ37rpofOq0EOp yPLWGzz2yzXcd2/gZVKftaiUnruZWG7uHrmVijfbV0WY2ZcPLlaDhyGf6DQuevTCb5 p1kwbO2N6mWvOuh3Jv724/4YKNBuK0OHHKmvKTQF1D2Ds7OfQ8LslxMLka08o0VZZe aq+SK0EuOjEltEWSsUE/ZKLheTpK0v+Q/sY/Ur/gMdCtmbvCKCTn6KyojPoIzU32Uv BCG1ToOajDd9o3r6IH0bWkhQf7dSlJWP3myGNSeG0f3Q8RNAdgloF/Ph0w3O6oEY09 MA5dvhhoIQsBA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Dmitry Baryshkov , Damon Ding , Vinod Koul , Sasha Levin , kishon@kernel.org, linux-phy@lists.infradead.org Subject: [PATCH AUTOSEL 6.12 355/486] phy: core: don't require set_mode() callback for phy_get_mode() to work Date: Mon, 5 May 2025 18:37:11 -0400 Message-Id: <20250505223922.2682012-355-sashal@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250505223922.2682012-1-sashal@kernel.org> References: <20250505223922.2682012-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.12.26 Content-Transfer-Encoding: 8bit From: Dmitry Baryshkov [ Upstream commit d58c04e305afbaa9dda7969151f06c4efe2c98b0 ] As reported by Damon Ding, the phy_get_mode() call doesn't work as expected unless the PHY driver has a .set_mode() call. This prompts PHY drivers to have empty stubs for .set_mode() for the sake of being able to get the mode. Make .set_mode() callback truly optional and update PHY's mode even if it there is none. Cc: Damon Ding Link: https://lore.kernel.org/r/96f8310f-93f1-4bcb-8637-137e1159ff83@rock-chips.com Tested-by: Damon Ding Signed-off-by: Dmitry Baryshkov Link: https://lore.kernel.org/r/20250209-phy-fix-set-moe-v2-1-76e248503856@linaro.org Signed-off-by: Vinod Koul Signed-off-by: Sasha Levin --- drivers/phy/phy-core.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c index 413f76e2d1744..e0a6a272f5714 100644 --- a/drivers/phy/phy-core.c +++ b/drivers/phy/phy-core.c @@ -405,13 +405,14 @@ EXPORT_SYMBOL_GPL(phy_power_off); int phy_set_mode_ext(struct phy *phy, enum phy_mode mode, int submode) { - int ret; + int ret = 0; - if (!phy || !phy->ops->set_mode) + if (!phy) return 0; mutex_lock(&phy->mutex); - ret = phy->ops->set_mode(phy, mode, submode); + if (phy->ops->set_mode) + ret = phy->ops->set_mode(phy, mode, submode); if (!ret) phy->attrs.mode = mode; mutex_unlock(&phy->mutex); -- 2.39.5