All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH can-next 0/5] can: add LED trigger support to common devices
@ 2012-08-05 14:48 Fabio Baltieri
  2012-08-05 14:51 ` [PATCH can-next 1/5] can: at91_can: add LED trigger support Fabio Baltieri
  0 siblings, 1 reply; 6+ messages in thread
From: Fabio Baltieri @ 2012-08-05 14:48 UTC (permalink / raw)
  To: linux-can; +Cc: Marc Kleine-Budde, Wolfgang Grandegger, linux-kernel

Hello,

this patch series adds support for LED triggers to CAN devices commonly
found on SoC architectures, using the support code recently merged in
Marc's can-next tree.

I actually modified only drivers who's devices may be commonly found
in embedded platforms with associated cpu-controlled LEDs, let me know
if I missed anything.

As I lack the actual hardware, these patches are *compile tested* only,
so I hope to get some test on real hardware from other developers,
through the modifications should be quite straightforward.

Also, I'll let you know that I may not have access to my email during
the next week, so if you write me, I'll try to answer as soon as
possible.

Fabio


Fabio Baltieri (5):
      can: at91_can: add LED trigger support
      can: ti_hecc: add LED trigger support
      can: c_can: add LED trigger support
      can: mcp251x: add LED trigger support
      can: sja1000: add LED trigger support

 at91_can.c        |   10 ++++++++++
 c_can/c_can.c     |   17 ++++++++++++++++-
 mcp251x.c         |   23 +++++++++++++++++++----
 sja1000/sja1000.c |   17 ++++++++++++++++-
 ti_hecc.c         |   10 ++++++++++
 5 files changed, 71 insertions(+), 6 deletions(-)

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH can-next 1/5] can: at91_can: add LED trigger support
  2012-08-05 14:48 [PATCH can-next 0/5] can: add LED trigger support to common devices Fabio Baltieri
@ 2012-08-05 14:51 ` Fabio Baltieri
  2012-08-05 14:51   ` [PATCH can-next 2/5] can: ti_hecc: " Fabio Baltieri
                     ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Fabio Baltieri @ 2012-08-05 14:51 UTC (permalink / raw)
  To: linux-can
  Cc: linux-kernel, Fabio Baltieri, Wolfgang Grandegger, Marc Kleine-Budde

Add support for canbus activity led indicators on at91_can devices by
calling appropriate can_led functions.

These are only enabled when CONFIG_CAN_LEDS is Y, becomes no-op
otherwise.

Cc: Wolfgang Grandegger <wg@grandegger.com>
Cc: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Fabio Baltieri <fabio.baltieri@gmail.com>
---
 drivers/net/can/at91_can.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/net/can/at91_can.c b/drivers/net/can/at91_can.c
index fcff73a..b496bff 100644
--- a/drivers/net/can/at91_can.c
+++ b/drivers/net/can/at91_can.c
@@ -36,6 +36,7 @@
 
 #include <linux/can/dev.h>
 #include <linux/can/error.h>
+#include <linux/can/led.h>
 
 #include <mach/board.h>
 
@@ -642,6 +643,8 @@ static void at91_read_msg(struct net_device *dev, unsigned int mb)
 
 	stats->rx_packets++;
 	stats->rx_bytes += cf->can_dlc;
+
+	can_led_event(dev, CAN_LED_EVENT_RX);
 }
 
 /**
@@ -876,6 +879,7 @@ static void at91_irq_tx(struct net_device *dev, u32 reg_sr)
 			/* _NOTE_: subtract AT91_MB_TX_FIRST offset from mb! */
 			can_get_echo_skb(dev, mb - get_mb_tx_first(priv));
 			dev->stats.tx_packets++;
+			can_led_event(dev, CAN_LED_EVENT_TX);
 		}
 	}
 
@@ -1129,6 +1133,8 @@ static int at91_open(struct net_device *dev)
 		goto out_close;
 	}
 
+	can_led_event(dev, CAN_LED_EVENT_OPEN);
+
 	/* start chip and queuing */
 	at91_chip_start(dev);
 	napi_enable(&priv->napi);
@@ -1160,6 +1166,8 @@ static int at91_close(struct net_device *dev)
 
 	close_candev(dev);
 
+	can_led_event(dev, CAN_LED_EVENT_STOP);
+
 	return 0;
 }
 
@@ -1322,6 +1330,8 @@ static int __devinit at91_can_probe(struct platform_device *pdev)
 		goto exit_free;
 	}
 
+	devm_can_led_init(dev);
+
 	dev_info(&pdev->dev, "device registered (reg_base=%p, irq=%d)\n",
 		 priv->reg_base, dev->irq);
 
-- 
1.7.11.rc1.9.gf623ca1.dirty


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH can-next 2/5] can: ti_hecc: add LED trigger support
  2012-08-05 14:51 ` [PATCH can-next 1/5] can: at91_can: add LED trigger support Fabio Baltieri
@ 2012-08-05 14:51   ` Fabio Baltieri
  2012-08-05 14:51   ` [PATCH can-next 3/5] can: c_can: " Fabio Baltieri
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Fabio Baltieri @ 2012-08-05 14:51 UTC (permalink / raw)
  To: linux-can
  Cc: linux-kernel, Fabio Baltieri, Anant Gole, Wolfgang Grandegger,
	Marc Kleine-Budde

Add support for canbus activity led indicators on ti_hecc devices by
calling appropriate can_led functions.

These are only enabled when CONFIG_CAN_LEDS is Y, becomes no-op
otherwise.

Cc: Anant Gole <anantgole@ti.com>
Cc: Wolfgang Grandegger <wg@grandegger.com>
Cc: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Fabio Baltieri <fabio.baltieri@gmail.com>
---
 drivers/net/can/ti_hecc.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/net/can/ti_hecc.c b/drivers/net/can/ti_hecc.c
index 527dbcf..0a45ba2 100644
--- a/drivers/net/can/ti_hecc.c
+++ b/drivers/net/can/ti_hecc.c
@@ -50,6 +50,7 @@
 
 #include <linux/can/dev.h>
 #include <linux/can/error.h>
+#include <linux/can/led.h>
 #include <linux/can/platform/ti_hecc.h>
 
 #define DRV_NAME "ti_hecc"
@@ -593,6 +594,7 @@ static int ti_hecc_rx_pkt(struct ti_hecc_priv *priv, int mbxno)
 	spin_unlock_irqrestore(&priv->mbx_lock, flags);
 
 	stats->rx_bytes += cf->can_dlc;
+	can_led_event(priv->ndev, CAN_LED_EVENT_RX);
 	netif_receive_skb(skb);
 	stats->rx_packets++;
 
@@ -796,6 +798,7 @@ static irqreturn_t ti_hecc_interrupt(int irq, void *dev_id)
 			stats->tx_bytes += hecc_read_mbx(priv, mbxno,
 						HECC_CANMCF) & 0xF;
 			stats->tx_packets++;
+			can_led_event(ndev, CAN_LED_EVENT_TX);
 			can_get_echo_skb(ndev, mbxno);
 			--priv->tx_tail;
 		}
@@ -851,6 +854,8 @@ static int ti_hecc_open(struct net_device *ndev)
 		return err;
 	}
 
+	can_led_event(ndev, CAN_LED_EVENT_OPEN);
+
 	ti_hecc_start(ndev);
 	napi_enable(&priv->napi);
 	netif_start_queue(ndev);
@@ -869,6 +874,8 @@ static int ti_hecc_close(struct net_device *ndev)
 	close_candev(ndev);
 	ti_hecc_transceiver_switch(priv, 0);
 
+	can_led_event(ndev, CAN_LED_EVENT_STOP);
+
 	return 0;
 }
 
