Message ID | 20240404114422.2905194-1-petr.zejdl@cern.ch |
---|---|
State | Accepted |
Commit | f03f962c602c428a1091c3e0fad25b4cf64c9497 |
Delegated to: | Michal Simek |
Headers | show |
Series | xilinx: common: Fix MAC address read from EEPROM | expand |
čt 4. 4. 2024 v 14:23 odesílatel Petr Zejdl <petr.zejdl@cern.ch> napsal: > The upper-to-lowercase character conversion now avoids altering the > MAC address field. In the previous version, this alteration corrupted > the MAC address. > > Signed-off-by: Petr Zejdl <petr.zejdl@cern.ch> > --- > board/xilinx/common/board.c | 12 ++++++++---- > 1 file changed, 8 insertions(+), 4 deletions(-) > > diff --git a/board/xilinx/common/board.c b/board/xilinx/common/board.c > index 66edf857f1..49dc5d10cc 100644 > --- a/board/xilinx/common/board.c > +++ b/board/xilinx/common/board.c > @@ -101,10 +101,14 @@ static void xilinx_eeprom_legacy_cleanup(char > *eeprom, int size) > for (i = 0; i < size; i++) { > byte = eeprom[i]; > > - /* Remove all non printable chars but ignore MAC address */ > - if ((i < offsetof(struct xilinx_legacy_format, eth_mac) || > - i >= offsetof(struct xilinx_legacy_format, unused1)) > && > - (byte < '!' || byte > '~')) { > + /* Ignore MAC address */ > + if (i >= offsetof(struct xilinx_legacy_format, eth_mac) && > + i < offsetof(struct xilinx_legacy_format, unused1)) { > + continue; > + } > + > + /* Remove all non printable chars */ > + if (byte < '!' || byte > '~') { > eeprom[i] = 0; > continue; > } > -- > 2.31.1 > > Applied. M
diff --git a/board/xilinx/common/board.c b/board/xilinx/common/board.c index 66edf857f1..49dc5d10cc 100644 --- a/board/xilinx/common/board.c +++ b/board/xilinx/common/board.c @@ -101,10 +101,14 @@ static void xilinx_eeprom_legacy_cleanup(char *eeprom, int size) for (i = 0; i < size; i++) { byte = eeprom[i]; - /* Remove all non printable chars but ignore MAC address */ - if ((i < offsetof(struct xilinx_legacy_format, eth_mac) || - i >= offsetof(struct xilinx_legacy_format, unused1)) && - (byte < '!' || byte > '~')) { + /* Ignore MAC address */ + if (i >= offsetof(struct xilinx_legacy_format, eth_mac) && + i < offsetof(struct xilinx_legacy_format, unused1)) { + continue; + } + + /* Remove all non printable chars */ + if (byte < '!' || byte > '~') { eeprom[i] = 0; continue; }
The upper-to-lowercase character conversion now avoids altering the MAC address field. In the previous version, this alteration corrupted the MAC address. Signed-off-by: Petr Zejdl <petr.zejdl@cern.ch> --- board/xilinx/common/board.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)