Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp5765824rwl; Tue, 4 Apr 2023 03:23:28 -0700 (PDT) X-Google-Smtp-Source: AKy350YnmftS8JEWHwVaSoyoI2y4bYv0F4JjXlNNzQFG7jCL02GX857tEmQ60lLoER/i+PEm2n0S X-Received: by 2002:a17:907:c70c:b0:948:5b3a:ce25 with SMTP id ty12-20020a170907c70c00b009485b3ace25mr2265044ejc.11.1680603808078; Tue, 04 Apr 2023 03:23:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680603808; cv=none; d=google.com; s=arc-20160816; b=ACZnizQ0/IJr1JqzMrMbJzUszmZAhA17fspI+P2fCx1JuxRlm1hvimvjUCowMMWIPq MRGLop9A13bp5dhzagD54StqNL0Qkg1Axqrg6p7e3xhPr/rlGGyiEmRSrZROLzVhbdmB UY5bEfbbdaFkoN928eFmPuR8yVDeArQ+HMmkDB28vUaWnCJsNI6KVfMfte1WI5gCUYNl Gr/GXjJLSzMuFMf8Tb38YmFrkuUClMGUJxCY0+ej6yqdaSZd72fKfPiRAZzLV9PuhCCC 8kejJUoreRgeGQ3p3FIZkPMyEAlfWgyLQnfeGI88D3edsag7H55cMbclGgG7T/dnfHkW igjw== 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=o0zUxNNnnOWPyFgoWzSGKnnDiBB1gI4QczCyEJWRn+M=; b=pO8AaxxiluoHBCwuKZBZ0YDc4MS89COmEh3ayL1KISKW9AJEe5G8RzoN1F+UqSYQxd mMmy5n47FROUwPkn+5KNNbFKgS4DyRAXKwuXKDAqqZg48RJuI9B1esJ8UCDd0NNYBsBv fj4tUWj/nVcyVLCPhqy+71RkQ3lvYbiGuk6hzvlPMnB9FOb/D7sKX69YwFdrUaY+7elg 0bdifgkxB+0/vwnzWc35PYQvdVUWZM7lwuNsCQ6fJ5n9yZSZ/c1KFggAaRyv8q0runSl reiIcbeWhGt+0BQx96TaM/ipSfj3BPV1ZJFuP+V/NcxlZ8MvZo1bXPup9DGSaSgXqSpJ uKdg== 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 gt25-20020a170906f21900b009474eb6bba8si7730461ejb.623.2023.04.04.03.23.03; Tue, 04 Apr 2023 03:23:28 -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 S234525AbjDDKTv (ORCPT + 99 others); Tue, 4 Apr 2023 06:19:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53254 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234474AbjDDKTf (ORCPT ); Tue, 4 Apr 2023 06:19:35 -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 7AE4A1BDB for ; Tue, 4 Apr 2023 03:18:57 -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 1pjdkU-00008N-AI; 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-008tRy-If; 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-005nnZ-NS; 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 5/7] net: dsa: microchip: ksz8_r_sta_mac_table(): Utilize error values from read/write functions Date: Tue, 4 Apr 2023 12:18:40 +0200 Message-Id: <20230404101842.1382986-6-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 Take advantage of the return values provided by read/write functions in ksz8_r_sta_mac_table() to handle cases where read/write operations may fail. Signed-off-by: Oleksij Rempel --- drivers/net/dsa/microchip/ksz8795.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/drivers/net/dsa/microchip/ksz8795.c b/drivers/net/dsa/microchip/ksz8795.c index 4dcf68a7f6c0..76a8ca329732 100644 --- a/drivers/net/dsa/microchip/ksz8795.c +++ b/drivers/net/dsa/microchip/ksz8795.c @@ -336,19 +336,26 @@ void ksz8_port_init_cnt(struct ksz_device *dev, int port) } } -static void ksz8_r_table(struct ksz_device *dev, int table, u16 addr, u64 *data) +static int ksz8_r_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 | TABLE_READ) | addr; mutex_lock(&dev->alu_mutex); - ksz_write16(dev, regs[REG_IND_CTRL_0], ctrl_addr); - ksz_read64(dev, regs[REG_IND_DATA_HI], data); + ret = ksz_write16(dev, regs[REG_IND_CTRL_0], ctrl_addr); + if (ret) + goto unlock_alu; + + ret = ksz_read64(dev, regs[REG_IND_DATA_HI], data); +unlock_alu: mutex_unlock(&dev->alu_mutex); + + return ret; } static void ksz8_w_table(struct ksz_device *dev, int table, u16 addr, u64 data) @@ -464,11 +471,15 @@ static int ksz8_r_sta_mac_table(struct ksz_device *dev, u16 addr, const u8 *shifts; const u32 *masks; u64 data; + int ret; shifts = dev->info->shifts; masks = dev->info->masks; - ksz8_r_table(dev, TABLE_STATIC_MAC, addr, &data); + ret = ksz8_r_table(dev, TABLE_STATIC_MAC, addr, &data); + if (ret) + return ret; + data_hi = data >> 32; data_lo = (u32)data; -- 2.39.2