drivers: can: remove DT_CHOSEN_ZEPHYR_CANBUS_LABEL macro

Remove the DT_CHOSEN_ZEPHYR_CANBUS_LABEL macro and replace it with
DEVICE_DT_GET(DT_CHOSEN(zephyr_canbus)) were possible.

Where both devicetree CAN controllers and Kconfig specified CAN loopback
controllers are supported, the macro is replaced with
DT_LABEL(DT_CHOSEN(zephyr_canbus)) for now.

This is the first pass for removing the requirement for devicetree
labels for CAN controllers.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
This commit is contained in:
Henrik Brix Andersen 2021-11-07 15:50:43 +01:00 committed by Carles Cufí
commit 5bc0451f72
10 changed files with 18 additions and 36 deletions

View file

@ -377,21 +377,18 @@ static struct net_can_api net_can_api_inst = {
static int net_can_init(const struct device *dev)
{
const struct device *can_dev;
const struct device *can_dev = DEVICE_DT_GET(DT_CHOSEN(zephyr_canbus));
struct net_can_context *ctx = dev->data;
can_dev = device_get_binding(DT_CHOSEN_ZEPHYR_CANBUS_LABEL);
ctx->recv_filter_id = CAN_NET_FILTER_NOT_SET;
#ifdef CONFIG_NET_L2_CANBUS_ETH_TRANSLATOR
ctx->eth_bridge_filter_id = CAN_NET_FILTER_NOT_SET;
ctx->all_mcast_filter_id = CAN_NET_FILTER_NOT_SET;
#endif /*CONFIG_NET_L2_CANBUS_ETH_TRANSLATOR*/
if (!can_dev) {
NET_ERR("Can't get binding to CAN device %s",
DT_CHOSEN_ZEPHYR_CANBUS_LABEL);
return -EIO;
if (!device_is_ready(can_dev)) {
NET_ERR("CAN device not ready");
return -ENODEV;
}
NET_DBG("Init net CAN device %p (%s) for dev %p (%s)",