@@ -961,6 +968,9 @@ static int ti_hecc_probe(struct platform_device *pdev)
 		dev_err(&pdev->dev, "register_candev() failed\n");
 		goto probe_exit_clk;
 	}
+
+	devm_can_led_init(ndev);
+
 	dev_info(&pdev->dev, "device registered (reg_base=%p, irq=%u)\n",
 		priv->base, (u32) ndev->irq);
 
-- 
1.7.11.rc1.9.gf623ca1.dirty

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH can-next 3/5] can: c_can: add LED trigger support
  2012-08-05 14:51 ` [PATCH can-next 1/5] can: at91_can: add LED trigger support Fabio Baltieri
  2012-08-05 14:51   ` [PATCH can-next 2/5] can: ti_hecc: " Fabio Baltieri
@ 2012-08-05 14:51   ` Fabio Baltieri
  2012-08-05 14:51   ` [PATCH can-next 4/5] can: mcp251x: " Fabio Baltieri
  2012-08-05 14:51   ` [PATCH can-next 5/5] can: sja1000: " Fabio Baltieri
  3 siblings, 0 replies; 6+ messages in thread
From: Fabio Baltieri @ 2012-08-05 14:51 UTC (permalink / raw)
  To: linux-can
  Cc: linux-kernel, Fabio Baltieri, Bhupesh Sharma, AnilKumar Ch,
	Wolfgang Grandegger, Marc Kleine-Budde

Add support for canbus activity led indicators on c_can devices by
calling appropriate can_led functions.

These are only enabled when CONFIG_CAN_LEDS is Y, becomes no-op
otherwise.

Cc: Bhupesh Sharma <bhupesh.sharma@st.com>
Cc: AnilKumar Ch <anilkumar@ti.com>
Cc: Wolfgang Grandegger <wg@grandegger.com>
Cc: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Fabio Baltieri <fabio.baltieri@gmail.com>
---
 drivers/net/can/c_can/c_can.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/drivers/net/can/c_can/c_can.c b/drivers/net/can/c_can/c_can.c
index 4c538e3..a8c5807 100644
--- a/drivers/net/can/c_can/c_can.c
+++ b/drivers/net/can/c_can/c_can.c
@@ -38,6 +38,7 @@
 #include <linux/can.h>
 #include <linux/can/dev.h>
 #include <linux/can/error.h>
+#include <linux/can/led.h>
 
 #include "c_can.h"
 
@@ -439,6 +440,8 @@ static int c_can_read_msg_object(struct net_device *dev, int iface, int ctrl)
 	stats->rx_packets++;
 	stats->rx_bytes += frame->can_dlc;
 
+	can_led_event(dev, CAN_LED_EVENT_RX);
+
 	return 0;
 }
 
@@ -709,6 +712,7 @@ static void c_can_do_tx(struct net_device *dev)
 					C_CAN_IFACE(MSGCTRL_REG, 0))
 					& IF_MCONT_DLC_MASK;
 			stats->tx_packets++;
+			can_led_event(dev, CAN_LED_EVENT_TX);
 			c_can_inval_msg_object(dev, 0, msg_obj_no);
 		} else {
 			break;
@@ -1070,6 +1074,8 @@ static int c_can_open(struct net_device *dev)
 
 	napi_enable(&priv->napi);
 
+	can_led_event(dev, CAN_LED_EVENT_OPEN);
+
 	/* start the c_can controller */
 	c_can_start(dev);
 
@@ -1092,6 +1098,8 @@ static int c_can_close(struct net_device *dev)
 	free_irq(dev->irq, dev);
 	close_candev(dev);
 
+	can_led_event(dev, CAN_LED_EVENT_STOP);
+
 	return 0;
 }
 
@@ -1133,10 +1141,17 @@ static const struct net_device_ops c_can_netdev_ops = {
 
 int register_c_can_dev(struct net_device *dev)
 {
+	int ret;
+
 	dev->flags |= IFF_ECHO;	/* we support local echo */
 	dev->netdev_ops = &c_can_netdev_ops;
 
-	return register_candev(dev);
+	ret = register_candev(dev);
+
+	if (!ret)
+		devm_can_led_init(dev);
+
+	return ret;
 }
 EXPORT_SYMBOL_GPL(register_c_can_dev);
 
-- 
1.7.11.rc1.9.gf623ca1.dirty

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH can-next 4/5] can: mcp251x: add LED trigger support
  2012-08-05 14:51 ` [PATCH can-next 1/5] can: at91_can: add LED trigger support Fabio Baltieri
  2012-08-05 14:51   ` [PATCH can-next 2/5] can: ti_hecc: " Fabio Baltieri
  2012-08-05 14:51   ` [PATCH can-next 3/5] can: c_can: " Fabio Baltieri
