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 DFC8426868E; Tue, 27 May 2025 17:05:49 +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=1748365550; cv=none; b=pGvbs8pEXUZgDmob3Rk19of7/N2f/1jAGakIQ7QWHTD+EsJMgJdJ0mJBTid8N7t+8VVlqnkDfG0JbNKoBxTI79NhCgxk1vbeA17TPRDpXXi6JGJw8v6CW7vzOA8066b2TWEbWWDBpWX5W6MlDxgvJFvcj+L1SLEXo2IdZFh24L0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748365550; c=relaxed/simple; bh=b56sm2T9v6+FQk5/XsEzaNpIh5foI+JBSBmE2+7JgaY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QHbuuIWicQOzz8Ucklb7WvOus4zoEUfWFfOLdaFa/ci3f0cGmzAI5Sag8K5tjOJl9aFwU5ef+BZfKHuT8ooo5aqMYgdKx98OyZJzjh81yBBiuCNmup7kr9u2ftOa4tjhGEpBs4WhBKSpmecS3HuCuCPYxG1GI+bey6fqrxbkxIk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Ngwr+m44; 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="Ngwr+m44" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 60870C4CEE9; Tue, 27 May 2025 17:05:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1748365549; bh=b56sm2T9v6+FQk5/XsEzaNpIh5foI+JBSBmE2+7JgaY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ngwr+m447bVOjsmTdMVzZwWBGpu6C+vBU2MsoN0SPAVT3BGU+Pd2bkwVMtYwcoIry YtTp/BrXv6J8hQBVt7UpirX/j4E3mh9qCQDEADlkymUddNEcBBI+VCdoScWBaoFLUg heg79YRYvHR5A523H6T9eW75qh2dLrwad4j9e17Y= 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 6.12 382/626] phy: core: dont require set_mode() callback for phy_get_mode() to work Date: Tue, 27 May 2025 18:24:35 +0200 Message-ID: <20250527162500.535883069@linuxfoundation.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250527162445.028718347@linuxfoundation.org> References: <20250527162445.028718347@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-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 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