aboutsummaryrefslogtreecommitdiff
path: root/drivers/net/can/usb/ucan.c
AgeCommit message (Collapse)AuthorFilesLines
2023-07-19can: ucan: Remove repeated wordMao Zhu1-1/+1
Delete one of repeated word 'information' in comment. Signed-off-by: Mao Zhu <[email protected]> Link: https://lore.kernel.org/all/[email protected] Signed-off-by: Marc Kleine-Budde <[email protected]>
2022-12-12can: ucan: remove unused ucan_priv::intfVincent Mailhol1-2/+0
Field intf of struct ucan_priv is set but never used. Remove it. Signed-off-by: Vincent Mailhol <[email protected]> Link: https://lore.kernel.org/all/[email protected] Signed-off-by: Marc Kleine-Budde <[email protected]>
2022-12-12can: ucan: use strscpy() to instead of strncpy()Xu Panda1-3/+2
The implementation of strscpy() is more robust and safer. That's now the recommended way to copy NUL terminated strings. Signed-off-by: Xu Panda <[email protected]> Signed-off-by: Yang Yang <[email protected]> Link: https://lore.kernel.org/all/[email protected] Signed-off-by: Marc Kleine-Budde <[email protected]>
2022-11-10Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/netJakub Kicinski1-1/+1
drivers/net/can/pch_can.c ae64438be192 ("can: dev: fix skb drop check") 1dd1b521be85 ("can: remove obsolete PCH CAN driver") https://lore.kernel.org/all/[email protected]/ Signed-off-by: Jakub Kicinski <[email protected]>
2022-11-07can: dev: fix skb drop checkOliver Hartkopp1-1/+1
In commit a6d190f8c767 ("can: skb: drop tx skb if in listen only mode") the priv->ctrlmode element is read even on virtual CAN interfaces that do not create the struct can_priv at startup. This out-of-bounds read may lead to CAN frame drops for virtual CAN interfaces like vcan and vxcan. This patch mainly reverts the original commit and adds a new helper for CAN interface drivers that provide the required information in struct can_priv. Fixes: a6d190f8c767 ("can: skb: drop tx skb if in listen only mode") Reported-by: Dariusz Stojaczyk <[email protected]> Cc: Vincent Mailhol <[email protected]> Cc: Max Staudt <[email protected]> Signed-off-by: Oliver Hartkopp <[email protected]> Acked-by: Vincent Mailhol <[email protected]> Link: https://lore.kernel.org/all/[email protected] Cc: [email protected] # 6.0.x [mkl: patch pch_can, too] Signed-off-by: Marc Kleine-Budde <[email protected]>
2022-10-26can: ucan: ucan_disconnect(): change unregister_netdev() to unregister_candev()Dongliang Mu1-1/+1
From API pairing, change unregister_netdev() to unregister_candev() since the registration function is register_candev(). Actually, they are the same. Signed-off-by: Dongliang Mu <[email protected]> Link: https://lore.kernel.org/all/[email protected] [mkl: adjust subject + commit message] Signed-off-by: Marc Kleine-Budde <[email protected]>
2022-10-19can: ucan: Replace zero-length array with DECLARE_FLEX_ARRAY() helperGustavo A. R. Silva1-1/+2
Zero-length arrays are deprecated and we are moving towards adopting C99 flexible-array members, instead. So, replace zero-length arrays declarations in anonymous union with the new DECLARE_FLEX_ARRAY() helper macro. This helper allows for flexible-array members in unions. Link: https://github.com/KSPP/linux/issues/193 Link: https://github.com/KSPP/linux/issues/214 Link: https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html Signed-off-by: Gustavo A. R. Silva <[email protected]> Reviewed-by: Kees Cook <[email protected]> Link: https://lore.kernel.org/all/YzIdHDdz30BH4SAv@work Signed-off-by: Marc Kleine-Budde <[email protected]>
2022-07-28can: tree-wide: advertise software timestamping capabilitiesVincent Mailhol1-0/+6
Currently, some CAN drivers support hardware timestamping, some do not. But userland has no method to query which features are supported (aside maybe of getting RX messages and observe whether or not hardware timestamps stay at zero). The canonical way for a network driver to advertised what kind of timestamping it supports is to implement ethtool_ops::get_ts_info(). This patch only targets the CAN drivers which *do not* support hardware timestamping. For each of those CAN drivers, implement the get_ts_info() using the generic ethtool_op_get_ts_info(). This way, userland can do: | $ ethtool --show-time-stamping canX to confirm the device timestamping capacities. N.B. the drivers which support hardware timestamping will be migrated in separate patches. Signed-off-by: Vincent Mailhol <[email protected]> Link: https://lore.kernel.org/all/[email protected] [mkl: mscan: add missing mscan_ethtool_ops] Signed-off-by: Marc Kleine-Budde <[email protected]>
2022-03-16can: ucan: fix typos in commentsJulia Lawall1-2/+2
Various spelling mistakes in comments. Detected with the help of Coccinelle. Link: https://lore.kernel.org/all/[email protected] Signed-off-by: Julia Lawall <[email protected]> Acked-by: Marc Kleine-Budde <[email protected]> Signed-off-by: Marc Kleine-Budde <[email protected]>
2022-01-05can: do not increase tx_bytes statistics for RTR framesVincent Mailhol1-7/+3
The actual payload length of the CAN Remote Transmission Request (RTR) frames is always 0, i.e. no payload is transmitted on the wire. However, those RTR frames still use the DLC to indicate the length of the requested frame. As such, net_device_stats::tx_bytes should not be increased when sending RTR frames. The function can_get_echo_skb() already returns the correct length, even for RTR frames (c.f. [1]). However, for historical reasons, the drivers do not use can_get_echo_skb()'s return value and instead, most of them store a temporary length (or dlc) in some local structure or array. Using the return value of can_get_echo_skb() solves the issue. After doing this, such length/dlc fields become unused and so this patch does the adequate cleaning when needed. This patch fixes all the CAN drivers. Finally, can_get_echo_skb() is decorated with the __must_check attribute in order to force future drivers to correctly use its return value (else the compiler would emit a warning). [1] commit ed3320cec279 ("can: dev: __can_get_echo_skb(): fix real payload length return value for RTR frames") Link: https://lore.kernel.org/all/[email protected] Cc: Nicolas Ferre <[email protected]> Cc: Alexandre Belloni <[email protected]> Cc: Ludovic Desroches <[email protected]> Cc: Maxime Ripard <[email protected]> Cc: Chen-Yu Tsai <[email protected]> Cc: Jernej Skrabec <[email protected]> Cc: Yasushi SHOJI <[email protected]> Cc: Oliver Hartkopp <[email protected]> Cc: Stephane Grosjean <[email protected]> Cc: Andreas Larsson <[email protected]> Tested-by: Jimmy Assarsson <[email protected]> # kvaser Signed-off-by: Vincent Mailhol <[email protected]> Acked-by: Stefan Mätje <[email protected]> # esd_usb2 Tested-by: Stefan Mätje <[email protected]> # esd_usb2 [mkl: add conversion for grcan] Signed-off-by: Marc Kleine-Budde <[email protected]>
2022-01-05can: do not increase rx_bytes statistics for RTR framesVincent Mailhol1-1/+2
The actual payload length of the CAN Remote Transmission Request (RTR) frames is always 0, i.e. no payload is transmitted on the wire. However, those RTR frames still use the DLC to indicate the length of the requested frame. As such, net_device_stats::rx_bytes should not be increased for the RTR frames. This patch fixes all the CAN drivers. Link: https://lore.kernel.org/all/[email protected] Cc: Marc Kleine-Budde <[email protected]> Cc: Nicolas Ferre <[email protected]> Cc: Alexandre Belloni <[email protected]> Cc: Ludovic Desroches <[email protected]> Cc: Chandrasekar Ramakrishnan <[email protected]> Cc: Maxime Ripard <[email protected]> Cc: Chen-Yu Tsai <[email protected]> Cc: Jernej Skrabec <[email protected]> Cc: Yasushi SHOJI <[email protected]> Cc: Appana Durga Kedareswara rao <[email protected]> Cc: Naga Sureshkumar Relli <[email protected]> Cc: Michal Simek <[email protected]> Cc: Stephane Grosjean <[email protected]> Tested-by: Jimmy Assarsson <[email protected]> # kvaser Signed-off-by: Vincent Mailhol <[email protected]> Acked-by: Stefan Mätje <[email protected]> # esd_usb2 Tested-by: Stefan Mätje <[email protected]> # esd_usb2 Signed-off-by: Marc Kleine-Budde <[email protected]>
2022-01-05can: do not increase rx statistics when generating a CAN rx error message frameVincent Mailhol1-2/+4
The CAN error message frames (i.e. error skb) are an interface specific to socket CAN. The payload of the CAN error message frames does not correspond to any actual data sent on the wire. Only an error flag and a delimiter are transmitted when an error occurs (c.f. ISO 11898-1 section 10.4.4.2 "Error flag"). For this reason, it makes no sense to increment the rx_packets and rx_bytes fields of struct net_device_stats because no actual payload were transmitted on the wire. This patch fixes all the CAN drivers. Link: https://lore.kernel.org/all/[email protected] CC: Marc Kleine-Budde <[email protected]> CC: Nicolas Ferre <[email protected]> CC: Alexandre Belloni <[email protected]> CC: Ludovic Desroches <[email protected]> CC: Chandrasekar Ramakrishnan <[email protected]> CC: Maxime Ripard <[email protected]> CC: Chen-Yu Tsai <[email protected]> CC: Jernej Skrabec <[email protected]> CC: Appana Durga Kedareswara rao <[email protected]> CC: Naga Sureshkumar Relli <[email protected]> CC: Michal Simek <[email protected]> CC: Stephane Grosjean <[email protected]> Tested-by: Jimmy Assarsson <[email protected]> # kvaser Signed-off-by: Vincent Mailhol <[email protected]> Acked-by: Stefan Mätje <[email protected]> # esd_usb2 Tested-by: Stefan Mätje <[email protected]> # esd_usb2 Signed-off-by: Marc Kleine-Budde <[email protected]>
2021-03-30can: ucan: fix alignment constraintsArnd Bergmann1-1/+1
struct ucan_message_in contains member with 4-byte alignment but is itself marked as unaligned, which triggers a warning: drivers/net/can/usb/ucan.c:249:1: warning: alignment 1 of 'struct ucan_message_in' is less than 4 [-Wpacked-not-aligned] Mark the outer structure to have the same alignment as the inner one. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Arnd Bergmann <[email protected]> Signed-off-by: Marc Kleine-Budde <[email protected]>
2021-03-30can: dev: can_free_echo_skb(): extend to return can frame lengthMarc Kleine-Budde1-3/+3
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/[email protected] Signed-off-by: Marc Kleine-Budde <[email protected]>
2021-01-14can: dev: can_get_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 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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Marc Kleine-Budde <[email protected]>
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/[email protected] Signed-off-by: Marc Kleine-Budde <[email protected]> Reviewed-by: Vincent Mailhol <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vincent Mailhol <[email protected]>
2020-11-20can: replace can_dlc as variable/element for payload lengthOliver Hartkopp1-7/+7
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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] [mkl: gs_usb: keep struct gs_host_frame::can_dlc as is] Signed-off-by: Marc Kleine-Budde <[email protected]>
2020-11-20can: rename get_can_dlc() macro with can_cc_dlc2len()Oliver Hartkopp1-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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Marc Kleine-Budde <[email protected]>
2020-09-21can: drivers: fix spelling mistakesMarc Kleine-Budde1-2/+2
This patch fixes spelling erros found by "codespell" in the drivers/net/can subtree. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Marc Kleine-Budde <[email protected]>
2019-12-03can: ucan: fix non-atomic allocation in completion handlerJohan Hovold1-1/+1
USB completion handlers are called in atomic context and must specifically not allocate memory using GFP_KERNEL. Fixes: 9f2d3eae88d2 ("can: ucan: add driver for Theobroma Systems UCAN devices") Cc: stable <[email protected]> # 4.19 Cc: Jakob Unterwurzacher <[email protected]> Cc: Martin Elshuber <[email protected]> Cc: Philipp Tomsich <[email protected]> Signed-off-by: Johan Hovold <[email protected]> Signed-off-by: Marc Kleine-Budde <[email protected]>
2018-11-28can: ucan: fix spelling mistake: "resumbmitting" -> "resubmitting"Colin Ian King1-1/+1
Trivial fix to spelling mistake in netdev_dbg error message Signed-off-by: Colin Ian King <[email protected]> Signed-off-by: Marc Kleine-Budde <[email protected]>
2018-11-09can: ucan: remove duplicated include from ucan.cYueHaibing1-4/+0
Remove duplicated include. Signed-off-by: YueHaibing <[email protected]> Reviewed-by: Martin Elshuber <[email protected]> Signed-off-by: Marc Kleine-Budde <[email protected]>
2018-11-09can: ucan: remove set but not used variable 'udev'YueHaibing1-3/+0
Fixes gcc '-Wunused-but-set-variable' warning: drivers/net/can/usb/ucan.c: In function 'ucan_disconnect': drivers/net/can/usb/ucan.c:1578:21: warning: variable 'udev' set but not used [-Wunused-but-set-variable] struct usb_device *udev; Signed-off-by: YueHaibing <[email protected]> Reviewed-by: Martin Elshuber <[email protected]> Signed-off-by: Marc Kleine-Budde <[email protected]>
2018-07-27can: ucan: add driver for Theobroma Systems UCAN devicesJakob Unterwurzacher1-0/+1613
The UCAN driver supports the microcontroller-based USB/CAN adapters from Theobroma Systems. There are two form-factors that run essentially the same firmware: * Seal: standalone USB stick ( https://www.theobroma-systems.com/seal ) * Mule: integrated on the PCB of various System-on-Modules from Theobroma Systems like the A31-µQ7 and the RK3399-Q7 ( https://www.theobroma-systems.com/rk3399-q7 ) The USB wire protocol has been designed to be as generic and hardware-indendent as possible in the hope of being useful for implementation on other microcontrollers. Signed-off-by: Martin Elshuber <[email protected]> Signed-off-by: Jakob Unterwurzacher <[email protected]> Signed-off-by: Philipp Tomsich <[email protected]> Acked-by: Wolfgang Grandegger <[email protected]> Signed-off-by: Marc Kleine-Budde <[email protected]>