Re: [RFC Patch net-next v2 3/9] net: dsa: microchip: perform the compatibility check for dev probed

From: Vladimir Oltean
Date: Mon May 16 2022 - 07:03:40 EST


On Fri, May 13, 2022 at 03:52:13PM +0530, Arun Ramadoss wrote:
> This patch perform the compatibility check for the device after the chip
> detect is done. It is to prevent the mismatch between the device
> compatible specified in the device tree and actual device found during
> the detect. The ksz9477 device doesn't use any .data in the
> of_device_id. But the ksz8795 uses .data for assigning the regmap
> between 8830 family and 87xx family switch. Changed the regmap
> assignment based on the chip_id from the .data.
>
> Signed-off-by: Arun Ramadoss <arun.ramadoss@xxxxxxxxxxxxx>
> ---
> drivers/net/dsa/microchip/ksz8795_spi.c | 37 ++++++++++++++++++++-----
> drivers/net/dsa/microchip/ksz9477_i2c.c | 30 ++++++++++++++++----
> drivers/net/dsa/microchip/ksz9477_spi.c | 30 ++++++++++++++++----
> drivers/net/dsa/microchip/ksz_common.c | 25 ++++++++++++++++-
> drivers/net/dsa/microchip/ksz_common.h | 1 +
> 5 files changed, 103 insertions(+), 20 deletions(-)
>
> diff --git a/drivers/net/dsa/microchip/ksz8795_spi.c b/drivers/net/dsa/microchip/ksz8795_spi.c
> index 5f8d94aee774..1ae1b1ee9f2a 100644
> --- a/drivers/net/dsa/microchip/ksz8795_spi.c
> +++ b/drivers/net/dsa/microchip/ksz8795_spi.c
> @@ -31,9 +31,12 @@ KSZ_REGMAP_TABLE(ksz8795, 16, KSZ8795_SPI_ADDR_SHIFT,
> KSZ_REGMAP_TABLE(ksz8863, 16, KSZ8863_SPI_ADDR_SHIFT,
> KSZ8863_SPI_TURNAROUND_SHIFT, KSZ8863_SPI_ADDR_ALIGN);
>
> +#define KSZ_88X3_FAMILY 0x8830
> +

Can we have this macro defined in ksz_common.h and used in the chip_id
of the ksz_chip_data structure as well? It makes things easier to follow
by pattern matching. And for symmetry, it would probably be good to have
such a macro for all chip ids.