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: Bernd Krumboeck <krumboeck@universalnet.at>
Signed-off-by: Fabio Baltieri <fabio.baltieri@gmail.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
diff --git a/drivers/net/can/usb/usb_8dev.c b/drivers/net/can/usb/usb_8dev.c
index a9e73fa..f789e6f 100644
--- a/drivers/net/can/usb/usb_8dev.c
+++ b/drivers/net/can/usb/usb_8dev.c
@@ -33,6 +33,7 @@
#include <linux/can.h>
#include <linux/can/dev.h>
#include <linux/can/error.h>
+#include <linux/can/led.h>
/* driver constants */
#define MAX_RX_URBS 20
@@ -497,6 +498,8 @@
stats->rx_packets++;
stats->rx_bytes += cf->can_dlc;
+
+ can_led_event(priv->netdev, CAN_LED_EVENT_RX);
} else {
netdev_warn(priv->netdev, "frame type %d unknown",
msg->type);
@@ -597,6 +600,8 @@
can_get_echo_skb(netdev, context->echo_index);
+ can_led_event(netdev, CAN_LED_EVENT_TX);
+
/* Release context */
context->echo_index = MAX_TX_URBS;
@@ -819,6 +824,8 @@
if (err)
return err;
+ can_led_event(netdev, CAN_LED_EVENT_OPEN);
+
/* finally start device */
err = usb_8dev_start(priv);
if (err) {
@@ -871,6 +878,8 @@
close_candev(netdev);
+ can_led_event(netdev, CAN_LED_EVENT_STOP);
+
return err;
}
@@ -978,6 +987,8 @@
(version>>8) & 0xff, version & 0xff);
}
+ devm_can_led_init(netdev);
+
return 0;
cleanup_cmd_msg_buffer: