You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by mi...@apache.org on 2026/04/09 11:21:57 UTC
(nuttx) branch master updated: arch/arm/stm32h7: fix stm32_mdio private structure use
This is an automated email from the ASF dual-hosted git repository.
michallenc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new b6cb94a06da arch/arm/stm32h7: fix stm32_mdio private structure use
b6cb94a06da is described below
commit b6cb94a06da8abbe5a30dd3104e6d9350b2b7ddc
Author: Pavel Pisa <pi...@fel.cvut.cz>
AuthorDate: Thu Apr 9 01:05:21 2026 +0200
arch/arm/stm32h7: fix stm32_mdio private structure use
The struct stm32_mdio_bus_s aka g_stm32_mdio_bus
has not been referenced at all, because mdio_register()
allocates its own structure. Then lower half drivers
receive only their respective part in mdio_read()
and mdio_write() because MDIO_WRITE/MDIO_READ provides
only d->lower to the specific lower level drivers.
Signed-off-by: Pavel Pisa <pi...@fel.cvut.cz>
---
arch/arm/src/stm32h7/stm32_mdio.c | 25 +++++++++++++------------
1 file changed, 13 insertions(+), 12 deletions(-)
diff --git a/arch/arm/src/stm32h7/stm32_mdio.c b/arch/arm/src/stm32h7/stm32_mdio.c
index 257cb95e381..d524b27ce1f 100644
--- a/arch/arm/src/stm32h7/stm32_mdio.c
+++ b/arch/arm/src/stm32h7/stm32_mdio.c
@@ -46,6 +46,7 @@ static void stm32_checksetup(void);
#include <nuttx/mutex.h>
#include <nuttx/config.h>
+#include <nuttx/nuttx.h>
#include <nuttx/debug.h>
#include <errno.h>
@@ -58,9 +59,9 @@ static void stm32_checksetup(void);
* Private Types
****************************************************************************/
-struct stm32_mdio_bus_s
+struct stm32_mdio_lowerhalf_s
{
- struct mdio_lowerhalf_s *lower;
+ struct mdio_lowerhalf_s base;
/* MDIO bus timeout in milliseconds */
@@ -88,14 +89,12 @@ const struct mdio_ops_s g_stm32_mdio_ops =
.reset = NULL,
};
-struct mdio_lowerhalf_s g_stm32_mdio_lowerhalf =
+struct stm32_mdio_lowerhalf_s g_stm32_mdio_lowerhalf =
{
- .ops = &g_stm32_mdio_ops
-};
-
-struct stm32_mdio_bus_s g_stm32_mdio_bus =
-{
- .lower = &g_stm32_mdio_lowerhalf,
+ .base =
+ {
+ .ops = &g_stm32_mdio_ops
+ },
.timeout = 10
};
@@ -110,7 +109,8 @@ static int stm32_c22_read(struct mdio_lowerhalf_s *dev, uint8_t phydev,
uint32_t regval;
int retval = -ETIMEDOUT;
- struct stm32_mdio_bus_s *priv = (struct stm32_mdio_bus_s *)dev;
+ struct stm32_mdio_lowerhalf_s *priv =
+ container_of(dev, struct stm32_mdio_lowerhalf_s, base);
/* Configure the MACMDIOAR register, preserving CSR Clock Range CR[3:0]
* bits
@@ -161,7 +161,8 @@ static int stm32_c22_write(struct mdio_lowerhalf_s *dev, uint8_t phydev,
uint32_t regval;
int retval = -ETIMEDOUT;
- struct stm32_mdio_bus_s *priv = (struct stm32_mdio_bus_s *)dev;
+ struct stm32_mdio_lowerhalf_s *priv =
+ container_of(dev, struct stm32_mdio_lowerhalf_s, base);
/* Configure the MACMDIOAR register, preserving CSR Clock Range CR[3:0]
* bits
@@ -228,5 +229,5 @@ static int stm32_c22_write(struct mdio_lowerhalf_s *dev, uint8_t phydev,
struct mdio_bus_s *stm32_mdio_bus_initialize(void)
{
- return mdio_register(&g_stm32_mdio_lowerhalf);
+ return mdio_register(&g_stm32_mdio_lowerhalf.base);
}