forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-13 9d77db3c730780c8ef5ccd4b66403ff5675cfe4e
kernel/drivers/net/can/vcan.c
....@@ -1,5 +1,4 @@
1
-/*
2
- * vcan.c - Virtual CAN interface
1
+/* vcan.c - Virtual CAN interface
32 *
43 * Copyright (c) 2002-2017 Volkswagen Group Electronic Research
54 * All rights reserved.
....@@ -39,12 +38,15 @@
3938 *
4039 */
4140
41
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
42
+
4243 #include <linux/module.h>
4344 #include <linux/init.h>
4445 #include <linux/netdevice.h>
4546 #include <linux/if_arp.h>
4647 #include <linux/if_ether.h>
4748 #include <linux/can.h>
49
+#include <linux/can/can-ml.h>
4850 #include <linux/can/dev.h>
4951 #include <linux/can/skb.h>
5052 #include <linux/slab.h>
....@@ -57,9 +59,7 @@
5759 MODULE_AUTHOR("Urs Thuermann <urs.thuermann@volkswagen.de>");
5860 MODULE_ALIAS_RTNL_LINK(DRV_NAME);
5961
60
-
61
-/*
62
- * CAN test feature:
62
+/* CAN test feature:
6363 * Enable the echo on driver level for testing the CAN core echo modes.
6464 * See Documentation/networking/can.rst for details.
6565 */
....@@ -67,7 +67,6 @@
6767 static bool echo; /* echo testing. Default: 0 (Off) */
6868 module_param(echo, bool, 0444);
6969 MODULE_PARM_DESC(echo, "Echo sent frames (for testing). Default: 0 (Off)");
70
-
7170
7271 static void vcan_rx(struct sk_buff *skb, struct net_device *dev)
7372 {
....@@ -101,10 +100,8 @@
101100
102101 if (!echo) {
103102 /* no echo handling available inside this driver */
104
-
105103 if (loop) {
106
- /*
107
- * only count the packets here, because the
104
+ /* only count the packets here, because the
108105 * CAN core already did the echo for us
109106 */
110107 stats->rx_packets++;
....@@ -117,7 +114,6 @@
117114 /* perform standard echo handling for CAN network interfaces */
118115
119116 if (loop) {
120
-
121117 skb = can_create_echo_skb(skb);
122118 if (!skb)
123119 return NETDEV_TX_OK;
....@@ -157,6 +153,7 @@
157153 dev->addr_len = 0;
158154 dev->tx_queue_len = 0;
159155 dev->flags = IFF_NOARP;
156
+ can_set_ml_priv(dev, netdev_priv(dev));
160157
161158 /* set flags according to driver capabilities */
162159 if (echo)
....@@ -167,16 +164,17 @@
167164 }
168165
169166 static struct rtnl_link_ops vcan_link_ops __read_mostly = {
170
- .kind = DRV_NAME,
171
- .setup = vcan_setup,
167
+ .kind = DRV_NAME,
168
+ .priv_size = sizeof(struct can_ml_priv),
169
+ .setup = vcan_setup,
172170 };
173171
174172 static __init int vcan_init_module(void)
175173 {
176
- pr_info("vcan: Virtual CAN interface driver\n");
174
+ pr_info("Virtual CAN interface driver\n");
177175
178176 if (echo)
179
- printk(KERN_INFO "vcan: enabled echo on driver level.\n");
177
+ pr_info("enabled echo on driver level.\n");
180178
181179 return rtnl_link_register(&vcan_link_ops);
182180 }