linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: ethernet: cortina: permit to set mac address in DT
@ 2021-10-26 19:17 Corentin Labbe
  2021-10-26 20:17 ` Linus Walleij
  2021-10-27  0:08 ` Andrew Lunn
  0 siblings, 2 replies; 4+ messages in thread
From: Corentin Labbe @ 2021-10-26 19:17 UTC (permalink / raw)
  To: davem, kuba, linus.walleij, ulli.kroll
  Cc: linux-arm-kernel, linux-kernel, netdev, Corentin Labbe

Add ability of setting mac address in DT for cortina ethernet driver.

Signed-off-by: Corentin Labbe <clabbe@baylibre.com>
---
 drivers/net/ethernet/cortina/gemini.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/net/ethernet/cortina/gemini.c b/drivers/net/ethernet/cortina/gemini.c
index 941f175fb911..f6aa2387a1af 100644
--- a/drivers/net/ethernet/cortina/gemini.c
+++ b/drivers/net/ethernet/cortina/gemini.c
@@ -2356,12 +2356,14 @@ static void gemini_port_save_mac_addr(struct gemini_ethernet_port *port)
 static int gemini_ethernet_port_probe(struct platform_device *pdev)
 {
 	char *port_names[2] = { "ethernet0", "ethernet1" };
+	struct device_node *np = pdev->dev.of_node;
 	struct gemini_ethernet_port *port;
 	struct device *dev = &pdev->dev;
 	struct gemini_ethernet *geth;
 	struct net_device *netdev;
 	struct device *parent;
 	unsigned int id;
+	u8 mac[ETH_ALEN];
 	int irq;
 	int ret;
 
@@ -2466,6 +2468,12 @@ static int gemini_ethernet_port_probe(struct platform_device *pdev)
 	netif_napi_add(netdev, &port->napi, gmac_napi_poll,
 		       DEFAULT_NAPI_WEIGHT);
 
+	ret = of_get_mac_address(np, mac);
+	if (!ret) {
+		dev_info(dev, "Setting macaddr from DT %pM\n", mac);
+		memcpy(port->mac_addr, mac, ETH_ALEN);
+	}
+
 	if (is_valid_ether_addr((void *)port->mac_addr)) {
 		eth_hw_addr_set(netdev, (u8 *)port->mac_addr);
 	} else {
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] net: ethernet: cortina: permit to set mac address in DT
  2021-10-26 19:17 [PATCH] net: ethernet: cortina: permit to set mac address in DT Corentin Labbe
@ 2021-10-26 20:17 ` Linus Walleij
  2021-10-27  0:08 ` Andrew Lunn
  1 sibling, 0 replies; 4+ messages in thread
From: Linus Walleij @ 2021-10-26 20:17 UTC (permalink / raw)
  To: Corentin Labbe
  Cc: David S. Miller, Jakub Kicinski, Hans Ulli Kroll, Linux ARM,
	linux-kernel, netdev

On Tue, Oct 26, 2021 at 9:17 PM Corentin Labbe <clabbe@baylibre.com> wrote:

> Add ability of setting mac address in DT for cortina ethernet driver.
>
> Signed-off-by: Corentin Labbe <clabbe@baylibre.com>

That looks useful!
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] net: ethernet: cortina: permit to set mac address in DT
  2021-10-26 19:17 [PATCH] net: ethernet: cortina: permit to set mac address in DT Corentin Labbe
  2021-10-26 20:17 ` Linus Walleij
@ 2021-10-27  0:08 ` Andrew Lunn
  2021-11-02  9:50   ` Corentin Labbe
  1 sibling, 1 reply; 4+ messages in thread
From: Andrew Lunn @ 2021-10-27  0:08 UTC (permalink / raw)
  To: Corentin Labbe
  Cc: davem, kuba, linus.walleij, ulli.kroll, linux-arm-kernel,
	linux-kernel, netdev

On Tue, Oct 26, 2021 at 07:17:03PM +0000, Corentin Labbe wrote:
> Add ability of setting mac address in DT for cortina ethernet driver.
> 
> Signed-off-by: Corentin Labbe <clabbe@baylibre.com>
> ---
>  drivers/net/ethernet/cortina/gemini.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/drivers/net/ethernet/cortina/gemini.c b/drivers/net/ethernet/cortina/gemini.c
> index 941f175fb911..f6aa2387a1af 100644
> --- a/drivers/net/ethernet/cortina/gemini.c
> +++ b/drivers/net/ethernet/cortina/gemini.c
> @@ -2356,12 +2356,14 @@ static void gemini_port_save_mac_addr(struct gemini_ethernet_port *port)
>  static int gemini_ethernet_port_probe(struct platform_device *pdev)
>  {
>  	char *port_names[2] = { "ethernet0", "ethernet1" };
> +	struct device_node *np = pdev->dev.of_node;
>  	struct gemini_ethernet_port *port;
>  	struct device *dev = &pdev->dev;
>  	struct gemini_ethernet *geth;
>  	struct net_device *netdev;
>  	struct device *parent;
>  	unsigned int id;
> +	u8 mac[ETH_ALEN];

Off by one in terms of reverse Christmas tree.

    Andrew

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] net: ethernet: cortina: permit to set mac address in DT
  2021-10-27  0:08 ` Andrew Lunn
@ 2021-11-02  9:50   ` Corentin Labbe
  0 siblings, 0 replies; 4+ messages in thread
From: Corentin Labbe @ 2021-11-02  9:50 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: Corentin Labbe, davem, kuba, linus.walleij, ulli.kroll,
	linux-arm-kernel, linux-kernel, netdev

Le Wed, Oct 27, 2021 at 02:08:04AM +0200, Andrew Lunn a écrit :
> On Tue, Oct 26, 2021 at 07:17:03PM +0000, Corentin Labbe wrote:
> > Add ability of setting mac address in DT for cortina ethernet driver.
> > 
> > Signed-off-by: Corentin Labbe <clabbe@baylibre.com>
> > ---
> >  drivers/net/ethernet/cortina/gemini.c | 8 ++++++++
> >  1 file changed, 8 insertions(+)
> > 
> > diff --git a/drivers/net/ethernet/cortina/gemini.c b/drivers/net/ethernet/cortina/gemini.c
> > index 941f175fb911..f6aa2387a1af 100644
> > --- a/drivers/net/ethernet/cortina/gemini.c
> > +++ b/drivers/net/ethernet/cortina/gemini.c
> > @@ -2356,12 +2356,14 @@ static void gemini_port_save_mac_addr(struct gemini_ethernet_port *port)
> >  static int gemini_ethernet_port_probe(struct platform_device *pdev)
> >  {
> >  	char *port_names[2] = { "ethernet0", "ethernet1" };
> > +	struct device_node *np = pdev->dev.of_node;
> >  	struct gemini_ethernet_port *port;
> >  	struct device *dev = &pdev->dev;
> >  	struct gemini_ethernet *geth;
> >  	struct net_device *netdev;
> >  	struct device *parent;
> >  	unsigned int id;
> > +	u8 mac[ETH_ALEN];
> 
> Off by one in terms of reverse Christmas tree.
> 

Hello

I will fix it in a v2

Thanks
Regards

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-11-02  9:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-26 19:17 [PATCH] net: ethernet: cortina: permit to set mac address in DT Corentin Labbe
2021-10-26 20:17 ` Linus Walleij
2021-10-27  0:08 ` Andrew Lunn
2021-11-02  9:50   ` Corentin Labbe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).