aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/can/usb/kvaser_usb (follow)
AgeCommit message (Collapse)AuthorFilesLines
2021-05-27can: kvaser_usb: Add new Kvaser hydra devicesJimmy Assarsson1-1/+5
Add new Kvaser hydra devices. Link: https://lore.kernel.org/r/20210429093730.499263-2-extja@kvaser.com Signed-off-by: Jimmy Assarsson <extja@kvaser.com> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2021-05-27can: kvaser_usb: Rename define USB_HYBRID_{,PRO_}CANLIN_PRODUCT_IDJimmy Assarsson1-4/+4
Rename define USB_HYBRID_{,PRO_}CANLIN_PRODUCT_ID to USB_HYBRID_{,PRO_}2CANLIN_PRODUCT_ID, to reflect the channel count. Link: https://lore.kernel.org/r/20210429093730.499263-1-extja@kvaser.com Signed-off-by: Jimmy Assarsson <extja@kvaser.com> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2021-03-30can: dev: can_free_echo_skb(): extend to return can frame lengthMarc Kleine-Budde1-1/+1
In order to implement byte queue limits (bql) in CAN drivers, the length of the CAN frame needs to be passed into the networking stack even if the transmission failed for some reason. To avoid to calculate this length twice, extend can_free_echo_skb() to return that value. Convert all users of this function, too. This patch is the natural extension of commit: | 9420e1d495e2 ("can: dev: can_get_echo_skb(): extend to return can | frame length") Link: https://lore.kernel.org/r/20210319142700.305648-3-mkl@pengutronix.de Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2021-03-16can: kvaser_usb: Add support for USBcan Pro 4xHSJimmy Assarsson1-1/+3
Add support for Kvaser USBcan Pro 4xHS. Link: https://lore.kernel.org/r/20210309091724.31262-2-jimmyassarsson@gmail.com Signed-off-by: Jimmy Assarsson <extja@kvaser.com> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2021-01-14can: dev: can_get_echo_skb(): extend to return can frame lengthMarc Kleine-Budde2-2/+2
In order to implement byte queue limits (bql) in CAN drivers, the length of the CAN frame needs to be passed into the networking stack after queueing and after transmission completion. To avoid to calculate this length twice, extend can_get_echo_skb() to return that value. Convert all users of this function, too. Reviewed-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr> Link: https://lore.kernel.org/r/20210111141930.693847-14-mkl@pengutronix.de Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2021-01-14can: dev: can_put_echo_skb(): extend to handle frame_lenVincent Mailhol1-1/+1
Add a frame_len argument to can_put_echo_skb() which is used to save length of the CAN frame into field frame_len of struct can_skb_priv so that it can be later used after transmission completion. Convert all users of this function, too. Drivers which implement BQL call can_put_echo_skb() with the output of can_skb_get_frame_len(skb) and drivers which do not simply pass zero as an input (in the same way that NULL would be given to can_get_echo_skb()). This way, we have a nice symmetry between the two echo functions. Link: https://lore.kernel.org/r/20210111061335.39983-1-mailhol.vincent@wanadoo.fr Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Reviewed-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr> Link: https://lore.kernel.org/r/20210111141930.693847-13-mkl@pengutronix.de Signed-off-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
2020-11-20can: kvaser_usb: Add new Kvaser hydra devicesJimmy Assarsson1-1/+7
Add new Kvaser hydra devices. Signed-off-by: Jimmy Assarsson <extja@kvaser.com> Link: https://lore.kernel.org/r/20201115163027.16851-6-jimmyassarsson@gmail.com Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2020-11-20can: kvaser_usb: kvaser_usb_hydra: Add support for new device variantChrister Beskow1-0/+37
Add support for a new variant of devices using the hydra platform, based on NXP i.MX RT (flexcan). Signed-off-by: Christer Beskow <chbe@kvaser.com> Signed-off-by: Jimmy Assarsson <extja@kvaser.com> Link: https://lore.kernel.org/r/20201115163027.16851-5-jimmyassarsson@gmail.com Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2020-11-20can: kvaser_usb: Add new Kvaser Leaf v2 devicesJimmy Assarsson1-1/+7
Add new Kvaser Leaf v2 devices. Signed-off-by: Jimmy Assarsson <extja@kvaser.com> Link: https://lore.kernel.org/r/20201115163027.16851-4-jimmyassarsson@gmail.com Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2020-11-20can: kvaser_usb: Add USB_{LEAF,HYDRA}_PRODUCT_ID_END definesJimmy Assarsson1-2/+6
Add USB_{LEAF,HYDRA}_PRODUCT_ID_END defines, representing the last USB PID entry in respectively family. This removes the need to update the kvaser_is_{leaf,hydra}() functions whenever new devices are added. Signed-off-by: Jimmy Assarsson <extja@kvaser.com> Link: https://lore.kernel.org/r/20201115163027.16851-3-jimmyassarsson@gmail.com Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2020-11-20can: rename CAN FD related can_len2dlc and can_dlc2len helpersOliver Hartkopp1-3/+3
The helper functions can_len2dlc and can_dlc2len are only relevant for CAN FD data length code (DLC) conversion. To fit the introduced can_cc_dlc2len for Classical CAN we rename: can_dlc2len -> can_fd_dlc2len to get the payload length from the DLC can_len2dlc -> can_fd_len2dlc to get the DLC from the payload length Suggested-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr> Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net> Link: https://lore.kernel.org/r/20201110101852.1973-6-socketcan@hartkopp.net Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2020-11-20can: replace can_dlc as variable/element for payload lengthOliver Hartkopp3-20/+20
The naming of can_dlc as element of struct can_frame and also as variable name is misleading as it claims to be a 'data length CODE' but in reality it always was a plain data length. With the indroduction of a new 'len' element in struct can_frame we can now remove can_dlc as name and make clear which of the former uses was a plain length (-> 'len') or a data length code (-> 'dlc') value. Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net> Link: https://lore.kernel.org/r/20201120100444.3199-1-socketcan@hartkopp.net [mkl: gs_usb: keep struct gs_host_frame::can_dlc as is] Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2020-11-20can: remove obsolete get_canfd_dlc() macroOliver Hartkopp1-1/+1
The macro was always used together with can_dlc2len() which sanitizes the given dlc value on its own. Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net> Link: https://lore.kernel.org/r/20201110101852.1973-4-socketcan@hartkopp.net Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2020-11-20can: rename get_can_dlc() macro with can_cc_dlc2len()Oliver Hartkopp2-4/+4
The get_can_dlc() macro is used to ensure the payload length information of the Classical CAN frame to be max 8 bytes (the CAN_MAX_DLEN). Rename the macro and use the correct constant in preparation of the len/dlc cleanup for Classical CAN frames. Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net> Link: https://lore.kernel.org/r/20201110101852.1973-3-socketcan@hartkopp.net Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2020-11-18can: kvaser_usb: kvaser_usb_hydra: Fix KCAN bittiming limitsJimmy Assarsson1-1/+1
Use correct bittiming limits for the KCAN CAN controller. Fixes: aec5fb2268b7 ("can: kvaser_usb: Add support for Kvaser USB hydra family") Signed-off-by: Jimmy Assarsson <extja@kvaser.com> Link: https://lore.kernel.org/r/20201115163027.16851-2-jimmyassarsson@gmail.com Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2020-01-02can: kvaser_usb: fix interface sanity checkJohan Hovold2-2/+2
Make sure to use the current alternate setting when verifying the interface descriptors to avoid binding to an invalid interface. Failing to do so could cause the driver to misbehave or trigger a WARN() in usb_submit_urb() that kernels with panic_on_warn set would choke on. Fixes: aec5fb2268b7 ("can: kvaser_usb: Add support for Kvaser USB hydra family") Cc: stable <stable@vger.kernel.org> # 4.19 Cc: Jimmy Assarsson <extja@kvaser.com> Cc: Christer Beskow <chbe@kvaser.com> Cc: Nicklas Johansson <extnj@kvaser.com> Cc: Martin Henriksson <mh@kvaser.com> Signed-off-by: Johan Hovold <johan@kernel.org> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2019-12-08can: kvaser_usb: kvaser_usb_leaf: Fix some info-leaks to USB devicesXiaolong Huang1-3/+3
Uninitialized Kernel memory can leak to USB devices. Fix this by using kzalloc() instead of kmalloc(). Signed-off-by: Xiaolong Huang <butterflyhuangxx@gmail.com> Fixes: 7259124eac7d ("can: kvaser_usb: Split driver into kvaser_usb_core.c and kvaser_usb_leaf.c") Cc: linux-stable <stable@vger.kernel.org> # >= v4.19 Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2019-07-24can: kvaser_usb: Use struct_size() in alloc_candev()Gustavo A. R. Silva1-2/+1
One of the more common cases of allocation size calculations is finding the size of a structure that has a zero-sized array at the end, along with memory for some number of elements for that array. For example: struct foo { int stuff; void *entry[]; }; instance = alloc(sizeof(struct foo) + count * sizeof(void *)); Instead of leaving these open-coded and prone to type mistakes, we can now use the new struct_size() helper: instance = alloc(struct_size(instance, entry, count)); This code was detected with the help of Coccinelle. Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2019-05-21treewide: Add SPDX license identifier - Makefile/KconfigThomas Gleixner1-0/+1
Add SPDX license identifiers to all Make/Kconfig files which: - Have no license information of any form These files fall under the project license, GPL v2 only. The resulting SPDX license identifier is: GPL-2.0-only Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-11-09can: kvaser_usb: Fix accessing freed memory in kvaser_usb_start_xmit()Jimmy Assarsson1-2/+2
The call to can_put_echo_skb() may result in the skb being freed. The skb is later used in the call to dev->ops->dev_frame_to_cmd(). This is avoided by moving the call to can_put_echo_skb() after dev->ops->dev_frame_to_cmd(). Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Jimmy Assarsson <jimmyassarsson@gmail.com> Cc: linux-stable <stable@vger.kernel.org> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2018-11-09can: kvaser_usb: Fix potential uninitialized variable useJimmy Assarsson1-5/+5
If alloc_can_err_skb() fails, cf is never initialized. Move assignment of cf inside check. Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Jimmy Assarsson <jimmyassarsson@gmail.com> Cc: linux-stable <stable@vger.kernel.org> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2018-07-27can: kvaser_usb: Simplify struct kvaser_cmd_cardinfoJimmy Assarsson1-11/+3
serial_number_high can be removed from the struct since it is never used in the USBcan II firmware. Signed-off-by: Jimmy Assarsson <jimmyassarsson@gmail.com> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2018-07-27can: kvaser_usb: Add support for Kvaser USB hydra familyJimmy Assarsson5-11/+2138
This patch adds support for a new Kvaser USB family, denoted hydra. The hydra family currently contains USB devices with one CAN channel up to five. There are devices with and without CAN FD support. Signed-off-by: Jimmy Assarsson <extja@kvaser.com> Signed-off-by: Christer Beskow <chbe@kvaser.com> Signed-off-by: Nicklas Johansson <extnj@kvaser.com> Signed-off-by: Martin Henriksson <mh@kvaser.com> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2018-07-27can: kvaser_usb: Split driver into kvaser_usb_core.c and kvaser_usb_leaf.cJimmy Assarsson4-0/+2292
First part of adding support for Kvaser USB device family "hydra". Split kvaser_usb.c into kvaser_usb/kvaser_usb{.h,_core.c,_leaf.c}. kvaser_usb_core.c contains common functionality, such as USB writing/reading and allocation of netdev. kvaser_usb_leaf.c contains device specific code, used in kvaser_usb_core.c. struct kvaser_usb_dev_ops contains device specific functions that are common for all devices in the family. While, struct kvaser_usb_dev_cfg describes the device configurations in terms of CAN clock frequency, timestamp frequency and CAN controller bittiming constants. Signed-off-by: Jimmy Assarsson <extja@kvaser.com> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>