All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dimitri Fedrau <dima.fedrau@gmail.com>
To: Andrew Lunn <andrew@lunn.ch>
Cc: Heiner Kallweit <hkallweit1@gmail.com>,
	Russell King <linux@armlinux.org.uk>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next] net: phy: dp83822: Add support for PHY LEDs on DP83822
Date: Wed, 18 Dec 2024 21:44:49 +0100	[thread overview]
Message-ID: <20241218204449.GA797439@debian> (raw)
In-Reply-To: <4f40c476-565f-4f74-8cab-7250045fdd90@lunn.ch>

Am Wed, Dec 18, 2024 at 09:19:47PM +0100 schrieb Andrew Lunn:
> On Wed, Dec 18, 2024 at 07:17:52PM +0100, Dimitri Fedrau wrote:
> > Am Wed, Dec 18, 2024 at 06:16:20PM +0100 schrieb Andrew Lunn:
> > > > By the way. Wouldn't it be helpful adding a u32 max_leds to
> > > > struct phy_driver ? Every driver supporting PHY LEDs validates index at the
> > > > moment. With max_leds it should be easy to check it in of_phy_leds and
> > > > return with an error if index is not valid.
> > > 
> > > I have been considering it. However, so far developers have been good
> > > at adding the checks, because the first driver had the checks, cargo
> > > cult at its best.
> > > 
> > > If we are going to add it, we should do it early, before there are too
> > > many PHY drivers which need updating.
> > >
> > Another solution without breaking others driver would be to add a
> > callback in struct phy_driver:
> 
> Adding the maximum number of LEDs to struct phy_driver will not break
> anything. But we would want to remove all the tests for the index
> value from the drivers, since they become pointless. That will be
> easier to do when there are less drivers which need editing.
>
Just adding the number will not break anything, but probably the test
that should be implemented in of_phy_led. Except the test gets skipped if
maximum number of LEDs is not set(zero). Otherwise we would have to
change all existing drivers to set the maximum numbers of LEDs.

> > int (*led_validate_index)(struct phy_device *dev, int index)
> > It should be called in of_phy_led right after reading in reg property:
> > if (phydev->drv->led_validate_index)
> > 	ret = phydev->drv->led_validate_index(phydev, index);
> > 
> > This would solve another isssue I have. The LED pins of the DP83822 can
> > be multiplexed. Not all of them have per default a LED function. So I
> > need to set them up. In dp83822_of_init_leds I iterate over all DT nodes
> > in leds to get the information which of the pins should output LED
> > function. Using the callback would eleminate the need for copying code of
> > functions of_phy_leds and of_phy_led.
> 
> Your hardware is pretty unique. It might be best to keep it in the
> driver, until there is a second driver which needs the same. I also
> think you need the complete configuration in order to validate it, not
> each LED one by one, which your led_validate_index() would provide.
>
I have implemented LED support for marvell-88q2xxx.c which I wanted to
upstream after LED support for DP83822 is done. There I have the same
issue.
You are right, I need the whole configuration. But at the moment I read
it in the same way as it is done in of_phy_led and save indices to
bool led_pin_enable[DP83822_MAX_LED_PINS] and set them up later in
dp83822_config_init.

How do we proceed ? Implement maximum numbers of LEDs ? Skip the
validation index callback when upstreaming LED support for
marvell-88q2xxx.c ?

Best regards,
Dimitri

  reply	other threads:[~2024-12-18 20:44 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-17  9:16 [PATCH net-next] net: phy: dp83822: Add support for PHY LEDs on DP83822 Dimitri Fedrau
2024-12-17 16:32 ` Simon Horman
2024-12-17 17:54   ` Dimitri Fedrau
2024-12-17 17:13 ` Andrew Lunn
2024-12-17 17:59   ` Dimitri Fedrau
2024-12-18 17:13     ` Andrew Lunn
2024-12-18  8:54   ` Dimitri Fedrau
2024-12-18 17:16     ` Andrew Lunn
2024-12-18 18:17       ` Dimitri Fedrau
2024-12-18 20:19         ` Andrew Lunn
2024-12-18 20:44           ` Dimitri Fedrau [this message]
2024-12-18  8:32 ` kernel test robot

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=20241218204449.GA797439@debian \
    --to=dima.fedrau@gmail.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=hkallweit1@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=netdev@vger.kernel.org \
    --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 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.