can: sja1000: add LED trigger support
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>
This commit is contained in:
parent
eb072a9bae
commit
a04282f54b
1 changed files with 16 additions and 1 deletions
|
@ -60,6 +60,7 @@
|
||||||
|
|
||||||
#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>
|
||||||
|
|
||||||
#include "sja1000.h"
|
#include "sja1000.h"
|
||||||
|
|
||||||
|
@ -368,6 +369,8 @@ static void sja1000_rx(struct net_device *dev)
|
||||||
|
|
||||||
stats->rx_packets++;
|
stats->rx_packets++;
|
||||||
stats->rx_bytes += cf->can_dlc;
|
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)
|
||||||
|
@ -521,6 +524,7 @@ irqreturn_t sja1000_interrupt(int irq, void *dev_id)
|
||||||
can_get_echo_skb(dev, 0);
|
can_get_echo_skb(dev, 0);
|
||||||
}
|
}
|
||||||
netif_wake_queue(dev);
|
netif_wake_queue(dev);
|
||||||
|
can_led_event(dev, CAN_LED_EVENT_TX);
|
||||||
}
|
}
|
||||||
if (isrc & IRQ_RI) {
|
if (isrc & IRQ_RI) {
|
||||||
/* receive interrupt */
|
/* receive interrupt */
|
||||||
|
@ -575,6 +579,8 @@ static int sja1000_open(struct net_device *dev)
|
||||||
/* init and start chi */
|
/* init and start chi */
|
||||||
sja1000_start(dev);
|
sja1000_start(dev);
|
||||||
|
|
||||||
|
can_led_event(dev, CAN_LED_EVENT_OPEN);
|
||||||
|
|
||||||
netif_start_queue(dev);
|
netif_start_queue(dev);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -592,6 +598,8 @@ static int sja1000_close(struct net_device *dev)
|
||||||
|
|
||||||
close_candev(dev);
|
close_candev(dev);
|
||||||
|
|
||||||
|
can_led_event(dev, CAN_LED_EVENT_STOP);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -639,6 +647,8 @@ static const struct net_device_ops sja1000_netdev_ops = {
|
||||||
|
|
||||||
int register_sja1000dev(struct net_device *dev)
|
int register_sja1000dev(struct net_device *dev)
|
||||||
{
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
if (!sja1000_probe_chip(dev))
|
if (!sja1000_probe_chip(dev))
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
|
||||||
|
@ -648,7 +658,12 @@ int register_sja1000dev(struct net_device *dev)
|
||||||
set_reset_mode(dev);
|
set_reset_mode(dev);
|
||||||
chipset_init(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);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue