Message ID | 20220530104257.21485-7-arun.ramadoss@microchip.com (mailing list archive) |
---|---|
State | RFC |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | net: dsa: microchip: common spi probe for the ksz series switches | expand |
Context | Check | Description |
---|---|---|
netdev/tree_selection | success | Clearly marked for net-next |
netdev/fixes_present | success | Fixes tag not required for -next series |
netdev/subject_prefix | success | Link |
netdev/cover_letter | success | Series has a cover letter |
netdev/patch_count | success | Link |
netdev/header_inline | success | No static functions without inline keyword in header files |
netdev/build_32bit | success | Errors and warnings before: 0 this patch: 0 |
netdev/cc_maintainers | success | CCed 11 of 11 maintainers |
netdev/build_clang | success | Errors and warnings before: 0 this patch: 0 |
netdev/module_param | success | Was 0 now: 0 |
netdev/verify_signedoff | success | Signed-off-by tag matches author and committer |
netdev/check_selftest | success | No net selftest shell script |
netdev/verify_fixes | success | No Fixes tag |
netdev/build_allmodconfig_warn | success | Errors and warnings before: 0 this patch: 0 |
netdev/checkpatch | success | total: 0 errors, 0 warnings, 0 checks, 123 lines checked |
netdev/kdoc | success | Errors and warnings before: 0 this patch: 0 |
netdev/source_inline | success | Was 0 now: 0 |
On Mon, May 30, 2022 at 04:12:48PM +0530, Arun Ramadoss wrote: > At present, P_STP_CTRL register value is passed as parameter to > ksz_port_stp_state from the individual dsa_switch_ops hooks. This patch > update the function to retrieve the register value through the > ksz_dev_ops function pointer. > And add the static to ksz_update_port_member since it is not called > outside the ksz_common. > > Signed-off-by: Arun Ramadoss <arun.ramadoss@microchip.com> > --- > drivers/net/dsa/microchip/ksz8795.c | 9 +++++---- > drivers/net/dsa/microchip/ksz9477.c | 10 +++++----- > drivers/net/dsa/microchip/ksz_common.c | 9 +++++---- > drivers/net/dsa/microchip/ksz_common.h | 5 ++--- > 4 files changed, 17 insertions(+), 16 deletions(-) > > diff --git a/drivers/net/dsa/microchip/ksz8795.c b/drivers/net/dsa/microchip/ksz8795.c > index 8657b520b336..e6982fa9d382 100644 > --- a/drivers/net/dsa/microchip/ksz8795.c > +++ b/drivers/net/dsa/microchip/ksz8795.c > @@ -920,9 +920,9 @@ static void ksz8_cfg_port_member(struct ksz_device *dev, int port, u8 member) > ksz_pwrite8(dev, port, P_MIRROR_CTRL, data); > } > > -static void ksz8_port_stp_state_set(struct dsa_switch *ds, int port, u8 state) > +static int ksz8_get_stp_reg(void) > { > - ksz_port_stp_state_set(ds, port, state, P_STP_CTRL); > + return P_STP_CTRL; > } Since there's nothing dynamic about get_stp_reg(), can the STP register location stay in struct ksz_chip_data?
On Mon, 2022-06-13 at 12:31 +0300, Vladimir Oltean wrote: > EXTERNAL EMAIL: Do not click links or open attachments unless you > know the content is safe > > On Mon, May 30, 2022 at 04:12:48PM +0530, Arun Ramadoss wrote: > > At present, P_STP_CTRL register value is passed as parameter to > > ksz_port_stp_state from the individual dsa_switch_ops hooks. This > > patch > > update the function to retrieve the register value through the > > ksz_dev_ops function pointer. > > And add the static to ksz_update_port_member since it is not called > > outside the ksz_common. > > > > Signed-off-by: Arun Ramadoss <arun.ramadoss@microchip.com> > > --- > > drivers/net/dsa/microchip/ksz8795.c | 9 +++++---- > > drivers/net/dsa/microchip/ksz9477.c | 10 +++++----- > > drivers/net/dsa/microchip/ksz_common.c | 9 +++++---- > > drivers/net/dsa/microchip/ksz_common.h | 5 ++--- > > 4 files changed, 17 insertions(+), 16 deletions(-) > > > > diff --git a/drivers/net/dsa/microchip/ksz8795.c > > b/drivers/net/dsa/microchip/ksz8795.c > > index 8657b520b336..e6982fa9d382 100644 > > --- a/drivers/net/dsa/microchip/ksz8795.c > > +++ b/drivers/net/dsa/microchip/ksz8795.c > > @@ -920,9 +920,9 @@ static void ksz8_cfg_port_member(struct > > ksz_device *dev, int port, u8 member) > > ksz_pwrite8(dev, port, P_MIRROR_CTRL, data); > > } > > > > -static void ksz8_port_stp_state_set(struct dsa_switch *ds, int > > port, u8 state) > > +static int ksz8_get_stp_reg(void) > > { > > - ksz_port_stp_state_set(ds, port, state, P_STP_CTRL); > > + return P_STP_CTRL; > > } > > Since there's nothing dynamic about get_stp_reg(), can the STP > register > location stay in struct ksz_chip_data? I will update the ksz_chip_data for holding the address of STP_CTL register.
diff --git a/drivers/net/dsa/microchip/ksz8795.c b/drivers/net/dsa/microchip/ksz8795.c index 8657b520b336..e6982fa9d382 100644 --- a/drivers/net/dsa/microchip/ksz8795.c +++ b/drivers/net/dsa/microchip/ksz8795.c @@ -920,9 +920,9 @@ static void ksz8_cfg_port_member(struct ksz_device *dev, int port, u8 member) ksz_pwrite8(dev, port, P_MIRROR_CTRL, data); } -static void ksz8_port_stp_state_set(struct dsa_switch *ds, int port, u8 state) +static int ksz8_get_stp_reg(void) { - ksz_port_stp_state_set(ds, port, state, P_STP_CTRL); + return P_STP_CTRL; } static void ksz8_flush_dyn_mac_table(struct ksz_device *dev, int port) @@ -1240,7 +1240,7 @@ static void ksz8_config_cpu_port(struct dsa_switch *ds) for (i = 0; i < dev->phy_port_cnt; i++) { p = &dev->ports[i]; - ksz8_port_stp_state_set(ds, i, BR_STATE_DISABLED); + ksz_port_stp_state_set(ds, i, BR_STATE_DISABLED); /* Last port may be disabled. */ if (i == dev->phy_port_cnt) @@ -1389,7 +1389,7 @@ static const struct dsa_switch_ops ksz8_switch_ops = { .get_sset_count = ksz_sset_count, .port_bridge_join = ksz_port_bridge_join, .port_bridge_leave = ksz_port_bridge_leave, - .port_stp_state_set = ksz8_port_stp_state_set, + .port_stp_state_set = ksz_port_stp_state_set, .port_fast_age = ksz_port_fast_age, .port_vlan_filtering = ksz_port_vlan_filtering, .port_vlan_add = ksz_port_vlan_add, @@ -1463,6 +1463,7 @@ static const struct ksz_dev_ops ksz8_dev_ops = { .vlan_del = ksz8_port_vlan_del, .mirror_add = ksz8_port_mirror_add, .mirror_del = ksz8_port_mirror_del, + .get_stp_reg = ksz8_get_stp_reg, .shutdown = ksz8_reset_switch, .init = ksz8_switch_init, .exit = ksz8_switch_exit, diff --git a/drivers/net/dsa/microchip/ksz9477.c b/drivers/net/dsa/microchip/ksz9477.c index 6796c9d89ab9..f08694aba6bb 100644 --- a/drivers/net/dsa/microchip/ksz9477.c +++ b/drivers/net/dsa/microchip/ksz9477.c @@ -344,10 +344,9 @@ static void ksz9477_cfg_port_member(struct ksz_device *dev, int port, ksz_pwrite32(dev, port, REG_PORT_VLAN_MEMBERSHIP__4, member); } -static void ksz9477_port_stp_state_set(struct dsa_switch *ds, int port, - u8 state) +static int ksz9477_get_stp_reg(void) { - ksz_port_stp_state_set(ds, port, state, P_STP_CTRL); + return P_STP_CTRL; } static void ksz9477_flush_dyn_mac_table(struct ksz_device *dev, int port) @@ -1237,7 +1236,7 @@ static void ksz9477_config_cpu_port(struct dsa_switch *ds) continue; p = &dev->ports[i]; - ksz9477_port_stp_state_set(ds, i, BR_STATE_DISABLED); + ksz_port_stp_state_set(ds, i, BR_STATE_DISABLED); p->on = 1; if (i < dev->phy_port_cnt) p->phy = 1; @@ -1315,7 +1314,7 @@ static const struct dsa_switch_ops ksz9477_switch_ops = { .get_sset_count = ksz_sset_count, .port_bridge_join = ksz_port_bridge_join, .port_bridge_leave = ksz_port_bridge_leave, - .port_stp_state_set = ksz9477_port_stp_state_set, + .port_stp_state_set = ksz_port_stp_state_set, .port_fast_age = ksz_port_fast_age, .port_vlan_filtering = ksz_port_vlan_filtering, .port_vlan_add = ksz_port_vlan_add, @@ -1406,6 +1405,7 @@ static const struct ksz_dev_ops ksz9477_dev_ops = { .vlan_del = ksz9477_port_vlan_del, .mirror_add = ksz9477_port_mirror_add, .mirror_del = ksz9477_port_mirror_del, + .get_stp_reg = ksz9477_get_stp_reg, .shutdown = ksz9477_reset_switch, .init = ksz9477_switch_init, .exit = ksz9477_switch_exit, diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c index 1ed4cc94795e..5cf183f753d9 100644 --- a/drivers/net/dsa/microchip/ksz_common.c +++ b/drivers/net/dsa/microchip/ksz_common.c @@ -532,7 +532,7 @@ void ksz_get_strings(struct dsa_switch *ds, int port, } EXPORT_SYMBOL_GPL(ksz_get_strings); -void ksz_update_port_member(struct ksz_device *dev, int port) +static void ksz_update_port_member(struct ksz_device *dev, int port) { struct ksz_port *p = &dev->ports[port]; struct dsa_switch *ds = dev->ds; @@ -589,7 +589,6 @@ void ksz_update_port_member(struct ksz_device *dev, int port) dev->dev_ops->cfg_port_member(dev, port, port_member | cpu_port); } -EXPORT_SYMBOL_GPL(ksz_update_port_member); static void port_r_cnt(struct ksz_device *dev, int port) { @@ -890,12 +889,14 @@ int ksz_enable_port(struct dsa_switch *ds, int port, struct phy_device *phy) } EXPORT_SYMBOL_GPL(ksz_enable_port); -void ksz_port_stp_state_set(struct dsa_switch *ds, int port, - u8 state, int reg) +void ksz_port_stp_state_set(struct dsa_switch *ds, int port, u8 state) { struct ksz_device *dev = ds->priv; struct ksz_port *p; u8 data; + int reg; + + reg = dev->dev_ops->get_stp_reg(); ksz_pread8(dev, port, reg, &data); data &= ~(PORT_TX_ENABLE | PORT_RX_ENABLE | PORT_LEARN_DISABLE); diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/microchip/ksz_common.h index 01080ec22bf1..2727934b7171 100644 --- a/drivers/net/dsa/microchip/ksz_common.h +++ b/drivers/net/dsa/microchip/ksz_common.h @@ -192,6 +192,7 @@ struct ksz_dev_ops { bool ingress, struct netlink_ext_ack *extack); void (*mirror_del)(struct ksz_device *dev, int port, struct dsa_mall_mirror_tc_entry *mirror); + int (*get_stp_reg)(void); void (*freeze_mib)(struct ksz_device *dev, int port, bool freeze); void (*port_init_cnt)(struct ksz_device *dev, int port); int (*shutdown)(struct ksz_device *dev); @@ -207,7 +208,6 @@ void ksz_switch_remove(struct ksz_device *dev); int ksz8_switch_register(struct ksz_device *dev); int ksz9477_switch_register(struct ksz_device *dev); -void ksz_update_port_member(struct ksz_device *dev, int port); void ksz_init_mib_timer(struct ksz_device *dev); void ksz_r_mib_stats64(struct ksz_device *dev, int port); void ksz_get_stats64(struct dsa_switch *ds, int port, @@ -229,8 +229,7 @@ int ksz_port_bridge_join(struct dsa_switch *ds, int port, struct netlink_ext_ack *extack); void ksz_port_bridge_leave(struct dsa_switch *ds, int port, struct dsa_bridge bridge); -void ksz_port_stp_state_set(struct dsa_switch *ds, int port, - u8 state, int reg); +void ksz_port_stp_state_set(struct dsa_switch *ds, int port, u8 state); void ksz_port_fast_age(struct dsa_switch *ds, int port); int ksz_port_fdb_dump(struct dsa_switch *ds, int port, dsa_fdb_dump_cb_t *cb, void *data);
At present, P_STP_CTRL register value is passed as parameter to ksz_port_stp_state from the individual dsa_switch_ops hooks. This patch update the function to retrieve the register value through the ksz_dev_ops function pointer. And add the static to ksz_update_port_member since it is not called outside the ksz_common. Signed-off-by: Arun Ramadoss <arun.ramadoss@microchip.com> --- drivers/net/dsa/microchip/ksz8795.c | 9 +++++---- drivers/net/dsa/microchip/ksz9477.c | 10 +++++----- drivers/net/dsa/microchip/ksz_common.c | 9 +++++---- drivers/net/dsa/microchip/ksz_common.h | 5 ++--- 4 files changed, 17 insertions(+), 16 deletions(-)