mirror of
https://github.com/apache/nuttx.git
synced 2026-09-03 23:52:58 +00:00
net/netdev: Combine the per-command CAN ioctl options into NETDEV_CAN_IOCTL
NETDEV_CAN_BITRATE_IOCTL, NETDEV_CAN_FILTER_IOCTL and NETDEV_CAN_STATE_IOCTL guarded identical option blocks, and every SIOCxCANxxx case in netdev_ifr_ioctl() forwarded a member of the same ifr_ifru union to d_ioctl(). One option and one case block now cover all of the CAN commands; drivers and defconfigs are updated to the new name. Assisted-by: Claude:claude-fable-5 Signed-off-by: Jacob Dahl <dahl.jakejacob@gmail.com>
This commit is contained in:
parent
fbe3468703
commit
60ef78f042
16 changed files with 40 additions and 90 deletions
|
|
@ -1544,7 +1544,7 @@ static int imx9_ioctl(struct net_driver_s *dev, int cmd,
|
|||
|
||||
switch (cmd)
|
||||
{
|
||||
#ifdef CONFIG_NETDEV_CAN_BITRATE_IOCTL
|
||||
#ifdef CONFIG_NETDEV_CAN_IOCTL
|
||||
case SIOCGCANBITRATE: /* Get bitrate from a CAN controller */
|
||||
{
|
||||
struct can_ioctl_data_s *req =
|
||||
|
|
|
|||
|
|
@ -1591,7 +1591,7 @@ static int imxrt_ioctl(struct net_driver_s *dev, int cmd,
|
|||
|
||||
switch (cmd)
|
||||
{
|
||||
#ifdef CONFIG_NETDEV_CAN_BITRATE_IOCTL
|
||||
#ifdef CONFIG_NETDEV_CAN_IOCTL
|
||||
case SIOCGCANBITRATE: /* Get bitrate from a CAN controller */
|
||||
{
|
||||
struct can_ioctl_data_s *req =
|
||||
|
|
|
|||
|
|
@ -1477,7 +1477,7 @@ static int kinetis_txavail(struct net_driver_s *dev)
|
|||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_NETDEV_CAN_BITRATE_IOCTL
|
||||
#ifdef CONFIG_NETDEV_CAN_IOCTL
|
||||
static int kinetis_ioctl(struct net_driver_s *dev, int cmd,
|
||||
unsigned long arg)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1460,7 +1460,7 @@ static int s32k1xx_txavail(struct net_driver_s *dev)
|
|||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_NETDEV_CAN_BITRATE_IOCTL
|
||||
#ifdef CONFIG_NETDEV_CAN_IOCTL
|
||||
static int s32k1xx_ioctl(struct net_driver_s *dev, int cmd,
|
||||
unsigned long arg)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1658,7 +1658,7 @@ static int s32k3xx_ioctl(struct net_driver_s *dev, int cmd,
|
|||
|
||||
switch (cmd)
|
||||
{
|
||||
#ifdef CONFIG_NETDEV_CAN_BITRATE_IOCTL
|
||||
#ifdef CONFIG_NETDEV_CAN_IOCTL
|
||||
case SIOCGCANBITRATE: /* Get bitrate from a CAN controller */
|
||||
{
|
||||
struct can_ioctl_data_s *req =
|
||||
|
|
|
|||
|
|
@ -1956,7 +1956,7 @@ static int fdcan_netdev_ioctl(struct net_driver_s *dev, int cmd,
|
|||
|
||||
switch (cmd)
|
||||
{
|
||||
#ifdef CONFIG_NETDEV_CAN_BITRATE_IOCTL
|
||||
#ifdef CONFIG_NETDEV_CAN_IOCTL
|
||||
case SIOCGCANBITRATE: /* Get bitrate from a CAN controller */
|
||||
{
|
||||
struct can_ioctl_data_s *req =
|
||||
|
|
@ -1985,7 +1985,7 @@ static int fdcan_netdev_ioctl(struct net_driver_s *dev, int cmd,
|
|||
ret = OK;
|
||||
}
|
||||
break;
|
||||
#endif /* CONFIG_NETDEV_CAN_BITRATE_IOCTL */
|
||||
#endif
|
||||
|
||||
default:
|
||||
ret = -ENOTSUP;
|
||||
|
|
|
|||
|
|
@ -554,7 +554,7 @@ static int imx9_ioctl(struct net_driver_s *dev, int cmd,
|
|||
|
||||
/* CAN ID filtering */
|
||||
|
||||
#ifdef CONFIG_NETDEV_CAN_FILTER_IOCTL
|
||||
#ifdef CONFIG_NETDEV_CAN_IOCTL
|
||||
static uint32_t imx9_add_filter(struct imx9_driver_s *priv,
|
||||
uint8_t filter_type,
|
||||
bool ext_id,
|
||||
|
|
@ -1607,7 +1607,7 @@ static int imx9_ioctl(struct net_driver_s *dev, int cmd,
|
|||
|
||||
switch (cmd)
|
||||
{
|
||||
#ifdef CONFIG_NETDEV_CAN_BITRATE_IOCTL
|
||||
#ifdef CONFIG_NETDEV_CAN_IOCTL
|
||||
case SIOCGCANBITRATE: /* Get bitrate from a CAN controller */
|
||||
{
|
||||
struct imx9_driver_s *priv = (struct imx9_driver_s *)dev;
|
||||
|
|
@ -1660,9 +1660,7 @@ static int imx9_ioctl(struct net_driver_s *dev, int cmd,
|
|||
}
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_NETDEV_CAN_FILTER_IOCTL
|
||||
case SIOCACANSTDFILTER: /* Set STD ID CAN filter */
|
||||
{
|
||||
struct imx9_driver_s *priv = (struct imx9_driver_s *)dev;
|
||||
|
|
@ -1728,7 +1726,7 @@ static int imx9_ioctl(struct net_driver_s *dev, int cmd,
|
|||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_NETDEV_CAN_FILTER_IOCTL
|
||||
#ifdef CONFIG_NETDEV_CAN_IOCTL
|
||||
static uint32_t imx9_add_filter(struct imx9_driver_s *priv,
|
||||
uint8_t filter_type,
|
||||
bool ext_id,
|
||||
|
|
@ -1869,7 +1867,7 @@ static uint8_t imx9_reset_filter(struct imx9_driver_s *priv)
|
|||
|
||||
return OK;
|
||||
}
|
||||
#endif /* CONFIG_NETDEV_CAN_FILTER_IOCTL */
|
||||
#endif /* CONFIG_NETDEV_CAN_IOCTL */
|
||||
|
||||
/****************************************************************************
|
||||
* Function: imx9_init_eccram
|
||||
|
|
|
|||
|
|
@ -474,12 +474,12 @@ static int mpfs_interrupt(int irq, void *context, void *arg);
|
|||
|
||||
/* RX SW/HW filter related functions */
|
||||
|
||||
#ifdef CONFIG_NETDEV_CAN_FILTER_IOCTL
|
||||
#ifdef CONFIG_NETDEV_CAN_IOCTL
|
||||
static uint8_t mpfs_can_add_filter(mpfs_can_instance_t *priv,
|
||||
uint8_t filter_type,
|
||||
uint32_t filter_id1,
|
||||
uint32_t filter_id2);
|
||||
#endif /* CONFIG_NETDEV_CAN_FILTER_IOCTL */
|
||||
#endif /* CONFIG_NETDEV_CAN_IOCTL */
|
||||
|
||||
static uint8_t mpfs_can_reset_filter(mpfs_can_instance_t *priv);
|
||||
|
||||
|
|
@ -523,7 +523,7 @@ static uint32_t mpfs_can_canid_to_msgid(uint32_t canid);
|
|||
static uint32_t mpfs_can_msgid_to_canid(uint32_t id, bool ide, bool rtr);
|
||||
static uint8_t mpfs_can_set_bitrate(mpfs_can_instance_t *priv,
|
||||
uint32_t bitrate);
|
||||
#if defined(CONFIG_DEBUG_NET_INFO) || defined(CONFIG_NETDEV_CAN_BITRATE_IOCTL)
|
||||
#if defined(CONFIG_DEBUG_NET_INFO) || defined(CONFIG_NETDEV_CAN_IOCTL)
|
||||
static uint32_t mpfs_can_get_sample_point(mpfs_can_instance_t *priv);
|
||||
#endif
|
||||
|
||||
|
|
@ -1081,7 +1081,7 @@ static int mpfs_interrupt(int irq, void *context, void *arg)
|
|||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_NETDEV_CAN_FILTER_IOCTL
|
||||
#ifdef CONFIG_NETDEV_CAN_IOCTL
|
||||
static uint8_t mpfs_can_add_filter(mpfs_can_instance_t *priv,
|
||||
uint8_t filter_type,
|
||||
uint32_t filter_id1,
|
||||
|
|
@ -1137,7 +1137,7 @@ static uint8_t mpfs_can_add_filter(mpfs_can_instance_t *priv,
|
|||
|
||||
return CAN_OK;
|
||||
}
|
||||
#endif /* CONFIG_NETDEV_CAN_FILTER_IOCTL */
|
||||
#endif /* CONFIG_NETDEV_CAN_IOCTL */
|
||||
|
||||
/****************************************************************************
|
||||
* Name: mpfs_can_reset_filter
|
||||
|
|
@ -1734,7 +1734,7 @@ static uint8_t mpfs_can_set_bitrate(mpfs_can_instance_t *priv,
|
|||
return CAN_OK;
|
||||
}
|
||||
|
||||
#if defined(CONFIG_DEBUG_NET_INFO) || defined(CONFIG_NETDEV_CAN_BITRATE_IOCTL)
|
||||
#if defined(CONFIG_DEBUG_NET_INFO) || defined(CONFIG_NETDEV_CAN_IOCTL)
|
||||
/****************************************************************************
|
||||
* Name: mpfs_can_get_sample_point
|
||||
*
|
||||
|
|
@ -2299,8 +2299,7 @@ static int mpfs_ioctl(struct netdev_lowerhalf_s *dev, int cmd,
|
|||
{
|
||||
ninfo("IOCTL received | cmd: %d arg: %ld\n", cmd, arg);
|
||||
|
||||
#if defined(CONFIG_NETDEV_CAN_BITRATE_IOCTL) || \
|
||||
defined(CONFIG_NETDEV_CAN_FILTER_IOCTL)
|
||||
#ifdef CONFIG_NETDEV_CAN_IOCTL
|
||||
mpfs_can_instance_t *priv =
|
||||
(mpfs_can_instance_t *)dev;
|
||||
#endif
|
||||
|
|
@ -2308,7 +2307,7 @@ defined(CONFIG_NETDEV_CAN_FILTER_IOCTL)
|
|||
|
||||
switch (cmd)
|
||||
{
|
||||
#ifdef CONFIG_NETDEV_CAN_BITRATE_IOCTL
|
||||
#ifdef CONFIG_NETDEV_CAN_IOCTL
|
||||
case SIOCGCANBITRATE:
|
||||
|
||||
/* Get bitrate from the CAN controller */
|
||||
|
|
@ -2340,9 +2339,7 @@ defined(CONFIG_NETDEV_CAN_FILTER_IOCTL)
|
|||
ret = CAN_OK;
|
||||
}
|
||||
break;
|
||||
#endif /* CONFIG_NETDEV_CAN_BITRATE_IOCTL */
|
||||
|
||||
#ifdef CONFIG_NETDEV_CAN_FILTER_IOCTL
|
||||
case SIOCACANSTDFILTER:
|
||||
case SIOCACANEXTFILTER:
|
||||
|
||||
|
|
@ -2370,7 +2367,7 @@ defined(CONFIG_NETDEV_CAN_FILTER_IOCTL)
|
|||
ret = CAN_OK;
|
||||
}
|
||||
break;
|
||||
#endif /* CONFIG_NETDEV_CAN_FILTER_IOCTL */
|
||||
#endif /* CONFIG_NETDEV_CAN_IOCTL */
|
||||
|
||||
default:
|
||||
ret = -ENOTTY;
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ CONFIG_INIT_ENTRYPOINT="nsh_main"
|
|||
CONFIG_INTELHEX_BINARY=y
|
||||
CONFIG_LINE_MAX=64
|
||||
CONFIG_NET=y
|
||||
CONFIG_NETDEV_CAN_BITRATE_IOCTL=y
|
||||
CONFIG_NETDEV_CAN_IOCTL=y
|
||||
CONFIG_NETDEV_IFINDEX=y
|
||||
CONFIG_NET_CAN=y
|
||||
CONFIG_NET_CAN_SOCK_OPTS=y
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ CONFIG_IOB_THROTTLE=8
|
|||
CONFIG_LIBC_LOCALTIME=y
|
||||
CONFIG_LPUART3_SERIAL_CONSOLE=y
|
||||
CONFIG_NET=y
|
||||
CONFIG_NETDEV_CAN_BITRATE_IOCTL=y
|
||||
CONFIG_NETDEV_CAN_IOCTL=y
|
||||
CONFIG_NETDEV_IFINDEX=y
|
||||
CONFIG_NETDEV_LATEINIT=y
|
||||
CONFIG_NET_CAN=y
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ CONFIG_INTELHEX_BINARY=y
|
|||
CONFIG_LINE_MAX=64
|
||||
CONFIG_MM_REGIONS=4
|
||||
CONFIG_NET=y
|
||||
CONFIG_NETDEV_CAN_BITRATE_IOCTL=y
|
||||
CONFIG_NETDEV_CAN_IOCTL=y
|
||||
CONFIG_NETDEV_IFINDEX=y
|
||||
CONFIG_NETDEV_LATEINIT=y
|
||||
CONFIG_NET_CAN=y
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ CONFIG_INTELHEX_BINARY=y
|
|||
CONFIG_LINE_MAX=64
|
||||
CONFIG_MM_REGIONS=4
|
||||
CONFIG_NET=y
|
||||
CONFIG_NETDEV_CAN_BITRATE_IOCTL=y
|
||||
CONFIG_NETDEV_CAN_IOCTL=y
|
||||
CONFIG_NETDEV_IFINDEX=y
|
||||
CONFIG_NETDEV_LATEINIT=y
|
||||
CONFIG_NET_CAN=y
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ CONFIG_INTELHEX_BINARY=y
|
|||
CONFIG_LINE_MAX=64
|
||||
CONFIG_MM_REGIONS=4
|
||||
CONFIG_NET=y
|
||||
CONFIG_NETDEV_CAN_BITRATE_IOCTL=y
|
||||
CONFIG_NETDEV_CAN_IOCTL=y
|
||||
CONFIG_NETDEV_IFINDEX=y
|
||||
CONFIG_NETDEV_LATEINIT=y
|
||||
CONFIG_NET_CAN=y
|
||||
|
|
|
|||
|
|
@ -35,8 +35,7 @@ CONFIG_MM_FILL_ALLOCATIONS=y
|
|||
CONFIG_NAME_MAX=64
|
||||
CONFIG_NET=y
|
||||
CONFIG_NETDB_DNSCLIENT=y
|
||||
CONFIG_NETDEV_CAN_BITRATE_IOCTL=y
|
||||
CONFIG_NETDEV_CAN_FILTER_IOCTL=y
|
||||
CONFIG_NETDEV_CAN_IOCTL=y
|
||||
CONFIG_NETDEV_LATEINIT=y
|
||||
CONFIG_NETDEV_PHY_IOCTL=y
|
||||
CONFIG_NETDOWN_NOTIFIER=y
|
||||
|
|
|
|||
|
|
@ -16,31 +16,15 @@ config NETDEV_PHY_IOCTL
|
|||
---help---
|
||||
Enable support for ioctl() commands to access PHY registers
|
||||
|
||||
config NETDEV_CAN_BITRATE_IOCTL
|
||||
bool "Enable CAN bitrate ioctl()"
|
||||
config NETDEV_CAN_IOCTL
|
||||
bool "Enable CAN ioctl()"
|
||||
default n
|
||||
select NETDEV_IOCTL
|
||||
depends on NET_CAN
|
||||
---help---
|
||||
Enable support for ioctl() commands to change CAN bitrate
|
||||
|
||||
config NETDEV_CAN_FILTER_IOCTL
|
||||
bool "Enable CAN filter ioctl()"
|
||||
default n
|
||||
select NETDEV_IOCTL
|
||||
depends on NET_CAN
|
||||
---help---
|
||||
Enable support for ioctl() commands to add/remove CAN hardware-level
|
||||
filters (NOTE: Not supported by all drivers)
|
||||
|
||||
config NETDEV_CAN_STATE_IOCTL
|
||||
bool "Enable CAN state ioctl()"
|
||||
default n
|
||||
select NETDEV_IOCTL
|
||||
depends on NET_CAN
|
||||
---help---
|
||||
Enable support for ioctl() commands to set/see CAN or LIN controller-state
|
||||
(NOTE: Not supported by all drivers)
|
||||
Enable support for the CAN network device ioctl() commands:
|
||||
bitrate, hardware-level filters and CAN/LIN controller state
|
||||
(NOTE: Not every command is supported by every driver)
|
||||
|
||||
config NETDEV_WIRELESS_IOCTL
|
||||
bool "Enable Wireless ioctl()"
|
||||
|
|
|
|||
|
|
@ -1244,7 +1244,7 @@ static int netdev_ifr_ioctl(FAR struct socket *psock, int cmd,
|
|||
break;
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_NETDEV_IOCTL) && defined(CONFIG_NETDEV_CAN_BITRATE_IOCTL)
|
||||
#if defined(CONFIG_NETDEV_IOCTL) && defined(CONFIG_NETDEV_CAN_IOCTL)
|
||||
case SIOCSCANBITRATE: /* Set bitrate of a CAN controller */
|
||||
if (dev->d_flags & IFF_UP)
|
||||
{
|
||||
|
|
@ -1254,52 +1254,24 @@ static int netdev_ifr_ioctl(FAR struct socket *psock, int cmd,
|
|||
break;
|
||||
}
|
||||
|
||||
/* If down, fall-through to common code in SIOCGCANBITRATE. */
|
||||
/* If down, fall-through to the common CAN ioctl code. */
|
||||
|
||||
case SIOCGCANBITRATE: /* Get bitrate from a CAN controller */
|
||||
if (dev->d_ioctl)
|
||||
{
|
||||
FAR struct can_ioctl_data_s *can_bitrate_data =
|
||||
&req->ifr_ifru.ifru_can_data;
|
||||
ret = dev->d_ioctl(dev, cmd,
|
||||
(unsigned long)(uintptr_t)can_bitrate_data);
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = -ENOSYS;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_NETDEV_IOCTL) && defined(CONFIG_NETDEV_CAN_FILTER_IOCTL)
|
||||
case SIOCGCANBITRATE: /* Get bitrate from a CAN controller */
|
||||
case SIOCACANEXTFILTER: /* Add an extended-ID filter */
|
||||
case SIOCDCANEXTFILTER: /* Delete an extended-ID filter */
|
||||
case SIOCACANSTDFILTER: /* Add a standard-ID filter */
|
||||
case SIOCDCANSTDFILTER: /* Delete a standard-ID filter */
|
||||
case SIOCCANRECOVERY: /* Recovery can controller when bus-off */
|
||||
case SIOCGCANSTATE: /* Get state from a CAN/LIN controller */
|
||||
case SIOCSCANSTATE: /* Set the LIN/CAN controller state */
|
||||
if (dev->d_ioctl)
|
||||
{
|
||||
FAR struct can_ioctl_filter_s *can_filter =
|
||||
&req->ifr_ifru.ifru_can_filter;
|
||||
ret = dev->d_ioctl(dev, cmd,
|
||||
(unsigned long)(uintptr_t)can_filter);
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = -ENOSYS;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
/* Every CAN ioctl argument struct is a member of the
|
||||
* ifr_ifru union, so cmd's struct is at its address.
|
||||
*/
|
||||
|
||||
#if defined(CONFIG_NETDEV_IOCTL) && defined(CONFIG_NETDEV_CAN_STATE_IOCTL)
|
||||
case SIOCGCANSTATE: /* Get state from a CAN/LIN controller */
|
||||
case SIOCSCANSTATE: /* Set the LIN/CAN controller state */
|
||||
if (dev->d_ioctl)
|
||||
{
|
||||
FAR struct can_ioctl_state_s *can_state =
|
||||
&req->ifr_ifru.ifru_can_state;
|
||||
ret = dev->d_ioctl(dev, cmd,
|
||||
(unsigned long)(uintptr_t)can_state);
|
||||
(unsigned long)(uintptr_t)&req->ifr_ifru);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue