> -----Original Message----- > From: Marc Kleine-Budde <mkl@xxxxxxxxxxxxxx> > Sent: 2020年9月16日 6:16 > To: Joakim Zhang <qiangqing.zhang@xxxxxxx>; Michael Walle > <michael@xxxxxxxx> > Cc: linux-can@xxxxxxxxxxxxxxx; dl-linux-imx <linux-imx@xxxxxxx>; > netdev@xxxxxxxxxxxxxxx > Subject: Re: [PATCH linux-can-next/flexcan] can: flexcan: fix TDC feature > > On 6/30/20 4:25 AM, Joakim Zhang wrote: > > I have also noticed this difference, although this could not break > > function, but IMO, using priv->can.ctrlmode should be better. > > [...] > > 2) Clean timing register. > > --- a/drivers/net/can/flexcan.c > > +++ b/drivers/net/can/flexcan.c > > @@ -1167,6 +1167,14 @@ static void flexcan_set_bittiming_cbt(const > struct net_device *dev) > > struct flexcan_regs __iomem *regs = priv->regs; > > u32 reg_cbt, reg_fdctrl; > > > > + reg_cbt = priv->read(®s->cbt); > > + reg_cbt &= ~(FLEXCAN_CBT_BTF | > > + FIELD_PREP(FLEXCAN_CBT_EPRESDIV_MASK, 0x3ff) | > > + FIELD_PREP(FLEXCAN_CBT_ERJW_MASK, 0x1f) | > > + FIELD_PREP(FLEXCAN_CBT_EPROPSEG_MASK, 0x3f) | > > + FIELD_PREP(FLEXCAN_CBT_EPSEG1_MASK, 0x1f) | > > + FIELD_PREP(FLEXCAN_CBT_EPSEG2_MASK, 0x1f)); > > + > > Why is this needed? The "reg_cbt &=" sets reg_cbt basically to 0, as the fields > and the BTF occupy all 32bit. > > The only thing that's left over is the read().... Yes, need not, I have not noticed it has occupy the whole 32bit. There is a small improve patch to balance the usage_count if register flexcandev failed. Could you pick up it by the way this time? https://www.spinics.net/lists/linux-can/msg03052.html Best Regards, Joakim Zhang