Re: [PATCH v7] can, tty: can327 CAN/ldisc driver for ELM327 based OBD-II adapters
From: Vincent Mailhol
Date: Fri Jun 03 2022 - 11:47:25 EST
On Sat. 4 June 2022 at 00:12, Vincent Mailhol <vincent.mailhol@xxxxxxxxx> wrote:
> Hi Max,
>
> I gave a final deep look into your driver. I found a few things which
> went through the cracks of my previous reviews. But overall, it start
> to look good. Well done and looking forward for the v8.
>
> On Fri. 3 June 2022 at 06:36, Max Staudt <max@xxxxxxxxx> wrote:
> > This is the can327 driver. It does a surprisingly good job at turning
> > ELM327 based OBD-II interfaces into cheap CAN interfaces for simple
> > homebrew projects.
> >
> > Please see the included documentation for details and limitations:
> > Documentation/networking/device_drivers/can/can327.rst
> >
> > Cc: linux-can <linux-can@xxxxxxxxxxxxxxx>
> > Signed-off-by: Max Staudt <max@xxxxxxxxx>
> > ---
[...]
> > diff --git a/drivers/net/can/can327.c b/drivers/net/can/can327.c
> > new file mode 100644
> > index 000000000000..e29031ad825d
> > --- /dev/null
> > +++ b/drivers/net/can/can327.c
> > @@ -0,0 +1,1158 @@
> > +// SPDX-License-Identifier: GPL-2.0
> > +/* ELM327 based CAN interface driver (tty line discipline)
> > + *
> > + * This driver started as a derivative of linux/drivers/net/can/slcan.c
> > + * and my thanks go to the original authors for their inspiration.
> > + *
> > + * can327.c Author : Max Staudt <max-linux@xxxxxxxxx>
> > + * slcan.c Author : Oliver Hartkopp <socketcan@xxxxxxxxxxxx>
> > + * slip.c Authors : Laurence Culhane <loz@xxxxxxxxxxxxxxxxxx>
> > + * Fred N. van Kempen <waltje@xxxxxxxxxxxxxxxxxxx>
> > + */
> > +
> > +#define pr_fmt(fmt) "can327: " fmt
> > +
> > +#include <linux/init.h>
> > +#include <linux/module.h>
> > +#include <linux/moduleparam.h>
>
> linux/moduleparam.h is not needed, right? Please make sure to clean up
> unused headers.
>
> > +
> > +#include <linux/atomic.h>
> > +#include <linux/bitops.h>
> > +#include <linux/ctype.h>
> > +#include <linux/delay.h>
> > +#include <linux/errno.h>
> > +#include <linux/if_ether.h>
> > +#include <linux/kernel.h>
> > +#include <linux/list.h>
> > +#include <linux/lockdep.h>
> > +#include <linux/netdevice.h>
> > +#include <linux/skbuff.h>
> > +#include <linux/spinlock.h>
> > +#include <linux/string.h>
> > +#include <linux/tty.h>
> > +#include <linux/tty_ldisc.h>
> > +#include <linux/workqueue.h>
> > +
> > +#include <uapi/linux/tty.h>
> > +
> > +#include <linux/can.h>
> > +#include <linux/can/dev.h>
> > +#include <linux/can/error.h>
> > +#include <linux/can/led.h>
>
> Rebase on net-next (or can-next) and remove CAN LED. c.f.:
> https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git/commit/?id=6c1e423a3c84953edcf91ff03ab97829b287184a
>
> > +#include <linux/can/rx-offload.h>
> > +
> > +#define ELM327_NAPI_WEIGHT 4
> > +
> > +#define ELM327_SIZE_RXBUF 224
> > +#define ELM327_SIZE_TXBUF 32
> > +
> > +#define ELM327_CAN_CONFIG_SEND_SFF 0x8000
> > +#define ELM327_CAN_CONFIG_VARIABLE_DLC 0x4000
> > +#define ELM327_CAN_CONFIG_RECV_BOTH_SFF_EFF 0x2000
> > +#define ELM327_CAN_CONFIG_BAUDRATE_MULT_8_7 0x1000
This ELM327_CAN_CONFIG_BAUDRATE_MULT_8_7 macro is not used.
> > +#define ELM327_DUMMY_CHAR 'y'
> > +#define ELM327_DUMMY_STRING "y"
> > +#define ELM327_READY_CHAR '>'
Yours sincerely,
Vincent Mailhol