@ 2012-08-05 14:51   ` Fabio Baltieri
  2012-08-05 14:51   ` [PATCH can-next 5/5] can: sja1000: " Fabio Baltieri
  3 siblings, 0 replies; 6+ messages in thread
From: Fabio Baltieri @ 2012-08-05 14:51 UTC (permalink / raw)
  To: linux-can
  Cc: linux-kernel, Fabio Baltieri, Christian Pellegrin,
	Wolfgang Grandegger, Marc Kleine-Budde

Add support for canbus activity led indicators on mcp251x devices by
calling appropriate can_led functions.

These are only enabled when CONFIG_CAN_LEDS is Y, becomes no-op
otherwise.

Cc: Christian Pellegrin <chripell@fsfe.org>
Cc: Wolfgang Grandegger <wg@grandegger.com>
Cc: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Fabio Baltieri <fabio.baltieri@gmail.com>
---
 drivers/net/can/mcp251x.c | 23 +++++++++++++++++++----
 1 file changed, 19 insertions(+), 4 deletions(-)

diff --git a/drivers/net/can/mcp251x.c b/drivers/net/can/mcp251x.c
index a580db2..128235e 100644
--- a/drivers/net/can/mcp251x.c
+++ b/drivers/net/can/mcp251x.c
@@ -60,6 +60,7 @@
 
 #include <linux/can/core.h>
 #include <linux/can/dev.h>
+#include <linux/can/led.h>
 #include <linux/can/platform/mcp251x.h>
 #include <linux/completion.h>
 #include <linux/delay.h>
@@ -485,6 +486,9 @@ static void mcp251x_hw_rx(struct spi_device *spi, int buf_idx)
 
 	priv->net->stats.rx_packets++;
 	priv->net->stats.rx_bytes += frame->can_dlc;
+
+	can_led_event(priv->net, CAN_LED_EVENT_RX);
+
 	netif_rx_ni(skb);
 }
 
@@ -698,6 +702,8 @@ static int mcp251x_stop(struct net_device *net)
 
 	mutex_unlock(&priv->mcp_lock);
 
+	can_led_event(net, CAN_LED_EVENT_STOP);
+
 	return 0;
 }
 
