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 DFACE225785; Mon, 2 Jun 2025 14:59:20 +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=1748876361; cv=none; b=WF6323OvxwIojaGW/WplZFG8iq9yVYKdzKrSiWJRrWMM8Ar0V0g5oe97M4Whl1g7gHZlHDoFCmv7yw+XfmE4jw7gpgmaTNBAneexs7bl3+utZkn3lbgv/5L9XCbb79aVdjZPmYfj0iUZqB7Zz03eWa3KabwQd+MrDU4+9aGq/og= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748876361; c=relaxed/simple; bh=XF+VFk5a19M+sYNpc/TS7V3iLd+Ck+vuqwZWxeBVXjo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=U/B6rqxyNwgu0CDjWRbX6+LnpQLcJrOrMKxd/fQroF8igX7fYosryGTA6H3p04dTgwUpOHKhj/PXQTJOPJdpgam6sp/86WMk8gVuMoECxkXuMKf2QHzm2rHOBu1u2SM4MseqW6pmW4Dt79pgYJCZLe+X8eGX2auzsZ/vkb0MyaE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=HRsdt998; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="HRsdt998" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1DB13C4CEEB; Mon, 2 Jun 2025 14:59:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1748876360; bh=XF+VFk5a19M+sYNpc/TS7V3iLd+Ck+vuqwZWxeBVXjo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HRsdt998NlqDO3EAwT7SIRCwDO9dvTDv1SqjSIRLPZtQO5ldMlrvVZFn9dI7x6nKq J0S0jsBA5KvI7WV7jLSuD2QmwboTcwbcAo/5lXLLOHxQ368CFgMxTjbEj72pVRNkQU jH+jE6JFZtOWS+1EmXJVWDuC//EqTwwcoOpmDZSM= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Damon Ding , Dmitry Baryshkov , Vinod Koul , Sasha Levin Subject: [PATCH 5.15 122/207] phy: core: dont require set_mode() callback for phy_get_mode() to work Date: Mon, 2 Jun 2025 15:48:14 +0200 Message-ID: <20250602134303.495375270@linuxfoundation.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250602134258.769974467@linuxfoundation.org> References: <20250602134258.769974467@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ 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 e2bfd56d5086e..21f12aeb7747f 100644 --- a/drivers/phy/phy-core.c +++ b/drivers/phy/phy-core.c @@ -360,13 +360,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