From c55277f05805cba7da46a6723e062a7947968932 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fin=20Maa=C3=9F?= Date: Fri, 13 Jun 2025 11:24:14 +0200 Subject: [PATCH] drivers: mdio: use DEVICE_API_GET MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit use DEVICE_API_GET in mdio.h Signed-off-by: Fin Maaß --- include/zephyr/drivers/mdio.h | 42 ++++++++++------------------------- 1 file changed, 12 insertions(+), 30 deletions(-) diff --git a/include/zephyr/drivers/mdio.h b/include/zephyr/drivers/mdio.h index bed1b7f73cc..ba1deedfb83 100644 --- a/include/zephyr/drivers/mdio.h +++ b/include/zephyr/drivers/mdio.h @@ -70,11 +70,8 @@ __syscall void mdio_bus_enable(const struct device *dev); static inline void z_impl_mdio_bus_enable(const struct device *dev) { - const struct mdio_driver_api *api = - (const struct mdio_driver_api *)dev->api; - - if (api->bus_enable != NULL) { - api->bus_enable(dev); + if (DEVICE_API_GET(mdio, dev)->bus_enable != NULL) { + DEVICE_API_GET(mdio, dev)->bus_enable(dev); } } @@ -88,11 +85,8 @@ __syscall void mdio_bus_disable(const struct device *dev); static inline void z_impl_mdio_bus_disable(const struct device *dev) { - const struct mdio_driver_api *api = - (const struct mdio_driver_api *)dev->api; - - if (api->bus_disable != NULL) { - api->bus_disable(dev); + if (DEVICE_API_GET(mdio, dev)->bus_disable != NULL) { + DEVICE_API_GET(mdio, dev)->bus_disable(dev); } } @@ -118,14 +112,11 @@ __syscall int mdio_read(const struct device *dev, uint8_t prtad, uint8_t regad, static inline int z_impl_mdio_read(const struct device *dev, uint8_t prtad, uint8_t regad, uint16_t *data) { - const struct mdio_driver_api *api = - (const struct mdio_driver_api *)dev->api; - - if (api->read == NULL) { + if (DEVICE_API_GET(mdio, dev)->read == NULL) { return -ENOSYS; } - return api->read(dev, prtad, regad, data); + return DEVICE_API_GET(mdio, dev)->read(dev, prtad, regad, data); } @@ -151,14 +142,11 @@ __syscall int mdio_write(const struct device *dev, uint8_t prtad, uint8_t regad, static inline int z_impl_mdio_write(const struct device *dev, uint8_t prtad, uint8_t regad, uint16_t data) { - const struct mdio_driver_api *api = - (const struct mdio_driver_api *)dev->api; - - if (api->write == NULL) { + if (DEVICE_API_GET(mdio, dev)->write == NULL) { return -ENOSYS; } - return api->write(dev, prtad, regad, data); + return DEVICE_API_GET(mdio, dev)->write(dev, prtad, regad, data); } /** @@ -185,14 +173,11 @@ static inline int z_impl_mdio_read_c45(const struct device *dev, uint8_t prtad, uint8_t devad, uint16_t regad, uint16_t *data) { - const struct mdio_driver_api *api = - (const struct mdio_driver_api *)dev->api; - - if (api->read_c45 == NULL) { + if (DEVICE_API_GET(mdio, dev)->read_c45 == NULL) { return -ENOSYS; } - return api->read_c45(dev, prtad, devad, regad, data); + return DEVICE_API_GET(mdio, dev)->read_c45(dev, prtad, devad, regad, data); } /** @@ -219,14 +204,11 @@ static inline int z_impl_mdio_write_c45(const struct device *dev, uint8_t prtad, uint8_t devad, uint16_t regad, uint16_t data) { - const struct mdio_driver_api *api = - (const struct mdio_driver_api *)dev->api; - - if (api->write_c45 == NULL) { + if (DEVICE_API_GET(mdio, dev)->write_c45 == NULL) { return -ENOSYS; } - return api->write_c45(dev, prtad, devad, regad, data); + return DEVICE_API_GET(mdio, dev)->write_c45(dev, prtad, devad, regad, data); } #ifdef __cplusplus