mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: Aleksander Jan Bajkowski <olek2@wp.pl>
Cc: lxu@maxlinear.com, hkallweit1@gmail.com, linux@armlinux.org.uk,
	davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
	pabeni@redhat.com, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, lee@kernel.org,
	linux-leds@vger.kernel.org, Daniel Golle <daniel@makrotopia.org>
Subject: Re: [PATCH net-next,v2 1/2] net: phy: add LED dimming support
Date: Sat, 5 Apr 2025 21:45:04 +0200	[thread overview]
Message-ID: <11bb4bcf-c3e6-4ab0-b61c-ef7f37dd695c@lunn.ch> (raw)
In-Reply-To: <20250405190954.703860-1-olek2@wp.pl>

On Sat, Apr 05, 2025 at 09:09:53PM +0200, Aleksander Jan Bajkowski wrote:
> Some PHYs support LED dimming. The use case is a router that dims LEDs
> at night. PHYs from different manufacturers support a different number of
> brightness levels, so it was necessary to extend the API with the
> led_max_brightness() function. If this function is omitted, a default
> value is used, assuming that only two levels are supported.
> 
> Signed-off-by: Aleksander Jan Bajkowski <olek2@wp.pl>
> Reviewed-by: Daniel Golle <daniel@makrotopia.org>

The merge window is still open at the moment, so you will need to
repost next week.


> ---
>  drivers/net/phy/phy_device.c | 7 ++++++-
>  include/linux/phy.h          | 7 +++++++
>  2 files changed, 13 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
> index 675fbd225378..4011ececca70 100644
> --- a/drivers/net/phy/phy_device.c
> +++ b/drivers/net/phy/phy_device.c
> @@ -3106,7 +3106,12 @@ static int of_phy_led(struct phy_device *phydev,
>  
>  	cdev->hw_control_get_device = phy_led_hw_control_get_device;
>  #endif
> -	cdev->max_brightness = 1;
> +	if (phydev->drv->led_max_brightness)
> +		cdev->max_brightness =
> +			phydev->drv->led_max_brightness(phydev, index);
> +	else
> +		cdev->max_brightness = 1;

> +	/**
> +	 * @led_max_brightness: Maximum number of brightness levels
> +	 * supported by hardware. When only two levels are supported
> +	 * i.e. LED_ON and LED_OFF the function can be omitted.
> +	 */
> +	int (*led_max_brightness)(struct phy_device *dev, u8 index);

We might want to consider types here. led_classdev->max_brightness is
an unsigned int. Your callback returns int, so it could include
-EOPNOTSUPP, -EINVAL, -ENODEV etc. There is no check for an error
code, so max_brightness is going to end up ~ 2^32, and not work very
well.

	Andrew

      parent reply	other threads:[~2025-04-05 19:45 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-05 19:09 Aleksander Jan Bajkowski
2025-04-05 19:09 ` [PATCH net-next,v2 2/2] net: phy: mxl-gpy: " Aleksander Jan Bajkowski
2025-04-05 19:52   ` Andrew Lunn
2025-04-06 12:20     ` Marek Behún
2025-04-05 19:45 ` Andrew Lunn [this message]

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=11bb4bcf-c3e6-4ab0-b61c-ef7f37dd695c@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=daniel@makrotopia.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=hkallweit1@gmail.com \
    --cc=kuba@kernel.org \
    --cc=lee@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=lxu@maxlinear.com \
    --cc=netdev@vger.kernel.org \
    --cc=olek2@wp.pl \
    --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

all inboxes | Powered by JetHome®