diff options
author | Vladimir Oltean <vladimir.oltean@nxp.com> | 2023-04-12 14:47:31 +0200 |
---|---|---|
committer | Jakub Kicinski <kuba@kernel.org> | 2023-04-14 06:56:06 +0200 |
commit | 40cd07cb42617f0e8b8597d0db288a5ce66621d9 (patch) | |
tree | b7d75e2edcb5f4b56421425ff7940ff5ba2060db /drivers/net/ethernet/mscc/ocelot.h | |
parent | net: mscc: ocelot: strengthen type of "u32 reg" in I/O accessors (diff) | |
download | linux-40cd07cb42617f0e8b8597d0db288a5ce66621d9.tar.xz linux-40cd07cb42617f0e8b8597d0db288a5ce66621d9.zip |
net: mscc: ocelot: refactor enum ocelot_reg decoding to helper
ocelot_io.c duplicates the decoding of an enum ocelot_reg (which holds
an enum ocelot_target in the upper bits and an index into a regmap array
in the lower bits) 4 times.
We'd like to reuse that logic once more, from ocelot.c. In order to do
that, let's consolidate the existing 4 instances into a header
accessible both by ocelot.c as well as by ocelot_io.c.
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'drivers/net/ethernet/mscc/ocelot.h')
-rw-r--r-- | drivers/net/ethernet/mscc/ocelot.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/drivers/net/ethernet/mscc/ocelot.h b/drivers/net/ethernet/mscc/ocelot.h index e9a0179448bf..d920ca930690 100644 --- a/drivers/net/ethernet/mscc/ocelot.h +++ b/drivers/net/ethernet/mscc/ocelot.h @@ -74,6 +74,15 @@ struct ocelot_multicast { struct ocelot_pgid *pgid; }; +static inline void ocelot_reg_to_target_addr(struct ocelot *ocelot, + enum ocelot_reg reg, + enum ocelot_target *target, + u32 *addr) +{ + *target = reg >> TARGET_OFFSET; + *addr = ocelot->map[*target][reg & REG_MASK]; +} + int ocelot_bridge_num_find(struct ocelot *ocelot, const struct net_device *bridge); |