summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorMarek Vasut <[email protected]>2025-02-22 21:33:23 +0100
committerMarek Vasut <[email protected]>2025-02-26 18:26:57 +0100
commit1b879bf5552bce022350bb96d616e5b2838af952 (patch)
tree4ae2d904380360718f4d52ec21b354a2444a9d77 /drivers
parentf15919436bea3336f2dcb86f564180aceccc9c47 (diff)
net: miiphybb: Introduce bb_miiphy_alloc()/bb_miiphy_free() wrappers
Introduce bb_miiphy_alloc()/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 . Reviewed-by: Paul Barker <[email protected]> Signed-off-by: Marek Vasut <[email protected]>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/phy/miiphybb.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/drivers/net/phy/miiphybb.c b/drivers/net/phy/miiphybb.c
index 75d9537b355..66d98d6cc26 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>
@@ -30,6 +31,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