Commit e2d5f2c7 authored by Bernd Krumboeck's avatar Bernd Krumboeck Committed by Marc Kleine-Budde

can: usb_8dev: add LED trigger support

Add support for canbus activity led indicators on usb_8dev devices by
calling appropriate can_led functions.

These are only enabled when CONFIG_CAN_LEDS is Y, becomes no-op
otherwise.
Signed-off-by: default avatarBernd Krumboeck <krumboeck@universalnet.at>
Signed-off-by: default avatarFabio Baltieri <fabio.baltieri@gmail.com>
Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
parent a04282f5
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include <linux/can.h> #include <linux/can.h>
#include <linux/can/dev.h> #include <linux/can/dev.h>
#include <linux/can/error.h> #include <linux/can/error.h>
#include <linux/can/led.h>
/* driver constants */ /* driver constants */
#define MAX_RX_URBS 20 #define MAX_RX_URBS 20
...@@ -497,6 +498,8 @@ static void usb_8dev_rx_can_msg(struct usb_8dev_priv *priv, ...@@ -497,6 +498,8 @@ static void usb_8dev_rx_can_msg(struct usb_8dev_priv *priv,
stats->rx_packets++; stats->rx_packets++;
stats->rx_bytes += cf->can_dlc; stats->rx_bytes += cf->can_dlc;
can_led_event(priv->netdev, CAN_LED_EVENT_RX);
} else { } else {
netdev_warn(priv->netdev, "frame type %d unknown", netdev_warn(priv->netdev, "frame type %d unknown",
msg->type); msg->type);
...@@ -597,6 +600,8 @@ static void usb_8dev_write_bulk_callback(struct urb *urb) ...@@ -597,6 +600,8 @@ static void usb_8dev_write_bulk_callback(struct urb *urb)
can_get_echo_skb(netdev, context->echo_index); can_get_echo_skb(netdev, context->echo_index);
can_led_event(netdev, CAN_LED_EVENT_TX);
/* Release context */ /* Release context */
context->echo_index = MAX_TX_URBS; context->echo_index = MAX_TX_URBS;
...@@ -819,6 +824,8 @@ static int usb_8dev_open(struct net_device *netdev) ...@@ -819,6 +824,8 @@ static int usb_8dev_open(struct net_device *netdev)
if (err) if (err)
return err; return err;
can_led_event(netdev, CAN_LED_EVENT_OPEN);
/* finally start device */ /* finally start device */
err = usb_8dev_start(priv); err = usb_8dev_start(priv);
if (err) { if (err) {
...@@ -871,6 +878,8 @@ static int usb_8dev_close(struct net_device *netdev) ...@@ -871,6 +878,8 @@ static int usb_8dev_close(struct net_device *netdev)
close_candev(netdev); close_candev(netdev);
can_led_event(netdev, CAN_LED_EVENT_STOP);
return err; return err;
} }
...@@ -978,6 +987,8 @@ static int usb_8dev_probe(struct usb_interface *intf, ...@@ -978,6 +987,8 @@ static int usb_8dev_probe(struct usb_interface *intf,
(version>>8) & 0xff, version & 0xff); (version>>8) & 0xff, version & 0xff);
} }
devm_can_led_init(netdev);
return 0; return 0;
cleanup_cmd_msg_buffer: cleanup_cmd_msg_buffer:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment