Message ID | 20220427162343.18092-3-arun.ramadoss@microchip.com (mailing list archive) |
---|---|
State | RFC |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | net: dsa: ksz: generic port mirror function for ksz9477 based switch | 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 10 of 10 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/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, 61 lines checked |
netdev/kdoc | success | Errors and warnings before: 0 this patch: 0 |
netdev/source_inline | success | Was 0 now: 0 |
On Wed, Apr 27, 2022 at 09:53:42PM +0530, Arun Ramadoss wrote: > ksz8795.c and ksz9477.c has individual ksz_cfg and ksz_port_cfg Plural (have). > function, both are same. Hence moving it to ksz_common.c. And removed Present tense (remove). > the individual references. > Small hint for writing commit messages. You should describe the entire change, and walk the reviewer through the thought process. Here, something which you are not mentioning is that the chip-local implementation for ksz_port_cfg() that ksz8795 and ksz9477 have uses the PORT_CTRL_ADDR() macro. Whereas the newly added generic ksz_port_cfg() uses dev->dev_ops->get_port_addr(). The transformation is safe because both ksz8795 and ksz9477 provide a get_port_addr() implementation. I didn't know that, so I had to check.
diff --git a/drivers/net/dsa/microchip/ksz8795.c b/drivers/net/dsa/microchip/ksz8795.c index f91deea9368e..33453060fa71 100644 --- a/drivers/net/dsa/microchip/ksz8795.c +++ b/drivers/net/dsa/microchip/ksz8795.c @@ -211,18 +211,6 @@ static bool ksz_is_ksz88x3(struct ksz_device *dev) return dev->chip_id == 0x8830; } -static void ksz_cfg(struct ksz_device *dev, u32 addr, u8 bits, bool set) -{ - regmap_update_bits(dev->regmap[0], addr, bits, set ? bits : 0); -} - -static void ksz_port_cfg(struct ksz_device *dev, int port, int offset, u8 bits, - bool set) -{ - regmap_update_bits(dev->regmap[0], PORT_CTRL_ADDR(port, offset), - bits, set ? bits : 0); -} - static int ksz8_ind_write8(struct ksz_device *dev, u8 table, u16 addr, u8 data) { struct ksz8 *ksz8 = dev->priv; diff --git a/drivers/net/dsa/microchip/ksz9477.c b/drivers/net/dsa/microchip/ksz9477.c index 90ce789107eb..f762120ce3fd 100644 --- a/drivers/net/dsa/microchip/ksz9477.c +++ b/drivers/net/dsa/microchip/ksz9477.c @@ -159,18 +159,6 @@ static void ksz9477_get_stats64(struct dsa_switch *ds, int port, spin_unlock(&mib->stats64_lock); } -static void ksz_cfg(struct ksz_device *dev, u32 addr, u8 bits, bool set) -{ - regmap_update_bits(dev->regmap[0], addr, bits, set ? bits : 0); -} - -static void ksz_port_cfg(struct ksz_device *dev, int port, int offset, u8 bits, - bool set) -{ - regmap_update_bits(dev->regmap[0], PORT_CTRL_ADDR(port, offset), - bits, set ? bits : 0); -} - static void ksz9477_cfg32(struct ksz_device *dev, u32 addr, u32 bits, bool set) { regmap_update_bits(dev->regmap[2], addr, bits, set ? bits : 0); diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/microchip/ksz_common.h index 4d978832c448..4f049e9d8952 100644 --- a/drivers/net/dsa/microchip/ksz_common.h +++ b/drivers/net/dsa/microchip/ksz_common.h @@ -246,6 +246,11 @@ static inline int ksz_write64(struct ksz_device *dev, u32 reg, u64 value) return regmap_bulk_write(dev->regmap[2], reg, val, 2); } +static inline void ksz_cfg(struct ksz_device *dev, u32 addr, u8 bits, bool set) +{ + regmap_update_bits(dev->regmap[0], addr, bits, set ? bits : 0); +} + static inline void ksz_pread8(struct ksz_device *dev, int port, int offset, u8 *data) { @@ -282,6 +287,14 @@ static inline void ksz_pwrite32(struct ksz_device *dev, int port, int offset, ksz_write32(dev, dev->dev_ops->get_port_addr(port, offset), data); } +static inline void ksz_port_cfg(struct ksz_device *dev, int port, int offset, + u8 bits, bool set) +{ + regmap_update_bits(dev->regmap[0], + dev->dev_ops->get_port_addr(port, offset), + bits, set ? bits : 0); +} + static inline void ksz_regmap_lock(void *__mtx) { struct mutex *mtx = __mtx;
ksz8795.c and ksz9477.c has individual ksz_cfg and ksz_port_cfg function, both are same. Hence moving it to ksz_common.c. And removed the individual references. Signed-off-by: Arun Ramadoss <arun.ramadoss@microchip.com> --- drivers/net/dsa/microchip/ksz8795.c | 12 ------------ drivers/net/dsa/microchip/ksz9477.c | 12 ------------ drivers/net/dsa/microchip/ksz_common.h | 13 +++++++++++++ 3 files changed, 13 insertions(+), 24 deletions(-)