Re: [net-next PATCH v4 09/14] net: dsa: qca8k: move set age/MTU/port enable/disable functions to common code

From: Vladimir Oltean
Date: Mon Jul 25 2022 - 20:17:30 EST


On Sun, Jul 24, 2022 at 10:19:33PM +0200, Christian Marangi wrote:
> The same set age, MTU and port enable/disable function are used by
> driver based on qca8k family switch.
> Move them to common code to make them accessible also by other drivers.
> While at it also drop unnecessary qca8k_priv cast for void pointers.
>
> Signed-off-by: Christian Marangi <ansuelsmth@xxxxxxxxx>
> ---
> diff --git a/drivers/net/dsa/qca/qca8k-common.c b/drivers/net/dsa/qca/qca8k-common.c
> index a50c21c90e81..7e573827dac6 100644
> --- a/drivers/net/dsa/qca/qca8k-common.c
> +++ b/drivers/net/dsa/qca/qca8k-common.c
> @@ -373,3 +373,91 @@ void qca8k_port_bridge_leave(struct dsa_switch *ds, int port,
> qca8k_rmw(priv, QCA8K_PORT_LOOKUP_CTRL(port),
> QCA8K_PORT_LOOKUP_MEMBER, BIT(cpu_port));
> }
> +
> +int
> +qca8k_set_ageing_time(struct dsa_switch *ds, unsigned int msecs)

Same comment about prototypes now fitting a single line. I won't be
making this comment everywhere.

> +{
> + struct qca8k_priv *priv = ds->priv;
> + unsigned int secs = msecs / 1000;
> + u32 val;
> +
> + /* AGE_TIME reg is set in 7s step */
> + val = secs / 7;
> +
> + /* Handle case with 0 as val to NOT disable
> + * learning
> + */
> + if (!val)
> + val = 1;
> +
> + return regmap_update_bits(priv->regmap, QCA8K_REG_ATU_CTRL, QCA8K_ATU_AGE_TIME_MASK,
> + QCA8K_ATU_AGE_TIME(val));

Maybe now would be a good time to trim this line to 80 characters?
Networking wasn't a huge fan of the 100 character limit increase,
I think this might even be pointed out in the process docs.