From: Fabio Baltieri <fabio.baltieri@gmail.com>
To: linux-can@vger.kernel.org
Cc: Fabio Baltieri <fabio.baltieri@gmail.com>
Subject: [RFC PATCH v2 2/2] can: flexcan: add LED trigger support
Date: Mon, 23 Apr 2012 23:02:46 +0200 [thread overview]
Message-ID: <1335214966-20478-2-git-send-email-fabio.baltieri@gmail.com> (raw)
In-Reply-To: <1335214966-20478-1-git-send-email-fabio.baltieri@gmail.com>
Add support for canbus activity led indicators on flexcan interfaces by
calling appropriate can_led_* functions.
These are only enabled when CONFIG_CAN_LEDS is Y, becomes no-op
otherwise.
Signed-off-by: Fabio Baltieri <fabio.baltieri@gmail.com>
---
drivers/net/can/flexcan.c | 13 +++++++++++++
1 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c
index 1efb083..0e55c4c 100644
--- a/drivers/net/can/flexcan.c
+++ b/drivers/net/can/flexcan.c
@@ -23,6 +23,7 @@
#include <linux/can.h>
#include <linux/can/dev.h>
#include <linux/can/error.h>
+#include <linux/can/led.h>
#include <linux/can/platform/flexcan.h>
#include <linux/clk.h>
#include <linux/delay.h>
@@ -524,6 +525,8 @@ static int flexcan_read_frame(struct net_device *dev)
stats->rx_packets++;
stats->rx_bytes += cf->can_dlc;
+ can_led_event(dev, CAN_LED_EVENT_RX);
+
return 1;
}
@@ -614,6 +617,8 @@ static irqreturn_t flexcan_irq(int irq, void *dev_id)
stats->tx_packets++;
flexcan_write((1 << FLEXCAN_TX_BUF_ID), ®s->iflag1);
netif_wake_queue(dev);
+
+ can_led_event(dev, CAN_LED_EVENT_TX);
}
return IRQ_HANDLED;
@@ -813,6 +818,8 @@ static int flexcan_open(struct net_device *dev)
if (err)
goto out_close;
+ can_led_event(dev, CAN_LED_EVENT_OPEN);
+
/* start chip and queuing */
err = flexcan_chip_start(dev);
if (err)
@@ -838,6 +845,8 @@ static int flexcan_close(struct net_device *dev)
napi_disable(&priv->napi);
flexcan_chip_stop(dev);
+ can_led_event(dev, CAN_LED_EVENT_STOP);
+
free_irq(dev->irq, dev);
clk_disable_unprepare(priv->clk);
@@ -1004,6 +1013,8 @@ static int __devinit flexcan_probe(struct platform_device *pdev)
goto failed_register;
}
+ can_led_init(dev);
+
dev_info(&pdev->dev, "device registered (reg_base=%p, irq=%d)\n",
priv->base, dev->irq);
@@ -1028,6 +1039,8 @@ static int __devexit flexcan_remove(struct platform_device *pdev)
struct flexcan_priv *priv = netdev_priv(dev);
struct resource *mem;
+ can_led_exit(dev);
+
unregister_flexcandev(dev);
platform_set_drvdata(pdev, NULL);
iounmap(priv->base);
--
1.7.5.1
next prev parent reply other threads:[~2012-04-23 21:01 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-23 21:02 [RFC PATCH v2 1/2] can: add tx/rx LED trigger support Fabio Baltieri
2012-04-23 21:02 ` Fabio Baltieri [this message]
2012-04-24 5:16 ` Oliver Hartkopp
2012-04-24 19:10 ` Fabio Baltieri
2012-04-24 6:46 ` Wolfgang Grandegger
2012-04-24 15:41 ` Oliver Hartkopp
2012-04-24 18:08 ` Wolfgang Grandegger
2012-04-24 18:57 ` Oliver Hartkopp
2012-04-25 7:05 ` Wolfgang Grandegger
2012-04-24 19:02 ` Fabio Baltieri
2012-04-25 7:26 ` Wolfgang Grandegger
2012-04-25 7:41 ` Marc Kleine-Budde
2012-04-25 10:04 ` Wolfgang Grandegger
2012-05-03 21:49 ` Fabio Baltieri
2012-05-04 7:03 ` Oliver Hartkopp
2012-05-04 7:30 ` Wolfgang Grandegger
2012-04-24 8:38 ` Kurt Van Dijck
2012-04-24 20:22 ` Fabio Baltieri
2012-04-25 7:50 ` Kurt Van Dijck
2012-04-24 8:45 ` Kurt Van Dijck
2012-04-24 20:34 ` Fabio Baltieri
2012-04-25 8:00 ` Kurt Van Dijck
2012-04-25 20:39 ` Fabio Baltieri
2012-04-26 8:21 ` Kurt Van Dijck
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1335214966-20478-2-git-send-email-fabio.baltieri@gmail.com \
--to=fabio.baltieri@gmail.com \
--cc=linux-can@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox