From nobody Fri Sep 19 07:01:45 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A3F68C352A1 for ; Sun, 27 Nov 2022 19:18:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229606AbiK0TSr (ORCPT ); Sun, 27 Nov 2022 14:18:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51966 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229540AbiK0TSm (ORCPT ); Sun, 27 Nov 2022 14:18:42 -0500 X-Greylist: delayed 905 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Sun, 27 Nov 2022 11:18:39 PST Received: from fritzc.com (mail.fritzc.com [IPv6:2a00:17d8:100::e31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 05D583A0; Sun, 27 Nov 2022 11:18:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=fritzc.com; s=dkim; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=4e0iHFbEGY3EtXZ64Kag7bjeqDn+/ViV93p9+8ED/ss=; b=CXns89WK0t1Pe6jS5ZDr4nj/Cx hMJtswiO7CuX/nhOyrOU1u76yvW7plb6OcYOKrQLZ69SqKWQUndXqX0hK2hTDlSqIQ6pRsXBqpm1A vdgcNG3PhtGBTnuDnvZVJwJAQnbBZ4V7FOZYNWnPo7UmDNP3lxVnfcb7/1mgBKiDxyqY=; Received: from 127.0.0.1 by fritzc.com with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim latest) (envelope-from ) id 1ozMvj-000XD6-DQ; Sun, 27 Nov 2022 20:03:08 +0100 From: Christoph Fritz To: Oliver Hartkopp , Pavel Pisa , Richard Weinberger , Andreas Lauser , Wolfgang Grandegger , Marc Kleine-Budde , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jonathan Corbet Cc: linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] [RFC] can: Introduce LIN bus as CANFD abstraction Date: Sun, 27 Nov 2022 20:02:43 +0100 Message-Id: <20221127190244.888414-2-christoph.fritz@hexdev.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221127190244.888414-1-christoph.fritz@hexdev.de> References: <20221127190244.888414-1-christoph.fritz@hexdev.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam_score: -1.0 X-Spam_bar: - Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" This patch adds a LIN bus abstraction ontop of CANFD. It is a glue driver adapting CAN on one side while offering LIN abstraction on the other side. So that upcoming LIN device drivers can make use of it. Signed-off-by: Christoph Fritz --- drivers/net/can/Kconfig | 10 ++ drivers/net/can/Makefile | 1 + drivers/net/can/lin.c | 181 +++++++++++++++++++++++++++++++ include/net/lin.h | 30 +++++ include/uapi/linux/can.h | 1 + include/uapi/linux/can/netlink.h | 1 + 6 files changed, 224 insertions(+) create mode 100644 drivers/net/can/lin.c create mode 100644 include/net/lin.h diff --git a/drivers/net/can/Kconfig b/drivers/net/can/Kconfig index 3048ad77edb3..d091994ea4fe 100644 --- a/drivers/net/can/Kconfig +++ b/drivers/net/can/Kconfig @@ -152,6 +152,16 @@ config CAN_KVASER_PCIEFD Kvaser Mini PCI Express HS v2 Kvaser Mini PCI Express 2xHS v2 =20 +config CAN_LIN + tristate "LIN mode support" + help + This is a glue driver for LIN-BUS support. + + The local interconnect (LIN) bus is a simple bus with a feature + subset of CAN. It is often combined with CAN for simple controls. + + Actual device drivers need to be enabled too. + config CAN_SLCAN tristate "Serial / USB serial CAN Adaptors (slcan)" depends on TTY diff --git a/drivers/net/can/Makefile b/drivers/net/can/Makefile index 61c75ce9d500..9114d9e97c0c 100644 --- a/drivers/net/can/Makefile +++ b/drivers/net/can/Makefile @@ -23,6 +23,7 @@ obj-$(CONFIG_CAN_GRCAN) +=3D grcan.o obj-$(CONFIG_CAN_IFI_CANFD) +=3D ifi_canfd/ obj-$(CONFIG_CAN_JANZ_ICAN3) +=3D janz-ican3.o obj-$(CONFIG_CAN_KVASER_PCIEFD) +=3D kvaser_pciefd.o +obj-$(CONFIG_CAN_LIN) +=3D lin.o obj-$(CONFIG_CAN_MSCAN) +=3D mscan/ obj-$(CONFIG_CAN_M_CAN) +=3D m_can/ obj-$(CONFIG_CAN_PEAK_PCIEFD) +=3D peak_canfd/ diff --git a/drivers/net/can/lin.c b/drivers/net/can/lin.c new file mode 100644 index 000000000000..25eaccc18ab6 --- /dev/null +++ b/drivers/net/can/lin.c @@ -0,0 +1,181 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2022 hexDEV GmbH + */ +#include +#include +#include +#include +#include +#include +#include + +static void lin_tx_work_handler(struct work_struct *ws) +{ + struct lin_device *priv =3D container_of(ws, struct lin_device, + tx_work); + struct net_device *net =3D priv->net; + struct device *dev =3D priv->dev; + struct canfd_frame *frame; + u8 id, n; + + priv->tx_busy =3D true; + + frame =3D (struct canfd_frame *)priv->tx_skb->data; + id =3D (u8)frame->can_id & 0xff; + n =3D frame->len; + + priv->lindev_ops->ldo_tx(dev, id, n, frame->data); + priv->tx_busy =3D false; + netif_wake_queue(net); +} + +static netdev_tx_t lin_start_xmit(struct sk_buff *skb, + struct net_device *netdev) +{ + struct lin_device *priv =3D netdev_priv(netdev); + + if (priv->tx_busy) + return NETDEV_TX_BUSY; + + netif_stop_queue(netdev); + priv->tx_skb =3D skb; + queue_work(priv->wq, &priv->tx_work); + + return NETDEV_TX_OK; +} + +static int lin_open(struct net_device *netdev) +{ + struct lin_device *priv =3D netdev_priv(netdev); + int ret; + + priv->tx_busy =3D false; + + ret =3D open_candev(netdev); + if (ret) + return ret; + + netif_wake_queue(netdev); + + return 0; +} + +static int lin_stop(struct net_device *net) +{ + close_candev(net); + + return 0; +} + +static const struct net_device_ops lin_netdev_ops =3D { + .ndo_open =3D lin_open, + .ndo_stop =3D lin_stop, + .ndo_start_xmit =3D lin_start_xmit, + .ndo_change_mtu =3D can_change_mtu, +}; + +int lin_rx(struct lin_device *priv, u8 id, u8 n, u8 *data, u8 checksum) +{ + struct net_device *ndev =3D priv->net; + struct net_device_stats *stats =3D &ndev->stats; + struct canfd_frame *cfd; + struct sk_buff *skb; + + skb =3D alloc_canfd_skb(ndev, &cfd); + if (unlikely(!skb)) { + stats->rx_dropped++; + return -ENOMEM; + } + + cfd->flags =3D CANFD_LIN; + cfd->can_id =3D id; + cfd->len =3D n + 1; /* n of data + checksum */ + memcpy(cfd->data, data, n); + cfd->data[n] =3D checksum; + + stats->rx_bytes +=3D cfd->len; + stats->rx_packets++; + + netif_receive_skb(skb); + + return 0; +} +EXPORT_SYMBOL_GPL(lin_rx); + +static int lin_set_bittiming(struct net_device *netdev) +{ + struct lin_device *priv =3D netdev_priv(netdev); + struct device *dev =3D priv->dev; + int ret; + + ret =3D priv->lindev_ops->update_bitrate(dev, priv->can.bittiming.bitrate= ); + + return ret; +} + +static const u32 lin_bitrate[] =3D { 2400, 4800, 9600, 19200 }; + +struct lin_device *register_lin(struct device *dev, + const struct lin_device_ops *ldops) +{ + struct net_device *ndev; + struct lin_device *priv; + int ret; + + ndev =3D alloc_candev(sizeof(struct lin_device), 1); + if (!ndev) + return NULL; + + ndev->netdev_ops =3D &lin_netdev_ops; + ndev->flags |=3D IFF_ECHO; + ndev->mtu =3D CANFD_MTU; + + priv =3D netdev_priv(ndev); + priv->lindev_ops =3D ldops; + priv->can.bittiming.bitrate =3D 9600; + priv->can.ctrlmode_supported =3D CAN_CTRLMODE_LIN; + priv->can.bitrate_const =3D lin_bitrate; + priv->can.bitrate_const_cnt =3D ARRAY_SIZE(lin_bitrate); + priv->can.do_set_bittiming =3D lin_set_bittiming; + priv->net =3D ndev; + priv->dev =3D dev; + + SET_NETDEV_DEV(ndev, dev); + + ret =3D register_candev(ndev); + if (ret) + goto exit_free; + + priv->wq =3D alloc_workqueue(dev_name(dev), WQ_FREEZABLE | WQ_MEM_RECLAIM, + 0); + if (!priv->wq) { + ret =3D -ENOMEM; + goto exit_free; + } + INIT_WORK(&priv->tx_work, lin_tx_work_handler); + + netdev_info(ndev, "LIN initialized.\n"); + + return priv; + +exit_free: + free_candev(ndev); + return NULL; +} +EXPORT_SYMBOL_GPL(register_lin); + +void unregister_lin(struct lin_device *priv) +{ + unregister_candev(priv->net); + + destroy_workqueue(priv->wq); + priv->wq =3D NULL; + + free_candev(priv->net); +} +EXPORT_SYMBOL_GPL(unregister_lin); + +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("Christoph Fritz "); +MODULE_DESCRIPTION("LIN bus to CAN glue driver"); diff --git a/include/net/lin.h b/include/net/lin.h new file mode 100644 index 000000000000..d3264844ce16 --- /dev/null +++ b/include/net/lin.h @@ -0,0 +1,30 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +#ifndef _NET_LIN_H_ +#define _NET_LIN_H_ + +#include +#include + +struct lin_device_ops { + int (*ldo_tx)(struct device *dev, u8 id, u8 n, u8 *data); + int (*update_bitrate)(struct device *dev, u16 bitrate); +}; + +struct lin_device { + struct can_priv can; + struct net_device *net; + const struct lin_device_ops *lindev_ops; + struct device *dev; + struct workqueue_struct *wq; + struct work_struct tx_work; + bool tx_busy; + struct sk_buff *tx_skb; +}; + +int lin_rx(struct lin_device *dev, u8 id, u8 n, u8 *bytes, u8 checksum); + +struct lin_device *register_lin(struct device *dev, + const struct lin_device_ops *ldops); +void unregister_lin(struct lin_device *lbd); + +#endif /* _NET_LIN_H_ */ diff --git a/include/uapi/linux/can.h b/include/uapi/linux/can.h index 90801ada2bbe..8596f9b23c68 100644 --- a/include/uapi/linux/can.h +++ b/include/uapi/linux/can.h @@ -147,6 +147,7 @@ struct can_frame { #define CANFD_BRS 0x01 /* bit rate switch (second bitrate for payload data= ) */ #define CANFD_ESI 0x02 /* error state indicator of the transmitting node */ #define CANFD_FDF 0x04 /* mark CAN FD for dual use of struct canfd_frame */ +#define CANFD_LIN 0x08 /* indicate LIN mode */ =20 /** * struct canfd_frame - CAN flexible data rate frame structure diff --git a/include/uapi/linux/can/netlink.h b/include/uapi/linux/can/netl= ink.h index 02ec32d69474..d65a24b2aa3c 100644 --- a/include/uapi/linux/can/netlink.h +++ b/include/uapi/linux/can/netlink.h @@ -103,6 +103,7 @@ struct can_ctrlmode { #define CAN_CTRLMODE_CC_LEN8_DLC 0x100 /* Classic CAN DLC option */ #define CAN_CTRLMODE_TDC_AUTO 0x200 /* CAN transiver automatically calcul= ates TDCV */ #define CAN_CTRLMODE_TDC_MANUAL 0x400 /* TDCV is manually set up by user = */ +#define CAN_CTRLMODE_LIN 0x800 /* LIN BUS mode */ =20 /* * CAN device statistics --=20 2.30.2 From nobody Fri Sep 19 07:01:45 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5BCC9C352A1 for ; Sun, 27 Nov 2022 19:18:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229632AbiK0TSv (ORCPT ); Sun, 27 Nov 2022 14:18:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52018 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229597AbiK0TSq (ORCPT ); Sun, 27 Nov 2022 14:18:46 -0500 Received: from fritzc.com (mail.fritzc.com [IPv6:2a00:17d8:100::e31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9EAFFDFEF; Sun, 27 Nov 2022 11:18:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=fritzc.com; s=dkim; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=C/vENORAh9FTRnO+WBV63DAMfi0IBlkeZpSgVUwP8Vc=; b=L9zthdNTNF7Omfx30tZyp7qmOH olQ9qIAJCYxrrfaxU2A3PPvTZlVH4Jfxs61Hj0HGSchDrhANRKn/ORZK+IfqR5ZQZu/a0si2HUg7r ZEqzFn4azZxHT1MKLuObVHBy44gDLrC7u0b3dqZyVdVQR/OGmutpN3id+xLY7Sf+dm4o=; Received: from 127.0.0.1 by fritzc.com with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim latest) (envelope-from ) id 1ozMvl-000XD6-WF; Sun, 27 Nov 2022 20:03:10 +0100 From: Christoph Fritz To: Oliver Hartkopp , Pavel Pisa , Richard Weinberger , Andreas Lauser , Wolfgang Grandegger , Marc Kleine-Budde , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jonathan Corbet Cc: linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] [RFC] can: Add LIN proto skeleton Date: Sun, 27 Nov 2022 20:02:44 +0100 Message-Id: <20221127190244.888414-3-christoph.fritz@hexdev.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221127190244.888414-1-christoph.fritz@hexdev.de> References: <20221127190244.888414-1-christoph.fritz@hexdev.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam_score: -1.0 X-Spam_bar: - Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Richard Weinberger Signed-off-by: Richard Weinberger --- include/uapi/linux/can.h | 7 +- include/uapi/linux/can/lin.h | 15 +++ net/can/Kconfig | 5 + net/can/Makefile | 3 + net/can/lin.c | 207 +++++++++++++++++++++++++++++++++++ 5 files changed, 236 insertions(+), 1 deletion(-) create mode 100644 include/uapi/linux/can/lin.h create mode 100644 net/can/lin.c diff --git a/include/uapi/linux/can.h b/include/uapi/linux/can.h index 8596f9b23c68..73526805dc5f 100644 --- a/include/uapi/linux/can.h +++ b/include/uapi/linux/can.h @@ -178,7 +178,8 @@ struct canfd_frame { #define CAN_MCNET 5 /* Bosch MCNet */ #define CAN_ISOTP 6 /* ISO 15765-2 Transport Protocol */ #define CAN_J1939 7 /* SAE J1939 */ -#define CAN_NPROTO 8 +#define CAN_LIN 8 /* LIN Bus */ +#define CAN_NPROTO 9 =20 #define SOL_CAN_BASE 100 =20 @@ -212,6 +213,10 @@ struct sockaddr_can { __u8 addr; } j1939; =20 + struct { + __u8 addr; //Dummy for now + } lin; + /* reserved for future CAN protocols address information */ } can_addr; }; diff --git a/include/uapi/linux/can/lin.h b/include/uapi/linux/can/lin.h new file mode 100644 index 000000000000..7e9f44992b7d --- /dev/null +++ b/include/uapi/linux/can/lin.h @@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: (GPL-2.0-only WITH Linux-syscall-note) */ +/* + * linux/can/lin.h + * TODO + */ + +#ifndef _UAPI_CAN_LIN_H +#define _UAPI_CAN_LIN_H + +#include +#include + +#define SOL_CAN_LIN (SOL_CAN_BASE + CAN_LIN) + +#endif /* !_UAPI_CAN_LIN_H */ diff --git a/net/can/Kconfig b/net/can/Kconfig index cb56be8e3862..d05e3fa813e2 100644 --- a/net/can/Kconfig +++ b/net/can/Kconfig @@ -70,4 +70,9 @@ config CAN_ISOTP If you want to perform automotive vehicle diagnostic services (UDS), say 'y'. =20 +config CAN_LIN + tristate "Support for LIN bus" + help + TODO + endif diff --git a/net/can/Makefile b/net/can/Makefile index 58f2c31c1ef3..5db51a56a78a 100644 --- a/net/can/Makefile +++ b/net/can/Makefile @@ -20,3 +20,6 @@ obj-$(CONFIG_CAN_J1939) +=3D j1939/ =20 obj-$(CONFIG_CAN_ISOTP) +=3D can-isotp.o can-isotp-y :=3D isotp.o + +obj-$(CONFIG_CAN_LIN) +=3D can-lin.o +can-lin-y :=3D lin.o diff --git a/net/can/lin.c b/net/can/lin.c new file mode 100644 index 000000000000..f8c8217efc8c --- /dev/null +++ b/net/can/lin.c @@ -0,0 +1,207 @@ +// SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause) + +//TODO copyright + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +MODULE_DESCRIPTION("PF_CAN LIN protocol"); +MODULE_LICENSE("GPLv2"); +MODULE_ALIAS("can-proto-8"); + +struct lin_sock { + struct sock sk; +}; + +static inline struct lin_sock *lin_sk(const struct sock *sk) +{ + return (struct lin_sock *)sk; +} + +static int lin_release(struct socket *sock) +{ + struct sock *sk =3D sock->sk; + struct lin_sock *so; + struct net *net; + + if (!sk) + return 0; + + so =3D lin_sk(sk); + net =3D sock_net(sk); + + // Nothing do to so far + + sock_orphan(sk); + sock->sk =3D NULL; + + release_sock(sk); + sock_put(sk); + + return 0; +} + +static int lin_bind(struct socket *sock, struct sockaddr *uaddr, int len) +{ + struct sockaddr_can *addr =3D (struct sockaddr_can *)uaddr; + struct sock *sk =3D sock->sk; + struct net *net =3D sock_net(sk); + struct net_device *dev; + int err =3D 0; + + //TODO + dev =3D dev_get_by_index(net, addr->can_ifindex); + if (!dev) { + err =3D -ENODEV; + goto out; + } + if (dev->type !=3D ARPHRD_CAN) { + dev_put(dev); + err =3D -ENODEV; + goto out; + } + +out: + return err; +} + +static int lin_setsockopt_locked(struct socket *sock, int level, int optna= me, + sockptr_t optval, unsigned int optlen) +{ + struct sock *sk =3D sock->sk; + struct lin_sock *so =3D lin_sk(sk); + int ret =3D 0; + + (void)so; + + switch (optname) { + // Nothing to do so far + default: + ret =3D -ENOPROTOOPT; + } + + return ret; +} + +static int lin_setsockopt(struct socket *sock, int level, int optname, + sockptr_t optval, unsigned int optlen) + +{ + struct sock *sk =3D sock->sk; + int ret; + + if (level !=3D SOL_CAN_LIN) + return -EINVAL; + + lock_sock(sk); + ret =3D lin_setsockopt_locked(sock, level, optname, optval, optlen); + release_sock(sk); + return ret; +} + +static int lin_getsockopt(struct socket *sock, int level, int optname, + char __user *optval, int __user *optlen) +{ + struct sock *sk =3D sock->sk; + struct lin_sock *so =3D lin_sk(sk); + int len; + void *val; + + (void)so; + + if (level !=3D SOL_CAN_LIN) + return -EINVAL; + if (get_user(len, optlen)) + return -EFAULT; + if (len < 0) + return -EINVAL; + + switch (optname) { + //Nothing to do so far. + default: + return -ENOPROTOOPT; + } + + if (put_user(len, optlen)) + return -EFAULT; + if (copy_to_user(optval, val, len)) + return -EFAULT; + return 0; +} + +static int lin_init(struct sock *sk) +{ + struct lin_sock *so =3D lin_sk(sk); + + (void)so; + // Nothing to do so far + + return 0; +} + +static const struct proto_ops lin_ops =3D { + .family =3D PF_CAN, + .release =3D lin_release, + .bind =3D lin_bind, + .connect =3D sock_no_connect, + .socketpair =3D sock_no_socketpair, + .accept =3D sock_no_accept, + .getname =3D sock_no_getname, + .poll =3D datagram_poll, + .ioctl =3D sock_no_ioctl, + .gettstamp =3D sock_gettstamp, + .listen =3D sock_no_listen, + .shutdown =3D sock_no_shutdown, + .setsockopt =3D lin_setsockopt, + .getsockopt =3D lin_getsockopt, + .sendmsg =3D sock_no_sendmsg, + .recvmsg =3D sock_no_recvmsg, + .mmap =3D sock_no_mmap, + .sendpage =3D sock_no_sendpage, +}; + +static struct proto lin_proto __read_mostly =3D { + .name =3D "CAN_LIN", + .owner =3D THIS_MODULE, + .obj_size =3D sizeof(struct lin_sock), + .init =3D lin_init, +}; + +static const struct can_proto lin_can_proto =3D { + .type =3D SOCK_DGRAM, + .protocol =3D CAN_LIN, + .ops =3D &lin_ops, + .prot =3D &lin_proto, +}; + +static __init int lin_module_init(void) +{ + pr_info("can: lin protocol\n"); + + return can_proto_register(&lin_can_proto); +} + +static __exit void lin_module_exit(void) +{ + can_proto_unregister(&lin_can_proto); +} + +module_init(lin_module_init); +module_exit(lin_module_exit); --=20 2.30.2