1
0
Fork 0
mirror of synced 2025-03-06 20:59:54 +01:00
linux/drivers/net/dsa/microchip
Vladimir Oltean 3bc05faf37 net: dsa: microchip: properly support platform_data probing
The ksz driver has bits and pieces of platform_data probing support, but
it doesn't work.

The conventional thing to do is to have an encapsulating structure for
struct dsa_chip_data that gets put into dev->platform_data. This driver
expects a struct ksz_platform_data, but that doesn't contain a struct
dsa_chip_data as first element, which will obviously not work with
dsa_switch_probe() -> dsa_switch_parse().

Pointing dev->platform_data to a struct dsa_chip_data directly is in
principle possible, but that doesn't work either. The driver has
ksz_switch_detect() to read the device ID from hardware, followed by
ksz_check_device_id() to compare it against a predetermined expected
value. This protects against early errors in the SPI/I2C communication.
With platform_data, the mechanism in ksz_check_device_id() doesn't work
and even leads to NULL pointer dereferences, since of_device_get_match_data()
doesn't work in that probe path.

So obviously, the platform_data support is actually missing, and the
existing handling of struct ksz_platform_data is bogus. Complete the
support by adding a struct dsa_chip_data as first element, and fixing up
ksz_check_device_id() to pick up the platform_data instead of the
unavailable of_device_get_match_data().

The early dev->chip_id assignment from ksz_switch_register() is also
bogus, because ksz_switch_detect() sets it to an initial value. So
remove it.

Also, ksz_platform_data :: enabled_ports isn't used anywhere, delete it.

Link: https://lore.kernel.org/netdev/20231204154315.3906267-1-dd@embedd.com/
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: Daniel Danzberger <dd@embedd.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
2023-12-07 12:00:20 +00:00
..
Kconfig net: dsa: microchip: ptp: fix up PTP dependency 2023-01-31 13:21:38 +01:00
ksz8.h net: dsa: microchip: ksz8: Make flow control, speed, and duplex on CPU port configurable 2023-11-29 08:38:34 -08:00
ksz8795.c net: dsa: microchip: add property to select internal RMII reference clock 2023-12-07 10:22:09 +00:00
ksz8795_reg.h net: dsa: microchip: add property to select internal RMII reference clock 2023-12-07 10:22:09 +00:00
ksz8863_smi.c net: dsa: Explicitly include correct DT includes 2023-07-26 21:54:16 -07:00
ksz9477.c net: dsa: microchip: ksz9477: Fix spelling mistake "Enery" -> "Energy" 2023-10-27 14:45:50 -07:00
ksz9477.h net: dsa: microchip: Ensure Stable PME Pin State for Wake-on-LAN 2023-10-27 14:43:53 -07:00
ksz9477_acl.c net: dsa: microchip: Fix uninitialized var in ksz9477_acl_move_entries() 2023-10-10 11:12:01 +02:00
ksz9477_i2c.c net: dsa: microchip: Refactor switch shutdown routine for WoL preparation 2023-10-27 14:43:53 -07:00
ksz9477_reg.h net: dsa: microchip: move REG_SW_MAC_ADDR to dev->info->regs[] 2023-10-03 13:51:02 +02:00
ksz9477_tc_flower.c net: dsa: microchip: Add partial ACL support for ksz9477 switches 2023-09-17 14:28:34 +01:00
ksz_common.c net: dsa: microchip: properly support platform_data probing 2023-12-07 12:00:20 +00:00
ksz_common.h net: dsa: microchip: ksz8: Add function to configure ports with integrated PHYs 2023-11-29 08:38:34 -08:00
ksz_ptp.c net: dsa: Use conduit and user terms 2023-10-24 13:08:14 -07:00
ksz_ptp.h net: dsa: microchip: ptp: add support for perout programmable pins 2023-01-13 08:40:41 +00:00
ksz_ptp_reg.h net: dsa: microchip: ptp: lan937x: Enable periodic output in LED pins 2023-01-13 08:40:41 +00:00
ksz_spi.c net: dsa: microchip: Refactor switch shutdown routine for WoL preparation 2023-10-27 14:43:53 -07:00
lan937x.h net: dsa: microchip: add support for credit based shaper 2023-01-23 22:12:35 -08:00
lan937x_main.c net: dsa: microchip: add an enum for regmap widths 2023-05-30 09:48:17 +02:00
lan937x_reg.h net: dsa: microchip: add support for credit based shaper 2023-01-23 22:12:35 -08:00
Makefile net: dsa: microchip: Add partial ACL support for ksz9477 switches 2023-09-17 14:28:34 +01:00