All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: "Marek Behún" <marek.behun@nic.cz>
Cc: "Marek Behún" <kabel@kernel.org>,
	linux-leds@vger.kernel.org, netdev@vger.kernel.org,
	"Pavel Machek" <pavel@ucw.cz>, "Dan Murphy" <dmurphy@ti.com>,
	"Russell King" <linux@armlinux.org.uk>,
	"Matthias Schiffer" <matthias.schiffer@ew.tq-group.com>,
	"Jacek Anaszewski" <jacek.anaszewski@gmail.com>,
	"Mauro Carvalho Chehab" <mchehab+huawei@kernel.org>
Subject: Re: [PATCH leds v1 4/5] leds: trigger: netdev: support HW offloading
Date: Fri, 28 May 2021 15:50:08 +0200	[thread overview]
Message-ID: <YLD1ELr5csaat6Uk@lunn.ch> (raw)
In-Reply-To: <20210528084556.69bbba1a@dellmb>

On Fri, May 28, 2021 at 08:45:56AM +0200, Marek Behún wrote:
> On Thu, 27 May 2021 18:57:17 +0200
> Andrew Lunn <andrew@lunn.ch> wrote:
> 
> > On Wed, May 26, 2021 at 08:00:19PM +0200, Marek Behún wrote:
> > > Add support for HW offloading of the netdev trigger.
> > > 
> > > We need to export the netdev_led_trigger variable so that drivers
> > > may check whether the LED is set to this trigger.  
> > 
> > Without seeing the driver side, it is not obvious to me why this is
> > needed. Please add the driver changes to this patchset, so we can
> > fully see how the API works.
> 
> OK, I will send an implementation for leds-turris-omnia with v2.
> 
> The idea is that the trigger_offload() method should check which
> trigger it should offload. A potential LED controller may be configured
> to link the LED on net activity, or on SATA activity. So the method
> should do something like this:
> 
>   static int my_trigger_offload(struct led_classdev *cdev, bool enable)
>   {
>     if (!enable)
>       return my_disable_hw_triggering(cdev);
> 	
>     if (cdev->trigger == &netdev_led_trigger)
>       return my_offload_netdev_triggering(cdev);
>     else if (cdev->trigger == &blkdev_led_trigger)
>       return my_offload_blkdev_triggering(cdev);
>     else
>       return -EOPNOTSUPP;
>   }

So the hardware driver does not need the contents of the trigger? It
never manipulates the trigger. Maybe to keep the abstraction cleaner,
an enum can be added to the trigger to identify it. The code then
becomes:

static int my_trigger_offload(struct led_classdev *cdev, bool enable)
{
	if (!enable)
        	return my_disable_hw_triggering(cdev);
 	
	switch(cdev->trigger->trigger) {
	case TRIGGER_NETDEV:
	       return my_offload_netdev_triggering(cdev);
	case TRIGGER_BLKDEV:
	       return my_offload_blkdev_triggering(cdev);
	default:
	       return -EOPNOTSUPP;
}	

	Andrew

  reply	other threads:[~2021-05-28 13:50 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-26 18:00 [PATCH leds v1 0/5] Add support for offloading netdev trigger to HW Marek Behún
2021-05-26 18:00 ` [PATCH leds v1 1/5] leds: trigger: netdev: don't explicitly zero kzalloced data Marek Behún
2021-05-27 16:38   ` Andrew Lunn
2021-05-26 18:00 ` [PATCH leds v1 2/5] leds: trigger: add API for HW offloading of triggers Marek Behún
2021-05-26 18:00 ` [PATCH leds v1 3/5] leds: trigger: netdev: move trigger data structure to global include dir Marek Behún
2021-05-27 16:48   ` Andrew Lunn
2021-05-28  6:28     ` Marek Behún
2021-05-26 18:00 ` [PATCH leds v1 4/5] leds: trigger: netdev: support HW offloading Marek Behún
2021-05-27 16:57   ` Andrew Lunn
2021-05-28  6:45     ` Marek Behún
2021-05-28 13:50       ` Andrew Lunn [this message]
2021-05-28 13:57         ` Marek Behún
2021-05-26 18:00 ` [PATCH leds v1 5/5] leds: trigger: netdev: change spinlock to mutex Marek Behún

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=YLD1ELr5csaat6Uk@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=dmurphy@ti.com \
    --cc=jacek.anaszewski@gmail.com \
    --cc=kabel@kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=marek.behun@nic.cz \
    --cc=matthias.schiffer@ew.tq-group.com \
    --cc=mchehab+huawei@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pavel@ucw.cz \
    /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 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.