* [PATCH] net/smscx5xx: change to of_get_mac_address() eth_platform_get_mac_address()
[not found] <CGME20200930142529eucas1p12ae6db625be4a7bdfaf2ca60bf94cb8e@eucas1p1.samsung.com>
@ 2020-09-30 14:25 ` Łukasz Stelmach
2020-10-02 2:05 ` David Miller
0 siblings, 1 reply; 5+ messages in thread
From: Łukasz Stelmach @ 2020-09-30 14:25 UTC (permalink / raw)
To: Steve Glendinning, Microchip Linux Driver Support,
David S. Miller, Jakub Kicinski, netdev, linux-usb
Cc: b.zolnierkie, m.szyprowski, Łukasz Stelmach
Use more generic eth_platform_get_mac_address() which can get a MAC
address from other than DT platform specific sources too. Check if the
obtained address is valid.
Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
---
drivers/net/usb/smsc75xx.c | 13 +++++++------
drivers/net/usb/smsc95xx.c | 13 +++++++------
2 files changed, 14 insertions(+), 12 deletions(-)
diff --git a/drivers/net/usb/smsc75xx.c b/drivers/net/usb/smsc75xx.c
index 9556d431885f..8689835a5214 100644
--- a/drivers/net/usb/smsc75xx.c
+++ b/drivers/net/usb/smsc75xx.c
@@ -757,13 +757,14 @@ static int smsc75xx_ioctl(struct net_device *netdev, struct ifreq *rq, int cmd)
static void smsc75xx_init_mac_address(struct usbnet *dev)
{
- const u8 *mac_addr;
-
/* maybe the boot loader passed the MAC address in devicetree */
- mac_addr = of_get_mac_address(dev->udev->dev.of_node);
- if (!IS_ERR(mac_addr)) {
- ether_addr_copy(dev->net->dev_addr, mac_addr);
- return;
+ if (!eth_platform_get_mac_address(&dev->udev->dev,
+ dev->net->dev_addr)) {
+ if (is_valid_ether_addr(dev->net->dev_addr)) {
+ /* device tree values are valid so use them */
+ netif_dbg(dev, ifup, dev->net, "MAC address read from the device tree\n");
+ return;
+ }
}
/* try reading mac address from EEPROM */
diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c
index 601fb40a2a0a..ea0d5f04dc3a 100644
--- a/drivers/net/usb/smsc95xx.c
+++ b/drivers/net/usb/smsc95xx.c
@@ -755,13 +755,14 @@ static int smsc95xx_ioctl(struct net_device *netdev, struct ifreq *rq, int cmd)
static void smsc95xx_init_mac_address(struct usbnet *dev)
{
- const u8 *mac_addr;
-
/* maybe the boot loader passed the MAC address in devicetree */
- mac_addr = of_get_mac_address(dev->udev->dev.of_node);
- if (!IS_ERR(mac_addr)) {
- ether_addr_copy(dev->net->dev_addr, mac_addr);
- return;
+ if (!eth_platform_get_mac_address(&dev->udev->dev,
+ dev->net->dev_addr)) {
+ if (is_valid_ether_addr(dev->net->dev_addr)) {
+ /* device tree values are valid so use them */
+ netif_dbg(dev, ifup, dev->net, "MAC address read from the device tree\n");
+ return;
+ }
}
/* try reading mac address from EEPROM */
--
2.26.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] net/smscx5xx: change to of_get_mac_address() eth_platform_get_mac_address()
2020-09-30 14:25 ` [PATCH] net/smscx5xx: change to of_get_mac_address() eth_platform_get_mac_address() Łukasz Stelmach
@ 2020-10-02 2:05 ` David Miller
2020-10-02 2:45 ` Florian Fainelli
0 siblings, 1 reply; 5+ messages in thread
From: David Miller @ 2020-10-02 2:05 UTC (permalink / raw)
To: l.stelmach
Cc: steve.glendinning, UNGLinuxDriver, kuba, netdev, linux-usb,
b.zolnierkie, m.szyprowski
From: Łukasz Stelmach <l.stelmach@samsung.com>
Date: Wed, 30 Sep 2020 16:25:25 +0200
> Use more generic eth_platform_get_mac_address() which can get a MAC
> address from other than DT platform specific sources too. Check if the
> obtained address is valid.
>
> Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
Failure to probe a MAC address should result in the selection of a
random one. This way, the interface still comes up and is usable
even when the MAC address fails to be probed.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] net/smscx5xx: change to of_get_mac_address() eth_platform_get_mac_address()
2020-10-02 2:05 ` David Miller
@ 2020-10-02 2:45 ` Florian Fainelli
[not found] ` <CGME20201002073950eucas1p24615a7f620afa1c1f9c0fc2e47daaef0@eucas1p2.samsung.com>
0 siblings, 1 reply; 5+ messages in thread
From: Florian Fainelli @ 2020-10-02 2:45 UTC (permalink / raw)
To: David Miller, l.stelmach
Cc: steve.glendinning, UNGLinuxDriver, kuba, netdev, linux-usb,
b.zolnierkie, m.szyprowski
On 10/1/2020 7:05 PM, David Miller wrote:
> From: Łukasz Stelmach <l.stelmach@samsung.com>
> Date: Wed, 30 Sep 2020 16:25:25 +0200
>
>> Use more generic eth_platform_get_mac_address() which can get a MAC
>> address from other than DT platform specific sources too. Check if the
>> obtained address is valid.
>>
>> Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
>
> Failure to probe a MAC address should result in the selection of a
> random one. This way, the interface still comes up and is usable
> even when the MAC address fails to be probed.
True, however this behavior is not changed after this patch is applied,
I would argue that this should be a separate patch.
--
Florian
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] net/smscx5xx: change to of_get_mac_address() eth_platform_get_mac_address()
[not found] ` <CGME20201002073950eucas1p24615a7f620afa1c1f9c0fc2e47daaef0@eucas1p2.samsung.com>
@ 2020-10-02 7:39 ` Lukasz Stelmach
2020-10-02 22:21 ` David Miller
0 siblings, 1 reply; 5+ messages in thread
From: Lukasz Stelmach @ 2020-10-02 7:39 UTC (permalink / raw)
To: Florian Fainelli
Cc: David Miller, steve.glendinning, UNGLinuxDriver, kuba, netdev,
linux-usb, b.zolnierkie, m.szyprowski
[-- Attachment #1: Type: text/plain, Size: 1397 bytes --]
It was <2020-10-01 czw 19:45>, when Florian Fainelli wrote:
> On 10/1/2020 7:05 PM, David Miller wrote:
>> From: Łukasz Stelmach <l.stelmach@samsung.com>
>> Date: Wed, 30 Sep 2020 16:25:25 +0200
>>
>>> Use more generic eth_platform_get_mac_address() which can get a MAC
>>> address from other than DT platform specific sources too. Check if the
>>> obtained address is valid.
>>>
>>> Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
>>
>> Failure to probe a MAC address should result in the selection of a
>> random one. This way, the interface still comes up and is usable
>> even when the MAC address fails to be probed.
>
> True, however this behavior is not changed after this patch is
> applied, I would argue that this should be a separate patch.
In both drivers the second to last line of the *_init_mac_address()[1][2]
functions is
eth_hw_addr_random(dev->net);
and I haven't changed that. My patches enable getting a MAC address via
arch/platform specific function[3] arch_get_platform_mac_address() if
of_get_mac_address() fails.
[1] https://elixir.bootlin.com/linux/v5.8/source/drivers/net/usb/smsc75xx.c#L758
[2] https://elixir.bootlin.com/linux/v5.8/source/drivers/net/usb/smsc95xx.c#L902
[3] https://elixir.bootlin.com/linux/v5.8/source/net/ethernet/eth.c#L502
--
Łukasz Stelmach
Samsung R&D Institute Poland
Samsung Electronics
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] net/smscx5xx: change to of_get_mac_address() eth_platform_get_mac_address()
2020-10-02 7:39 ` Lukasz Stelmach
@ 2020-10-02 22:21 ` David Miller
0 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2020-10-02 22:21 UTC (permalink / raw)
To: l.stelmach
Cc: f.fainelli, steve.glendinning, UNGLinuxDriver, kuba, netdev,
linux-usb, b.zolnierkie, m.szyprowski
From: Lukasz Stelmach <l.stelmach@samsung.com>
Date: Fri, 02 Oct 2020 09:39:40 +0200
> In both drivers the second to last line of the *_init_mac_address()[1][2]
> functions is
>
> eth_hw_addr_random(dev->net);
My bad, indeed it does take care of this already.
Applied to net-next, thanks.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-10-02 22:21 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <CGME20200930142529eucas1p12ae6db625be4a7bdfaf2ca60bf94cb8e@eucas1p1.samsung.com>
2020-09-30 14:25 ` [PATCH] net/smscx5xx: change to of_get_mac_address() eth_platform_get_mac_address() Łukasz Stelmach
2020-10-02 2:05 ` David Miller
2020-10-02 2:45 ` Florian Fainelli
[not found] ` <CGME20201002073950eucas1p24615a7f620afa1c1f9c0fc2e47daaef0@eucas1p2.samsung.com>
2020-10-02 7:39 ` Lukasz Stelmach
2020-10-02 22:21 ` David Miller
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.