mbox series

[net-next,00/13] net: dsa: microchip: common spi probe for the ksz series switches - part 2

Message ID 20220622090425.17709-1-arun.ramadoss@microchip.com (mailing list archive)
Headers show
Series net: dsa: microchip: common spi probe for the ksz series switches - part 2 | expand

Message

Arun Ramadoss June 22, 2022, 9:04 a.m. UTC
This patch series aims to refactor the ksz_switch_register routine to have the
common flow for the ksz series switch. And this is the follow up patch series.

First, it tries moves the common implementation in the setup from individual
files to ksz_setup. Then implements the common dsa_switch_ops structure instead
of independent registration. And then moves the ksz_dev_ops to ksz_common.c,
it allows the dynamic detection of which ksz_dev_ops to be used based on
the switch detection function.

Finally, the patch updates the ksz_spi probe function to be same for all the
ksz_switches.

Arun Ramadoss (13):
  net: dsa: microchip: rename shutdown to reset in ksz_dev_ops
  net: dsa: microchip: add config_cpu_port to struct ksz_dev_ops
  net: dsa: microchip: add the enable_stp_addr pointer in ksz_dev_ops
  net: dsa: microchip: move setup function to ksz_common
  net: dsa: microchip: move broadcast rate limit to ksz_setup
  net: dsa: microchip: move multicast enable to ksz_setup
  net: dsa: microchip: move start of switch to ksz_setup
  net: dsa: microchip: common dsa_switch_ops for ksz switches
  net: dsa: microchip: ksz9477: separate phylink mode from switch
    register
  net: dsa: microchip: common menuconfig for ksz series switch
  net: dsa: microchip: move ksz_dev_ops to ksz_common.c
  net: dsa: microchip: remove the ksz8/ksz9477_switch_register
  net: dsa: microchip: common ksz_spi_probe for ksz switches

 drivers/net/dsa/microchip/Kconfig             |  42 +--
 drivers/net/dsa/microchip/Makefile            |  10 +-
 drivers/net/dsa/microchip/ksz8.h              |  48 +++
 drivers/net/dsa/microchip/ksz8795.c           | 195 +++--------
 drivers/net/dsa/microchip/ksz8795_reg.h       |  12 -
 drivers/net/dsa/microchip/ksz8863_smi.c       |   2 +-
 drivers/net/dsa/microchip/ksz9477.c           | 244 +++++--------
 drivers/net/dsa/microchip/ksz9477.h           |  60 ++++
 drivers/net/dsa/microchip/ksz9477_i2c.c       |   6 +-
 drivers/net/dsa/microchip/ksz9477_reg.h       |  12 -
 drivers/net/dsa/microchip/ksz9477_spi.c       | 150 --------
 drivers/net/dsa/microchip/ksz_common.c        | 326 +++++++++++++-----
 drivers/net/dsa/microchip/ksz_common.h        |  82 ++---
 .../microchip/{ksz8795_spi.c => ksz_spi.c}    |  89 +++--
 14 files changed, 598 insertions(+), 680 deletions(-)
 create mode 100644 drivers/net/dsa/microchip/ksz9477.h
 delete mode 100644 drivers/net/dsa/microchip/ksz9477_spi.c
 rename drivers/net/dsa/microchip/{ksz8795_spi.c => ksz_spi.c} (60%)


base-commit: 8720bd951b8e8515ffd995c7631790fdabaa9265

Comments

patchwork-bot+netdevbpf@kernel.org June 24, 2022, 10:50 a.m. UTC | #1
Hello:

This series was applied to netdev/net-next.git (master)
by David S. Miller <davem@davemloft.net>:

On Wed, 22 Jun 2022 14:34:12 +0530 you wrote:
> This patch series aims to refactor the ksz_switch_register routine to have the
> common flow for the ksz series switch. And this is the follow up patch series.
> 
> First, it tries moves the common implementation in the setup from individual
> files to ksz_setup. Then implements the common dsa_switch_ops structure instead
> of independent registration. And then moves the ksz_dev_ops to ksz_common.c,
> it allows the dynamic detection of which ksz_dev_ops to be used based on
> the switch detection function.
> 
> [...]

