public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: "Marek Behún" <kabel@kernel.org>
To: Heiner Kallweit <hkallweit1@gmail.com>
Cc: Realtek linux nic maintainers <nic_swsd@realtek.com>,
	Paolo Abeni <pabeni@redhat.com>, Jakub Kicinski <kuba@kernel.org>,
	David Miller <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>
Subject: Re: [PATCH v2 net-next] r8169: add support for LED's on RTL8168/RTL8101
Date: Mon, 11 Dec 2023 10:53:29 +0100	[thread overview]
Message-ID: <20231211105329.598473b9@dellmb> (raw)
In-Reply-To: <8861e5b7-b1f5-4ae7-9115-76d7256dec62@gmail.com>

Hello Heiner,

On Fri, 8 Dec 2023 18:48:27 +0100
Heiner Kallweit <hkallweit1@gmail.com> wrote:

> +static void rtl8168_setup_ldev(struct r8169_led_classdev *ldev,
> +			       struct net_device *ndev, int index)
> +{
> +	struct rtl8169_private *tp = netdev_priv(ndev);
> +	struct led_classdev *led_cdev = &ldev->led;
> +	char led_name[LED_MAX_NAME_SIZE];
> +
> +	ldev->ndev = ndev;
> +	ldev->index = index;
> +
> +	r8169_get_led_name(tp, index, led_name, LED_MAX_NAME_SIZE);
> +	led_cdev->name = led_name;
> +	led_cdev->default_trigger = "netdev";
> +	led_cdev->hw_control_trigger = "netdev";
> +	led_cdev->flags |= LED_RETAIN_AT_SHUTDOWN;
> +	led_cdev->hw_control_is_supported = rtl8168_led_hw_control_is_supported;
> +	led_cdev->hw_control_set = rtl8168_led_hw_control_set;
> +	led_cdev->hw_control_get = rtl8168_led_hw_control_get;
> +	led_cdev->hw_control_get_device = r8169_led_hw_control_get_device;
> +
> +	/* ignore errors */
> +	devm_led_classdev_register(&ndev->dev, led_cdev);
> +}

...

> +void r8169_get_led_name(struct rtl8169_private *tp, int idx,
> +			char *buf, int buf_len)
> +{
> +	snprintf(buf, buf_len, "r8169-%x%x-led%d",
> +		 pci_domain_nr(tp->pci_dev->bus),
> +		 pci_dev_id(tp->pci_dev), idx);
> +}

Please look at Documentation/leds/leds-class.rst:
  https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/leds/leds-class.rst?h=v6.7-rc5

LED devices should have name in the format
  "devicename:color:function"
Where color is one from the led_colors array from
drivers/leds/led-core.c (or omitted if you cannot know) and function is
one from the LED_FUNCTION_ macros from
include/dt-bindings/leds/common.h.

When skipping color, you should keep the colon sign, i.e.
  usbnet0::lan

Regarding the devicename part: originally it was thought to be
something like eth0 (like the LED for mmc0 has devicename mmc0),
but since network interfaces can be renamed and their names are not
guaranteeed to be persisnet across boots, maybe you can reuse the
Predictable Network Interface Names scheme for USB devices
  https://www.freedesktop.org/software/systemd/man/latest/systemd.net-naming-scheme.html

Please don't put the driver name (r8169) there.

Marek

  reply	other threads:[~2023-12-11  9:53 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-08 17:48 [PATCH v2 net-next] r8169: add support for LED's on RTL8168/RTL8101 Heiner Kallweit
2023-12-11  9:53 ` Marek Behún [this message]
  -- strict thread matches above, loose matches on Subject: below --
2023-12-16 19:58 Heiner Kallweit
2023-12-20 11:50 ` patchwork-bot+netdevbpf

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=20231211105329.598473b9@dellmb \
    --to=kabel@kernel.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=hkallweit1@gmail.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=nic_swsd@realtek.com \
    --cc=pabeni@redhat.com \
    /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