On Mon, Jan 11, 2021 at 02:21:54AM +0100, Marek Behún wrote:
> There are two implementations of the .set_egress_port method, and both
> of them, if successful, set chip->*gress_dest_port variable.
>
> To avoid code repetition, wrap this method into
> mv88e6xxx_set_egress_port.
>
> Signed-off-by: Marek Behún <[email protected]>
> ---
> drivers/net/dsa/mv88e6xxx/chip.c | 48 ++++++++++++++++++-----------
> drivers/net/dsa/mv88e6xxx/global1.c | 19 ++----------
> 2 files changed, 32 insertions(+), 35 deletions(-)
>
> diff --git a/drivers/net/dsa/mv88e6xxx/chip.c
> b/drivers/net/dsa/mv88e6xxx/chip.c
> index 9bddd70449c6..62bef0759077 100644
> --- a/drivers/net/dsa/mv88e6xxx/chip.c
> +++ b/drivers/net/dsa/mv88e6xxx/chip.c
> @@ -2521,6 +2521,26 @@ static int mv88e6xxx_serdes_power(struct
> mv88e6xxx_chip *chip, int port,
> return err;
> }
>
> +static int mv88e6xxx_set_egress_port(struct mv88e6xxx_chip *chip,
> + enum mv88e6xxx_egress_direction direction,
> + int port)
> +{
> + int err = -EOPNOTSUPP;
> +
> + if (chip->info->ops->set_egress_port) {
I would probably return -EOPNOTSUPP early and reduce the indentation
level by one:
if (!chip->info->ops->set_egress_port)
return -EOPNOTSUPP;