Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp5765845rwl; Tue, 4 Apr 2023 03:23:30 -0700 (PDT) X-Google-Smtp-Source: AKy350aiKDDRlpSfYDKvFvxvKtj4HCJquJHackusyppeeln8NeCoJP0N3YqOcf7UuMTwc8lEhqR5 X-Received: by 2002:a17:90b:4b46:b0:23b:4614:6f84 with SMTP id mi6-20020a17090b4b4600b0023b46146f84mr2300136pjb.28.1680603810116; Tue, 04 Apr 2023 03:23:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680603810; cv=none; d=google.com; s=arc-20160816; b=laKNFoDJZI6u2PtUvwmjy6D0yWS/afxFZMHHPqRmrhotaArxM9gzORVZEkvOmTPrAJ viBUnJ36DV61Q2F6U5Ju/DYvG7pYhXpbOMhdUMkxlcm9spuEIenPGn0ZYjc41zbKx2BM o2qI+7EN+Nl4iDiJnNwEvuIJ4MJoxuxe628MSnbg+ryuRfjpnsmsmVhohld3uTyu4Ahb DR+wUyRVX0h+jJVVg2UmewtnwmG4vxOqpBb0mp4VhEPuGd4sap9PPpyx01Dl29YrqJ7T w9d/g8ik9V+DmXXjTUH6cFqdnk7sOVIs3YLrfJ+RPaGI0mzo+Ah7CYuJDVJLjhrzHUD7 H7jg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=StyRYmKOvz0CgdFxJjvZ4oy+tKhFKT57sHjCaIzXfv0=; b=jcZGRHhYlK9ip7LkTU6UePh9uC1G3IPXAveWjSI0uYJOMArwEswqO3aUvEHnVQKHcT krKFHhsfZJFYHSRau5j6pCSKzg/f8cs/eIbH4IrLwMiFyv+o+DmACeV1zQKWfGoE3Zt9 QF3mYRPx/WXEMTmj+jSJ3EoyNOkQrcAD405XLfVFNmKFZjVeMHnQNkXd1S4JwhDQL32p 8APcZFGN7T5dlkqYkDIiovKnDDavNpurx6QPExRgrn8FZUE2rS5A/OY+EK7+yrcDwqox UJmIBta+9dIdpH2sv4ahm3mZCjEZAKME9GDQLtwe6l1kD2yb2BBNb0v321Sn0+uMga0O tyiw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m7-20020a170902bb8700b001a216fddd00si2716196pls.646.2023.04.04.03.23.17; Tue, 04 Apr 2023 03:23:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234487AbjDDKTr (ORCPT + 99 others); Tue, 4 Apr 2023 06:19:47 -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: 8bit 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 X-Spam-Status: No, score=-2.3 required=5.0 tests=RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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/microchip/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 table, u16 addr, u64 *data) return ret; } -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 data) { const u16 *regs; u16 ctrl_addr; + int ret; regs = dev->info->regs; ctrl_addr = IND_ACC_TABLE(table) | addr; 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 = ksz_write64(dev, regs[REG_IND_DATA_HI], data); + if (ret) + goto unlock_alu; + + ret = ksz_write16(dev, regs[REG_IND_CTRL_0], ctrl_addr); +unlock_alu: mutex_unlock(&dev->alu_mutex); + + return ret; } 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; } -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 &= ~masks[STATIC_MAC_TABLE_OVERRIDE]; data = (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); } 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, int port, /* Need a way to map VID to FID. */ alu.fid = vid; } - ksz8_w_sta_mac_table(dev, index, &alu); - return 0; + return ksz8_w_sta_mac_table(dev, index, &alu); } 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, /* no available entry */ if (index == dev->info->num_statics) - goto exit; + return 0; /* clear port */ alu.port_forward &= ~BIT(port); if (!alu.port_forward) alu.is_static = false; - ksz8_w_sta_mac_table(dev, index, &alu); -exit: - return 0; + return ksz8_w_sta_mac_table(dev, index, &alu); } 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 = true; alu.port_forward = dev->info->cpu_ports; - ksz8_w_sta_mac_table(dev, 0, &alu); - - return 0; + return ksz8_w_sta_mac_table(dev, 0, &alu); } int ksz8_setup(struct dsa_switch *ds) -- 2.39.2