can: Unify MTU settings for CAN interfaces
authorOliver Hartkopp <socketcan@hartkopp.net>
Fri, 7 Mar 2014 08:23:41 +0000 (09:23 +0100)
committerMarc Kleine-Budde <mkl@pengutronix.de>
Mon, 17 Mar 2014 08:20:16 +0000 (09:20 +0100)
CAN interfaces only support MTU values of 16 (CAN 2.0) and 72 (CAN FD).
Setting the MTU to other values is pointless but it does not really hurt.
With the introduction of the CAN FD support in drivers/net/can a new
function to switch the MTU for CAN FD has been introduced.

This patch makes use of this can_change_mtu() function to check for correct
MTU settings also in legacy CAN (2.0) devices.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
19 files changed:
drivers/net/can/at91_can.c
drivers/net/can/bfin_can.c
drivers/net/can/c_can/c_can.c
drivers/net/can/cc770/cc770.c
drivers/net/can/flexcan.c
drivers/net/can/grcan.c
drivers/net/can/janz-ican3.c
drivers/net/can/mcp251x.c
drivers/net/can/mscan/mscan.c
drivers/net/can/pch_can.c
drivers/net/can/sja1000/sja1000.c
drivers/net/can/slcan.c
drivers/net/can/softing/softing_main.c
drivers/net/can/ti_hecc.c
drivers/net/can/usb/ems_usb.c
drivers/net/can/usb/esd_usb2.c
drivers/net/can/usb/kvaser_usb.c
drivers/net/can/usb/peak_usb/pcan_usb_core.c
drivers/net/can/usb/usb_8dev.c

