Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp3307716pxx; Mon, 2 Nov 2020 05:44:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJy6RLfX7PqrZyWfnrO4U/A/9oDXhknvas7OPJlrhqWaNKH28eQ2fCuT4XRgoCLwJH4tHlV3 X-Received: by 2002:a50:a441:: with SMTP id v1mr16412766edb.30.1604324647867; Mon, 02 Nov 2020 05:44:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604324647; cv=none; d=google.com; s=arc-20160816; b=M+jHzoDFyc5MqHUYtlDJ/RBqM7SK0ggskL2g6X8i9kLP4sXiCRf1HCv8X0sM3NnSRO 2sZFyTGF3jBWWEKzjxPWlP3GemTULELtSJk3lSQ3od057sBAJl7o39MBwnxLgbvyVSko xasYx6bDNb3uGjaV8reAtXnJzthMX/nh/9camwoVSQSVdvbknEWQqoKkJbXPzz1A1Y+0 GVWxdAfr3Zu3kad9EzUlAlGclRvEEnh92pFj7WM/sVm5ns6Wx+WhnVKNeDqal0/c/BNB /1C2iKJHEbkyC29j1Lc6qxf0gibprI1frRRK9LGbgEUxl0e6up5298LwNcb0Kvyi2kDE 5z6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=aNyhi0e+1J33uLYtTu+U8pqvqzbkOCl2PbMIhu8Fas0=; b=v5OntXPbEs3bjb7Ff1lfgN2K/wu4c8SuxLDB/Sv0XqdmHZHlwFqARw2zALFY4bFQDw 20LjwQtdy5v5iOwHy+8heATTh6ihp/+Yb4Rlg5jKlWUGT9sWsouZZoDydJ42T112zaXf XK3EnkXfjpp73rkmnoMrrth90z8qc4woEVrYuyKWClaoBJmnQozN6R4VI395LCtL9X1P Xu7Sx/LaZ+PaP2ffGTGy8BgsLopEiQZzuw4+/yTL3L9PXL9mL4PJfJPIDppqQqWicVyb z6nC3aWmR0Xwj8LrBToRKccmBCmnux3/uNS81HNkQmO57RlRHUt+MKzRI42jh16va7LD 5h7g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g10si10369507edj.302.2020.11.02.05.43.44; Mon, 02 Nov 2020 05:44:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725849AbgKBNkK (ORCPT + 99 others); Mon, 2 Nov 2020 08:40:10 -0500 Received: from vps0.lunn.ch ([185.16.172.187]:58538 "EHLO vps0.lunn.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725788AbgKBNkJ (ORCPT ); Mon, 2 Nov 2020 08:40:09 -0500 Received: from andrew by vps0.lunn.ch with local (Exim 4.94) (envelope-from ) id 1kZa41-004owc-3L; Mon, 02 Nov 2020 14:40:01 +0100 Date: Mon, 2 Nov 2020 14:40:01 +0100 From: Andrew Lunn To: Pavana Sharma Cc: marek.behun@nic.cz, ashkan.boldaji@digi.com, davem@davemloft.net, f.fainelli@gmail.com, gregkh@linuxfoundation.org, kuba@kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, vivien.didelot@gmail.com Subject: Re: [PATCH v7 3/4] net: dsa: mv88e6xxx: Change serdes lane parameter from u8 type to int Message-ID: <20201102134001.GH1109407@lunn.ch> References: <205569de82d73e543625583e55e808981a7c9ee8.1604298276.git.pavana.sharma@digi.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <205569de82d73e543625583e55e808981a7c9ee8.1604298276.git.pavana.sharma@digi.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Nov 02, 2020 at 04:43:09PM +1000, Pavana Sharma wrote: > Returning 0 is no more an error case with MV88E6393 family > which has serdes lane numbers 0, 9 or 10. > So with this change .serdes_get_lane will return lane number > or error (-ENODEV). > > Signed-off-by: Pavana Sharma > --- > drivers/net/dsa/mv88e6xxx/chip.c | 28 +++++------ > drivers/net/dsa/mv88e6xxx/chip.h | 16 +++---- > drivers/net/dsa/mv88e6xxx/port.c | 6 +-- > drivers/net/dsa/mv88e6xxx/serdes.c | 76 +++++++++++++++--------------- > drivers/net/dsa/mv88e6xxx/serdes.h | 50 ++++++++++---------- > 5 files changed, 88 insertions(+), 88 deletions(-) > > diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c > index f0dbc05e30a4..4994b8eee659 100644 > --- a/drivers/net/dsa/mv88e6xxx/chip.c > +++ b/drivers/net/dsa/mv88e6xxx/chip.c > @@ -484,12 +484,12 @@ static int mv88e6xxx_serdes_pcs_get_state(struct dsa_switch *ds, int port, > struct phylink_link_state *state) > { > struct mv88e6xxx_chip *chip = ds->priv; > - u8 lane; > + int lane = -ENODEV; > int err; You have added a lot of initialises which are not needed. > > mv88e6xxx_reg_lock(chip); > lane = mv88e6xxx_serdes_get_lane(chip, port); lane is always set, so there is no point in setting it to -ENODEV first. > - if (lane && chip->info->ops->serdes_pcs_get_state) > + if ((lane >= 0) && chip->info->ops->serdes_pcs_get_state) > err = chip->info->ops->serdes_pcs_get_state(chip, port, lane, > state); > else > @@ -505,11 +505,11 @@ static int mv88e6xxx_serdes_pcs_config(struct mv88e6xxx_chip *chip, int port, > const unsigned long *advertise) > { > const struct mv88e6xxx_ops *ops = chip->info->ops; > - u8 lane; > + int lane = -ENODEV; > > if (ops->serdes_pcs_config) { > lane = mv88e6xxx_serdes_get_lane(chip, port); > - if (lane) > + if (lane >= 0) > return ops->serdes_pcs_config(chip, port, lane, mode, > interface, advertise); > } > @@ -521,15 +521,15 @@ static void mv88e6xxx_serdes_pcs_an_restart(struct dsa_switch *ds, int port) > { > struct mv88e6xxx_chip *chip = ds->priv; > const struct mv88e6xxx_ops *ops; > + int lane = -ENODEV; > int err = 0; > - u8 lane; > > ops = chip->info->ops; > > if (ops->serdes_pcs_an_restart) { > mv88e6xxx_reg_lock(chip); > lane = mv88e6xxx_serdes_get_lane(chip, port); > - if (lane) lane is always set inside this if statement, and is never used outside of it. > + if (lane >= 0) > err = ops->serdes_pcs_an_restart(chip, port, lane); > mv88e6xxx_reg_unlock(chip); > > @@ -543,11 +543,11 @@ static int mv88e6xxx_serdes_pcs_link_up(struct mv88e6xxx_chip *chip, int port, > int speed, int duplex) > { > const struct mv88e6xxx_ops *ops = chip->info->ops; > - u8 lane; > + int lane = -ENODEV; > > if (!phylink_autoneg_inband(mode) && ops->serdes_pcs_link_up) { > lane = mv88e6xxx_serdes_get_lane(chip, port); > - if (lane) > + if (lane >= 0) > return ops->serdes_pcs_link_up(chip, port, lane, lane is always set, and never used outside of the if .... Andrew