From 7bd1451a18c50a6f636053225d5a78be88c54d8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Bj=C3=B6rnsson?= Date: Tue, 26 Jul 2022 10:12:16 +0200 Subject: [PATCH] drivers: mdio: mdio: Update mdio_shell to use DEVICE_DT_GET MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Update mdio_shell to use DEVICE_DT_GET to remove usage of device_get_binding. Signed-off-by: Benjamin Björnsson --- drivers/mdio/mdio_shell.c | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/drivers/mdio/mdio_shell.c b/drivers/mdio/mdio_shell.c index 01ce0847b7..972f1e222f 100644 --- a/drivers/mdio/mdio_shell.c +++ b/drivers/mdio/mdio_shell.c @@ -9,11 +9,12 @@ #include #include #include +#include #include LOG_MODULE_REGISTER(mdio_shell, CONFIG_LOG_DEFAULT_LEVEL); -#define MDIO_DEVICE "MDIO" +#define MDIO_NODE_ID DT_COMPAT_GET_ANY_STATUS_OKAY(atmel_sam_mdio) /* * Scan the entire 5-bit address space of the MDIO bus @@ -27,10 +28,9 @@ static int cmd_mdio_scan(const struct shell *sh, size_t argc, char **argv) uint16_t data; uint16_t dev_addr; - dev = device_get_binding(MDIO_DEVICE); - if (!dev) { - shell_error(sh, "MDIO: Device driver %s not found.", - MDIO_DEVICE); + dev = DEVICE_DT_GET(MDIO_NODE_ID); + if (!device_is_ready(dev)) { + shell_error(sh, "MDIO: Device driver %s is not ready.", dev->name); return -ENODEV; } @@ -59,7 +59,7 @@ static int cmd_mdio_scan(const struct shell *sh, size_t argc, char **argv) mdio_bus_disable(dev); - shell_print(sh, "%u devices found on %s", cnt, MDIO_DEVICE); + shell_print(sh, "%u devices found on %s", cnt, dev->name); return 0; } @@ -72,10 +72,9 @@ static int cmd_mdio_write(const struct shell *sh, size_t argc, char **argv) uint16_t dev_addr; uint16_t port_addr; - dev = device_get_binding(MDIO_DEVICE); - if (!dev) { - shell_error(sh, "MDIO: Device driver %s not found.", - MDIO_DEVICE); + dev = DEVICE_DT_GET(MDIO_NODE_ID); + if (!device_is_ready(dev)) { + shell_error(sh, "MDIO: Device driver %s is not ready.", dev->name); return -ENODEV; } @@ -87,7 +86,7 @@ static int cmd_mdio_write(const struct shell *sh, size_t argc, char **argv) mdio_bus_enable(dev); if (mdio_write(dev, port_addr, dev_addr, data) < 0) { - shell_error(sh, "Failed to write to device: %s", MDIO_DEVICE); + shell_error(sh, "Failed to write to device: %s", dev->name); mdio_bus_disable(dev); return -EIO; @@ -106,10 +105,9 @@ static int cmd_mdio_read(const struct shell *sh, size_t argc, char **argv) uint16_t dev_addr; uint16_t port_addr; - dev = device_get_binding(MDIO_DEVICE); - if (!dev) { - shell_error(sh, "MDIO: Device driver %s not found.", - MDIO_DEVICE); + dev = DEVICE_DT_GET(MDIO_NODE_ID); + if (!device_is_ready(dev)) { + shell_error(sh, "MDIO: Device driver %s is not ready.", dev->name); return -ENODEV; } @@ -120,7 +118,7 @@ static int cmd_mdio_read(const struct shell *sh, size_t argc, char **argv) mdio_bus_enable(dev); if (mdio_read(dev, port_addr, dev_addr, &data) < 0) { - shell_error(sh, "Failed to read from device: %s", MDIO_DEVICE); + shell_error(sh, "Failed to read from device: %s", dev->name); mdio_bus_disable(dev); return -EIO;