All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: Michael Walle <michael@walle.cc>
Cc: netdev <netdev@vger.kernel.org>
Subject: Re: [PATCH 2/2] of: net: fix of_get_mac_addr_nvmem() for PCI and DSA nodes
Date: Tue, 6 Apr 2021 00:13:34 +0200	[thread overview]
Message-ID: <YGuLjiozGIxsGYQy@lunn.ch> (raw)
In-Reply-To: <2d6eef78762562bcbb732179b32f0fd9@walle.cc>

On Mon, Apr 05, 2021 at 11:46:04PM +0200, Michael Walle wrote:
> Hi Andrew,
> 
> Am 2021-04-05 23:34, schrieb Andrew Lunn:
> > > -static int of_get_mac_addr_nvmem(struct device_node *np, u8 addr)
> > > +static int of_get_mac_addr_nvmem(struct device_node *np, u8 *addr)
> > >  {
> > >  	struct platform_device *pdev = of_find_device_by_node(np);
> > > +	struct nvmem_cell *cell;
> > > +	const void *mac;
> > > +	size_t len;
> > >  	int ret;
> > > 
> > > -	if (!pdev)
> > > -		return -ENODEV;
> > > +	/* Try lookup by device first, there might be a nvmem_cell_lookup
> > > +	 * associated with a given device.
> > > +	 */
> > > +	if (pdev) {
> > > +		ret = nvmem_get_mac_address(&pdev->dev, addr);
> > > +		put_device(&pdev->dev);
> > > +		return ret;
> > > +	}
> > 
> > Can you think of any odd corner case where nvmem_get_mac_address()
> > would fail, but of_nvmem_cell_get(np, "mac-address") would work?
> 
> You mean, it might make sense to just return here when
> nvmem_get_mac_address() will succeed and fall back to the
> of_nvmem_cell_get() in case of an error?

I've not read the documentation for nvmem_get_mac_address(). I was
thinking we might want to return real errors, and -EPROBE_DEFER. But
maybe with -ENODEV we should try of_nvmem_cell_get()?

But i'm not sure if there are any real use cases? The only thing i can
think of is if np points to something deeper inside the device tree
than what pdev does?

     Andrew

  reply	other threads:[~2021-04-05 22:13 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-05 16:46 [PATCH 0/2] of: net: support non-platform devices in of_get_mac_address() Michael Walle
2021-04-05 16:46 ` Michael Walle
2021-04-05 16:46 ` Michael Walle
2021-04-05 16:46 ` Michael Walle
2021-04-05 16:46 ` [PATCH 1/2] of: net: pass the dst buffer to of_get_mac_address() Michael Walle
2021-04-05 16:46   ` Michael Walle
2021-04-05 16:46   ` Michael Walle
2021-04-05 16:46   ` Michael Walle
2021-04-05 19:19   ` kernel test robot
2021-04-05 19:19     ` kernel test robot
2021-04-05 19:19     ` kernel test robot
2021-04-05 19:19     ` kernel test robot
2021-04-05 19:19     ` kernel test robot
2021-04-05 21:25     ` Andrew Lunn
2021-04-05 21:25       ` Andrew Lunn
2021-04-05 21:25       ` Andrew Lunn
2021-04-05 21:25       ` Andrew Lunn
2021-04-05 21:25       ` Andrew Lunn
2021-04-05 21:25       ` Andrew Lunn
2021-04-05 16:46 ` [PATCH 2/2] of: net: fix of_get_mac_addr_nvmem() for PCI and DSA nodes Michael Walle
2021-04-05 16:46   ` Michael Walle
2021-04-05 16:46   ` Michael Walle
2021-04-05 16:46   ` Michael Walle
2021-04-05 21:34   ` Andrew Lunn
2021-04-05 21:46     ` Michael Walle
2021-04-05 22:13       ` Andrew Lunn [this message]
2021-04-06  8:59         ` Michael Walle
2021-04-06 12:40           ` Andrew Lunn
2021-04-07  1:13   ` Rob Herring
2021-04-07  1:13     ` Rob Herring
2021-04-07  1:13     ` Rob Herring
2021-04-07  1:13     ` Rob Herring

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=YGuLjiozGIxsGYQy@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=michael@walle.cc \
    --cc=netdev@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 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.