@@ -896,6 +902,7 @@ static irqreturn_t mcp251x_can_ist(int irq, void *dev_id)
 		if (intf & CANINTF_TX) {
 			net->stats.tx_packets++;
 			net->stats.tx_bytes += priv->tx_len - 1;
+			can_led_event(net, CAN_LED_EVENT_TX);
 			if (priv->tx_len) {
 				can_get_echo_skb(net, 0);
 				priv->tx_len = 0;
@@ -959,6 +966,9 @@ static int mcp251x_open(struct net_device *net)
 		mcp251x_open_clean(net);
 		goto open_unlock;
 	}
+
+	can_led_event(net, CAN_LED_EVENT_OPEN);
+
 	netif_wake_queue(net);
 
 open_unlock:
@@ -1068,10 +1078,15 @@ static int __devinit mcp251x_can_probe(struct spi_device *spi)
 		pdata->transceiver_enable(0);
 
 	ret = register_candev(net);
-	if (!ret) {
-		dev_info(&spi->dev, "probed\n");
-		return ret;
-	}
+	if (ret)
+		goto error_probe;
+
+	devm_can_led_init(net);
+
+	dev_info(&spi->dev, "probed\n");
+
+	return ret;
+
 error_probe:
 	if (!mcp251x_enable_dma)
 		kfree(priv->spi_rx_buf);
-- 
1.7.11.rc1.9.gf623ca1.dirty

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH can-next 5/5] can: sja1000: add LED trigger support
  2012-08-05 14:51 ` [PATCH can-next 1/5] can: at91_can: add LED trigger support Fabio Baltieri
                     ` (2 preceding siblings ...)
  2012-08-05 14:51   ` [PATCH can-next 4/5] can: mcp251x: " Fabio Baltieri
@ 2012-08-05 14:51   ` Fabio Baltieri
  3 siblings, 0 replies; 6+ messages in thread
From: Fabio Baltieri @ 2012-08-05 14:51 UTC (permalink / raw)
  To: linux-can
  Cc: linux-kernel, Fabio Baltieri, Oliver Hartkopp,
	Wolfgang Grandegger, Marc Kleine-Budde

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>
---
 drivers/net/can/sja1000/sja1000.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/drivers/net/can/sja1000/sja1000.c b/drivers/net/can/sja1000/sja1000.c
index 4c4f33d..bf2721c 100644
--- a/drivers/net/can/sja1000/sja1000.c
+++ b/drivers/net/can/sja1000/sja1000.c
@@ -60,6 +60,7 @@
 
 #include <linux/can/dev.h>
 #include <linux/can/error.h>
+#include <linux/can/led.h>
 
 #include "sja1000.h"
 
@@ -365,6 +366,8 @@ static void sja1000_rx(struct net_device *dev)
 
 	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)
@@ -510,6 +513,7 @@ irqreturn_t sja1000_interrupt(int irq, void *dev_id)
 			stats->tx_packets++;
 			can_get_echo_skb(dev, 0);
 			netif_wake_queue(dev);
+			can_led_event(dev, CAN_LED_EVENT_TX);
 		}
 		if (isrc & IRQ_RI) {
 			/* receive interrupt */
@@ -565,6 +569,8 @@ static int sja1000_open(struct net_device *dev)
 	sja1000_start(dev);
 	priv->open_time = jiffies;
 
+	can_led_event(dev, CAN_LED_EVENT_OPEN);
+
 	netif_start_queue(dev);
 
 	return 0;
@@ -584,6 +590,8 @@ static int sja1000_close(struct net_device *dev)
 
 	priv->open_time = 0;
 
+	can_led_event(dev, CAN_LED_EVENT_STOP);
+
 	return 0;
 }
 
@@ -630,6 +638,8 @@ static const struct net_device_ops sja1000_netdev_ops = {
 
 int register_sja1000dev(struct net_device *dev)
 {
+	int ret;
+
 	if (!sja1000_probe_chip(dev))
 		return -ENODEV;
 
@@ -639,7 +649,12 @@ int register_sja1000dev(struct net_device *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);
 
-- 
1.7.11.rc1.9.gf623ca1.dirty

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-08-05 14:51 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-05 14:48 [PATCH can-next 0/5] can: add LED trigger support to common devices Fabio Baltieri
2012-08-05 14:51 ` [PATCH can-next 1/5] can: at91_can: add LED trigger support Fabio Baltieri
2012-08-05 14:51   ` [PATCH can-next 2/5] can: ti_hecc: " Fabio Baltieri
2012-08-05 14:51   ` [PATCH can-next 3/5] can: c_can: " Fabio Baltieri
2012-08-05 14:51   ` [PATCH can-next 4/5] can: mcp251x: " Fabio Baltieri
2012-08-05 14:51   ` [PATCH can-next 5/5] can: sja1000: " Fabio Baltieri

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.