drivers: can: Fix building with socket_can_generic.h

socket_can_generic.h makes some assumptions that are not always valid
for various drivers with regards to numbering.  To clean this up we
add defines for SOCKET_CAN_NAME_0 and SOCKET_CAN_NAME_2 in addition to
SOCKET_CAN_NAME_1.

We also move struct socket_can_context into the drivers themselves
since they know best how many CAN interfaces are getting supported and
what naming/number convention they'd have.

Additionally, this also exposes a few other build issues with the
can_mcux_flexcan driver that get fixed.

Finally, we remove the platform_allow from samples/net/sockets/can
since it is no longer needed.

Fixes #31733

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
This commit is contained in:
Kumar Gala 2021-02-02 12:58:15 -06:00 committed by Anas Nashif
commit 6defabebad
6 changed files with 13 additions and 5 deletions

View file

@ -820,11 +820,12 @@ static const struct can_driver_api mcux_flexcan_driver_api = {
DT_INST_FOREACH_STATUS_OKAY(FLEXCAN_DEVICE_INIT_MCUX)
#if defined(CONFIG_NET_SOCKETS_CAN)
#include "socket_can_generic.h" \
#include "socket_can_generic.h"
#define FLEXCAN_DEVICE_SOCKET_CAN(id) \
static struct socket_can_context socket_can_context_##id; \
static int socket_can_init_##id(const struct device *dev) \
{ \
struct device *can_dev = DEVICE_DT_INST_GET(id); \
const struct device *can_dev = DEVICE_DT_INST_GET(id); \
struct socket_can_context *socket_context = dev->data; \
LOG_DBG("Init socket CAN device %p (%s) for dev %p (%s)", \
dev, dev->name, can_dev, can_dev->name); \