can: Add g_ prefix to can_dlc_to_len and len_to_can_dlc.

detail: Add g_ prefix to can_dlc_to_len and len_to_can_dlc to
follow NuttX coding style conventions for global symbols,
improving code readability and maintainability.

Signed-off-by: zhaohaiyang1 <zhaohaiyang1@xiaomi.com>
This commit is contained in:
Xiang Xiao 2024-04-06 00:38:55 +08:00 committed by Xiang Xiao
parent 3cce16dd0c
commit f76c2ed83b
8 changed files with 101 additions and 100 deletions

View File

@ -696,7 +696,7 @@ static int imxrt_transmit(struct imxrt_driver_s *priv)
cs.rtr = frame->can_id & FLAGRTR ? 1 : 0; cs.rtr = frame->can_id & FLAGRTR ? 1 : 0;
cs.dlc = len_to_can_dlc[frame->len]; cs.dlc = g_len_to_can_dlc[frame->len];
frame_data_word = (uint32_t *)&frame->data[0]; frame_data_word = (uint32_t *)&frame->data[0];
@ -877,7 +877,7 @@ static void imxrt_receive(struct imxrt_driver_s *priv,
frame->can_id |= FLAGRTR; frame->can_id |= FLAGRTR;
} }
frame->len = can_dlc_to_len[rf->cs.dlc]; frame->len = g_can_dlc_to_len[rf->cs.dlc];
frame_data_word = (uint32_t *)&frame->data[0]; frame_data_word = (uint32_t *)&frame->data[0];

View File

@ -724,7 +724,7 @@ static int kinetis_transmit(struct kinetis_driver_s *priv)
cs.rtr = frame->can_id & FLAGRTR ? 1 : 0; cs.rtr = frame->can_id & FLAGRTR ? 1 : 0;
cs.dlc = len_to_can_dlc[frame->len]; cs.dlc = g_len_to_can_dlc[frame->len];
frame_data_word = (uint32_t *)&frame->data[0]; frame_data_word = (uint32_t *)&frame->data[0];
@ -877,7 +877,7 @@ static void kinetis_receive(struct kinetis_driver_s *priv,
frame->can_id |= FLAGRTR; frame->can_id |= FLAGRTR;
} }
frame->len = can_dlc_to_len[rf->cs.dlc]; frame->len = g_can_dlc_to_len[rf->cs.dlc];
frame_data_word = (uint32_t *)&frame->data[0]; frame_data_word = (uint32_t *)&frame->data[0];

View File

@ -728,7 +728,7 @@ static int s32k1xx_transmit(struct s32k1xx_driver_s *priv)
cs.rtr = frame->can_id & FLAGRTR ? 1 : 0; cs.rtr = frame->can_id & FLAGRTR ? 1 : 0;
cs.dlc = len_to_can_dlc[frame->len]; cs.dlc = g_len_to_can_dlc[frame->len];
frame_data_word = (uint32_t *)&frame->data[0]; frame_data_word = (uint32_t *)&frame->data[0];
@ -881,7 +881,7 @@ static void s32k1xx_receive(struct s32k1xx_driver_s *priv,
frame->can_id |= FLAGRTR; frame->can_id |= FLAGRTR;
} }
frame->len = can_dlc_to_len[rf->cs.dlc]; frame->len = g_can_dlc_to_len[rf->cs.dlc];
frame_data_word = (uint32_t *)&frame->data[0]; frame_data_word = (uint32_t *)&frame->data[0];

View File

@ -890,7 +890,7 @@ static int s32k3xx_transmit(struct s32k3xx_driver_s *priv)
cs.rtr = frame->can_id & FLAGRTR ? 1 : 0; cs.rtr = frame->can_id & FLAGRTR ? 1 : 0;
cs.dlc = len_to_can_dlc[frame->len]; cs.dlc = g_len_to_can_dlc[frame->len];
frame_data_word = (uint32_t *)&frame->data[0]; frame_data_word = (uint32_t *)&frame->data[0];
@ -1041,7 +1041,7 @@ static void s32k3xx_receive(struct s32k3xx_driver_s *priv, uint32_t flags)
frame->can_id |= FLAGRTR; frame->can_id |= FLAGRTR;
} }
frame->len = can_dlc_to_len[rf->cs.dlc]; frame->len = g_can_dlc_to_len[rf->cs.dlc];
frame_data_word = (uint32_t *)&frame->data[0]; frame_data_word = (uint32_t *)&frame->data[0];

View File

@ -1749,7 +1749,7 @@ static int fdcan_send(struct stm32_fdcan_s *priv)
/* Set DLC */ /* Set DLC */
txbuffer[1] |= BUFFER_R1_DLC(len_to_can_dlc[frame->len]); txbuffer[1] |= BUFFER_R1_DLC(g_len_to_can_dlc[frame->len]);
/* Set flags */ /* Set flags */
@ -2467,8 +2467,8 @@ static void fdcan_receive(struct stm32_fdcan_s *priv,
/* Word R1 contains the DLC and timestamp */ /* Word R1 contains the DLC and timestamp */
frame->len = can_dlc_to_len[((rxbuffer[1] & BUFFER_R1_DLC_MASK) >> frame->len = g_can_dlc_to_len[((rxbuffer[1] & BUFFER_R1_DLC_MASK) >>
BUFFER_R1_DLC_SHIFT)]; BUFFER_R1_DLC_SHIFT)];
/* Get CANFD flags */ /* Get CANFD flags */

View File

@ -880,7 +880,7 @@ static int fdcan_transmit(struct fdcan_driver_s *priv)
header.id.esi = (frame->can_id & CAN_ERR_FLAG) ? 1 : 0; header.id.esi = (frame->can_id & CAN_ERR_FLAG) ? 1 : 0;
header.id.rtr = (frame->can_id & CAN_RTR_FLAG) ? 1 : 0; header.id.rtr = (frame->can_id & CAN_RTR_FLAG) ? 1 : 0;
header.dlc = len_to_can_dlc[frame->len]; header.dlc = g_len_to_can_dlc[frame->len];
header.brs = brs; /* Bitrate switching */ header.brs = brs; /* Bitrate switching */
header.fdf = 1; /* CAN-FD frame */ header.fdf = 1; /* CAN-FD frame */
header.efc = 0; /* Don't store Tx events */ header.efc = 0; /* Don't store Tx events */
@ -1161,7 +1161,7 @@ static void fdcan_receive_work(void *arg)
frame->can_id |= CAN_RTR_FLAG; frame->can_id |= CAN_RTR_FLAG;
} }
frame->len = can_dlc_to_len[rf->header.dlc]; frame->len = g_can_dlc_to_len[rf->header.dlc];
uint32_t *frame_data_word = (uint32_t *)&frame->data[0]; uint32_t *frame_data_word = (uint32_t *)&frame->data[0];

View File

@ -52,10 +52,11 @@
/**************************************************************************** /****************************************************************************
* Pre-processor Definitions * Pre-processor Definitions
****************************************************************************/ ****************************************************************************/
#ifdef CONFIG_NET_CAN_CANFD #ifdef CONFIG_NET_CAN_CANFD
#define NET_CAN_PKTSIZE sizeof(struct canfd_frame) # define NET_CAN_PKTSIZE sizeof(struct canfd_frame)
#else #else
#define NET_CAN_PKTSIZE sizeof(struct can_frame) # define NET_CAN_PKTSIZE sizeof(struct can_frame)
#endif #endif
/**************************************************************************** /****************************************************************************
@ -70,8 +71,8 @@
/* Lookup tables convert can_dlc <-> payload len */ /* Lookup tables convert can_dlc <-> payload len */
extern const uint8_t can_dlc_to_len[16]; extern const uint8_t g_can_dlc_to_len[16];
extern const uint8_t len_to_can_dlc[65]; extern const uint8_t g_len_to_can_dlc[65];
#endif #endif

View File

@ -40,92 +40,92 @@
* Public Data * Public Data
****************************************************************************/ ****************************************************************************/
const uint8_t can_dlc_to_len[16] = const uint8_t g_can_dlc_to_len[16] =
{ {
0, 0,
1, 1,
2, 2,
3, 3,
4, 4,
5, 5,
6, 6,
7, 7,
8, 8,
12, 12,
16, 16,
20, 20,
24, 24,
32, 32,
48, 48,
64, 64,
}; };
const uint8_t len_to_can_dlc[65] = const uint8_t g_len_to_can_dlc[65] =
{ {
0, 0,
1, 1,
2, 2,
3, 3,
4, 4,
5, 5,
6, 6,
7, 7,
8, 8,
9, 9,
9, 9,
9, 9,
9, 9,
10, 10,
10, 10,
10, 10,
10, 10,
11, 11,
11, 11,
11, 11,
11, 11,
12, 12,
12, 12,
12, 12,
12, 12,
13, 13,
13, 13,
13, 13,
13, 13,
13, 13,
13, 13,
13, 13,
13, 13,
14, 14,
14, 14,
14, 14,
14, 14,
14, 14,
14, 14,
14, 14,
14, 14,
14, 14,
14, 14,
14, 14,
14, 14,
14, 14,
14, 14,
14, 14,
14, 14,
15, 15,
15, 15,
15, 15,
15, 15,
15, 15,
15, 15,
15, 15,
15, 15,
15, 15,
15, 15,
15, 15,
15, 15,
15, 15,
15, 15,
15, 15,
15, 15,
}; };
/**************************************************************************** /****************************************************************************