On 10/28/20 12:00 PM, Oliver Hartkopp wrote: > Cleanup the can_dlc usage by renaming it with len from can_frame.len > > Signed-off-by: Oliver Hartkopp <socketcan@xxxxxxxxxxxx> [...] > diff --git a/drivers/net/can/dev.c b/drivers/net/can/dev.c > index 6dee4f8f2024..537dd4636c90 100644 > --- a/drivers/net/can/dev.c > +++ b/drivers/net/can/dev.c > @@ -28,14 +28,14 @@ MODULE_AUTHOR("Wolfgang Grandegger <wg@xxxxxxxxxxxxxx>"); > /* CAN DLC to real data length conversion helpers */ > > static const u8 dlc2len[] = {0, 1, 2, 3, 4, 5, 6, 7, > 8, 12, 16, 20, 24, 32, 48, 64}; > > -/* get data length from can_dlc with sanitized can_dlc */ > -u8 can_dlc2len(u8 can_dlc) > +/* get data length from dlc with sanitized len */ > +u8 can_dlc2len(u8 dlc) > { > - return dlc2len[can_dlc & 0x0F]; > + return dlc2len[dlc & 0x0F]; > } > EXPORT_SYMBOL_GPL(can_dlc2len); unrelated change. [...] > diff --git a/drivers/net/can/peak_canfd/peak_canfd.c b/drivers/net/can/peak_canfd/peak_canfd.c > index cc01db0c18b8..c25cb53eba4e 100644 > --- a/drivers/net/can/peak_canfd/peak_canfd.c > +++ b/drivers/net/can/peak_canfd/peak_canfd.c [...] > @@ -650,11 +650,11 @@ static netdev_tx_t peak_canfd_start_xmit(struct sk_buff *skb, > struct pucan_tx_msg *msg; > u16 msg_size, msg_flags; > unsigned long flags; > bool should_stop_tx_queue; > int room_left; > - u8 can_dlc; > + u8 len; unrelated change > > if (can_dropped_invalid_skb(ndev, skb)) > return NETDEV_TX_OK; > > msg_size = ALIGN(sizeof(*msg) + cf->len, 4); > @@ -680,22 +680,22 @@ static netdev_tx_t peak_canfd_start_xmit(struct sk_buff *skb, > msg->can_id = cpu_to_le32(cf->can_id & CAN_SFF_MASK); > } > > if (can_is_canfd_skb(skb)) { > /* CAN FD frame format */ > - can_dlc = can_len2dlc(cf->len); > + len = can_len2dlc(cf->len); > > msg_flags |= PUCAN_MSG_EXT_DATA_LEN; > > if (cf->flags & CANFD_BRS) > msg_flags |= PUCAN_MSG_BITRATE_SWITCH; > > if (cf->flags & CANFD_ESI) > msg_flags |= PUCAN_MSG_ERROR_STATE_IND; > } else { > /* CAN 2.0 frame format */ > - can_dlc = cf->len; > + len = cf->len; > > if (cf->can_id & CAN_RTR_FLAG) > msg_flags |= PUCAN_MSG_RTR; > } > > @@ -705,11 +705,11 @@ static netdev_tx_t peak_canfd_start_xmit(struct sk_buff *skb, > /* set driver specific bit to differentiate with application loopback */ > if (priv->can.ctrlmode & CAN_CTRLMODE_LOOPBACK) > msg_flags |= PUCAN_MSG_SELF_RECEIVE; > > msg->flags = cpu_to_le16(msg_flags); > - msg->channel_dlc = PUCAN_MSG_CHANNEL_DLC(priv->index, can_dlc); > + msg->channel_dlc = PUCAN_MSG_CHANNEL_DLC(priv->index, len); > memcpy(msg->d, cf->data, cf->len); > > /* struct msg client field is used as an index in the echo skbs ring */ > msg->client = priv->echo_idx; > [...] > diff --git a/drivers/net/can/softing/softing_fw.c b/drivers/net/can/softing/softing_fw.c > index ccd649a8e37b..7e1536877993 100644 > --- a/drivers/net/can/softing/softing_fw.c > +++ b/drivers/net/can/softing/softing_fw.c > @@ -622,11 +622,11 @@ int softing_startstop(struct net_device *dev, int up) > * from here, no errors should occur, or the failed: part > * must be reviewed > */ > memset(&msg, 0, sizeof(msg)); > msg.can_id = CAN_ERR_FLAG | CAN_ERR_RESTARTED; > - msg.can_dlc = CAN_ERR_DLC; > + msg.len = CAN_ERR_DLC; unrelated? _u> for (j = 0; j < ARRAY_SIZE(card->net); ++j) { > if (!(bus_bitmask_start & (1 << j))) > continue; > netdev = card->net[j]; > if (!netdev) > diff --git a/drivers/net/can/softing/softing_main.c b/drivers/net/can/softing/softing_main.c > index 5cc175fd7067..42acfd5149e5 100644 > --- a/drivers/net/can/softing/softing_main.c > +++ b/drivers/net/can/softing/softing_main.c > @@ -82,22 +82,22 @@ static netdev_tx_t softing_netdev_start_xmit(struct sk_buff *skb, > if (cf->can_id & CAN_EFF_FLAG) > *ptr |= CMD_XTD; > if (priv->index) > *ptr |= CMD_BUS2; > ++ptr; > - *ptr++ = cf->can_dlc; > + *ptr++ = cf->len; > *ptr++ = (cf->can_id >> 0); > *ptr++ = (cf->can_id >> 8); > if (cf->can_id & CAN_EFF_FLAG) { > *ptr++ = (cf->can_id >> 16); > *ptr++ = (cf->can_id >> 24); > } else { > /* increment 1, not 2 as you might think */ > ptr += 1; > } > if (!(cf->can_id & CAN_RTR_FLAG)) > - memcpy(ptr, &cf->data[0], cf->can_dlc); > + memcpy(ptr, &cf->data[0], cf->len); > memcpy_toio(&card->dpram[DPRAM_TX + DPRAM_TX_SIZE * fifo_wr], > buf, DPRAM_TX_SIZE); > if (++fifo_wr >= DPRAM_TX_CNT) > fifo_wr = 0; > iowrite8(fifo_wr, &card->dpram[DPRAM_TX_WR]); > @@ -165,11 +165,11 @@ static int softing_handle_1(struct softing *card) > int j; > /* reset condition */ > iowrite8(0, &card->dpram[DPRAM_RX_LOST]); > /* prepare msg */ > msg.can_id = CAN_ERR_FLAG | CAN_ERR_CRTL; > - msg.can_dlc = CAN_ERR_DLC; > + msg.len = CAN_ERR_DLC; > msg.data[1] = CAN_ERR_CRTL_RX_OVERFLOW; > /* > * service to all buses, we don't know which it was applicable > * but only service buses that are online > */ > @@ -216,11 +216,11 @@ static int softing_handle_1(struct softing *card) > uint8_t can_state, state; > > state = *ptr++; > > msg.can_id = CAN_ERR_FLAG; > - msg.can_dlc = CAN_ERR_DLC; > + msg.len = CAN_ERR_DLC; unrelated? > > if (state & SF_MASK_BUSOFF) { > can_state = CAN_STATE_BUS_OFF; > msg.can_id |= CAN_ERR_BUSOFF; > state = STATE_BUSOFF; > @@ -259,11 +259,11 @@ static int softing_handle_1(struct softing *card) > } > > } else { > if (cmd & CMD_RTR) > msg.can_id |= CAN_RTR_FLAG; > - msg.can_dlc = can_get_cc_len(*ptr++); > + msg.len = can_get_cc_len(*ptr++); same here? > if (cmd & CMD_XTD) { > msg.can_id |= CAN_EFF_FLAG; > msg.can_id |= le32_to_cpup((void *)ptr); > ptr += 4; > } else { > @@ -292,19 +292,19 @@ static int softing_handle_1(struct softing *card) > --priv->tx.pending; > if (card->tx.pending) > --card->tx.pending; > ++netdev->stats.tx_packets; > if (!(msg.can_id & CAN_RTR_FLAG)) > - netdev->stats.tx_bytes += msg.can_dlc; > + netdev->stats.tx_bytes += msg.len; same here? > } else { > int ret; > > ret = softing_netdev_rx(netdev, &msg, ktime); > if (ret == NET_RX_SUCCESS) { > ++netdev->stats.rx_packets; > if (!(msg.can_id & CAN_RTR_FLAG)) > - netdev->stats.rx_bytes += msg.can_dlc; > + netdev->stats.rx_bytes += msg.len; same here? > } else { > ++netdev->stats.rx_dropped; > } > } > } [...] > diff --git a/drivers/net/can/usb/gs_usb.c b/drivers/net/can/usb/gs_usb.c > index 07fe84968391..3a097c240e5a 100644 > --- a/drivers/net/can/usb/gs_usb.c > +++ b/drivers/net/can/usb/gs_usb.c > @@ -133,11 +133,11 @@ struct gs_device_bt_const { > > struct gs_host_frame { > u32 echo_id; > u32 can_id; > > - u8 can_dlc; > + u8 len; unrelated change? > u8 channel; > u8 flags; > u8 reserved; > > u8 data[8]; > @@ -329,19 +329,19 @@ static void gs_usb_receive_bulk_callback(struct urb *urb) > if (!skb) > return; > > cf->can_id = hf->can_id; > > - cf->can_dlc = can_get_cc_len(hf->can_dlc); > + cf->len = can_get_cc_len(hf->len); > memcpy(cf->data, hf->data, 8); > > /* ERROR frames tell us information about the controller */ > if (hf->can_id & CAN_ERR_FLAG) > gs_update_state(dev, cf); > > netdev->stats.rx_packets++; > - netdev->stats.rx_bytes += hf->can_dlc; > + netdev->stats.rx_bytes += hf->len; > > netif_rx(skb); > } else { /* echo_id == hf->echo_id */ > if (hf->echo_id >= GS_MAX_TX_URBS) { > netdev_err(netdev, > @@ -349,11 +349,11 @@ static void gs_usb_receive_bulk_callback(struct urb *urb) > hf->echo_id); > goto resubmit_urb; > } > > netdev->stats.tx_packets++; > - netdev->stats.tx_bytes += hf->can_dlc; > + netdev->stats.tx_bytes += hf->len; > > txc = gs_get_tx_context(dev, hf->echo_id); > > /* bad devices send bad echo_ids. */ > if (!txc) { > @@ -376,11 +376,11 @@ static void gs_usb_receive_bulk_callback(struct urb *urb) > skb = alloc_can_err_skb(netdev, &cf); > if (!skb) > goto resubmit_urb; > > cf->can_id |= CAN_ERR_CRTL; > - cf->can_dlc = CAN_ERR_DLC; > + cf->len = CAN_ERR_DLC; > cf->data[1] = CAN_ERR_CRTL_RX_OVERFLOW; > stats->rx_over_errors++; > stats->rx_errors++; > netif_rx(skb); > } > @@ -502,12 +502,12 @@ static netdev_tx_t gs_can_start_xmit(struct sk_buff *skb, > hf->channel = dev->channel; > > cf = (struct can_frame *)skb->data; > > hf->can_id = cf->can_id; > - hf->can_dlc = cf->can_dlc; > - memcpy(hf->data, cf->data, cf->can_dlc); > + hf->len = cf->len; > + memcpy(hf->data, cf->data, cf->len); > > usb_fill_bulk_urb(urb, dev->udev, > usb_sndbulkpipe(dev->udev, GSUSB_ENDPOINT_OUT), > hf, > sizeof(*hf), > diff --git a/drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c b/drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c > index 0f1d3e807d63..d6e18bcb1a7f 100644 > --- a/drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c > +++ b/drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c > @@ -256,11 +256,11 @@ int kvaser_usb_can_rx_over_error(struct net_device *netdev) > > cf->can_id |= CAN_ERR_CRTL; > cf->data[1] = CAN_ERR_CRTL_RX_OVERFLOW; > > stats->rx_packets++; > - stats->rx_bytes += cf->can_dlc; > + stats->rx_bytes += cf->len; > netif_rx(skb); > > return 0; > } > > diff --git a/drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c b/drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c > index b2d56bb1950a..a9a1f7f5a50e 100644 > --- a/drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c > +++ b/drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c > @@ -893,11 +893,11 @@ static void kvaser_usb_hydra_update_state(struct kvaser_usb_net_priv *priv, > cf->data[6] = bec->txerr; > cf->data[7] = bec->rxerr; > > stats = &netdev->stats; > stats->rx_packets++; > - stats->rx_bytes += cf->can_dlc; > + stats->rx_bytes += cf->len; > netif_rx(skb); > } > > static void kvaser_usb_hydra_state_event(const struct kvaser_usb *dev, > const struct kvaser_cmd *cmd) > @@ -1047,11 +1047,11 @@ kvaser_usb_hydra_error_frame(struct kvaser_usb_net_priv *priv, > cf->can_id |= CAN_ERR_BUSERROR; > cf->data[6] = bec.txerr; > cf->data[7] = bec.rxerr; > > stats->rx_packets++; > - stats->rx_bytes += cf->can_dlc; > + stats->rx_bytes += cf->len; > netif_rx(skb); > > priv->bec.txerr = bec.txerr; > priv->bec.rxerr = bec.rxerr; > } > @@ -1082,11 +1082,11 @@ static void kvaser_usb_hydra_one_shot_fail(struct kvaser_usb_net_priv *priv, > priv->can.can_stats.arbitration_lost++; > } > > stats->tx_errors++; > stats->rx_packets++; > - stats->rx_bytes += cf->can_dlc; > + stats->rx_bytes += cf->len; > netif_rx(skb); > } > > static void kvaser_usb_hydra_tx_acknowledge(const struct kvaser_usb *dev, > const struct kvaser_cmd *cmd) > @@ -1178,19 +1178,19 @@ static void kvaser_usb_hydra_rx_msg_std(const struct kvaser_usb *dev, > } > > if (flags & KVASER_USB_HYDRA_CF_FLAG_OVERRUN) > kvaser_usb_can_rx_over_error(priv->netdev); > > - cf->can_dlc = can_get_cc_len(cmd->rx_can.dlc); > + cf->len = can_get_cc_len(cmd->rx_can.dlc); > > if (flags & KVASER_USB_HYDRA_CF_FLAG_REMOTE_FRAME) > cf->can_id |= CAN_RTR_FLAG; > else > - memcpy(cf->data, cmd->rx_can.data, cf->can_dlc); > + memcpy(cf->data, cmd->rx_can.data, cf->len); > > stats->rx_packets++; > - stats->rx_bytes += cf->can_dlc; > + stats->rx_bytes += cf->len; > netif_rx(skb); > } > > static void kvaser_usb_hydra_rx_msg_ext(const struct kvaser_usb *dev, > const struct kvaser_cmd_ext *cmd) > @@ -1432,11 +1432,11 @@ kvaser_usb_hydra_frame_to_cmd_std(const struct kvaser_usb_net_priv *priv, > struct kvaser_cmd *cmd; > struct can_frame *cf = (struct can_frame *)skb->data; > u32 flags; > u32 id; > > - *frame_len = cf->can_dlc; > + *frame_len = cf->len; > > cmd = kcalloc(1, sizeof(struct kvaser_cmd), GFP_ATOMIC); > if (!cmd) > return NULL; > > @@ -1453,11 +1453,11 @@ kvaser_usb_hydra_frame_to_cmd_std(const struct kvaser_usb_net_priv *priv, > id |= KVASER_USB_HYDRA_EXTENDED_FRAME_ID; > } else { > id = cf->can_id & CAN_SFF_MASK; > } > > - cmd->tx_can.dlc = cf->can_dlc; > + cmd->tx_can.dlc = cf->len; > > flags = (cf->can_id & CAN_EFF_FLAG ? > KVASER_USB_HYDRA_CF_FLAG_EXTENDED_ID : 0); > > if (cf->can_id & CAN_RTR_FLAG) > diff --git a/drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c b/drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c > index dcc5aa022e8f..493a33bbe2df 100644 > --- a/drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c > +++ b/drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c > @@ -348,11 +348,11 @@ kvaser_usb_leaf_frame_to_cmd(const struct kvaser_usb_net_priv *priv, > struct kvaser_usb *dev = priv->dev; > struct kvaser_cmd *cmd; > u8 *cmd_tx_can_flags = NULL; /* GCC */ > struct can_frame *cf = (struct can_frame *)skb->data; > > - *frame_len = cf->can_dlc; > + *frame_len = cf->len; > > cmd = kmalloc(sizeof(*cmd), GFP_ATOMIC); > if (cmd) { > cmd->u.tx_can.tid = transid & 0xff; > cmd->len = *cmd_len = CMD_HEADER_LEN + > @@ -381,12 +381,12 @@ kvaser_usb_leaf_frame_to_cmd(const struct kvaser_usb_net_priv *priv, > cmd->id = CMD_TX_STD_MESSAGE; > cmd->u.tx_can.data[0] = (cf->can_id >> 6) & 0x1f; > cmd->u.tx_can.data[1] = cf->can_id & 0x3f; > } > > - cmd->u.tx_can.data[5] = cf->can_dlc; > - memcpy(&cmd->u.tx_can.data[6], cf->data, cf->can_dlc); > + cmd->u.tx_can.data[5] = cf->len; > + memcpy(&cmd->u.tx_can.data[6], cf->data, cf->len); > > if (cf->can_id & CAN_RTR_FLAG) > *cmd_tx_can_flags |= MSG_FLAG_REMOTE_FRAME; > } > return cmd; > @@ -574,11 +574,11 @@ static void kvaser_usb_leaf_tx_acknowledge(const struct kvaser_usb *dev, > skb = alloc_can_err_skb(priv->netdev, &cf); > if (skb) { > cf->can_id |= CAN_ERR_RESTARTED; > > stats->rx_packets++; > - stats->rx_bytes += cf->can_dlc; > + stats->rx_bytes += cf->len; > netif_rx(skb); > } else { > netdev_err(priv->netdev, > "No memory left for err_skb\n"); > } > @@ -692,11 +692,11 @@ kvaser_usb_leaf_rx_error_update_can_state(struct kvaser_usb_net_priv *priv, > static void kvaser_usb_leaf_rx_error(const struct kvaser_usb *dev, > const struct kvaser_usb_err_summary *es) > { > struct can_frame *cf; > struct can_frame tmp_cf = { .can_id = CAN_ERR_FLAG, > - .can_dlc = CAN_ERR_DLC }; > + .len = CAN_ERR_DLC }; > struct sk_buff *skb; > struct net_device_stats *stats; > struct kvaser_usb_net_priv *priv; > enum can_state old_state, new_state; > > @@ -776,11 +776,11 @@ static void kvaser_usb_leaf_rx_error(const struct kvaser_usb *dev, > > cf->data[6] = es->txerr; > cf->data[7] = es->rxerr; > > stats->rx_packets++; > - stats->rx_bytes += cf->can_dlc; > + stats->rx_bytes += cf->len; > netif_rx(skb); > } > > /* For USBCAN, report error to userspace if the channels's errors counter > * has changed, or we're the only channel seeing a bus error state. > @@ -976,17 +976,17 @@ static void kvaser_usb_leaf_rx_can_msg(const struct kvaser_usb *dev, > if (cf->can_id & KVASER_EXTENDED_FRAME) > cf->can_id &= CAN_EFF_MASK | CAN_EFF_FLAG; > else > cf->can_id &= CAN_SFF_MASK; > > - cf->can_dlc = can_get_cc_len(cmd->u.leaf.log_message.dlc); > + cf->len = can_get_cc_len(cmd->u.leaf.log_message.dlc); > > if (cmd->u.leaf.log_message.flags & MSG_FLAG_REMOTE_FRAME) > cf->can_id |= CAN_RTR_FLAG; > else > memcpy(cf->data, &cmd->u.leaf.log_message.data, > - cf->can_dlc); > + cf->len); > } else { > cf->can_id = ((rx_data[0] & 0x1f) << 6) | (rx_data[1] & 0x3f); > > if (cmd->id == CMD_RX_EXT_MESSAGE) { > cf->can_id <<= 18; > @@ -994,20 +994,20 @@ static void kvaser_usb_leaf_rx_can_msg(const struct kvaser_usb *dev, > ((rx_data[3] & 0xff) << 6) | > (rx_data[4] & 0x3f); > cf->can_id |= CAN_EFF_FLAG; > } > > - cf->can_dlc = can_get_cc_len(rx_data[5]); > + cf->len = can_get_cc_len(rx_data[5]); > > if (cmd->u.rx_can_header.flag & MSG_FLAG_REMOTE_FRAME) > cf->can_id |= CAN_RTR_FLAG; > else > - memcpy(cf->data, &rx_data[6], cf->can_dlc); > + memcpy(cf->data, &rx_data[6], cf->len); > } > > stats->rx_packets++; > - stats->rx_bytes += cf->can_dlc; > + stats->rx_bytes += cf->len; > netif_rx(skb); > } > > static void kvaser_usb_leaf_start_chip_reply(const struct kvaser_usb *dev, > const struct kvaser_cmd *cmd) > diff --git a/drivers/net/can/usb/mcba_usb.c b/drivers/net/can/usb/mcba_usb.c > index 14352718b004..3d5bd8b0fbd3 100644 > --- a/drivers/net/can/usb/mcba_usb.c > +++ b/drivers/net/can/usb/mcba_usb.c > @@ -182,11 +182,11 @@ static inline struct mcba_usb_ctx *mcba_usb_get_free_ctx(struct mcba_priv *priv, > ctx = &priv->tx_context[i]; > ctx->ndx = i; > > if (cf) { > ctx->can = true; > - ctx->dlc = cf->can_dlc; > + ctx->dlc = cf->len; > } else { > ctx->can = false; > ctx->dlc = 0; > } > > @@ -348,11 +348,11 @@ static netdev_tx_t mcba_usb_start_xmit(struct sk_buff *skb, > put_unaligned_be16((cf->can_id & CAN_SFF_MASK) << 5, > &usb_msg.sid); > usb_msg.eid = 0; > } > > - usb_msg.dlc = cf->can_dlc; > + usb_msg.dlc = cf->len; > > memcpy(usb_msg.data, cf->data, usb_msg.dlc); > > if (cf->can_id & CAN_RTR_FLAG) > usb_msg.dlc |= MCBA_DLC_RTR_MASK; > @@ -449,16 +449,16 @@ static void mcba_usb_process_can(struct mcba_priv *priv, > } > > if (msg->dlc & MCBA_DLC_RTR_MASK) > cf->can_id |= CAN_RTR_FLAG; > > - cf->can_dlc = can_get_cc_len(msg->dlc & MCBA_DLC_MASK); > + cf->len = can_get_cc_len(msg->dlc & MCBA_DLC_MASK); > > - memcpy(cf->data, msg->data, cf->can_dlc); > + memcpy(cf->data, msg->data, cf->len); > > stats->rx_packets++; > - stats->rx_bytes += cf->can_dlc; > + stats->rx_bytes += cf->len; > > can_led_event(priv->netdev, CAN_LED_EVENT_RX); > netif_rx(skb); > } > > diff --git a/drivers/net/can/usb/peak_usb/pcan_usb.c b/drivers/net/can/usb/peak_usb/pcan_usb.c > index 5df74533ba4d..abecb77e34f2 100644 > --- a/drivers/net/can/usb/peak_usb/pcan_usb.c > +++ b/drivers/net/can/usb/peak_usb/pcan_usb.c > @@ -594,11 +594,11 @@ static int pcan_usb_decode_error(struct pcan_usb_msg_context *mc, u8 n, > peak_usb_get_ts_time(&mc->pdev->time_ref, mc->ts16, > &hwts->hwtstamp); > } > > mc->netdev->stats.rx_packets++; > - mc->netdev->stats.rx_bytes += cf->can_dlc; > + mc->netdev->stats.rx_bytes += cf->len; > netif_rx(skb); > > return 0; > } > > @@ -732,11 +732,11 @@ static int pcan_usb_decode_data(struct pcan_usb_msg_context *mc, u8 status_len) > mc->ptr += 2; > > cf->can_id = le16_to_cpu(tmp16) >> 5; > } > > - cf->can_dlc = can_get_cc_len(rec_len); > + cf->len = can_get_cc_len(rec_len); > > /* Only first packet timestamp is a word */ > if (pcan_usb_decode_ts(mc, !mc->rec_ts_idx)) > goto decode_failed; > > @@ -749,21 +749,21 @@ static int pcan_usb_decode_data(struct pcan_usb_msg_context *mc, u8 status_len) > cf->can_id |= CAN_RTR_FLAG; > } else { > if ((mc->ptr + rec_len) > mc->end) > goto decode_failed; > > - memcpy(cf->data, mc->ptr, cf->can_dlc); > + memcpy(cf->data, mc->ptr, cf->len); > mc->ptr += rec_len; > } > > /* convert timestamp into kernel time */ > hwts = skb_hwtstamps(skb); > peak_usb_get_ts_time(&mc->pdev->time_ref, mc->ts16, &hwts->hwtstamp); > > /* update statistics */ > mc->netdev->stats.rx_packets++; > - mc->netdev->stats.rx_bytes += cf->can_dlc; > + mc->netdev->stats.rx_bytes += cf->len; > /* push the skb */ > netif_rx(skb); > > return 0; > > @@ -836,11 +836,11 @@ static int pcan_usb_encode_msg(struct peak_usb_device *dev, struct sk_buff *skb, > obuf[1] = 1; > > pc = obuf + PCAN_USB_MSG_HEADER_LEN; > > /* status/len byte */ > - *pc = cf->can_dlc; > + *pc = cf->len; > if (cf->can_id & CAN_RTR_FLAG) > *pc |= PCAN_USB_STATUSLEN_RTR; > > /* can id */ > if (cf->can_id & CAN_EFF_FLAG) { > @@ -856,12 +856,12 @@ static int pcan_usb_encode_msg(struct peak_usb_device *dev, struct sk_buff *skb, > pc += 2; > } > > /* can data */ > if (!(cf->can_id & CAN_RTR_FLAG)) { > - memcpy(pc, cf->data, cf->can_dlc); > - pc += cf->can_dlc; > + memcpy(pc, cf->data, cf->len); > + pc += cf->len; > } > > obuf[(*size)-1] = (u8)(stats->tx_packets & 0xff); > > return 0; > diff --git a/drivers/net/can/usb/peak_usb/pcan_usb_fd.c b/drivers/net/can/usb/peak_usb/pcan_usb_fd.c > index 57dfa443c995..3e875cdbadac 100644 > --- a/drivers/net/can/usb/peak_usb/pcan_usb_fd.c > +++ b/drivers/net/can/usb/peak_usb/pcan_usb_fd.c > @@ -579,11 +579,11 @@ static int pcan_usb_fd_decode_status(struct pcan_usb_fd_if *usb_if, > return -ENOMEM; > > peak_usb_netif_rx(skb, &usb_if->time_ref, le32_to_cpu(sm->ts_low)); > > netdev->stats.rx_packets++; > - netdev->stats.rx_bytes += cf->can_dlc; > + netdev->stats.rx_bytes += cf->len; > > return 0; > } > > /* handle uCAN error message */ > @@ -735,11 +735,11 @@ static int pcan_usb_fd_encode_msg(struct peak_usb_device *dev, > struct sk_buff *skb, u8 *obuf, size_t *size) > { > struct pucan_tx_msg *tx_msg = (struct pucan_tx_msg *)obuf; > struct canfd_frame *cfd = (struct canfd_frame *)skb->data; > u16 tx_msg_size, tx_msg_flags; > - u8 can_dlc; > + u8 len; > > if (cfd->len > CANFD_MAX_DLEN) > return -EINVAL; > > tx_msg_size = ALIGN(sizeof(struct pucan_tx_msg) + cfd->len, 4); > @@ -754,29 +754,29 @@ static int pcan_usb_fd_encode_msg(struct peak_usb_device *dev, > tx_msg->can_id = cpu_to_le32(cfd->can_id & CAN_SFF_MASK); > } > > if (can_is_canfd_skb(skb)) { > /* considering a CANFD frame */ > - can_dlc = can_len2dlc(cfd->len); > + len = can_len2dlc(cfd->len); > > tx_msg_flags |= PUCAN_MSG_EXT_DATA_LEN; > > if (cfd->flags & CANFD_BRS) > tx_msg_flags |= PUCAN_MSG_BITRATE_SWITCH; > > if (cfd->flags & CANFD_ESI) > tx_msg_flags |= PUCAN_MSG_ERROR_STATE_IND; > } else { > /* CAND 2.0 frames */ > - can_dlc = cfd->len; > + len = cfd->len; > > if (cfd->can_id & CAN_RTR_FLAG) > tx_msg_flags |= PUCAN_MSG_RTR; > } > > tx_msg->flags = cpu_to_le16(tx_msg_flags); > - tx_msg->channel_dlc = PUCAN_MSG_CHANNEL_DLC(dev->ctrl_idx, can_dlc); > + tx_msg->channel_dlc = PUCAN_MSG_CHANNEL_DLC(dev->ctrl_idx, len); > memcpy(tx_msg->d, cfd->data, cfd->len); > > /* add null size message to tag the end (messages are 32-bits aligned) > */ > tx_msg = (struct pucan_tx_msg *)(obuf + tx_msg_size); > diff --git a/drivers/net/can/usb/peak_usb/pcan_usb_pro.c b/drivers/net/can/usb/peak_usb/pcan_usb_pro.c > index c7564773fb2b..275087c39602 100644 > --- a/drivers/net/can/usb/peak_usb/pcan_usb_pro.c > +++ b/drivers/net/can/usb/peak_usb/pcan_usb_pro.c > @@ -530,26 +530,26 @@ static int pcan_usb_pro_handle_canmsg(struct pcan_usb_pro_interface *usb_if, > skb = alloc_can_skb(netdev, &can_frame); > if (!skb) > return -ENOMEM; > > can_frame->can_id = le32_to_cpu(rx->id); > - can_frame->can_dlc = rx->len & 0x0f; > + can_frame->len = rx->len & 0x0f; > > if (rx->flags & PCAN_USBPRO_EXT) > can_frame->can_id |= CAN_EFF_FLAG; > > if (rx->flags & PCAN_USBPRO_RTR) > can_frame->can_id |= CAN_RTR_FLAG; > else > - memcpy(can_frame->data, rx->data, can_frame->can_dlc); > + memcpy(can_frame->data, rx->data, can_frame->len); > > hwts = skb_hwtstamps(skb); > peak_usb_get_ts_time(&usb_if->time_ref, le32_to_cpu(rx->ts32), > &hwts->hwtstamp); > > netdev->stats.rx_packets++; > - netdev->stats.rx_bytes += can_frame->can_dlc; > + netdev->stats.rx_bytes += can_frame->len; > netif_rx(skb); > > return 0; > } > > @@ -660,11 +660,11 @@ static int pcan_usb_pro_handle_error(struct pcan_usb_pro_interface *usb_if, > dev->can.state = new_state; > > hwts = skb_hwtstamps(skb); > peak_usb_get_ts_time(&usb_if->time_ref, le32_to_cpu(er->ts32), &hwts->hwtstamp); > netdev->stats.rx_packets++; > - netdev->stats.rx_bytes += can_frame->can_dlc; > + netdev->stats.rx_bytes += can_frame->len; > netif_rx(skb); > > return 0; > } > > @@ -765,18 +765,18 @@ static int pcan_usb_pro_encode_msg(struct peak_usb_device *dev, > u8 data_type, len, flags; > struct pcan_usb_pro_msg usb_msg; > > pcan_msg_init_empty(&usb_msg, obuf, *size); > > - if ((cf->can_id & CAN_RTR_FLAG) || (cf->can_dlc == 0)) > + if ((cf->can_id & CAN_RTR_FLAG) || (cf->len == 0)) > data_type = PCAN_USBPRO_TXMSG0; > - else if (cf->can_dlc <= 4) > + else if (cf->len <= 4) > data_type = PCAN_USBPRO_TXMSG4; > else > data_type = PCAN_USBPRO_TXMSG8; > > - len = (dev->ctrl_idx << 4) | (cf->can_dlc & 0x0f); > + len = (dev->ctrl_idx << 4) | (cf->len & 0x0f); > > flags = 0; > if (cf->can_id & CAN_EFF_FLAG) > flags |= 0x02; > if (cf->can_id & CAN_RTR_FLAG) > diff --git a/drivers/net/can/usb/ucan.c b/drivers/net/can/usb/ucan.c > index ea11a3f0392b..ef8f449ce475 100644 > --- a/drivers/net/can/usb/ucan.c > +++ b/drivers/net/can/usb/ucan.c > @@ -612,19 +612,19 @@ static void ucan_rx_can_msg(struct ucan_priv *up, struct ucan_message_in *m) > > /* fill the can frame */ > cf->can_id = canid; > > /* compute DLC taking RTR_FLAG into account */ > - cf->can_dlc = ucan_can_get_cc_len(&m->msg.can_msg, len); > + cf->len = ucan_can_get_cc_len(&m->msg.can_msg, len); > > /* copy the payload of non RTR frames */ > if (!(cf->can_id & CAN_RTR_FLAG) || (cf->can_id & CAN_ERR_FLAG)) > - memcpy(cf->data, m->msg.can_msg.data, cf->can_dlc); > + memcpy(cf->data, m->msg.can_msg.data, cf->len); > > /* don't count error frames as real packets */ > stats->rx_packets++; > - stats->rx_bytes += cf->can_dlc; > + stats->rx_bytes += cf->len; > > /* pass it to Linux */ > netif_rx(skb); > } > > @@ -1076,19 +1076,19 @@ static struct urb *ucan_prepare_tx_urb(struct ucan_priv *up, > > if (cf->can_id & CAN_RTR_FLAG) { > mlen = UCAN_OUT_HDR_SIZE + > offsetof(struct ucan_can_msg, dlc) + > sizeof(m->msg.can_msg.dlc); > - m->msg.can_msg.dlc = cf->can_dlc; > + m->msg.can_msg.dlc = cf->len; > } else { > mlen = UCAN_OUT_HDR_SIZE + > - sizeof(m->msg.can_msg.id) + cf->can_dlc; > - memcpy(m->msg.can_msg.data, cf->data, cf->can_dlc); > + sizeof(m->msg.can_msg.id) + cf->len; > + memcpy(m->msg.can_msg.data, cf->data, cf->len); > } > m->len = cpu_to_le16(mlen); > > - context->dlc = cf->can_dlc; > + context->dlc = cf->len; > > m->subtype = echo_index; > > /* build the urb */ > usb_fill_bulk_urb(urb, up->udev, > diff --git a/drivers/net/can/usb/usb_8dev.c b/drivers/net/can/usb/usb_8dev.c > index 9d1597ad7ba4..8aedb2ba37fb 100644 > --- a/drivers/net/can/usb/usb_8dev.c > +++ b/drivers/net/can/usb/usb_8dev.c > @@ -447,11 +447,11 @@ static void usb_8dev_rx_err_msg(struct usb_8dev_priv *priv, > > priv->bec.txerr = txerr; > priv->bec.rxerr = rxerr; > > stats->rx_packets++; > - stats->rx_bytes += cf->can_dlc; > + stats->rx_bytes += cf->len; > netif_rx(skb); > } > > /* Read data and status frames */ > static void usb_8dev_rx_can_msg(struct usb_8dev_priv *priv, > @@ -468,22 +468,22 @@ static void usb_8dev_rx_can_msg(struct usb_8dev_priv *priv, > skb = alloc_can_skb(priv->netdev, &cf); > if (!skb) > return; > > cf->can_id = be32_to_cpu(msg->id); > - cf->can_dlc = can_get_cc_len(msg->dlc & 0xF); > + cf->len = can_get_cc_len(msg->dlc & 0xF); > > if (msg->flags & USB_8DEV_EXTID) > cf->can_id |= CAN_EFF_FLAG; > > if (msg->flags & USB_8DEV_RTR) > cf->can_id |= CAN_RTR_FLAG; > else > - memcpy(cf->data, msg->data, cf->can_dlc); > + memcpy(cf->data, msg->data, cf->len); > > stats->rx_packets++; > - stats->rx_bytes += cf->can_dlc; > + stats->rx_bytes += cf->len; > netif_rx(skb); > > can_led_event(priv->netdev, CAN_LED_EVENT_RX); > } else { > netdev_warn(priv->netdev, "frame type %d unknown", > @@ -635,12 +635,12 @@ static netdev_tx_t usb_8dev_start_xmit(struct sk_buff *skb, > > if (cf->can_id & CAN_EFF_FLAG) > msg->flags |= USB_8DEV_EXTID; > > msg->id = cpu_to_be32(cf->can_id & CAN_ERR_MASK); > - msg->dlc = cf->can_dlc; > - memcpy(msg->data, cf->data, cf->can_dlc); > + msg->dlc = cf->len; > + memcpy(msg->data, cf->data, cf->len); > msg->end = USB_8DEV_DATA_END; > > for (i = 0; i < MAX_TX_URBS; i++) { > if (priv->tx_contexts[i].echo_index == MAX_TX_URBS) { > context = &priv->tx_contexts[i]; > @@ -654,11 +654,11 @@ static netdev_tx_t usb_8dev_start_xmit(struct sk_buff *skb, > if (!context) > goto nofreecontext; > > context->priv = priv; > context->echo_index = i; > - context->dlc = cf->can_dlc; > + context->dlc = cf->len; > > usb_fill_bulk_urb(urb, priv->udev, > usb_sndbulkpipe(priv->udev, USB_8DEV_ENDP_DATA_TX), > buf, size, usb_8dev_write_bulk_callback, context); > urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; > diff --git a/drivers/net/can/xilinx_can.c b/drivers/net/can/xilinx_can.c > index 1740fbc371c4..f8445f6dbb3a 100644 > --- a/drivers/net/can/xilinx_can.c > +++ b/drivers/net/can/xilinx_can.c > @@ -757,11 +757,11 @@ static int xcan_rx(struct net_device *ndev, int frame_base) > id_xcan = priv->read_reg(priv, XCAN_FRAME_ID_OFFSET(frame_base)); > dlc = priv->read_reg(priv, XCAN_FRAME_DLC_OFFSET(frame_base)) >> > XCAN_DLCR_DLC_SHIFT; > > /* Change Xilinx CAN data length format to socketCAN data format */ > - cf->can_dlc = can_get_cc_len(dlc); > + cf->len = can_get_cc_len(dlc); > > /* Change Xilinx CAN ID format to socketCAN ID format */ > if (id_xcan & XCAN_IDR_IDE_MASK) { > /* The received frame is an Extended format frame */ > cf->can_id = (id_xcan & XCAN_IDR_ID1_MASK) >> 3; > @@ -782,17 +782,17 @@ static int xcan_rx(struct net_device *ndev, int frame_base) > data[0] = priv->read_reg(priv, XCAN_FRAME_DW1_OFFSET(frame_base)); > data[1] = priv->read_reg(priv, XCAN_FRAME_DW2_OFFSET(frame_base)); > > if (!(cf->can_id & CAN_RTR_FLAG)) { > /* Change Xilinx CAN data format to socketCAN data format */ > - if (cf->can_dlc > 0) > + if (cf->len > 0) > *(__be32 *)(cf->data) = cpu_to_be32(data[0]); > - if (cf->can_dlc > 4) > + if (cf->len > 4) > *(__be32 *)(cf->data + 4) = cpu_to_be32(data[1]); > } > > - stats->rx_bytes += cf->can_dlc; > + stats->rx_bytes += cf->len; > stats->rx_packets++; > netif_receive_skb(skb); > > return 1; > } > @@ -968,11 +968,11 @@ static void xcan_update_error_state_after_rxtx(struct net_device *ndev) > > if (skb) { > struct net_device_stats *stats = &ndev->stats; > > stats->rx_packets++; > - stats->rx_bytes += cf->can_dlc; > + stats->rx_bytes += cf->len; > netif_rx(skb); > } > } > } > > diff --git a/include/linux/can/dev.h b/include/linux/can/dev.h > index 41b897965376..d045a0dc3dae 100644 > --- a/include/linux/can/dev.h > +++ b/include/linux/can/dev.h > @@ -183,12 +183,12 @@ static inline void can_set_static_ctrlmode(struct net_device *dev, > /* override MTU which was set by default in can_setup()? */ > if (static_mode & CAN_CTRLMODE_FD) > dev->mtu = CANFD_MTU; > } > > -/* get data length from can_dlc with sanitized can_dlc */ > -u8 can_dlc2len(u8 can_dlc); > +/* get data length from dlc with sanitized len */ > +u8 can_dlc2len(u8 dlc); unrealted? regards, Marc -- Pengutronix e.K. | Marc Kleine-Budde | Embedded Linux | https://www.pengutronix.de | Vertretung West/Dortmund | Phone: +49-231-2826-924 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
Attachment:
signature.asc
Description: OpenPGP digital signature