From nobody Wed Feb 11 06:00:07 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4BBB0C761A6 for ; Tue, 4 Apr 2023 10:20:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234520AbjDDKTt (ORCPT ); Tue, 4 Apr 2023 06:19:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53224 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234462AbjDDKTe (ORCPT ); Tue, 4 Apr 2023 06:19:34 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 51FDE3AAD for ; Tue, 4 Apr 2023 03:18:55 -0700 (PDT) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pjdkT-00008A-S0; Tue, 04 Apr 2023 12:18:46 +0200 Received: from [2a0a:edc0:0:1101:1d::ac] (helo=dude04.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1pjdkT-008tRp-6C; Tue, 04 Apr 2023 12:18:45 +0200 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1pjdkR-005nnt-Od; Tue, 04 Apr 2023 12:18:43 +0200 From: Oleksij Rempel To: "David S. Miller" , Andrew Lunn , Eric Dumazet , Florian Fainelli , Jakub Kicinski , Paolo Abeni , Vladimir Oltean , Woojung Huh , Arun Ramadoss Cc: Oleksij Rempel , kernel@pengutronix.de, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, UNGLinuxDriver@microchip.com Subject: [PATCH net-next v1 7/7] net: dsa: microchip: Utilize error values in ksz8_w_sta_mac_table() Date: Tue, 4 Apr 2023 12:18:42 +0200 Message-Id: <20230404101842.1382986-8-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230404101842.1382986-1-o.rempel@pengutronix.de> References: <20230404101842.1382986-1-o.rempel@pengutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" To handle potential read/write operation failures, update ksz8_w_sta_mac_table() to make use of the return values provided by read/write functions. Signed-off-by: Oleksij Rempel Acked-by: Arun Ramadoss --- drivers/net/dsa/microchip/ksz8795.c | 33 ++++++++++++++++------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/drivers/net/dsa/microchip/ksz8795.c b/drivers/net/dsa/microchi= p/ksz8795.c index 81ce1e3fdf56..fe17ce27e5e2 100644 --- a/drivers/net/dsa/microchip/ksz8795.c +++ b/drivers/net/dsa/microchip/ksz8795.c @@ -358,19 +358,26 @@ static int ksz8_r_table(struct ksz_device *dev, int t= able, u16 addr, u64 *data) return ret; } =20 -static void ksz8_w_table(struct ksz_device *dev, int table, u16 addr, u64 = data) +static int ksz8_w_table(struct ksz_device *dev, int table, u16 addr, u64 d= ata) { const u16 *regs; u16 ctrl_addr; + int ret; =20 regs =3D dev->info->regs; =20 ctrl_addr =3D IND_ACC_TABLE(table) | addr; =20 mutex_lock(&dev->alu_mutex); - ksz_write64(dev, regs[REG_IND_DATA_HI], data); - ksz_write16(dev, regs[REG_IND_CTRL_0], ctrl_addr); + ret =3D ksz_write64(dev, regs[REG_IND_DATA_HI], data); + if (ret) + goto unlock_alu; + + ret =3D ksz_write16(dev, regs[REG_IND_CTRL_0], ctrl_addr); +unlock_alu: mutex_unlock(&dev->alu_mutex); + + return ret; } =20 static int ksz8_valid_dyn_entry(struct ksz_device *dev, u8 *data) @@ -510,8 +517,8 @@ static int ksz8_r_sta_mac_table(struct ksz_device *dev,= u16 addr, return 0; } =20 -static void ksz8_w_sta_mac_table(struct ksz_device *dev, u16 addr, - struct alu_struct *alu) +static int ksz8_w_sta_mac_table(struct ksz_device *dev, u16 addr, + struct alu_struct *alu) { u32 data_hi, data_lo; const u8 *shifts; @@ -539,7 +546,8 @@ static void ksz8_w_sta_mac_table(struct ksz_device *dev= , u16 addr, data_hi &=3D ~masks[STATIC_MAC_TABLE_OVERRIDE]; =20 data =3D (u64)data_hi << 32 | data_lo; - ksz8_w_table(dev, TABLE_STATIC_MAC, addr, data); + + return ksz8_w_table(dev, TABLE_STATIC_MAC, addr, data); } =20 static void ksz8_from_vlan(struct ksz_device *dev, u32 vlan, u8 *fid, @@ -1047,9 +1055,8 @@ static int ksz8_add_sta_mac(struct ksz_device *dev, i= nt port, /* Need a way to map VID to FID. */ alu.fid =3D vid; } - ksz8_w_sta_mac_table(dev, index, &alu); =20 - return 0; + return ksz8_w_sta_mac_table(dev, index, &alu); } =20 static int ksz8_del_sta_mac(struct ksz_device *dev, int port, @@ -1073,16 +1080,14 @@ static int ksz8_del_sta_mac(struct ksz_device *dev,= int port, =20 /* no available entry */ if (index =3D=3D dev->info->num_statics) - goto exit; + return 0; =20 /* clear port */ alu.port_forward &=3D ~BIT(port); if (!alu.port_forward) alu.is_static =3D false; - ksz8_w_sta_mac_table(dev, index, &alu); =20 -exit: - return 0; + return ksz8_w_sta_mac_table(dev, index, &alu); } =20 int ksz8_mdb_add(struct ksz_device *dev, int port, @@ -1446,9 +1451,7 @@ int ksz8_enable_stp_addr(struct ksz_device *dev) alu.is_override =3D true; alu.port_forward =3D dev->info->cpu_ports; =20 - ksz8_w_sta_mac_table(dev, 0, &alu); - - return 0; + return ksz8_w_sta_mac_table(dev, 0, &alu); } =20 int ksz8_setup(struct dsa_switch *ds) --=20 2.39.2