Add support for canbus activity led indicators on sja1000 devices by
calling appropriate can_led functions.
These are only enabled when CONFIG_CAN_LEDS is Y, becomes no-op
otherwise.
Cc: Oliver Hartkopp <socketcan@hartkopp.net>
Cc: Wolfgang Grandegger <wg@grandegger.com>
Cc: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Fabio Baltieri <fabio.baltieri@gmail.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
#include <linux/can/dev.h>
#include <linux/can/error.h>
#include <linux/can/dev.h>
#include <linux/can/error.h>
+#include <linux/can/led.h>
stats->rx_packets++;
stats->rx_bytes += cf->can_dlc;
stats->rx_packets++;
stats->rx_bytes += cf->can_dlc;
+
+ can_led_event(dev, CAN_LED_EVENT_RX);
}
static int sja1000_err(struct net_device *dev, uint8_t isrc, uint8_t status)
}
static int sja1000_err(struct net_device *dev, uint8_t isrc, uint8_t status)
can_get_echo_skb(dev, 0);
}
netif_wake_queue(dev);
can_get_echo_skb(dev, 0);
}
netif_wake_queue(dev);
+ can_led_event(dev, CAN_LED_EVENT_TX);
}
if (isrc & IRQ_RI) {
/* receive interrupt */
}
if (isrc & IRQ_RI) {
/* receive interrupt */
/* init and start chi */
sja1000_start(dev);
/* init and start chi */
sja1000_start(dev);
+ can_led_event(dev, CAN_LED_EVENT_OPEN);
+
netif_start_queue(dev);
return 0;
netif_start_queue(dev);
return 0;
+ can_led_event(dev, CAN_LED_EVENT_STOP);
+
int register_sja1000dev(struct net_device *dev)
{
int register_sja1000dev(struct net_device *dev)
{
if (!sja1000_probe_chip(dev))
return -ENODEV;
if (!sja1000_probe_chip(dev))
return -ENODEV;
set_reset_mode(dev);
chipset_init(dev);
set_reset_mode(dev);
chipset_init(dev);
- return register_candev(dev);
+ ret = register_candev(dev);
+
+ if (!ret)
+ devm_can_led_init(dev);
+
+ return ret;
}
EXPORT_SYMBOL_GPL(register_sja1000dev);
}
EXPORT_SYMBOL_GPL(register_sja1000dev);