On 25.02.2025 16:16:41, Ming Yu wrote: [...] > diff --git a/drivers/net/can/usb/nct6694_canfd.c b/drivers/net/can/usb/nct6694_canfd.c > new file mode 100644 > index 000000000000..d97fce5cdf32 > --- /dev/null > +++ b/drivers/net/can/usb/nct6694_canfd.c [...] > +static const struct can_bittiming_const nct6694_can_bittiming_nominal_const = { > + .name = DRVNAME, > + .tseg1_min = 2, > + .tseg1_max = 256, > + .tseg2_min = 2, > + .tseg2_max = 128, > + .sjw_max = 128, > + .brp_min = 1, > + .brp_max = 511, > + .brp_inc = 1, > +}; > + > +static const struct can_bittiming_const nct6694_can_bittiming_data_const = { > + .name = DRVNAME, > + .tseg1_min = 1, > + .tseg1_max = 32, > + .tseg2_min = 1, > + .tseg2_max = 16, > + .sjw_max = 16, > + .brp_min = 1, > + .brp_max = 31, > + .brp_inc = 1, > +}; [...] > +static int nct6694_can_start(struct net_device *ndev) > +{ > + struct nct6694_can_priv *priv = netdev_priv(ndev); > + const struct can_bittiming *d_bt = &priv->can.data_bittiming; > + const struct can_bittiming *n_bt = &priv->can.bittiming; > + struct nct6694_can_setting *setting __free(kfree) = NULL; > + const struct nct6694_cmd_header cmd_hd = { > + .mod = NCT6694_CAN_MOD, > + .cmd = NCT6694_CAN_SETTING, > + .sel = ndev->dev_port, > + .len = cpu_to_le16(sizeof(*setting)) > + }; > + int ret; > + > + setting = kzalloc(sizeof(*setting), GFP_KERNEL); > + if (!setting) > + return -ENOMEM; > + > + setting->nbr = cpu_to_le32(n_bt->bitrate); > + setting->dbr = cpu_to_le32(d_bt->bitrate); I just noticed one thing that needs clarification/documentation. You have nct6694_can_bittiming_nominal_const and nct6694_can_bittiming_data_const, but only pass the bit rates to your device. Do the bit timing const really reflect the HW limitations of your device? Are you sure your device uses the same algorithm as the kernel and calculates the same bit timing parameters as the kernel, so that the values given to the user space reflects the bit timing parameter chosen by your device? > + > + if (priv->can.ctrlmode & CAN_CTRLMODE_LISTENONLY) > + setting->ctrl1 |= cpu_to_le16(NCT6694_CAN_SETTING_CTRL1_MON); > + > + if (priv->can.ctrlmode & CAN_CTRLMODE_FD_NON_ISO) > + setting->ctrl1 |= cpu_to_le16(NCT6694_CAN_SETTING_CTRL1_NISO); > + > + if (priv->can.ctrlmode & CAN_CTRLMODE_LOOPBACK) > + setting->ctrl1 |= cpu_to_le16(NCT6694_CAN_SETTING_CTRL1_LBCK); > + > + ret = nct6694_write_msg(priv->nct6694, &cmd_hd, setting); > + if (ret) > + return ret; > + > + priv->can.state = CAN_STATE_ERROR_ACTIVE; > + > + return 0; > +} regards, Marc -- Pengutronix e.K. | Marc Kleine-Budde | Embedded Linux | https://www.pengutronix.de | Vertretung Nürnberg | Phone: +49-5121-206917-129 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-9 |
Attachment:
signature.asc
Description: PGP signature