Received: by 2002:a05:7412:f690:b0:e2:908c:2ebd with SMTP id ej16csp311830rdb; Thu, 19 Oct 2023 05:29:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFxlNPmSAmUYHdWQtMAzl9V0pNDqM3Tdw5IYPBX49gRJR//BuYo0WmYDXkrIu8iKmo1v15S X-Received: by 2002:a17:90a:eb8a:b0:27d:6d9c:6959 with SMTP id o10-20020a17090aeb8a00b0027d6d9c6959mr1868073pjy.25.1697718584892; Thu, 19 Oct 2023 05:29:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697718584; cv=none; d=google.com; s=arc-20160816; b=GwQN0DHReHpOkoqICxalec3pgw4oxxivOpaUV6VUhGOKntjb1a8XnYdX0ZRYbLq46G ZPcs8KlEFypKbaFskZnOf39ZMKduLYp3mAl2CYzbQlAulHkVQdnKW0O9qEuKnK0F39oU +bb8B5YfYmQ03DfClSLe5PLNf/ft1Z3imLKzMbXiJnfUJHt8yCL0rh9pdBijvUmbFe5T v+/MQTTBQ20oD/mVsMfhMrRrKg4QjEbWlOT1nopoPw2kV93mPDNYGlldOlMhj40Ebmz0 YStXJo8R9WZKHvLX2qqcYrP7QhbkMXBUW6Rx1Fsf8HFT4fOyEIAKgH3nQ9gigYT4ZzJG ytAw== 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=qg+M8mvk7yxj/VboNGwBKCG34lNWWtwvMc1wkZzmSuw=; fh=oL5u1qxwpthPG0onT/4SNMwjdlMbLicDue2DPzZvioY=; b=w5QA93JsYH++YK45+XVSl6Yo4u9+C9RGSgXUMM8Hjek7CqoUGeBebN3ULmo7cUeJHf TLCsqG5C/pd6BzKaxuUEtrZQVDIIUkkM3vKOePe+isGm4OfI+KN02QhF5yYMA1Z5kHJ7 1aG5dNI45rCWoVexwSj2AX1Mr+FoNd1QYt60AVvPn+C3OYml6LMxtLoedn4bXWxMe94i 4vWq4fe57VG6XYzctm/8Yzgmi5PbDXn1Xb60XhRwrQto0v6+TMcIS3+Vxk1ehUqLbtXb fOdVTtoK5PmByMkSq94HWk7SYDPQNffUIRgIoCMD8OpQBcHqOSr5YXsx3nU5+Y399nQA jdUQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id mi12-20020a17090b4b4c00b0027d18475bd3si2088482pjb.168.2023.10.19.05.29.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 05:29:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id AEEFE81AA500; Thu, 19 Oct 2023 05:29:37 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345577AbjJSM3T (ORCPT + 99 others); Thu, 19 Oct 2023 08:29:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345534AbjJSM3R (ORCPT ); Thu, 19 Oct 2023 08:29:17 -0400 Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [IPv6:2a0a:edc0:2:b01:1d::104]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 38861CF for ; Thu, 19 Oct 2023 05:29:15 -0700 (PDT) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qtS8y-0006Kx-OT; Thu, 19 Oct 2023 14:28:52 +0200 Received: from [2a0a:edc0:0:1101:1d::ac] (helo=dude04.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qtS8x-002mrr-Ln; Thu, 19 Oct 2023 14:28:51 +0200 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1qtS8x-00529h-1p; Thu, 19 Oct 2023 14:28:51 +0200 From: Oleksij Rempel To: "David S. Miller" , Andrew Lunn , Eric Dumazet , Florian Fainelli , Jakub Kicinski , Paolo Abeni , Vladimir Oltean , Woojung Huh , Arun Ramadoss , Conor Dooley , Krzysztof Kozlowski , Rob Herring Cc: Oleksij Rempel , Florian Fainelli , kernel@pengutronix.de, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, UNGLinuxDriver@microchip.com, "Russell King (Oracle)" , devicetree@vger.kernel.org Subject: [PATCH net-next v6 7/9] net: dsa: microchip: Add error handling for ksz_switch_macaddr_get() Date: Thu, 19 Oct 2023 14:28:48 +0200 Message-Id: <20231019122850.1199821-8-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231019122850.1199821-1-o.rempel@pengutronix.de> References: <20231019122850.1199821-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.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,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 pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Thu, 19 Oct 2023 05:29:37 -0700 (PDT) Enhance the ksz_switch_macaddr_get() function to handle errors that may occur during the call to ksz_write8(). Specifically, this update checks the return value of ksz_write8(), which may fail if regmap ranges validation is not passed and returns the error code. Signed-off-by: Oleksij Rempel Reviewed-by: Andrew Lunn Reviewed-by: Florian Fainelli --- drivers/net/dsa/microchip/ksz_common.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c index 7b05de6fe987..79052a54880c 100644 --- a/drivers/net/dsa/microchip/ksz_common.c +++ b/drivers/net/dsa/microchip/ksz_common.c @@ -3612,7 +3612,7 @@ int ksz_switch_macaddr_get(struct dsa_switch *ds, int port, struct ksz_switch_macaddr *switch_macaddr; struct ksz_device *dev = ds->priv; const u16 *regs = dev->info->regs; - int i; + int i, ret; /* Make sure concurrent MAC address changes are blocked */ ASSERT_RTNL(); @@ -3639,8 +3639,11 @@ int ksz_switch_macaddr_get(struct dsa_switch *ds, int port, dev->switch_macaddr = switch_macaddr; /* Program the switch MAC address to hardware */ - for (i = 0; i < ETH_ALEN; i++) - ksz_write8(dev, regs[REG_SW_MAC_ADDR] + i, addr[i]); + for (i = 0; i < ETH_ALEN; i++) { + ret = ksz_write8(dev, regs[REG_SW_MAC_ADDR] + i, addr[i]); + if (ret) + return ret; + } return 0; } -- 2.39.2