netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Florian Fainelli <f.fainelli@gmail.com>
To: Vivien Didelot <vivien.didelot@gmail.com>, netdev@vger.kernel.org
Cc: marek.behun@nic.cz, davem@davemloft.net, andrew@lunn.ch
Subject: Re: [PATCH net-next 1/6] net: dsa: use a single switch statement for port setup
Date: Mon, 19 Aug 2019 10:14:24 -0700	[thread overview]
Message-ID: <cb37b6b0-c6c4-6f77-3658-a5cf676fabfe@gmail.com> (raw)
In-Reply-To: <20190818173548.19631-2-vivien.didelot@gmail.com>

On 8/18/19 10:35 AM, Vivien Didelot wrote:
> It is currently difficult to read the different steps involved in the
> setup and teardown of ports in the DSA code. Keep it simple with a
> single switch statement for each port type: UNUSED, CPU, DSA, or USER.
> 
> Also no need to call devlink_port_unregister from within dsa_port_setup
> as this step is inconditionally handled by dsa_port_teardown on error.
> 
> Signed-off-by: Vivien Didelot <vivien.didelot@gmail.com>
> ---

[snip]

>  	case DSA_PORT_TYPE_CPU:
> +		memset(dlp, 0, sizeof(*dlp));
> +		devlink_port_attrs_set(dlp, DEVLINK_PORT_FLAVOUR_CPU,
> +				       dp->index, false, 0, id, len);
> +		err = devlink_port_register(dl, dlp, dp->index);
> +		if (err)
> +			return err;

This is shared between all port flavors with the exception that the
flavor type is different, maybe we should create a helper function and
factor out even more code. I don't feel great about repeating 3 times t
the same code without making use of a fall through.
-- 
Florian

  reply	other threads:[~2019-08-19 17:14 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-18 17:35 [PATCH net-next 0/6] net: dsa: enable and disable all ports Vivien Didelot
2019-08-18 17:35 ` [PATCH net-next 1/6] net: dsa: use a single switch statement for port setup Vivien Didelot
2019-08-19 17:14   ` Florian Fainelli [this message]
2019-08-19 17:20     ` Vivien Didelot
2019-08-18 17:35 ` [PATCH net-next 2/6] net: dsa: do not enable or disable non user ports Vivien Didelot
2019-08-19 17:16   ` Florian Fainelli
2019-08-18 17:35 ` [PATCH net-next 3/6] net: dsa: enable and disable all ports Vivien Didelot
2019-08-19 17:17   ` Florian Fainelli
2019-08-19 17:32   ` Marek Behun
2019-08-19 18:03     ` Vivien Didelot
2019-08-18 17:35 ` [PATCH net-next 4/6] net: dsa: mv88e6xxx: do not change STP state on port disabling Vivien Didelot
2019-08-19 13:40   ` Andrew Lunn
2019-08-19 15:27     ` Vivien Didelot
2019-08-19 16:10       ` Andrew Lunn
2019-08-19 16:27         ` Vivien Didelot
2019-08-19 16:44           ` Andrew Lunn
2019-08-18 17:35 ` [PATCH net-next 5/6] net: dsa: mv88e6xxx: enable SERDES after setup Vivien Didelot
2019-08-18 17:35 ` [PATCH net-next 6/6] net: dsa: mv88e6xxx: wrap SERDES IRQ in power function Vivien Didelot
2019-08-19 20:11 ` [PATCH net-next 0/6] net: dsa: enable and disable all ports David Miller

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=cb37b6b0-c6c4-6f77-3658-a5cf676fabfe@gmail.com \
    --to=f.fainelli@gmail.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=marek.behun@nic.cz \
    --cc=netdev@vger.kernel.org \
    --cc=vivien.didelot@gmail.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;
as well as URLs for NNTP newsgroup(s).