From nobody Sat Feb 7 15:09:55 2026 Received: from fw2.prolan.hu (fw2.prolan.hu [193.68.50.107]) (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 678BC345CCD; Fri, 31 Oct 2025 11:32:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.68.50.107 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761910356; cv=none; b=L7VZFZpdrNtdx6SeDZzTTo1q76TvPcWlxBCj6EiEOA+6fdWNJCtkEqyfuxcSRhX5L2uw4cgOCUEWJANcwskSjzkiFEAqSRpTePjl7YkuTwzJ/J4JkoUXf1n+i3pb50y+8nq2AxHaMPrAnogQra/ugc8NufSiSkAvCvfvNVGAkIQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761910356; c=relaxed/simple; bh=zLXljtxNeGil4tVodSFVJBMMRARpQudfdoCr1hFMJcA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=BaQHK9l1NbyVncEYv5T4Z1CMRjmzEg+M8X7YRvLrKQ5yVocB6WNJSkhuLCrWANLIRQixIWTQNumBKpEAATZzXguTx7Upxool1nsYtf3GkPHbCvXNIDaItmCQh9+DdaA05nAY56LG3mc/VLSUEpjKt1hjuFihp79gUxDo+37Rz1s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=prolan.hu; spf=pass smtp.mailfrom=prolan.hu; dkim=pass (4096-bit key) header.d=prolan.hu header.i=@prolan.hu header.b=nD8yJqjj; arc=none smtp.client-ip=193.68.50.107 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=prolan.hu Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=prolan.hu Authentication-Results: smtp.subspace.kernel.org; dkim=pass (4096-bit key) header.d=prolan.hu header.i=@prolan.hu header.b="nD8yJqjj" Received: from proxmox-mailgw.intranet.prolan.hu (localhost.localdomain [127.0.0.1]) by proxmox-mailgw.intranet.prolan.hu (Proxmox) with ESMTP id 1C32FA13FD; Fri, 31 Oct 2025 12:32:31 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=prolan.hu; h=cc :cc:content-transfer-encoding:content-type:content-type:date :from:from:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=mail; bh=BKpyHjHhRf5ksYaNNHmr cZ1RxCByOAimOnmst8sw3sQ=; b=nD8yJqjjd5WKPIzZQZFi7n3oCs1TpHfEZniY IMKqG95fKky7CBJcY0sN/UOQBjh1VaJGxUSM0V9f1drKWusAc8PmASi98DT5GQMd GlLAiVOjPJzOZk8koBnc9Q7cht6j+gwLqAZJblnkOdL/R86PU6RL87uDmty/fGM0 Wkr7+5pbakswoZgELqVVhQvYV9h1FVNN6ZWy1/JQQTP40fE2WgvmbRS9uQGeik8W BSbeEUxDIwKxE69flnn2HE/j/61QUb83hLjhJxg+HC2o5JaFCPF7laKNP01zHGEg 2H0yKUIE8dTJJthoJLybCwAOQr4sWR8e3K1Dyio+eVTf8sIJMOKrf2aPQK5mdydk oAXvmCFlQFjMxsVWmy22G3yrzrwqNcHJRAxtVHiQayIOD8Z4KcCX0tspKRzKsnGA BEZYH8ycxFKmaffy2dNzxeLhPYQCEB/qs8kbbfw/b6rgBnb8e8Zo2uA83RLgQYeJ zqPy8DwlBUJ6NhCmD/TYuGwFA89wsR1Sdosr8pPmy9dFTKZN+nvXKlLd4Oh0hwIR p4+Kur+YSSD2dnxEI9eGI8UMz7n2D3iI/Fd2ivTzmVHQbHSfbQCJhOwRCp3Ozys7 1w/XNt0uo7WWEli7nyZYePBOrv2mLNjqQmM0KIqGxBvhQhoTY3M1VzEfSyjX/fLO YAQushs= From: Buday Csaba To: Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Philipp Zabel , , CC: Buday Csaba Subject: [PATCH net-next 1/3] net: mdio: move device reset functions to mdio_device.c Date: Fri, 31 Oct 2025 12:32:26 +0100 Message-ID: <809bbe7fd239d17ad55cca12038d4bf30924f126.1761909948.git.buday.csaba@prolan.hu> X-Mailer: git-send-email 2.39.5 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ESET-AS: R=OK;S=0;OP=CALC;TIME=1761910350;VERSION=8001;MC=2560744196;ID=195342;TRN=0;CRV=0;IPC=;SP=0;SIPS=0;PI=3;F=0 X-ESET-Antispam: OK X-EsetResult: clean, is OK X-EsetId: 37303A296767155F677D60 Content-Type: text/plain; charset="utf-8" The functions mdiobus_register_gpiod() and mdiobus_register_reset() handle the mdio device reset initialization, which belong to mdio_device.c. Move them from mdio_bus.c to mdio_device.c, and rename them to match the corresponding source file: mdio_device_register_gpio() and mdio_device_register_reset(). Remove 'static' qualifiers and declare them in mdio.h. Signed-off-by: Buday Csaba --- drivers/net/phy/mdio_bus.c | 31 ++----------------------------- drivers/net/phy/mdio_device.c | 27 +++++++++++++++++++++++++++ include/linux/mdio.h | 2 ++ 3 files changed, 31 insertions(+), 29 deletions(-) diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c index cad6ed3aa..f23298232 100644 --- a/drivers/net/phy/mdio_bus.c +++ b/drivers/net/phy/mdio_bus.c @@ -33,33 +33,6 @@ #define CREATE_TRACE_POINTS #include =20 -static int mdiobus_register_gpiod(struct mdio_device *mdiodev) -{ - /* Deassert the optional reset signal */ - mdiodev->reset_gpio =3D gpiod_get_optional(&mdiodev->dev, - "reset", GPIOD_OUT_LOW); - if (IS_ERR(mdiodev->reset_gpio)) - return PTR_ERR(mdiodev->reset_gpio); - - if (mdiodev->reset_gpio) - gpiod_set_consumer_name(mdiodev->reset_gpio, "PHY reset"); - - return 0; -} - -static int mdiobus_register_reset(struct mdio_device *mdiodev) -{ - struct reset_control *reset; - - reset =3D reset_control_get_optional_exclusive(&mdiodev->dev, "phy"); - if (IS_ERR(reset)) - return PTR_ERR(reset); - - mdiodev->reset_ctrl =3D reset; - - return 0; -} - int mdiobus_register_device(struct mdio_device *mdiodev) { int err; @@ -68,11 +41,11 @@ int mdiobus_register_device(struct mdio_device *mdiodev) return -EBUSY; =20 if (mdiodev->flags & MDIO_DEVICE_FLAG_PHY) { - err =3D mdiobus_register_gpiod(mdiodev); + err =3D mdio_device_register_gpiod(mdiodev); if (err) return err; =20 - err =3D mdiobus_register_reset(mdiodev); + err =3D mdio_device_register_reset(mdiodev); if (err) return err; =20 diff --git a/drivers/net/phy/mdio_device.c b/drivers/net/phy/mdio_device.c index f64176e0e..5a78d8624 100644 --- a/drivers/net/phy/mdio_device.c +++ b/drivers/net/phy/mdio_device.c @@ -118,6 +118,33 @@ void mdio_device_remove(struct mdio_device *mdiodev) } EXPORT_SYMBOL(mdio_device_remove); =20 +int mdio_device_register_gpiod(struct mdio_device *mdiodev) +{ + /* Deassert the optional reset signal */ + mdiodev->reset_gpio =3D gpiod_get_optional(&mdiodev->dev, + "reset", GPIOD_OUT_LOW); + if (IS_ERR(mdiodev->reset_gpio)) + return PTR_ERR(mdiodev->reset_gpio); + + if (mdiodev->reset_gpio) + gpiod_set_consumer_name(mdiodev->reset_gpio, "PHY reset"); + + return 0; +} + +int mdio_device_register_reset(struct mdio_device *mdiodev) +{ + struct reset_control *reset; + + reset =3D reset_control_get_optional_exclusive(&mdiodev->dev, "phy"); + if (IS_ERR(reset)) + return PTR_ERR(reset); + + mdiodev->reset_ctrl =3D reset; + + return 0; +} + void mdio_device_reset(struct mdio_device *mdiodev, int value) { unsigned int d; diff --git a/include/linux/mdio.h b/include/linux/mdio.h index 42d6d47e4..1322d2623 100644 --- a/include/linux/mdio.h +++ b/include/linux/mdio.h @@ -92,6 +92,8 @@ void mdio_device_free(struct mdio_device *mdiodev); struct mdio_device *mdio_device_create(struct mii_bus *bus, int addr); int mdio_device_register(struct mdio_device *mdiodev); void mdio_device_remove(struct mdio_device *mdiodev); +int mdio_device_register_gpiod(struct mdio_device *mdiodev); +int mdio_device_register_reset(struct mdio_device *mdiodev); void mdio_device_reset(struct mdio_device *mdiodev, int value); int mdio_driver_register(struct mdio_driver *drv); void mdio_driver_unregister(struct mdio_driver *drv); --=20 2.39.5 From nobody Sat Feb 7 15:09:55 2026 Received: from fw2.prolan.hu (fw2.prolan.hu [193.68.50.107]) (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 AD415345CD4; Fri, 31 Oct 2025 11:32:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.68.50.107 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761910357; cv=none; b=ol80SR00+in9OVNnla/NIPtTwzB3k+imhgxXH5iIi/oWqyKOGRAyc2TNFCHqulGtKfrvkHopYEBQ7igTN2xtX87Ka0L+Nt6NBslWXe6osCQd5ePLiOahWVdQJEm1Bcr6rD7wauZeWW2R5eDxYzLwE/006TlDm3OKd/HqUFFYMGE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761910357; c=relaxed/simple; bh=S5IFUps93qpDO2XZbKKT67i/iIJg4oYrcX2D840XN2w=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=c4r1VGGqOcLeoGncW6RhoMdh8b7n8JoTvYqsVWbZ3EYtsiKRMdtBiFu3sxzEqWJUWjO7c2Bc/7/ekcpFz13xgmtyLtQorkuwrnTdR/u+Q8rfZPCk8qeWCL5oBy1sAKN0MxZtFWSMVNtb9wj+jFJoSHUwFO/U+/uqbr+CNLdKz9g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=prolan.hu; spf=pass smtp.mailfrom=prolan.hu; dkim=pass (4096-bit key) header.d=prolan.hu header.i=@prolan.hu header.b=tZk+K69y; arc=none smtp.client-ip=193.68.50.107 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=prolan.hu Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=prolan.hu Authentication-Results: smtp.subspace.kernel.org; dkim=pass (4096-bit key) header.d=prolan.hu header.i=@prolan.hu header.b="tZk+K69y" Received: from proxmox-mailgw.intranet.prolan.hu (localhost.localdomain [127.0.0.1]) by proxmox-mailgw.intranet.prolan.hu (Proxmox) with ESMTP id 78C06A1851; Fri, 31 Oct 2025 12:32:31 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=prolan.hu; h=cc :cc:content-transfer-encoding:content-type:content-type:date :from:from:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=mail; bh=g7IU8MOev+9Q8khQL+wq jLCoSKrjT/n0LAN06kkjTgo=; b=tZk+K69yLPNrs5aRNx0kZwMgsRzxDL+Claq3 3jJN0689bA5We4dG/Yf5FgDpmm2rJMwxViV5b7VxZ7EKIZjQ0vSlXbNtoUIH3YSI 9OD6N65PERlOssldn5pMrmY+SVAUv2+u5CSIXqBa37CTQno7HuEK2RiFwJeYi79W Qe9yRORSV6GdjzPvkzWZ/NRTkxfcTX4EWclxzSlJgrLfBwr2cpZFzCsmsMT5rZrd 8SGovlNlnfBOhyg4OjYkV/vkxPlIxcxX79CT7AUGdfoWEBJ8rqoEfsAv58rXz8M+ 2c18ZnMdr2FMsDFv1jpulQYT9BAbfALbJZ4gkYmPwMKrIn6ryADuX9ggq6Plhqpz ZTjwBgg+3pMyumrL+K3BrA3yzs2jetfZReKOyFukDWSrFEKcvZfPpBJBE2KqKKIx J1+d4YFjharncBqOWrxoLN+diGwxcaiXHetHxZ/bj6nb7qprX2HFExg8NUKh13kj ygrX3S398cxNzwwvZsyDYjwJuzMoWkge6byW7eMfQYO1OIPx4aczeSCSWprgurxs LjiDYHgUq/i9Tn9u7s14dUvUpMF0leSfAB7yKVKr5B3KVKjnPZMwuQULq/Dgw43F ZFKkW+DtB4u7J/b3IPE9Za7KWMyNVb3HZJynvhrqBu4KjgOpferHntdXlR37cATB cel099o= From: Buday Csaba To: Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Philipp Zabel , , CC: Buday Csaba Subject: [PATCH net-next 2/3] net: mdio: common handling of phy device reset properties Date: Fri, 31 Oct 2025 12:32:27 +0100 Message-ID: X-Mailer: git-send-email 2.39.5 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ESET-AS: R=OK;S=0;OP=CALC;TIME=1761910350;VERSION=8001;MC=3731004014;ID=195343;TRN=0;CRV=0;IPC=;SP=0;SIPS=0;PI=3;F=0 X-ESET-Antispam: OK X-EsetResult: clean, is OK X-EsetId: 37303A296767155F677D60 Content-Type: text/plain; charset="utf-8" Unify the handling of the per device reset properties for `mdio_device`. Merge mdio_device_register_gpiod() and mdio_device_register_reset() into mdio_device_register_reset(), that handles both reset-controllers and reset-gpios. Move reading of the reset firmware properties (reset-assert-us, reset-deassert-us) from fwnode_mdio.c to mdio_device_register_reset(), so all reset related initialization code is kept in one place. Introduce mdio_device_unregister_reset() to release the associated resources. These changes make tracking the reset properties easier. Added kernel-doc for mdio_device_register/unregister_reset(). No functional changes intended. Signed-off-by: Buday Csaba --- drivers/net/mdio/fwnode_mdio.c | 5 ----- drivers/net/phy/mdio_bus.c | 7 +------ drivers/net/phy/mdio_device.c | 35 ++++++++++++++++++++++++++-------- include/linux/mdio.h | 2 +- 4 files changed, 29 insertions(+), 20 deletions(-) diff --git a/drivers/net/mdio/fwnode_mdio.c b/drivers/net/mdio/fwnode_mdio.c index 9b41d4697..ba7091518 100644 --- a/drivers/net/mdio/fwnode_mdio.c +++ b/drivers/net/mdio/fwnode_mdio.c @@ -92,11 +92,6 @@ int fwnode_mdiobus_phy_device_register(struct mii_bus *m= dio, if (fwnode_property_read_bool(child, "broken-turn-around")) mdio->phy_ignore_ta_mask |=3D 1 << addr; =20 - fwnode_property_read_u32(child, "reset-assert-us", - &phy->mdio.reset_assert_delay); - fwnode_property_read_u32(child, "reset-deassert-us", - &phy->mdio.reset_deassert_delay); - /* Associate the fwnode with the device structure so it * can be looked up later */ diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c index f23298232..748c6a9aa 100644 --- a/drivers/net/phy/mdio_bus.c +++ b/drivers/net/phy/mdio_bus.c @@ -41,10 +41,6 @@ int mdiobus_register_device(struct mdio_device *mdiodev) return -EBUSY; =20 if (mdiodev->flags & MDIO_DEVICE_FLAG_PHY) { - err =3D mdio_device_register_gpiod(mdiodev); - if (err) - return err; - err =3D mdio_device_register_reset(mdiodev); if (err) return err; @@ -64,8 +60,7 @@ int mdiobus_unregister_device(struct mdio_device *mdiodev) if (mdiodev->bus->mdio_map[mdiodev->addr] !=3D mdiodev) return -EINVAL; =20 - gpiod_put(mdiodev->reset_gpio); - reset_control_put(mdiodev->reset_ctrl); + mdio_device_unregister_reset(mdiodev); =20 mdiodev->bus->mdio_map[mdiodev->addr] =3D NULL; =20 diff --git a/drivers/net/phy/mdio_device.c b/drivers/net/phy/mdio_device.c index 5a78d8624..ec0263264 100644 --- a/drivers/net/phy/mdio_device.c +++ b/drivers/net/phy/mdio_device.c @@ -118,8 +118,17 @@ void mdio_device_remove(struct mdio_device *mdiodev) } EXPORT_SYMBOL(mdio_device_remove); =20 -int mdio_device_register_gpiod(struct mdio_device *mdiodev) +/** + * mdio_device_register_reset - Read and initialize the reset properties of + * an mdio device + * @mdiodev: mdio_device structure + * + * Return: Zero if successful, negative error code on failure + */ +int mdio_device_register_reset(struct mdio_device *mdiodev) { + struct reset_control *reset; + /* Deassert the optional reset signal */ mdiodev->reset_gpio =3D gpiod_get_optional(&mdiodev->dev, "reset", GPIOD_OUT_LOW); @@ -129,22 +138,32 @@ int mdio_device_register_gpiod(struct mdio_device *md= iodev) if (mdiodev->reset_gpio) gpiod_set_consumer_name(mdiodev->reset_gpio, "PHY reset"); =20 - return 0; -} - -int mdio_device_register_reset(struct mdio_device *mdiodev) -{ - struct reset_control *reset; - reset =3D reset_control_get_optional_exclusive(&mdiodev->dev, "phy"); if (IS_ERR(reset)) return PTR_ERR(reset); =20 mdiodev->reset_ctrl =3D reset; =20 + /* Read optional firmware properties */ + fwnode_property_read_u32(dev_fwnode(&mdiodev->dev), "reset-assert-us", + &mdiodev->reset_assert_delay); + fwnode_property_read_u32(dev_fwnode(&mdiodev->dev), "reset-deassert-us", + &mdiodev->reset_deassert_delay); + return 0; } =20 +/** + * mdio_device_unregister_reset - uninitialize the reset properties of + * an mdio device + * @mdiodev: mdio_device structure + */ +void mdio_device_unregister_reset(struct mdio_device *mdiodev) +{ + gpiod_put(mdiodev->reset_gpio); + reset_control_put(mdiodev->reset_ctrl); +} + void mdio_device_reset(struct mdio_device *mdiodev, int value) { unsigned int d; diff --git a/include/linux/mdio.h b/include/linux/mdio.h index 1322d2623..e76f5a6c2 100644 --- a/include/linux/mdio.h +++ b/include/linux/mdio.h @@ -92,8 +92,8 @@ void mdio_device_free(struct mdio_device *mdiodev); struct mdio_device *mdio_device_create(struct mii_bus *bus, int addr); int mdio_device_register(struct mdio_device *mdiodev); void mdio_device_remove(struct mdio_device *mdiodev); -int mdio_device_register_gpiod(struct mdio_device *mdiodev); int mdio_device_register_reset(struct mdio_device *mdiodev); +void mdio_device_unregister_reset(struct mdio_device *mdiodev); void mdio_device_reset(struct mdio_device *mdiodev, int value); int mdio_driver_register(struct mdio_driver *drv); void mdio_driver_unregister(struct mdio_driver *drv); --=20 2.39.5 From nobody Sat Feb 7 15:09:55 2026 Received: from fw2.prolan.hu (fw2.prolan.hu [193.68.50.107]) (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 AAAED33B96F; Fri, 31 Oct 2025 11:32:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.68.50.107 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761910355; cv=none; b=TdVJjF1bCHUA51K0LLElsnANUxNJry6/XnSKWLykCO9Kl8oQnHVv8EtPDA1OklYinYPTfL4Hw1kjovcIqnMviRPJMCWPbfyyO29kNHMx6VrKJS4ZYMo7cVTu7ruMlZ3qgmQ+X/vaKSXRh8mIIGC0LpU2+xh8Jj6OkV92G1M+Pfc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761910355; c=relaxed/simple; bh=B48clSXiuUvuM3hoU+3tOFN6zI8pHgapG4peXvojYm8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=O84WBBMGfTxFN+s+G1g2jVOJCVgZOTBDDa8s0Vo6kwtUHdyQ+omUvk3rh8yB4BwpnvYfrjPNBHZuB96q2/Hf9HTeSNSesisXCZH5jzpKz7dpr9ebEsYoFOqwdO7+YeNaeVO7c6SAinAEnyafZfl4UiqSNxE2cd/awviulgYhdpI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=prolan.hu; spf=pass smtp.mailfrom=prolan.hu; dkim=pass (4096-bit key) header.d=prolan.hu header.i=@prolan.hu header.b=FA1oXAU9; arc=none smtp.client-ip=193.68.50.107 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=prolan.hu Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=prolan.hu Authentication-Results: smtp.subspace.kernel.org; dkim=pass (4096-bit key) header.d=prolan.hu header.i=@prolan.hu header.b="FA1oXAU9" Received: from proxmox-mailgw.intranet.prolan.hu (localhost.localdomain [127.0.0.1]) by proxmox-mailgw.intranet.prolan.hu (Proxmox) with ESMTP id 6F5C5A156A; Fri, 31 Oct 2025 12:32:31 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=prolan.hu; h=cc :cc:content-transfer-encoding:content-type:content-type:date :from:from:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=mail; bh=iVSjyIKCQTGv8GkSx/6A seNBhKr161aQL3VM4f1SFXM=; b=FA1oXAU9eOJsoH9qpftKPiRjp+UsOcdMM5z4 AY7PtmYzkryZdyY2VnAbLl4zeNTJMCuXfrJUv9pe1HqyRhjiVNOosl1GbSRVcrvK nTudcKuKgsBzQTUesSsw1KzTwa7hAhPD82kZXX0OtqswRPiG3EvQExhEhG+4CT4Z Yaf533PjjamjvXHEmBlLG34kotZsRmGeCdP9zxqPGue6N4nctf5JJ2RrFOy1iZfA XfrrtoilkuEs8K0ViLlzV4TKdhjRdsiR4btqFz8cxJaQX+JSUhQKb6vhtWMGNyNM gf9iY9iTOnijJm7GKZahbVV81ZR1xjJ8rS4DfecZNevV5kUTSt8CX1AuRR7Uhq7U EU9oQuNCvhHZ86YGqlZKkxbxUWHrx0TQZVe/b29fcrQ9ZG9o7Wl1YRBeukxXnqLM tw2wi/Xe3F60SZji7PYPrj0n1o02EamzimZAqWIIADc4G3LgdxFfC3Yih7HGdgZB hrcsAHmdvcBJE7WoWdkPSSIedrB+dxADJn3HtUa5f3GcC9J0CQfbim6mLQImx5L+ WFYrXSdmToKCtUYN8a5CdqIaQEYrEa80sEvAZzwK3byL4lyLdEKhbrAyFtqgF50L CAvmK2BczssEX1xpSyKiYhrKSqTscarfL9CYj4Lq4DJtDXxWrJ94fr6/PcxL6Q25 rJELPkM= From: Buday Csaba To: Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Philipp Zabel , , CC: Buday Csaba Subject: [PATCH net-next 3/3] net: mdio: improve reset handling in mdio_device.c Date: Fri, 31 Oct 2025 12:32:28 +0100 Message-ID: <11b197641e5498cab3e43f8983120fcabe06257e.1761909948.git.buday.csaba@prolan.hu> X-Mailer: git-send-email 2.39.5 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ESET-AS: R=OK;S=0;OP=CALC;TIME=1761910350;VERSION=8001;MC=1035019571;ID=195344;TRN=0;CRV=0;IPC=;SP=0;SIPS=0;PI=3;F=0 X-ESET-Antispam: OK X-EsetResult: clean, is OK X-EsetId: 37303A296767155F677D60 Content-Type: text/plain; charset="utf-8" Change fwnode_property_read_u32() in mdio_device_register_reset() to device_property_read_u32(), which is more appropriate here. Fix a potential leak in mdio_device_register_reset() if both a reset-gpio and a reset-controller are present. Make mdio_device_unregister_reset() truly reverse mdio_device_register_reset() by setting the internal fields to their default values. Signed-off-by: Buday Csaba --- drivers/net/phy/mdio_device.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/net/phy/mdio_device.c b/drivers/net/phy/mdio_device.c index ec0263264..2de401961 100644 --- a/drivers/net/phy/mdio_device.c +++ b/drivers/net/phy/mdio_device.c @@ -139,15 +139,18 @@ int mdio_device_register_reset(struct mdio_device *md= iodev) gpiod_set_consumer_name(mdiodev->reset_gpio, "PHY reset"); =20 reset =3D reset_control_get_optional_exclusive(&mdiodev->dev, "phy"); - if (IS_ERR(reset)) + if (IS_ERR(reset)) { + gpiod_put(mdiodev->reset_gpio); + mdiodev->reset_gpio =3D NULL; return PTR_ERR(reset); + } =20 mdiodev->reset_ctrl =3D reset; =20 /* Read optional firmware properties */ - fwnode_property_read_u32(dev_fwnode(&mdiodev->dev), "reset-assert-us", + device_property_read_u32(&mdiodev->dev, "reset-assert-us", &mdiodev->reset_assert_delay); - fwnode_property_read_u32(dev_fwnode(&mdiodev->dev), "reset-deassert-us", + device_property_read_u32(&mdiodev->dev, "reset-deassert-us", &mdiodev->reset_deassert_delay); =20 return 0; @@ -161,7 +164,11 @@ int mdio_device_register_reset(struct mdio_device *mdi= odev) void mdio_device_unregister_reset(struct mdio_device *mdiodev) { gpiod_put(mdiodev->reset_gpio); + mdiodev->reset_gpio =3D NULL; reset_control_put(mdiodev->reset_ctrl); + mdiodev->reset_ctrl =3D NULL; + mdiodev->reset_assert_delay =3D 0; + mdiodev->reset_deassert_delay =3D 0; } =20 void mdio_device_reset(struct mdio_device *mdiodev, int value) --=20 2.39.5