Re: [PATCH net-next v6 08/10] net: dsa: microchip: Add Microchip KSZ8863 SMI based driver support
From: Andrew Lunn
Date: Sat Apr 24 2021 - 12:01:15 EST
> +static int ksz8863_mdio_read(void *ctx, const void *reg_buf, size_t reg_len,
> + void *val_buf, size_t val_len)
> +{
> + struct ksz_device *dev = ctx;
> + struct ksz8 *ksz8 = dev->priv;
> + struct mdio_device *mdev = ksz8->priv;
> + u8 reg = *(u8 *)reg_buf;
> + u8 *val = val_buf;
> + int ret = 0;
> + int i;
...
> +
> + mutex_lock_nested(&mdev->bus->mdio_lock, MDIO_MUTEX_NESTED);
> + for (i = 0; i < val_len; i++) {
> + int tmp = reg + i;
> +
> + ret = __mdiobus_read(mdev->bus, ((tmp & 0xE0) >> 5) |
> + SMI_KSZ88XX_READ_PHY, tmp);
> + if (ret < 0)
> + goto out;
> +
> + val[i] = ret;
> + }
> + ret = 0;
> +
> + out:
> + mutex_unlock(&mdev->bus->mdio_lock);
> +
> + return ret;
> +}
> +
> +static int ksz8863_mdio_write(void *ctx, const void *data, size_t count)
> +{
> + struct ksz_device *dev = ctx;
> + struct ksz8 *ksz8 = dev->priv;
> + struct mdio_device *mdev = ksz8->priv;
> + u8 *val = (u8 *)(data + 4);
> + u32 reg = *(u32 *)data;
> + int ret = 0;
> + int i;
...
> +static const struct of_device_id ksz8863_dt_ids[] = {
> + { .compatible = "microchip,ksz8863" },
> + { .compatible = "microchip,ksz8873" },
> + { },
> +};
Is there code somewhere which verifies that what has been found really
does match what is in device tree? We don't want errors in the device
tree to be ignored.
Andrew