public inbox for linux-can@vger.kernel.org
 help / color / mirror / Atom feed
From: Oliver Hartkopp <socketcan@hartkopp.net>
To: Fabio Baltieri <fabio.baltieri@gmail.com>
Cc: linux-can@vger.kernel.org
Subject: Re: [RFC PATCH] can: add tx/rx led trigger support
Date: Wed, 11 Apr 2012 20:29:33 +0200	[thread overview]
Message-ID: <4F85CD8D.9070107@hartkopp.net> (raw)
In-Reply-To: <CABkP77eNeTTwSxtKyfUmr7OC4H1nXEN4EeFH7pdR6=BcpKuE6w@mail.gmail.com>

On 11.04.2012 19:58, Fabio Baltieri wrote:


> On Wed, Apr 11, 2012 at 8:14 AM, Oliver Hartkopp <socketcan@hartkopp.net> wrote:

>> I wonder if it makes more sense to add the LED trigger stuff into
>> drivers/net/can/dev.c ?!?
> 
> Of course that seems to be the obvious (=correct) place to trap this
> stuff. The reason why I worked on upper layer is that I did not found
> any generic place to trap tx/rx events in the dev file without
> modifying every device driver, as while tx can be trapped in
> can_get_echo_skb(), rx frames are handled directly to the network
> layer.


I think that depends heavily on the driver and therefore adding the
can_led_tx() and can_led_rx() calls to the appropriate places is the most
transparent implementation.

IMO i would not(!) hide can_led_tx() in can_get_echo_skb() but place it next to
it in the interrupt function.

> 
>> Of course the correct calling points to trigger the rx/tx-LEDs need to be
>> implemented inside *each* driver at the correct position.
> 
> That's the point. So, do you think it would be better to add trigger
> functions into dev.c and modify each driver to call them?


Yes - as described above - something like this:

$ diff -U6 drivers/net/can/sja1000/sja1000.c drivers/net/can/sja1000/sja1000.c-new
--- drivers/net/can/sja1000/sja1000.c	2012-02-27 19:37:56.440594122 +0100
+++ drivers/net/can/sja1000/sja1000.c-new	2012-04-11 20:26:11.089344979 +0200
@@ -505,24 +505,26 @@
 			netdev_warn(dev, "wakeup interrupt\n");
 
 		if (isrc & IRQ_TI) {
 			/* transmission complete interrupt */
 			stats->tx_bytes += priv->read_reg(priv, REG_FI) & 0xf;
 			stats->tx_packets++;
+			can_led_tx(dev);
 			can_get_echo_skb(dev, 0);
 			netif_wake_queue(dev);
 		}
 		if (isrc & IRQ_RI) {
 			/* receive interrupt */
 			while (status & SR_RBS) {
 				sja1000_rx(dev);
 				status = priv->read_reg(priv, REG_SR);
 				/* check for absent controller */
 				if (status == 0xFF && sja1000_is_absent(priv))
 					return IRQ_NONE;
 			}
+			can_led_rx(dev);
 		}
 		if (isrc & (IRQ_DOI | IRQ_EI | IRQ_BEI | IRQ_EPI | IRQ_ALI)) {
 			/* error interrupt */
 			if (sja1000_err(dev, isrc, status))
 				break;
 		}



>> The question would be, if this code
>>
>>> +     if (!timer_pending(&priv->tx_off_timer)) {
>>> +             led_trigger_event(priv->tx_led, LED_FULL);
>>> +
>>> +             mod_timer(&priv->tx_off_timer,
>>> +                     jiffies + msecs_to_jiffies(led_off_delay));
>>> +     }
>>
>>
>> is ready to be used in hard IRQ context?
>>
>> If not we may use a construct with a tasklet that can be triggered from hard
>> IRQ context, like here:
>>
>>        http://lxr.linux.no/#linux+v3.3.1/net/can/bcm.c#L356
> 
> I think that led_trigger_event is ok as long as the actual
> led-<device>'s brigthness_set function is safe - for example
> leds-gpio's one seems to make some check about it. See:
> 
> http://lxr.linux.no/#linux+v3.3.1/drivers/leds/leds-gpio.c#L70
> 
> Will think about it.


Fine. So i'm looking forward to v2 :-)

Regards,
Oliver

  reply	other threads:[~2012-04-11 18:29 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-10 21:39 [RFC PATCH] can: add tx/rx led trigger support Fabio Baltieri
2012-04-11  6:14 ` Oliver Hartkopp
2012-04-11 17:58   ` Fabio Baltieri
2012-04-11 18:29     ` Oliver Hartkopp [this message]
2012-04-11 18:58       ` Wolfgang Grandegger
2012-04-12  6:16         ` Oliver Hartkopp
2012-04-11 19:02     ` Oliver Hartkopp
2012-04-11 19:36       ` Fabio Baltieri
2012-04-12  6:05         ` Oliver Hartkopp
2012-04-12  6:32         ` Alexander Stein
2012-04-12 15:52           ` Oliver Hartkopp
2012-04-12 18:30             ` Fabio Baltieri
2012-04-13 19:00               ` Oliver Hartkopp
2012-04-12  7:37         ` Wolfgang Grandegger
2012-04-12 11:07           ` Martin Gysel
2012-04-12 16:02             ` Oliver Hartkopp
2012-04-12 16:13               ` Wolfgang Grandegger
2012-04-12 17:28                 ` Fabio Baltieri
2012-04-12 18:47                   ` Wolfgang Grandegger
2012-04-12 17:46           ` Fabio Baltieri
2012-04-12 18:53             ` Wolfgang Grandegger
2012-04-11  6:29 ` Alexander Stein
2012-04-11 18:03   ` Fabio Baltieri
2012-04-11 14:45 ` Wolfgang Grandegger
2012-04-11 16:24   ` Oliver Hartkopp
2012-04-11 19:11   ` Fabio Baltieri

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=4F85CD8D.9070107@hartkopp.net \
    --to=socketcan@hartkopp.net \
    --cc=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