mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Florian Fainelli <f.fainelli@gmail.com>
To: Thomas Bogendoerfer <tsbogend@alpha.franken.de>,
	"David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 net-next 7/9] net: korina: Add support for device tree
Date: Wed, 14 Apr 2021 11:33:25 -0700	[thread overview]
Message-ID: <ac7b7eb9-5208-f895-943d-3191111442e0@gmail.com> (raw)
In-Reply-To: <20210414152946.12517-8-tsbogend@alpha.franken.de>



On 4/14/2021 8:29 AM, Thomas Bogendoerfer wrote:
> If there is no mac address passed via platform data try to get it via
> device tree and fall back to a random mac address, if all fail.
> 
> Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
> ---
>  drivers/net/ethernet/korina.c | 29 ++++++++++++++++++++++++++---
>  1 file changed, 26 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/net/ethernet/korina.c b/drivers/net/ethernet/korina.c
> index 69c8baa87a6e..c4590b2c65aa 100644
> --- a/drivers/net/ethernet/korina.c
> +++ b/drivers/net/ethernet/korina.c
> @@ -42,6 +42,8 @@
>  #include <linux/interrupt.h>
>  #include <linux/ioport.h>
>  #include <linux/in.h>
> +#include <linux/of_device.h>
> +#include <linux/of_net.h>
>  #include <linux/slab.h>
>  #include <linux/string.h>
>  #include <linux/delay.h>
> @@ -1056,7 +1058,7 @@ static const struct net_device_ops korina_netdev_ops = {
>  
>  static int korina_probe(struct platform_device *pdev)
>  {
> -	u8 *mac_addr = dev_get_platdata(&pdev->dev);
> +	const u8 *mac_addr = dev_get_platdata(&pdev->dev);
>  	struct korina_private *lp;
>  	struct net_device *dev;
>  	void __iomem *p;
> @@ -1069,7 +1071,15 @@ static int korina_probe(struct platform_device *pdev)
>  	SET_NETDEV_DEV(dev, &pdev->dev);
>  	lp = netdev_priv(dev);
>  
> -	memcpy(dev->dev_addr, mac_addr, ETH_ALEN);
> +	if (mac_addr) {
> +		ether_addr_copy(dev->dev_addr, mac_addr);
> +	} else {
> +		mac_addr = of_get_mac_address(pdev->dev.of_node);
> +		if (!IS_ERR(mac_addr))
> +			ether_addr_copy(dev->dev_addr, mac_addr);
> +		else
> +			eth_hw_addr_random(dev);
> +	}
>  
>  	lp->rx_irq = platform_get_irq_byname(pdev, "korina_rx");
>  	lp->tx_irq = platform_get_irq_byname(pdev, "korina_tx");
> @@ -1149,8 +1159,21 @@ static int korina_remove(struct platform_device *pdev)
>  	return 0;
>  }
>  
> +#ifdef CONFIG_OF
> +static const struct of_device_id korina_match[] = {
> +	{
> +		.compatible = "korina",
> +	},

If you add Device Tree, you might as well provide a binding document for
this controller and possibly pick up a better name than what this driver
had to begin with (in hindsight rb532 is also a bad name since it was
just one board instance), how about using idt,rc32434-emac or something
along these lines?
-- 
Florian

  reply	other threads:[~2021-04-14 18:33 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-14 15:29 [PATCH v2 net-next 0/9] net: Korina improvements Thomas Bogendoerfer
2021-04-14 15:29 ` [PATCH v2 net-next 1/9] net: korina: Fix MDIO functions Thomas Bogendoerfer
2021-04-14 15:29 ` [PATCH v2 net-next 2/9] net: korina: Use devres functions Thomas Bogendoerfer
2021-04-14 15:29 ` [PATCH v2 net-next 3/9] net: korina: Remove not needed cache flushes Thomas Bogendoerfer
2021-04-14 15:29 ` [PATCH v2 net-next 4/9] net: korina: Remove nested helpers Thomas Bogendoerfer
2021-04-14 15:29 ` [PATCH v2 net-next 5/9] net: korina: Use DMA API Thomas Bogendoerfer
2021-04-14 15:29 ` [PATCH v2 net-next 6/9] net: korina: Only pass mac address via platform data Thomas Bogendoerfer
2021-04-14 15:29 ` [PATCH v2 net-next 7/9] net: korina: Add support for device tree Thomas Bogendoerfer
2021-04-14 18:33   ` Florian Fainelli [this message]
2021-04-14 15:29 ` [PATCH v2 net-next 8/9] net: korina: Get mdio input clock via common clock framework Thomas Bogendoerfer
2021-04-14 15:29 ` [PATCH v2 net-next 9/9] net: korina: Make driver COMPILE_TESTable Thomas Bogendoerfer
2021-04-15  2:48   ` kernel test robot
2021-04-14 21:10 ` [PATCH v2 net-next 0/9] net: Korina improvements David Miller

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=ac7b7eb9-5208-f895-943d-3191111442e0@gmail.com \
    --to=f.fainelli@gmail.com \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=tsbogend@alpha.franken.de \
    /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®