[PATCH 02/17] net: miiphybb: Introduce bb_miiphy_free()/bb_miiphy_free() wrappers
Marek Vasut
marek.vasut+renesas at mailbox.org
Sat Jan 18 07:53:06 CET 2025
Introduce bb_miiphy_free()/bb_miiphy_free() wrappers to allocate and free
struct bb_miiphy_bus. Make struct bb_miiphy_bus wrap struct mii_dev, which
will become useful later in bb_miiphy_bus accessors, which would be able
to access struct bb_miiphy_bus using container_of, even if the PHY stack
only passes in the inner struct mii_dev .
Signed-off-by: Marek Vasut <marek.vasut+renesas at mailbox.org>
---
Cc: Christian Marangi <ansuelsmth at gmail.com>
Cc: Evgeny Bachinin <EABachinin at salutedevices.com>
Cc: Ilias Apalodimas <ilias.apalodimas at linaro.org>
Cc: Jerome Forissier <jerome.forissier at linaro.org>
Cc: Joe Hershberger <joe.hershberger at ni.com>
Cc: Mario Six <mario.six at gdsys.cc>
Cc: Michal Simek <michal.simek at amd.com>
Cc: Nobuhiro Iwamatsu <iwamatsu at nigauri.org>
Cc: Paul Barker <paul.barker.ct at bp.renesas.com>
Cc: Ramon Fried <rfried.dev at gmail.com>
Cc: Simon Glass <sjg at chromium.org>
Cc: Sughosh Ganu <sughosh.ganu at linaro.org>
Cc: Tom Rini <trini at konsulko.com>
Cc: u-boot at lists.denx.de
---
drivers/net/phy/miiphybb.c | 19 +++++++++++++++++++
include/miiphy.h | 3 +++
2 files changed, 22 insertions(+)
diff --git a/drivers/net/phy/miiphybb.c b/drivers/net/phy/miiphybb.c
index 5497b838225..9733ebf6f09 100644
--- a/drivers/net/phy/miiphybb.c
+++ b/drivers/net/phy/miiphybb.c
@@ -14,6 +14,7 @@
#include <ioports.h>
#include <ppc_asm.tmpl>
+#include <malloc.h>
#include <miiphy.h>
#include <asm/global_data.h>
@@ -41,6 +42,24 @@ static inline struct bb_miiphy_bus *bb_miiphy_getbus(const char *devname)
return NULL;
}
+struct bb_miiphy_bus *bb_miiphy_alloc(void)
+{
+ struct bb_miiphy_bus *bus;
+
+ bus = malloc(sizeof(*bus));
+ if (!bus)
+ return bus;
+
+ mdio_init(&bus->mii);
+
+ return bus;
+}
+
+void bb_miiphy_free(struct bb_miiphy_bus *bus)
+{
+ free(bus);
+}
+
/*****************************************************************************
*
* Utility to send the preamble, address, and register (common to read
diff --git a/include/miiphy.h b/include/miiphy.h
index f385f3f47e7..962ace13079 100644
--- a/include/miiphy.h
+++ b/include/miiphy.h
@@ -74,6 +74,7 @@ struct bb_miiphy_bus {
int (*set_mdc)(struct bb_miiphy_bus *bus, int v);
int (*delay)(struct bb_miiphy_bus *bus);
void *priv;
+ struct mii_dev mii;
};
extern struct bb_miiphy_bus bb_miiphy_buses[];
@@ -87,6 +88,8 @@ extern int bb_miiphy_buses_num;
* Return: 0 if OK
*/
int bb_miiphy_init(void);
+struct bb_miiphy_bus *bb_miiphy_alloc(void);
+void bb_miiphy_free(struct bb_miiphy_bus *bus);
int bb_miiphy_read(struct mii_dev *miidev, int addr, int devad, int reg);
int bb_miiphy_write(struct mii_dev *miidev, int addr, int devad, int reg,
--
2.45.2
More information about the U-Boot
mailing list