From patchwork Fri Dec 13 12:36:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zijun Hu X-Patchwork-Id: 13906970 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 9141DE7717D for ; Fri, 13 Dec 2024 12:38:10 +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:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=lRjDO96iq/sXSdB9fbX7SbWNarBaR1BMXggkzqgtsGE=; b=lATDxWcROuy+oa Bs/Sy7d3yE7AT20v2Z2pm4lkxH5IXVIYSd1/Wn5RtUkWa99pf0lJab12lyUrZHPZTWjG8xQcDERM0 7C+6s/xOUO6j+OenzoLuJo2fJ8zzNhGd5vVLfUiQ9hzrAMqUbvlqWnvt3o7lL73G4/LTkGNcWPTh+ 1D6KgWE5gDhZ54dHA2auBk7YCfTADLqv9m3XtOteyAHr8Ly42u3/6bEZ+dh+aLPLhk2cmwFGQMZ8H QuzMDWZgF1B+SRT3zob5agTDTUn8+BUWfYHB1l4AjEX8Tpjr7PHI6STZdFC3qG3r6GX8Tg8r8D9i4 Bj0QkOZvGXSfCSbnpZFQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tM4vq-00000003joW-1OS4; Fri, 13 Dec 2024 12:38:10 +0000 Received: from mr85p00im-zteg06021501.me.com ([17.58.23.183]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tM4vo-00000003jnq-0jrF for linux-phy@lists.infradead.org; Fri, 13 Dec 2024 12:38:09 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=icloud.com; s=1a1hai; t=1734093486; bh=gAZiIBAW97iSqVxa0yzt2S2NKUuhI3+PKJU5sy0ohIM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To: x-icloud-hme; b=GTPLGRqI7p1Ug1WY1aEwDN1yujO59xixCqprE1ZG56aOCN7U68v4cuc4Ch2zXZAkN sg1zCwuNzK0bo1+vCD/XBDB6DBmyNkcby5lP8BWIwd2ZuWDSJBdh9T/nBh151AQw61 G9ec6MNgTav9ZpzCC7yhOC273s6iEocbnvYEF8ADLbNEjKSK5Cia+9h8C4KbH5NPfY Jom59IwQG3XT7TUQXZahOaiP8XfmBWbPu89fq3gdCD9zGi3fbbneUL0JQyME7gV9Fv 97nNftPHguBSu6PI6oCin36dAV7X1olD48w8k3waOe8DiFLAL1u47yZlmc4wb9x1Wa g4/RmMai0Lwwg== Received: from [192.168.1.26] (mr38p00im-dlb-asmtp-mailmevip.me.com [17.57.152.18]) by mr85p00im-zteg06021501.me.com (Postfix) with ESMTPSA id E31592793D1D; Fri, 13 Dec 2024 12:37:57 +0000 (UTC) From: Zijun Hu Date: Fri, 13 Dec 2024 20:36:46 +0800 Subject: [PATCH v6 6/6] phy: core: Simplify API of_phy_simple_xlate() implementation MIME-Version: 1.0 Message-Id: <20241213-phy_core_fix-v6-6-40ae28f5015a@quicinc.com> References: <20241213-phy_core_fix-v6-0-40ae28f5015a@quicinc.com> In-Reply-To: <20241213-phy_core_fix-v6-0-40ae28f5015a@quicinc.com> To: Vinod Koul , Kishon Vijay Abraham I , Felipe Balbi , Greg Kroah-Hartman , Rob Herring , Arnd Bergmann , Lee Jones Cc: Greg Kroah-Hartman , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy?= =?utf-8?q?=C5=84ski?= , Bjorn Helgaas , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Christophe JAILLET , Johan Hovold , Zijun Hu , stable@vger.kernel.org, linux-phy@lists.infradead.org, linux-kernel@vger.kernel.org, Zijun Hu , Simon Horman X-Mailer: b4 0.14.2 X-Proofpoint-ORIG-GUID: 2JINNleipOqtTWVGoJDHTzZH0QuUezzf X-Proofpoint-GUID: 2JINNleipOqtTWVGoJDHTzZH0QuUezzf X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2024-12-13_05,2024-12-12_03,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 phishscore=0 bulkscore=0 clxscore=1015 mlxlogscore=999 adultscore=0 mlxscore=0 suspectscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2308100000 definitions=main-2412130089 X-Apple-Remote-Links: v=1;h=KCk=;charset=UTF-8 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241213_043808_227965_84A4088F X-CRM114-Status: GOOD ( 10.96 ) 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: , Sender: "linux-phy" Errors-To: linux-phy-bounces+linux-phy=archiver.kernel.org@lists.infradead.org From: Zijun Hu Simplify of_phy_simple_xlate() implementation by API class_find_device_by_of_node(). Also correct comments to mark its parameter @dev as unused instead of @args in passing. Signed-off-by: Zijun Hu Cc: Simon Horman --- drivers/phy/phy-core.c | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c index 413f76e2d1744dd8ffb63a6c3a093f5c6cbead7b..8dfdce605a905d7f38205727151258af41f807a9 100644 --- a/drivers/phy/phy-core.c +++ b/drivers/phy/phy-core.c @@ -749,8 +749,8 @@ EXPORT_SYMBOL_GPL(devm_phy_put); /** * of_phy_simple_xlate() - returns the phy instance from phy provider - * @dev: the PHY provider device - * @args: of_phandle_args (not used here) + * @dev: the PHY provider device (not used here) + * @args: of_phandle_args * * Intended to be used by phy provider for the common case where #phy-cells is * 0. For other cases where #phy-cells is greater than '0', the phy provider @@ -760,21 +760,14 @@ EXPORT_SYMBOL_GPL(devm_phy_put); struct phy *of_phy_simple_xlate(struct device *dev, const struct of_phandle_args *args) { - struct phy *phy; - struct class_dev_iter iter; - - class_dev_iter_init(&iter, &phy_class, NULL, NULL); - while ((dev = class_dev_iter_next(&iter))) { - phy = to_phy(dev); - if (args->np != phy->dev.of_node) - continue; + struct device *target_dev; - class_dev_iter_exit(&iter); - return phy; - } + target_dev = class_find_device_by_of_node(&phy_class, args->np); + if (!target_dev) + return ERR_PTR(-ENODEV); - class_dev_iter_exit(&iter); - return ERR_PTR(-ENODEV); + put_device(target_dev); + return to_phy(target_dev); } EXPORT_SYMBOL_GPL(of_phy_simple_xlate);