Here is the summary with links:
  - [net-next,01/13] net: dsa: microchip: rename shutdown to reset in ksz_dev_ops
    https://git.kernel.org/netdev/net-next/c/673b196fdd34
  - [net-next,02/13] net: dsa: microchip: add config_cpu_port to struct ksz_dev_ops
    https://git.kernel.org/netdev/net-next/c/fb9324beb5d4
  - [net-next,03/13] net: dsa: microchip: add the enable_stp_addr pointer in ksz_dev_ops
    https://git.kernel.org/netdev/net-next/c/331d64f752bb
  - [net-next,04/13] net: dsa: microchip: move setup function to ksz_common
    https://git.kernel.org/netdev/net-next/c/d2822e686879
  - [net-next,05/13] net: dsa: microchip: move broadcast rate limit to ksz_setup
    https://git.kernel.org/netdev/net-next/c/1ca6437fafc9
  - [net-next,06/13] net: dsa: microchip: move multicast enable to ksz_setup
    https://git.kernel.org/netdev/net-next/c/0abab9f3ec6b
  - [net-next,07/13] net: dsa: microchip: move start of switch to ksz_setup
    https://git.kernel.org/netdev/net-next/c/ad08ac189758
  - [net-next,08/13] net: dsa: microchip: common dsa_switch_ops for ksz switches
    https://git.kernel.org/netdev/net-next/c/1958eee85f67
  - [net-next,09/13] net: dsa: microchip: ksz9477: separate phylink mode from switch register
    https://git.kernel.org/netdev/net-next/c/7a8988a17c48
  - [net-next,10/13] net: dsa: microchip: common menuconfig for ksz series switch
    https://git.kernel.org/netdev/net-next/c/07bca160469b
  - [net-next,11/13] net: dsa: microchip: move ksz_dev_ops to ksz_common.c
    https://git.kernel.org/netdev/net-next/c/6ec23aaaac43
  - [net-next,12/13] net: dsa: microchip: remove the ksz8/ksz9477_switch_register
    https://git.kernel.org/netdev/net-next/c/ff3f3a3090d2
  - [net-next,13/13] net: dsa: microchip: common ksz_spi_probe for ksz switches
    https://git.kernel.org/netdev/net-next/c/4658f2fe8fbc

You are awesome, thank you!
Vladimir Oltean June 24, 2022, 11:23 a.m. UTC | #2
On Wed, Jun 22, 2022 at 02:34:12PM +0530, Arun Ramadoss wrote:
> This patch series aims to refactor the ksz_switch_register routine to have the
> common flow for the ksz series switch. And this is the follow up patch series.
> 
> First, it tries moves the common implementation in the setup from individual
> files to ksz_setup. Then implements the common dsa_switch_ops structure instead
> of independent registration. And then moves the ksz_dev_ops to ksz_common.c,
> it allows the dynamic detection of which ksz_dev_ops to be used based on
> the switch detection function.
> 
> Finally, the patch updates the ksz_spi probe function to be same for all the
> ksz_switches.

Sorry for being late to the party again. I've looked over the resulting
code and it appears that there is still some cleanup to do.

We now have a stray struct ksz8 pointer being allocated by the common
ksz_spi_probe(), and passed as dev->priv to ksz_switch_alloc() by this
generic code.

Only ksz8 accesses dev->priv, although it is interesting to note that
ksz9477_i2c_probe() calls ksz_switch_alloc() with a type-incompatible
struct i2c_client *i2c that is unused but bogus.

The concept of struct ksz8 was added by commit 9f73e11250fb ("net: dsa:
microchip: ksz8795: move register offsets and shifts to separate
struct"), and in essence it isn't a bad idea, it's just that I wasn't
aware of it, and only ksz8 makes use of it.

You've added some register offsets yourself to ksz_chip_data
(stp_ctrl_reg, broadcast_ctrl_reg, multicast_ctrl_reg, start_ctrl_reg),
and it looks like struct ksz8 shares more or less the same purpose -
regs, masks, shifts etc. Would you mind doing some more consolidation
work and trying to figure out if we could eliminate a data structure
unique for ksz8 and integrate that information into struct ksz_chip_data
(and perhaps use it in more places)?