index 1d00b95f8983c0a22dfe5b30af7f2e1f3dccd7a5..f07fa89b5fd5b294a5a234e949985080a0617a1d 100644 (file)
@@ -1194,6 +1194,7 @@ static const struct net_device_ops at91_netdev_ops = {
        .ndo_open       = at91_open,
        .ndo_stop       = at91_close,
        .ndo_start_xmit = at91_start_xmit,
+       .ndo_change_mtu = can_change_mtu,
 };
 
 static ssize_t at91_sysfs_show_mb0_id(struct device *dev,
index 8d2b89a12e09b5f19c35757fc7fddb75689395e5..543ecceb33e91341ca0a6651e92d3dcbce1d0978 100644 (file)
@@ -528,6 +528,7 @@ static const struct net_device_ops bfin_can_netdev_ops = {
        .ndo_open               = bfin_can_open,
        .ndo_stop               = bfin_can_close,
        .ndo_start_xmit         = bfin_can_start_xmit,
+       .ndo_change_mtu         = can_change_mtu,
 };
 
 static int bfin_can_probe(struct platform_device *pdev)
index 951bfede8f3d80b7026b2bfba219d5c3e092f210..9c32e9ef76942192fd94fca634a6565468458946 100644 (file)
@@ -1277,6 +1277,7 @@ static const struct net_device_ops c_can_netdev_ops = {
        .ndo_open = c_can_open,
        .ndo_stop = c_can_close,
        .ndo_start_xmit = c_can_start_xmit,
+       .ndo_change_mtu = can_change_mtu,
 };
 
 int register_c_can_dev(struct net_device *dev)
index 0f12abf6591ce79bdc30b1f69844f7d811ac5d1e..d8379278d648a2160f63d386eb5056dc47d70b7a 100644 (file)
@@ -823,6 +823,7 @@ static const struct net_device_ops cc770_netdev_ops = {
        .ndo_open = cc770_open,
        .ndo_stop = cc770_close,
        .ndo_start_xmit = cc770_start_xmit,
+       .ndo_change_mtu = can_change_mtu,
 };
 
 int register_cc770dev(struct net_device *dev)
index c94d698b73c2d85bfcc23823d4d453e0d5a491b6..f425ec2c7839de4abe1a481cf94d0fd03435c845 100644 (file)
@@ -1011,6 +1011,7 @@ static const struct net_device_ops flexcan_netdev_ops = {
        .ndo_open       = flexcan_open,
        .ndo_stop       = flexcan_close,
        .ndo_start_xmit = flexcan_start_xmit,
+       .ndo_change_mtu = can_change_mtu,
 };
 
 static int register_flexcandev(struct net_device *dev)
index ab506d6cab37743a6e207e6bfc3899db749b5148..3fd9fd942c6ef0b38ddaca66492c115f5f5ea771 100644 (file)
@@ -1578,6 +1578,7 @@ static const struct net_device_ops grcan_netdev_ops = {
        .ndo_open       = grcan_open,
        .ndo_stop       = grcan_close,
        .ndo_start_xmit = grcan_start_xmit,
+       .ndo_change_mtu = can_change_mtu,
 };
 
 static int grcan_setup_netdev(struct platform_device *ofdev,
index b47df5e482fa596aea172d3667fcaceb2064fbab..2382c04dc7807d9c513e64bc1b4f4a2c0ea181e1 100644 (file)
@@ -1594,6 +1594,7 @@ static const struct net_device_ops ican3_netdev_ops = {
        .ndo_open       = ican3_open,
        .ndo_stop       = ican3_stop,
        .ndo_start_xmit = ican3_xmit,
+       .ndo_change_mtu = can_change_mtu,
 };
 
 /*
index 50aa630c7dd4fdaded13a0fe558a9501ee279efe..a8b74f8da03d5c716d4870610802e20c604fef5c 100644 (file)
@@ -996,6 +996,7 @@ static const struct net_device_ops mcp251x_netdev_ops = {
        .ndo_open = mcp251x_open,
        .ndo_stop = mcp251x_stop,
        .ndo_start_xmit = mcp251x_hard_start_xmit,
+       .ndo_change_mtu = can_change_mtu,
 };
 
 static const struct of_device_id mcp251x_of_match[] = {
index b9f3faabb0f30ecbc466664ec6e5ca564fa52409..e0c9be5e2ab74676e8e3bb9fe026b145d3f4d3ab 100644 (file)
@@ -647,9 +647,10 @@ static int mscan_close(struct net_device *dev)
 }
 
 static const struct net_device_ops mscan_netdev_ops = {
-       .ndo_open               = mscan_open,
-       .ndo_stop               = mscan_close,
-       .ndo_start_xmit         = mscan_start_xmit,
+       .ndo_open       = mscan_open,
+       .ndo_stop       = mscan_close,
+       .ndo_start_xmit = mscan_start_xmit,
+       .ndo_change_mtu = can_change_mtu,
 };
 
 int register_mscandev(struct net_device *dev, int mscan_clksrc)
index 6c077eb87b5e90c98b9431bd5dcb3238685ee1ef..6472562efedc921468212f8b8300b88dff6f2e95 100644 (file)
@@ -950,6 +950,7 @@ static const struct net_device_ops pch_can_netdev_ops = {
        .ndo_open               = pch_can_open,
        .ndo_stop               = pch_close,
        .ndo_start_xmit         = pch_xmit,
+       .ndo_change_mtu         = can_change_mtu,
 };
 
 static void pch_can_remove(struct pci_dev *pdev)
index 55cce4737518ae0f11270caeacaa70f88512f165..f31499a32d7dcf4fde4eb1a0864af4f15bfb6118 100644 (file)
@@ -642,9 +642,10 @@ void free_sja1000dev(struct net_device *dev)
 EXPORT_SYMBOL_GPL(free_sja1000dev);
 
 static const struct net_device_ops sja1000_netdev_ops = {
-       .ndo_open               = sja1000_open,
-       .ndo_stop               = sja1000_close,
-       .ndo_start_xmit         = sja1000_start_xmit,
+       .ndo_open       = sja1000_open,
+       .ndo_stop       = sja1000_close,
+       .ndo_start_xmit = sja1000_start_xmit,
+       .ndo_change_mtu = can_change_mtu,
 };
 
 int register_sja1000dev(struct net_device *dev)
index 3fcdae266377a8141546f239ff805160d6cadbb9..f5b16e0e3a125f4e38a93408e92b8218808339af 100644 (file)
@@ -411,10 +411,16 @@ static void slc_free_netdev(struct net_device *dev)
        slcan_devs[i] = NULL;
 }
 
+static int slcan_change_mtu(struct net_device *dev, int new_mtu)
+{
+       return -EINVAL;
+}
+
 static const struct net_device_ops slc_netdev_ops = {
        .ndo_open               = slc_open,
        .ndo_stop               = slc_close,
        .ndo_start_xmit         = slc_xmit,
+       .ndo_change_mtu         = slcan_change_mtu,
 };
 
 static void slc_setup(struct net_device *dev)
index 9ea0dcde94ce0fe948fd3f059a9084516c8beaee..3766bd90f3ed9e5d93844199e131a9acc0e6f725 100644 (file)
@@ -628,6 +628,7 @@ static const struct net_device_ops softing_netdev_ops = {
        .ndo_open = softing_netdev_open,
        .ndo_stop = softing_netdev_stop,
        .ndo_start_xmit = softing_netdev_start_xmit,
+       .ndo_change_mtu = can_change_mtu,
 };
 
 static const struct can_bittiming_const softing_btr_const = {
index 2c62fe6c8fa967382796e99bbe1b85c37cd12916..258b9c4856ec6c1726c0e78a64becf19ae8c40d9 100644 (file)
@@ -871,6 +871,7 @@ static const struct net_device_ops ti_hecc_netdev_ops = {
        .ndo_open               = ti_hecc_open,
        .ndo_stop               = ti_hecc_close,
        .ndo_start_xmit         = ti_hecc_xmit,
+       .ndo_change_mtu         = can_change_mtu,
 };
 
 static int ti_hecc_probe(struct platform_device *pdev)
index 52c42fd49510014f909b63efefa9ba1891dc8e11..00f2534dde736f1dd8cda9b016bd6a78f79eeab0 100644 (file)
@@ -883,6 +883,7 @@ static const struct net_device_ops ems_usb_netdev_ops = {
        .ndo_open = ems_usb_open,
        .ndo_stop = ems_usb_close,
        .ndo_start_xmit = ems_usb_start_xmit,
+       .ndo_change_mtu = can_change_mtu,
 };
 
 static const struct can_bittiming_const ems_usb_bittiming_const = {
index 7fbe85935f1d1071e7efbd917797a3da19938a70..1f8ce91adbd3307646415590327aec77ff250fa7 100644 (file)
@@ -888,6 +888,7 @@ static const struct net_device_ops esd_usb2_netdev_ops = {
        .ndo_open = esd_usb2_open,
        .ndo_stop = esd_usb2_close,
        .ndo_start_xmit = esd_usb2_start_xmit,
+       .ndo_change_mtu = can_change_mtu,
 };
 
 static const struct can_bittiming_const esd_usb2_bittiming_const = {
index e77d11049747047a3824d7e9a1dc32fc004f552d..ea596b53a5ae7e71d585829c0c60cd9fe59c1824 100644 (file)
@@ -1388,6 +1388,7 @@ static const struct net_device_ops kvaser_usb_netdev_ops = {
        .ndo_open = kvaser_usb_open,
        .ndo_stop = kvaser_usb_close,
        .ndo_start_xmit = kvaser_usb_start_xmit,
+       .ndo_change_mtu = can_change_mtu,
 };
 
 static const struct can_bittiming_const kvaser_usb_bittiming_const = {
index 0b7a4c3b01a2976176878607bd457a9ea282e21e..93e4a55a6c236948ca1d065ea1a540a0b829f175 100644 (file)
@@ -702,6 +702,7 @@ static const struct net_device_ops peak_usb_netdev_ops = {
        .ndo_open = peak_usb_ndo_open,
        .ndo_stop = peak_usb_ndo_stop,
        .ndo_start_xmit = peak_usb_ndo_start_xmit,
+       .ndo_change_mtu = can_change_mtu,
 };
 
 /*
index a0fa1fd5092ba8243dcba8c6abfa67eac0f60694..cde263459932aff184d919b1881de5c9885831fa 100644 (file)
@@ -887,6 +887,7 @@ static const struct net_device_ops usb_8dev_netdev_ops = {
        .ndo_open = usb_8dev_open,
        .ndo_stop = usb_8dev_close,
        .ndo_start_xmit = usb_8dev_start_xmit,
+       .ndo_change_mtu = can_change_mtu,
 };
 
 static const struct can_bittiming_const usb_8dev_bittiming_const = {