Re: [RFC PATCH net-next v4 2/3] net: stmmac: Add glue driver for Motorcomm YT6801 ethernet controller

Andrew Lunn
2025-12-21T20:42:38Z

> +static int motorcomm_efuse_read_patch(struct dwmac_motorcomm_priv *priv,
> + u8 index,
> + struct motorcomm_efuse_patch *patch)
> +{
> + u8 buf[sizeof(*patch)], offset;
> + int i, ret;
> +
> + for (i = 0; i < sizeof(*patch); i++) {
> + offset = EFUSE_PATCH_REGION_OFFSET + sizeof(*patch) * index + i;
> +
> + ret = motorcomm_efuse_read_byte(priv, offset, &buf[i]);
> + if (ret)
> + return ret;
> + }
> +
> + memcpy(patch, buf, sizeof(*patch));

Why do you write it into a temporary buffer and then copy it to patch?
Why not put it straight into patch?

> + ret = motorcomm_efuse_read_mac(priv, res.mac);
> + if (ret == -ENOENT) {
> + dev_warn(&pdev->dev, "eFuse contains no valid MAC address\n");
> + dev_warn(&pdev->dev, "fallback to random MAC address\n");
> +
> + memset(res.mac, 0, sizeof(res.mac));

It is not clear how setting this to zero results in a random MAC
address. Maybe actually call eth_random_addr()?

Andrew