On Mon, Mar 21, 2022 at 10:26:06AM +0100, Oleksij Rempel wrote:
> Port SJA11xx driver from u-boot v2022.04-rc2 to provide support for NXP 
> SJA11xx
> series of switches.
> 
> Signed-off-by: Oleksij Rempel <o.rem...@pengutronix.de>
> ---
>  drivers/net/Kconfig   |   17 +
>  drivers/net/Makefile  |    1 +
>  drivers/net/sja1105.c | 2918 +++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 2936 insertions(+)
>  create mode 100644 drivers/net/sja1105.c
> 
> +
> +static int sja1105_check_device_id(struct sja1105_private *priv)
> +{
> +     const struct sja1105_regs *regs = priv->info->regs;
> +     u8 packed_buf[SJA1105_SIZE_DEVICE_ID] = {0};
> +     enum sja1105_switch_id id;
> +     u64 device_id;
> +     u64 part_no;
> +     int rc;
> +
> +     rc = sja1105_xfer_buf(priv, SPI_READ, regs->device_id, packed_buf,
> +                           SJA1105_SIZE_DEVICE_ID);
> +     if (rc < 0)
> +             return rc;
> +
> +     sja1105_packing(packed_buf, &device_id, 31, 0, SJA1105_SIZE_DEVICE_ID,
> +                     UNPACK);
> +
> +     rc = sja1105_xfer_buf(priv, SPI_READ, regs->prod_id, packed_buf,
> +                           SJA1105_SIZE_DEVICE_ID);
> +     if (rc < 0)
> +             return rc;
> +
> +     sja1105_packing(packed_buf, &part_no, 19, 4, SJA1105_SIZE_DEVICE_ID,
> +                     UNPACK);
> +
> +     for (id = 0; id < SJA1105_MAX_SWITCH_ID; id++) {
> +             const struct sja1105_info *info = &sja1105_info[id];
> +
> +             /* Is what's been probed in our match table at all? */
> +             if (info->device_id != device_id || info->part_no != part_no)
> +                     continue;
> +
> +             /* But is it what's in the device tree? */
> +             if (priv->info->device_id != device_id ||
> +                 priv->info->part_no != part_no) {
> +                     printf("Device tree specifies chip %s but found %s, 
> please fix it!\n",
> +                            priv->info->name, info->name);

Replace printf with dev_err throughout this patch,

> +     priv->max_xfer_len = SJA1105_SIZE_SPI_MSG_MAXLEN;
> +     if (priv->max_xfer_len > max_xfer)
> +             priv->max_xfer_len = max_xfer;
> +     if (priv->max_xfer_len > max_msg - SJA1105_SIZE_SPI_MSG_HEADER)
> +             priv->max_xfer_len = max_msg - SJA1105_SIZE_SPI_MSG_HEADER;
> +
> +     rc = sja1105_check_device_id(priv);
> +     if (rc < 0) {
> +             dev_err(dev, "Device ID check failed: %d\n", rc);
> +             return rc;
> +     }
> +
> +     ds = &priv->ds;
> +     ds->dev = dev;
> +     ds->num_ports = sja1105_info[id].num_ports;
> +     ds->ops = &sja1105_dsa_ops;
> +     ds->needed_headroom = VLAN_HLEN;
> +
> +     dsa_register_switch(ds);

Return value should be checked.

Sascha

-- 
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 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

Reply via email to