Patch "can: pcan_usb: don't provide CAN FD bittimings by non-FD adapters" has been added to the 4.1-stable tree
Subsystems (2)
This is a note to let you know that I've just added the patch titled
can: pcan_usb: don't provide CAN FD bittimings by non-FD adapters
to the 4.1-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
can-pcan_usb-don-t-provide-can-fd-bittimings-by-non-fd-adapters.patch
and it can be found in the queue-4.1 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 1 line
From
06b23f7fbbf26a025fd68395c7586949db586b47Mon Sep 17 00:00:00 2001
From: Marc Kleine-Budde <[email protected]>
Date: Thu, 6 Aug 2015 09:48:34 +0200
Subject: can: pcan_usb: don't provide CAN FD bittimings by non-FD adapters
From: Marc Kleine-Budde <[email protected]>
commit 06b23f7fbbf26a025fd68395c7586949db586b47 upstream.
The CAN FD data bittiming constants are provided via netlink only when there are valid CAN FD constants available in priv->data_bittiming_const.
Due to the indirection of pointer assignments in the peak_usb driver the priv->data_bittiming_const never becomes NULL - not even for non-FD adapters.
The data_bittiming_const points to zero'ed data which leads to this result when running 'ip -details link show can0':
35: can0: <NOARP,ECHO> mtu 16 qdisc noop state DOWN mode DEFAULT group default qlen 10
link/can promiscuity 0
can state STOPPED restart-ms 0
pcan_usb: tseg1 1..16 tseg2 1..8 sjw 1..4 brp 1..64 brp-inc 1
: dtseg1 0..0 dtseg2 0..0 dsjw 1..0 dbrp 0..0 dbrp-inc 0 <== BROKEN!
clock 8000000This patch changes the struct peak_usb_adapter::bittiming_const and struct peak_usb_adapter::data_bittiming_const to pointers to fix the assignemnt problems.
--- drivers/net/can/usb/peak_usb/pcan_usb.c | 24 +++--- drivers/net/can/usb/peak_usb/pcan_usb_core.c | 4 - drivers/net/can/usb/peak_usb/pcan_usb_core.h | 4 - drivers/net/can/usb/peak_usb/pcan_usb_fd.c | 96 ++++++++++++++------------- drivers/net/can/usb/peak_usb/pcan_usb_pro.c | 24 +++--- 5 files changed, 82 insertions(+), 70 deletions(-)
drivers/net/can/usb/peak_usb/pcan_usb.c +13 -11
@@ -855,6 +855,18 @@ static int pcan_usb_probe(struct usb_int/* * describe the PCAN-USB adapter */ +static const struct can_bittiming_const pcan_usb_const = { + .name ="pcan_usb" , + .tseg1_min =1 , + .tseg1_max =16 , + .tseg2_min =1 , + .tseg2_max =8 , + .sjw_max =4 , + .brp_min =1 , + .brp_max =64 , + .brp_inc =1 , +}; +const struct peak_usb_adapter pcan_usb = { .name ="PCAN-USB" , .device_id =PCAN_USB_PRODUCT_ID ,
@@ -863,17 +875,7 @@ const struct peak_usb_adapter pcan_usb = .clock = { .freq = PCAN_USB_CRYSTAL_HZ / 2 , }, - .bittiming_const = { - .name = "pcan_usb", - .tseg1_min = 1, - .tseg1_max = 16, - .tseg2_min = 1, - .tseg2_max = 8, - .sjw_max = 4, - .brp_min = 1, - .brp_max = 64, - .brp_inc = 1, - }, + .bittiming_const = &pcan_usb_const,/* size of device private data */ .sizeof_dev_private = sizeof(struct pcan_usb),
drivers/net/can/usb/peak_usb/pcan_usb_core.c +2 -2
@@ -792,9 +792,9 @@ static int peak_usb_create_dev(const str dev->ep_msg_out = peak_usb_adapter->ep_msg_out[ctrl_idx]; dev->can.clock = peak_usb_adapter->clock; - dev->can.bittiming_const = &peak_usb_adapter->bittiming_const; + dev->can.bittiming_const = peak_usb_adapter->bittiming_const; dev->can.do_set_bittiming = peak_usb_set_bittiming; - dev->can.data_bittiming_const = &peak_usb_adapter->data_bittiming_const; + dev->can.data_bittiming_const = peak_usb_adapter->data_bittiming_const; dev->can.do_set_data_bittiming = peak_usb_set_data_bittiming; dev->can.do_set_mode = peak_usb_set_mode; dev->can.do_get_berr_counter = peak_usb_adapter->do_get_berr_counter;
drivers/net/can/usb/peak_usb/pcan_usb_core.h +2 -2
@@ -48,8 +48,8 @@ struct peak_usb_adapter {u32 device_id;u32 ctrlmode_supported;struct can_clock clock; -const struct can_bittiming_const bittiming_const; -const struct can_bittiming_const data_bittiming_const; +const struct can_bittiming_const *const bittiming_const; +const struct can_bittiming_const *const data_bittiming_const;unsigned int ctrl_count;int (*intf_probe)(struct usb_interface *intf);
drivers/net/can/usb/peak_usb/pcan_usb_fd.c +52 -44
120 lines not on this page · raw message
drivers/net/can/usb/peak_usb/pcan_usb_pro.c +13 -11
@@ -1004,6 +1004,18 @@ int pcan_usb_pro_probe(struct usb_interf/* * describe the PCAN-USB Pro adapter */ +static const struct can_bittiming_const pcan_usb_pro_const = { + .name ="pcan_usb_pro" , + .tseg1_min =1 , + .tseg1_max =16 , + .tseg2_min =1 , + .tseg2_max =8 , + .sjw_max =4 , + .brp_min =1 , + .brp_max =1024 , + .brp_inc =1 , +}; +const struct peak_usb_adapter pcan_usb_pro = { .name ="PCAN-USB Pro" , .device_id =PCAN_USBPRO_PRODUCT_ID ,
@@ -1012,17 +1024,7 @@ const struct peak_usb_adapter pcan_usb_p .clock = { .freq = PCAN_USBPRO_CRYSTAL_HZ, }, - .bittiming_const = { - .name = "pcan_usb_pro", - .tseg1_min = 1, - .tseg1_max = 16, - .tseg2_min = 1, - .tseg2_max = 8, - .sjw_max = 4, - .brp_min = 1, - .brp_max = 1024, - .brp_inc = 1, - }, + .bittiming_const = &pcan_usb_pro_const,/* size of device private data */ .sizeof_dev_private = sizeof(struct pcan_usb_pro_device),
Patches currently in stable-queue which might be from [email protected] are
queue-4.1/can-pcan_usb-don-t-provide-can-fd-bittimings-by-non-fd-adapters.patch