Re: [PATCH net v6 1/6] net: marvell: prestera: Add driver for Prestera family ASIC devices

From: Andy Shevchenko
Date: Thu Sep 03 2020 - 11:35:58 EST


On Thu, Sep 3, 2020 at 6:23 PM Willem de Bruijn
<willemdebruijn.kernel@xxxxxxxxx> wrote:
> On Wed, Sep 2, 2020 at 5:37 PM Vadym Kochan <vadym.kochan@xxxxxxxxxxx> wrote:

...

> > +static int prestera_is_valid_mac_addr(struct prestera_port *port, u8 *addr)
> > +{
> > + if (!is_valid_ether_addr(addr))
> > + return -EADDRNOTAVAIL;
> > +
> > + if (memcmp(port->sw->base_mac, addr, ETH_ALEN - 1))
>
> Why ETH_ALEN - 1?

We even have a lot of helpers specifically for ethernet MACs.
Starting from [1] till almost the end of the file. Here [2] can be
used (or its unaligned counterpart).

[1]: https://elixir.bootlin.com/linux/latest/source/include/linux/etherdevice.h#L67
[2]: https://elixir.bootlin.com/linux/latest/source/include/linux/etherdevice.h#L67

> > + return -EINVAL;
> > +
> > + return 0;
> > +}

> > + memcpy(dev->dev_addr, addr->sa_data, dev->addr_len);
>
> Is addr_len ever not ETH_ALEN for this device?

And if it is ETH_ALEN, here is [3].
[3]: https://elixir.bootlin.com/linux/latest/source/include/linux/etherdevice.h#L287

--
With Best Regards,
Andy Shevchenko