diff options
author | Fabio Baltieri <fabio.baltieri@gmail.com> | 2012-12-18 12:51:03 -0500 |
---|---|---|
committer | Marc Kleine-Budde <mkl@pengutronix.de> | 2013-01-26 10:59:00 -0500 |
commit | a04282f54b52cf5a629a98f09712da1e630a1060 (patch) | |
tree | a907bb7a8adc7614f2a12792673e7014ccf6c785 /drivers/net/can/sja1000/sja1000.c | |
parent | eb072a9baebefeef33ece48c0a6fc2f8200e5ed2 (diff) |
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>
Diffstat (limited to 'drivers/net/can/sja1000/sja1000.c')
-rw-r--r-- | drivers/net/can/sja1000/sja1000.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/drivers/net/can/sja1000/sja1000.c b/drivers/net/can/sja1000/sja1000.c index 83ee11eca0e2..daf4013a8fc7 100644 --- a/drivers/net/can/sja1000/sja1000.c +++ b/drivers/net/can/sja1000/sja1000.c | |||
@@ -60,6 +60,7 @@ | |||
60 | 60 | ||
61 | #include <linux/can/dev.h> | 61 | #include <linux/can/dev.h> |
62 | #include <linux/can/error.h> | 62 | #include <linux/can/error.h> |
63 | #include <linux/can/led.h> | ||
63 | 64 | ||
64 | #include "sja1000.h" | 65 | #include "sja1000.h" |
65 | 66 | ||
@@ -368,6 +369,8 @@ static void sja1000_rx(struct net_device *dev) | |||
368 | 369 | ||
369 | stats->rx_packets++; | 370 | stats->rx_packets++; |
370 | stats->rx_bytes += cf->can_dlc; | 371 | stats->rx_bytes += cf->can_dlc; |
372 | |||
373 | can_led_event(dev, CAN_LED_EVENT_RX); | ||
371 | } | 374 | } |
372 | 375 | ||
373 | static int sja1000_err(struct net_device *dev, uint8_t isrc, uint8_t status) | 376 | 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) | |||
521 | can_get_echo_skb(dev, 0); | 524 | can_get_echo_skb(dev, 0); |
522 | } | 525 | } |
523 | netif_wake_queue(dev); | 526 | netif_wake_queue(dev); |
527 | can_led_event(dev, CAN_LED_EVENT_TX); | ||
524 | } | 528 | } |
525 | if (isrc & IRQ_RI) { | 529 | if (isrc & IRQ_RI) { |
526 | /* receive interrupt */ | 530 | /* receive interrupt */ |
@@ -575,6 +579,8 @@ static int sja1000_open(struct net_device *dev) | |||
575 | /* init and start chi */ | 579 | /* init and start chi */ |
576 | sja1000_start(dev); | 580 | sja1000_start(dev); |
577 | 581 | ||
582 | can_led_event(dev, CAN_LED_EVENT_OPEN); | ||
583 | |||
578 | netif_start_queue(dev); | 584 | netif_start_queue(dev); |
579 | 585 | ||
580 | return 0; | 586 | return 0; |
@@ -592,6 +598,8 @@ static int sja1000_close(struct net_device *dev) | |||
592 | 598 | ||
593 | close_candev(dev); | 599 | close_candev(dev); |
594 | 600 | ||
601 | can_led_event(dev, CAN_LED_EVENT_STOP); | ||
602 | |||
595 | return 0; | 603 | return 0; |
596 | } | 604 | } |
597 | 605 | ||
@@ -639,6 +647,8 @@ static const struct net_device_ops sja1000_netdev_ops = { | |||
639 | 647 | ||
640 | int register_sja1000dev(struct net_device *dev) | 648 | int register_sja1000dev(struct net_device *dev) |
641 | { | 649 | { |
650 | int ret; | ||
651 | |||
642 | if (!sja1000_probe_chip(dev)) | 652 | if (!sja1000_probe_chip(dev)) |
643 | return -ENODEV; | 653 | return -ENODEV; |
644 | 654 | ||
@@ -648,7 +658,12 @@ int register_sja1000dev(struct net_device *dev) | |||
648 | set_reset_mode(dev); | 658 | set_reset_mode(dev); |
649 | chipset_init(dev); | 659 | chipset_init(dev); |
650 | 660 | ||
651 | return register_candev(dev); | 661 | ret = register_candev(dev); |
662 | |||
663 | if (!ret) | ||
664 | devm_can_led_init(dev); | ||
665 | |||
666 | return ret; | ||
652 | } | 667 | } |
653 | EXPORT_SYMBOL_GPL(register_sja1000dev); | 668 | EXPORT_SYMBOL_GPL(register_sja1000dev); |
654 | 669 | ||