From: Jacob Keller <jacob.e.keller@intel.com>
To: Vladimir Oltean <vladimir.oltean@nxp.com>, <netdev@vger.kernel.org>
Cc: Andrew Lunn <andrew@lunn.ch>,
Florian Fainelli <f.fainelli@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
"Claudiu Manoil" <claudiu.manoil@nxp.com>,
Alexandre Belloni <alexandre.belloni@bootlin.com>,
<UNGLinuxDriver@microchip.com>,
Colin Foster <colin.foster@in-advantage.com>,
<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH net-next 2/8] net: mscc: ocelot: refactor enum ocelot_reg decoding to helper
Date: Wed, 12 Apr 2023 14:16:19 -0700 [thread overview]
Message-ID: <e7edc87b-3c1b-1b10-9c4f-0a7b114dd2fe@intel.com> (raw)
In-Reply-To: <20230412124737.2243527-3-vladimir.oltean@nxp.com>
On 4/12/2023 5:47 AM, Vladimir Oltean wrote:
> 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>
> ---
> drivers/net/ethernet/mscc/ocelot.h | 9 ++++++++
> drivers/net/ethernet/mscc/ocelot_io.c | 30 ++++++++++++++-------------
> 2 files changed, 25 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/net/ethernet/mscc/ocelot.h b/drivers/net/ethernet/mscc/ocelot.h
> index 9e0f2e4ed556..14440a3b04c3 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];
> +}
> +
Ok this takes a reg and returns it split into target and address, so you
can't just directly return the value.
You could do this with two separate functions, but thats not really any
better. I do wish it was easier to return tuples from a C function, but
alas...
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
next prev parent reply other threads:[~2023-04-12 21:16 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-12 12:47 [PATCH net-next 0/8] Ocelot/Felix driver cleanup Vladimir Oltean
2023-04-12 12:47 ` [PATCH net-next 1/8] net: mscc: ocelot: strengthen type of "u32 reg" in I/O accessors Vladimir Oltean
2023-04-12 21:11 ` Jacob Keller
2023-04-12 12:47 ` [PATCH net-next 2/8] net: mscc: ocelot: refactor enum ocelot_reg decoding to helper Vladimir Oltean
2023-04-12 21:16 ` Jacob Keller [this message]
2023-04-12 12:47 ` [PATCH net-next 3/8] net: mscc: ocelot: debugging print for statistics regions Vladimir Oltean
2023-04-12 21:17 ` Jacob Keller
2023-04-12 12:47 ` [PATCH net-next 4/8] net: mscc: ocelot: remove blank line at the end of ocelot_stats.c Vladimir Oltean
2023-04-12 15:59 ` Colin Foster
2023-04-12 21:18 ` Jacob Keller
2023-04-12 12:47 ` [PATCH net-next 5/8] net: dsa: felix: remove confusing/incorrect comment from felix_setup() Vladimir Oltean
2023-04-12 21:18 ` Jacob Keller
2023-04-12 12:47 ` [PATCH net-next 6/8] net: mscc: ocelot: strengthen type of "u32 reg" and "u32 base" in ocelot_stats.c Vladimir Oltean
2023-04-12 21:19 ` Jacob Keller
2023-04-12 12:47 ` [PATCH net-next 7/8] net: mscc: ocelot: strengthen type of "int i" " Vladimir Oltean
2023-04-12 21:21 ` Jacob Keller
2023-04-12 12:47 ` [PATCH net-next 8/8] net: mscc: ocelot: fix ineffective WARN_ON() " Vladimir Oltean
2023-04-12 21:23 ` Jacob Keller
2023-04-13 0:45 ` [PATCH net-next 0/8] Ocelot/Felix driver cleanup Colin Foster
2023-04-13 10:08 ` Vladimir Oltean
2023-04-14 5:20 ` patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e7edc87b-3c1b-1b10-9c4f-0a7b114dd2fe@intel.com \
--to=jacob.e.keller@intel.com \
--cc=UNGLinuxDriver@microchip.com \
--cc=alexandre.belloni@bootlin.com \
--cc=andrew@lunn.ch \
--cc=claudiu.manoil@nxp.com \
--cc=colin.foster@in-advantage.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=f.fainelli@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=vladimir.oltean@nxp.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®