Re: [PATCH 3/3] ARM: boards: Add MyirTech MYD-YA15XC-T development board support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 05.09.23 10:25, Ahmad Fatoum wrote:
> On 31.08.23 11:41, Alexander Shiyan wrote:
>>>> +struct id_eeprom {
>>>> +     u8 hrcw_primary[0x10];
>>>> +     u8 pn[64];
>>>> +     u8 sn[64];
>>>> +     u8 mac0[6];
>>>> +     u8 mac1[6];
>>>> +} __packed;
>>>
>>> You could describe this as nvmem-cells in the DT and you'd automatically
>>> get the MAC addresses assigned.
>> ...
>>>> +     if (!is_valid_ether_addr(eeprom.mac0)) {
>>>> +             int i, j;
>>>> +
>>>> +             /* Make fixed MAC-address based on serial number */
>>>> +             memcpy(eeprom.mac0, str, sizeof(eeprom.mac0));
>>>> +             for (i = sizeof(eeprom.mac0); i < len; i++)
>>>> +                     for (j = 0; j < sizeof(eeprom.mac0); j++)
>>>> +                             eeprom.mac0[j] ^= str[i];
>>>> +     }
>>>> +
>>>> +     eth_register_ethaddr(0, eeprom.mac0);
>>> You could check if the nvmem cell exists and only do the fixup
>>> if it doesn't. Check Marco's recent Debix patches for an example
>>> of how to call nvmem from board code.
>>
>> I can't find a way to know if an MAC address that was automatically
>> assigned via nvmem is valid.
>> So in this case we always need to use eth_register_ethaddr() manually?
> 
> You could fetch the nvmem cell and verify it yourself before MAC address
> is assigned. What I'd like to have eventually is a Kconfig option to
> generate a MAC address out of the serial number automatically if one was
> set and if not, only then fall back to randomization.
> 
> I even have patches somewhere. Let me check.

I reworked them a bit and just sent them out. Looking forward to your feedback.

> 
> Cheers,
> Ahmad
> 
>>
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |





[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux