aboutsummaryrefslogtreecommitdiffstats
path: root/net/can/raw.c
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2019-08-15 15:43:22 -0400
committerDavid S. Miller <davem@davemloft.net>2019-08-15 15:43:22 -0400
commit8714652fcd327df170e241394d5c83c38a2f0e27 (patch)
tree96cb74f1944d3f32c36ec13efcd9dba47f675682 /net/can/raw.c
parent8d73f8f23e6b869b726cb01dd4747f56dc88660a (diff)
parent3ca3c4aad2efa2931b663acc4ece7a38b31071d1 (diff)
Merge tag 'linux-can-next-for-5.4-20190814' of git://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can-next
Marc Kleine-Budde says: ==================== pull-request: can-next 2019-08-14 this is a pull request for net-next/master consisting of 41 patches. The first two patches are for the kvaser_pciefd driver: Christer Beskow removes unnecessary code in the kvaser_pciefd_pwm_stop() function, YueHaibing removes the unused including of <linux/version.h>. In the next patch YueHaibing also removes the unused including of <linux/version.h> in the f81601 driver. In the ti_hecc driver the next 6 patches are by me and fix checkpatch warnings. YueHaibing's patch removes an unused variable in the ti_hecc_mailbox_read() function. The next 6 patches all target the xilinx_can driver. Anssi Hannula's patch fixes a chip start failure with an invalid bus. The patch by Venkatesh Yadav Abbarapu skips an error message in case of a deferred probe. The 3 patches by Appana Durga Kedareswara rao fix the RX and TX path for CAN-FD frames. Srinivas Neeli's patch fixes the bit timing calculations for CAN-FD. The next 12 patches are by me and several checkpatch warnings in the af_can, raw and bcm components. Thomas Gleixner provides a patch for the bcm, which switches the timer to HRTIMER_MODE_SOFT and removes the hrtimer_tasklet. Then 6 more patches by me for the gw component, which fix checkpatch warnings, followed by 2 patches by Oliver Hartkopp to add CAN-FD support. The vcan driver gets 3 patches by me, fixing checkpatch warnings. And finally a patch by Andre Hartmann to fix typos in CAN's netlink header. ====================
Diffstat (limited to 'net/can/raw.c')
-rw-r--r--net/can/raw.c34
1 files changed, 16 insertions, 18 deletions
diff --git a/net/can/raw.c b/net/can/raw.c
index da386f1fa815..fdbc36140e9b 100644
--- a/net/can/raw.c
+++ b/net/can/raw.c
@@ -1,6 +1,5 @@
1// SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) 1// SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause)
2/* 2/* raw.c - Raw sockets for protocol family CAN
3 * raw.c - Raw sockets for protocol family CAN
4 * 3 *
5 * Copyright (c) 2002-2007 Volkswagen Group Electronic Research 4 * Copyright (c) 2002-2007 Volkswagen Group Electronic Research
6 * All rights reserved. 5 * All rights reserved.
@@ -65,8 +64,7 @@ MODULE_ALIAS("can-proto-1");
65 64
66#define MASK_ALL 0 65#define MASK_ALL 0
67 66
68/* 67/* A raw socket has a list of can_filters attached to it, each receiving
69 * A raw socket has a list of can_filters attached to it, each receiving
70 * the CAN frames matching that filter. If the filter list is empty, 68 * the CAN frames matching that filter. If the filter list is empty,
71 * no CAN frames will be received by the socket. The default after 69 * no CAN frames will be received by the socket. The default after
72 * opening the socket, is to have one filter which receives all frames. 70 * opening the socket, is to have one filter which receives all frames.
@@ -97,8 +95,7 @@ struct raw_sock {
97 struct uniqframe __percpu *uniq; 95 struct uniqframe __percpu *uniq;
98}; 96};
99 97
100/* 98/* Return pointer to store the extra msg flags for raw_recvmsg().
101 * Return pointer to store the extra msg flags for raw_recvmsg().
102 * We use the space of one unsigned int beyond the 'struct sockaddr_can' 99 * We use the space of one unsigned int beyond the 'struct sockaddr_can'
103 * in skb->cb. 100 * in skb->cb.
104 */ 101 */
@@ -157,8 +154,7 @@ static void raw_rcv(struct sk_buff *oskb, void *data)
157 if (!skb) 154 if (!skb)
158 return; 155 return;
159 156
160 /* 157 /* Put the datagram to the queue so that raw_recvmsg() can
161 * Put the datagram to the queue so that raw_recvmsg() can
162 * get it from there. We need to pass the interface index to 158 * get it from there. We need to pass the interface index to
163 * raw_recvmsg(). We pass a whole struct sockaddr_can in skb->cb 159 * raw_recvmsg(). We pass a whole struct sockaddr_can in skb->cb
164 * containing the interface index. 160 * containing the interface index.
@@ -284,7 +280,6 @@ static int raw_notifier(struct notifier_block *nb,
284 return NOTIFY_DONE; 280 return NOTIFY_DONE;
285 281
286 switch (msg) { 282 switch (msg) {
287
288 case NETDEV_UNREGISTER: 283 case NETDEV_UNREGISTER:
289 lock_sock(sk); 284 lock_sock(sk);
290 /* remove current filters & unregister */ 285 /* remove current filters & unregister */
@@ -370,8 +365,9 @@ static int raw_release(struct socket *sock)
370 raw_disable_allfilters(dev_net(dev), dev, sk); 365 raw_disable_allfilters(dev_net(dev), dev, sk);
371 dev_put(dev); 366 dev_put(dev);
372 } 367 }
373 } else 368 } else {
374 raw_disable_allfilters(sock_net(sk), NULL, sk); 369 raw_disable_allfilters(sock_net(sk), NULL, sk);
370 }
375 } 371 }
376 372
377 if (ro->count > 1) 373 if (ro->count > 1)
@@ -451,8 +447,9 @@ static int raw_bind(struct socket *sock, struct sockaddr *uaddr, int len)
451 dev, sk); 447 dev, sk);
452 dev_put(dev); 448 dev_put(dev);
453 } 449 }
454 } else 450 } else {
455 raw_disable_allfilters(sock_net(sk), NULL, sk); 451 raw_disable_allfilters(sock_net(sk), NULL, sk);
452 }
456 } 453 }
457 ro->ifindex = ifindex; 454 ro->ifindex = ifindex;
458 ro->bound = 1; 455 ro->bound = 1;
@@ -503,7 +500,6 @@ static int raw_setsockopt(struct socket *sock, int level, int optname,
503 return -EINVAL; 500 return -EINVAL;
504 501
505 switch (optname) { 502 switch (optname) {
506
507 case CAN_RAW_FILTER: 503 case CAN_RAW_FILTER:
508 if (optlen % sizeof(struct can_filter) != 0) 504 if (optlen % sizeof(struct can_filter) != 0)
509 return -EINVAL; 505 return -EINVAL;
@@ -666,17 +662,18 @@ static int raw_getsockopt(struct socket *sock, int level, int optname,
666 return -EINVAL; 662 return -EINVAL;
667 663
668 switch (optname) { 664 switch (optname) {
669
670 case CAN_RAW_FILTER: 665 case CAN_RAW_FILTER:
671 lock_sock(sk); 666 lock_sock(sk);
672 if (ro->count > 0) { 667 if (ro->count > 0) {
673 int fsize = ro->count * sizeof(struct can_filter); 668 int fsize = ro->count * sizeof(struct can_filter);
669
674 if (len > fsize) 670 if (len > fsize)
675 len = fsize; 671 len = fsize;
676 if (copy_to_user(optval, ro->filter, len)) 672 if (copy_to_user(optval, ro->filter, len))
677 err = -EFAULT; 673 err = -EFAULT;
678 } else 674 } else {
679 len = 0; 675 len = 0;
676 }
680 release_sock(sk); 677 release_sock(sk);
681 678
682 if (!err) 679 if (!err)
@@ -743,8 +740,9 @@ static int raw_sendmsg(struct socket *sock, struct msghdr *msg, size_t size)
743 return -EINVAL; 740 return -EINVAL;
744 741
745 ifindex = addr->can_ifindex; 742 ifindex = addr->can_ifindex;
746 } else 743 } else {
747 ifindex = ro->ifindex; 744 ifindex = ro->ifindex;
745 }
748 746
749 dev = dev_get_by_index(sock_net(sk), ifindex); 747 dev = dev_get_by_index(sock_net(sk), ifindex);
750 if (!dev) 748 if (!dev)
@@ -837,8 +835,8 @@ static int raw_recvmsg(struct socket *sock, struct msghdr *msg, size_t size,
837 return size; 835 return size;
838} 836}
839 837
840int raw_sock_no_ioctlcmd(struct socket *sock, unsigned int cmd, 838static int raw_sock_no_ioctlcmd(struct socket *sock, unsigned int cmd,
841 unsigned long arg) 839 unsigned long arg)
842{ 840{
843 /* no ioctls for socket layer -> hand it down to NIC layer */ 841 /* no ioctls for socket layer -> hand it down to NIC layer */
844 return -ENOIOCTLCMD; 842 return -ENOIOCTLCMD;
@@ -887,7 +885,7 @@ static __init int raw_module_init(void)
887 885
888 err = can_proto_register(&raw_can_proto); 886 err = can_proto_register(&raw_can_proto);
889 if (err < 0) 887 if (err < 0)
890 printk(KERN_ERR "can: registration of raw protocol failed\n"); 888 pr_err("can: registration of raw protocol failed\n");
891 889
892 return err; 890 return err;
893} 891}