From patchwork Sat Sep 17 17:51:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Foster X-Patchwork-Id: 12979224 X-Patchwork-Delegate: kuba@kernel.org 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 E7E7AC6FA86 for ; Sat, 17 Sep 2022 17:51:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229495AbiIQRvr (ORCPT ); Sat, 17 Sep 2022 13:51:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51522 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229471AbiIQRvq (ORCPT ); Sat, 17 Sep 2022 13:51:46 -0400 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2136.outbound.protection.outlook.com [40.107.244.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 11CE527B16; Sat, 17 Sep 2022 10:51:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ELuYb9pGQfUR5XT2nw6MOcEqj/lGI8u2crq8doaKJg3M/K29Weqr+ahONpZhgjMQrQ6aiXLNvbzlj2w7aUT9Zf/jkrOtdQO/8nKiVE5Qd2DfGzctJ0EtAskZ56kpAueFBG81tosNGoy1lAT3qYyEci+fHS6o/XqV9SmYGz0KL65UR7K0j7r8brOB99jXC3Qv+GkT9JCOD2ydS2JOgSeXRwixQCSvH6hLhkra3fZ2y62aXeeof7jynyN4REUkLJeTJoQnyrm2PbyL+SC4GQA3zyZa4atj2V7gHp9Jhe8s75qE/58SuJDbppAJcECJPlC55fqfO9Wq5UgI3Ve+FO80jA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=4N/TKcvNDpZF0/hnRDSfAFCjOiUMlWIYjyyK68djk/w=; b=YWo5Km5fn8iYm/asbyBeV0gkkaP9d3gckadMjmzHncefD5QC9rwtrvbj4NLGKQS2/vaW2h6QjqJbRwy7wBnCEy4SeAkJi3rAd2QBwZBsgMQdRbZ5k3fcoemJsroJIdWWI7IMQgZQ7A8eFVoohbaKkgl9xNnupTSGDh6w1ZAl+a4h+taZLrq8tYHIf9c/NYsnR30J+uaPXTBUiJ8BEA4DMzdKg5LAmesjmaFrFAXOYFvQMvfMEltKHiyE+UCKtFQ9UlgBwhzvB4Jf+e0f/m++BNDkNHGrxJWqGU3PC1/L8b7reMT3jNPmXbLshYnjVn3mdiaF9QXqN9ODZ0OpOnFJBg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=in-advantage.com; dmarc=pass action=none header.from=in-advantage.com; dkim=pass header.d=in-advantage.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inadvantage.onmicrosoft.com; s=selector2-inadvantage-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4N/TKcvNDpZF0/hnRDSfAFCjOiUMlWIYjyyK68djk/w=; b=zN5gO+3lSdNg0FMr7KYD20/BBXzu3peq6Jd2nh9kF5zblom+8TuCXNT5uPmChJUBNEIOgVMb+QLKItG85hAEa5Wwjpkdqr+sWve77Cgsbaiyf4u6pHJU5wJNKRd1DQw6P090VWtt7txuh0mKi9NtKyPIYXiYo0uYWZu33KQldC8= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=in-advantage.com; Received: from MWHPR1001MB2351.namprd10.prod.outlook.com (2603:10b6:301:35::37) by SA2PR10MB4523.namprd10.prod.outlook.com (2603:10b6:806:113::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5632.18; Sat, 17 Sep 2022 17:51:42 +0000 Received: from MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::dcf2:ddbd:b18d:bb49]) by MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::dcf2:ddbd:b18d:bb49%3]) with mapi id 15.20.5632.018; Sat, 17 Sep 2022 17:51:42 +0000 From: Colin Foster To: linux-kernel@vger.kernel.org, netdev@vger.kernel.org Cc: Paolo Abeni , Jakub Kicinski , Eric Dumazet , "David S. Miller" , UNGLinuxDriver@microchip.com, Alexandre Belloni , Claudiu Manoil , Vladimir Oltean , kernel test robot Subject: [PATCH v2 net-next 1/2] net: mscc: ocelot: utilize readx_poll_timeout() for chip reset Date: Sat, 17 Sep 2022 10:51:26 -0700 Message-Id: <20220917175127.161504-2-colin.foster@in-advantage.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220917175127.161504-1-colin.foster@in-advantage.com> References: <20220917175127.161504-1-colin.foster@in-advantage.com> X-ClientProxiedBy: SJ0PR05CA0148.namprd05.prod.outlook.com (2603:10b6:a03:33d::33) To MWHPR1001MB2351.namprd10.prod.outlook.com (2603:10b6:301:35::37) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWHPR1001MB2351:EE_|SA2PR10MB4523:EE_ X-MS-Office365-Filtering-Correlation-Id: c2f1e926-de3f-41f8-ff60-08da98d5472d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: sv354KRKX+IRL9Q0K0xCFx6RgEN3hcmLugR4JTCXk1r8wpfaaWu8NRnGNHprUJaCH00YLCVPnVdJaznHYmbyBFXL4gVIbBY8OePSXiXazF5AGMXX5vlDA+vq35IDbL2Q7ktD5HBQj/xOxs7ljv5xOkTIcwqPdg+TR49TmR6kgTpsa0jfmWkun3Ucc5CChDq5pZtfJxSotblUyCL5AYm1gb2TTXUi57+Atf0stcor/W+aZ/FpxXeB5okFLgLVtEdOGCGITxiUKLJpWIWofcXPAPaOjlBJ0zyiA5LPGWRT2odhi0vAXJazir0Pmzgs2c+GmZLcm9jAcsMIwTnPSoEUxi3o1d6N3uQH4cvvq7yM+0uegSIpOKaEfSgn532Yts5l/N3WLSxM4xR3MtYLyNXkAfkNONiMCha+05WOTE4WK/b9JYSKDodZdCIThEESn4EbUF9DnfACogXBkkLhR46OVgeztdGKT89hBHzjl3oze5sHtL6kmEb2UZ2yxbNYfvzKcCwlFPsncV75tSL1nU7Cyt2M0n6U7YpEY1zcWbnOtNhpyW4bzV8nM9Sp6NmoprFZu7cSA7Rxk7Vj4z+IHU6HdLDltpN1feI7DOClwLrHGnIq2FP+eLAa0MJy+icn7SZTVzvzSf0qpItGDcxGU4eAsjMk3ysCZtHwC+YP+75I07cD9CFkMOfWf5Vjn+intPewaVXKdr6UadO4xJ8XnNxWRor9oq6ruLi/kwqTKZbhM4O4BQ7srZm1q4QHYVOzAKz6yIYZJcosPifd19AnO8qHvg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MWHPR1001MB2351.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(136003)(39830400003)(366004)(376002)(346002)(396003)(451199015)(36756003)(5660300002)(8936002)(2616005)(7416002)(38350700002)(66556008)(66946007)(38100700002)(8676002)(66476007)(86362001)(44832011)(2906002)(4326008)(54906003)(478600001)(6486002)(83380400001)(1076003)(186003)(52116002)(316002)(6506007)(41300700001)(6666004)(26005)(6512007);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: rpaWPo5oD6BO2tlNv069AFE76VfGq2dww4+cU3PJ6R3WY/9vQYTveDxi+kMQL5GS/xNr1fv2qwZ3x9ZbH1zR6QtISTf0ukIR5RAxWm6XT6yN99nQPGFQ2h+WR3u2UUBvOddgk9AJ3MhkWT9VnT/1NqqBdh1Cd1WZ40hW69gp7RxVHS3ao2ZFAz5tO2QP/cXYAOUZawziLSkDRMlGFVplsnrdLy+x4bpx3NKaRfXI6B4oZwk/5DzVQ7Zz60JJ2fR9AY6IiiFcqCxihiZhAFCdQXrjBcp0LMGkQ1R/YJCccTvZGcZjVniQnEhTgxGbN8Xc1WDLj2UaRRj6Zbq7CcUFhJG9jlpZW2jHHCSlNI7nzqWIW4pnLLJuCkmq/8KRSZ8Tw6r4/BNACXl8iLOVK5k+i9n/2xq6zrIBSO7xCmW4cJt4FlXmeoEXEPCjFpexFmnvcEXjBY2mXIrpNvY2ojmEUIlSEuXHpwnvn9OCOGZKS/DNdhrs/6kLZ3Pd5JWcnAhT5O8rfCigqW6JA7fhaESDrgAP+g4yjUzXQ6KbJT9U90ky8HrzwlKStx+9QQYTaahRrQ9BkAaZ6VjUo7MOeQ6WBw77r8tht+16l6nxPpmYcld5jRaqZto1G9h1KAZmcImp0qspOXndC5u+DeHeGCqYV75Z/hrVXI+IPVzMih+jFbAxuRHa7NvdIV/Y1n/bHl/anXHm5xZ4XrpYaPBWT31SfJeboqe5fuPQ9QhKfPTU5yCwUmXkfM8JwnkdZ1+9SQnD01OWgOtrvncu32GldJzaAXv4afrUFfTRg4J96zcCrsDkbg+gxOCH26dgiG4xzCv06PUBDOcuA1NqdsjjWiCtBmdOwPT5SjFSeTzxrzMd0MHmucdcbw5k+7nmMy+8+tczwDUfdw7YfiIgo0Mg7bchpAq/1xXf7tiKww1jikqgZ1aEkJMq4hhSA9HozGCCPEX32yMj/iILU9Q4gNjNCo7T7TkfcSIcyoYqPI1C36vpVdqDh3GkHB/VyrlCb18JSC/uovvpaz+5/La+6Co0nviyzMOgit6noRacAFylnHDQTmvAeliWMOV/e1KXxIW0rtDMmh0FdqSGofPnkTyjFKo9hKdr73Id6XQTBu3ZD0zuh16tAkANMYlbL5l05K2AOfAsRtHFzWOgb2Lg5dlBAs7ZccjWsUZwGXJQZjqPCPcBfkIFe9iiyIC9ElrlIOi/HZphwl6qqSF8MscbRUPSgcCXQIogvmhauwyEoT+bNPzYx5UIsxHWJweeKVdGucVPnnb1PdlvEiBjInUvv23wSV1ra4k0lJ0OWE6yOTugSPDCtlSuPranwdB15YIgubJQQTKiSw8yHS1bS9xY3DHo9hsiVrHkZf2obPQC/YxO3i5vd4ykq08tPDL0mZpheOg3OmtosU0JtVR+5xcl7gQKaXj4exj+YSX5ZucJ6E7BIzzJzfuteryC9TqCMU1YrIlsblVpoIxKwsrr907LMo/PXNad2yljseOESnTZWbUS7PNNPz6bn5qHMUhjuGgXQ2gJ+RuOwtkiP2dOTr0fyWU01NhhXtOStazIHXnNzE/tnpdoHAmK9ZEeEyR3tHLDYgaAwBBjGxoB1A6tonBE/OAuocI1lch7JqGNrtEaMvgx1y36yA8= X-OriginatorOrg: in-advantage.com X-MS-Exchange-CrossTenant-Network-Message-Id: c2f1e926-de3f-41f8-ff60-08da98d5472d X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2351.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Sep 2022 17:51:41.9436 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 48e842ca-fbd8-4633-a79d-0c955a7d3aae X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 81pEUVeOw8NY8+TNoTlHGSZ6m9rovPD8c/cjHtLeXg+sQKT/KYfvlM1CLnkbPLQjROklT6OQACu6zeVXJ9CxmEmzmvRUDN5kKLJ8+hqMBVI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA2PR10MB4523 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Clean up the reset code by utilizing readx_poll_timeout instead of a custom loop. Signed-off-by: Colin Foster Reviewed-by: Vladimir Oltean Reported-by: kernel test robot --- v2: Remove IS_ERR_VALUE macro compile error for 64-bit Add Reviewed and Reported tags --- drivers/net/ethernet/mscc/ocelot_vsc7514.c | 32 ++++++++++++++++------ 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/drivers/net/ethernet/mscc/ocelot_vsc7514.c b/drivers/net/ethernet/mscc/ocelot_vsc7514.c index ae42bbba5747..3fb9183c1159 100644 --- a/drivers/net/ethernet/mscc/ocelot_vsc7514.c +++ b/drivers/net/ethernet/mscc/ocelot_vsc7514.c @@ -6,6 +6,7 @@ */ #include #include +#include #include #include #include @@ -25,6 +26,9 @@ #define VSC7514_VCAP_POLICER_BASE 128 #define VSC7514_VCAP_POLICER_MAX 191 +#define MEM_INIT_SLEEP_US 1000 +#define MEM_INIT_TIMEOUT_US 100000 + static const u32 *ocelot_regmap[TARGET_MAX] = { [ANA] = vsc7514_ana_regmap, [QS] = vsc7514_qs_regmap, @@ -191,22 +195,32 @@ static const struct of_device_id mscc_ocelot_match[] = { }; MODULE_DEVICE_TABLE(of, mscc_ocelot_match); +static int ocelot_mem_init_status(struct ocelot *ocelot) +{ + unsigned int val; + int err; + + err = regmap_field_read(ocelot->regfields[SYS_RESET_CFG_MEM_INIT], + &val); + + return err ?: val; +} + static int ocelot_reset(struct ocelot *ocelot) { - int retries = 100; + int err; u32 val; regmap_field_write(ocelot->regfields[SYS_RESET_CFG_MEM_INIT], 1); regmap_field_write(ocelot->regfields[SYS_RESET_CFG_MEM_ENA], 1); - do { - msleep(1); - regmap_field_read(ocelot->regfields[SYS_RESET_CFG_MEM_INIT], - &val); - } while (val && --retries); - - if (!retries) - return -ETIMEDOUT; + /* MEM_INIT is a self-clearing bit. Wait for it to be cleared (should be + * 100us) before enabling the switch core. + */ + err = readx_poll_timeout(ocelot_mem_init_status, ocelot, val, !val, + MEM_INIT_SLEEP_US, MEM_INIT_TIMEOUT_US); + if (err) + return err; regmap_field_write(ocelot->regfields[SYS_RESET_CFG_MEM_ENA], 1); regmap_field_write(ocelot->regfields[SYS_RESET_CFG_CORE_ENA], 1); From patchwork Sat Sep 17 17:51:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Foster X-Patchwork-Id: 12979225 X-Patchwork-Delegate: kuba@kernel.org 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 948C8C6FA82 for ; Sat, 17 Sep 2022 17:51:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229501AbiIQRvt (ORCPT ); Sat, 17 Sep 2022 13:51:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51530 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229483AbiIQRvq (ORCPT ); Sat, 17 Sep 2022 13:51:46 -0400 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2136.outbound.protection.outlook.com [40.107.244.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2506527CC9; Sat, 17 Sep 2022 10:51:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=B7X5mzs9Whna/oIF/DkAkdeiBwXEkZdQCEq/s6mmjmjsrh9ccKeM9NrYTaiy2Qw+4GGc38ltlIfU80OsLM5UoTQfmaE14aYv9OO41UKWPAYzfh7TMgtdDgdxb86/uI5x/NtI4knq8eexM+K1llIC5DvVBp5tbtBelIty+qrLNuDWwlRS8qVYcCn/3ylXk6qyhhtH0eljWGaqRaNUPsUeJFyIN8BYb1QaVgkBnmHXWvMsDP23nPiVO4WwWSneRnSfgOO2EEEYLjaaSAHNBZ+M3mYL/CeBpd8Ra7x3FVyOZwqhhMCmOVwdOuwJJruHCzTTUmkL2gDWP8XxMSi9JR0TYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=BLnXy1snSQcnSi8vxiR/A8j7yP0N54nPVaYfN7HRKCc=; b=ZPy8CjMdvmI5PI5QkWkp1c1PIocaAPsyhCZhPNm5LbNYC2CXo/djKlQ1e22xwlYtd//wq0gnuVG8MBhNw1UR2IT6mioYoA9rDLWTDpQ8qOd8uKSCEu1bpMfXONmcuH9cMEjeGBBZM8gPQPs5b7jsfR8iAzbNUo27MrTTIakaoCS5oNF2srCtITZS3crlcQpNj1u9Gy/lobL5OKpz5MWxgW3w39pBuKwtPb565dj7L70DwxZNjt4CxkcicgL/KFjP+yQiRw94q6JoTC5KsdZenNT5CZ9Pl+TyiVDaec3/UOxMprlzQE+qM4oJHTXCMh+R7O18GwF2qaeZYShDGgDBmg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=in-advantage.com; dmarc=pass action=none header.from=in-advantage.com; dkim=pass header.d=in-advantage.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inadvantage.onmicrosoft.com; s=selector2-inadvantage-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=BLnXy1snSQcnSi8vxiR/A8j7yP0N54nPVaYfN7HRKCc=; b=xhO5E3Ofkw5QvrDS+ijWEOrK3PVDzT/AOtWOf1W/0tZO2EnkhhNKERWq0fYeLtLYQ9+EsztOTSPAue82tkotQw4cUgZ5/Oj/BhiYMALkqPN/QQcZaeFltmd7DUVW5inkcdL7T4HRQTIJ/a9PUSoNEtrZHb01JUmNBWyB3wo13h0= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=in-advantage.com; Received: from MWHPR1001MB2351.namprd10.prod.outlook.com (2603:10b6:301:35::37) by SA2PR10MB4523.namprd10.prod.outlook.com (2603:10b6:806:113::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5632.18; Sat, 17 Sep 2022 17:51:43 +0000 Received: from MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::dcf2:ddbd:b18d:bb49]) by MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::dcf2:ddbd:b18d:bb49%3]) with mapi id 15.20.5632.018; Sat, 17 Sep 2022 17:51:43 +0000 From: Colin Foster To: linux-kernel@vger.kernel.org, netdev@vger.kernel.org Cc: Paolo Abeni , Jakub Kicinski , Eric Dumazet , "David S. Miller" , UNGLinuxDriver@microchip.com, Alexandre Belloni , Claudiu Manoil , Vladimir Oltean Subject: [PATCH v2 net-next 2/2] net: mscc: ocelot: check return values of writes during reset Date: Sat, 17 Sep 2022 10:51:27 -0700 Message-Id: <20220917175127.161504-3-colin.foster@in-advantage.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220917175127.161504-1-colin.foster@in-advantage.com> References: <20220917175127.161504-1-colin.foster@in-advantage.com> X-ClientProxiedBy: SJ0PR05CA0148.namprd05.prod.outlook.com (2603:10b6:a03:33d::33) To MWHPR1001MB2351.namprd10.prod.outlook.com (2603:10b6:301:35::37) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWHPR1001MB2351:EE_|SA2PR10MB4523:EE_ X-MS-Office365-Filtering-Correlation-Id: b5213f95-1d4e-4830-7eaf-08da98d547d2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6kI2ppEoQpZ1Mmz/Tw7NKTbYVj4rGKyRddMs87ykyGYP93CWqIsU4rMIkbQaP3+qI4fuCwGOdSgn486q4TEGbE/x/NNIGtJCYATAffTQe9n1eM8zCE4Hr8j5owJM5Vq14hjQdR1wKlMsGlt2hCzmtemUDwlJQkD9etBYQj2bBNgdK/+ZieSAcM3wHU7i5nkqOuigaE/kiWQLtMVjw+IAQ4CXGG36Hc4ehYLpeqYhlIeyuy94qMd7Ya7wB5PWqJ7RAWUt4RRWMvDD2U/c7XuCSxnq7WH/c4wwgSIdcR9UA8+za1S91Vb8GbtilwW5VoUTHDet/0O184vPvQPjYqr6zxc1CLmMnH/HdhH8TPTCibC3+7koueO9xE+Wt3wVCfcwKTPMLoParqJX7jC8WvBsSiGK0nXhn7ujeotYGVtoKW6NZb46TImyLvbitlzICNJjiDX2by21re6o1TybOAUKqFdA5ig+cReFZfZkKV8X83j+dbkx6Nc4d//kKQwut9lXBts6JjRijP+u44fDj+bCyOaYyAacz56glpfCI6/GZyM0kJShLkdS6ckXDGZsDZS8Bl4WaPH5lVaoMXtFLZffft2LeYGhr1H4Pd07HwNfJ6e1FRbskcMJPnw/wHRiL91CQ8aZF9jwu7kiXHUOqJf1/KFUgknsqFFORoCPEGpl8tuWUODVgWLmy2jeIaHzit8bnjL0bnNrZHbivlAD1Fzwx2GV8W0RK8ooiVfEq/FXxr7w25j99yyXxZJToQy5sjaML0lz4iEqjyvCMxhfY62/Og== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MWHPR1001MB2351.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(136003)(39830400003)(366004)(376002)(346002)(396003)(451199015)(36756003)(5660300002)(8936002)(2616005)(7416002)(38350700002)(66556008)(66946007)(38100700002)(8676002)(66476007)(86362001)(44832011)(2906002)(4326008)(54906003)(478600001)(6486002)(83380400001)(1076003)(186003)(52116002)(316002)(6506007)(41300700001)(6666004)(26005)(6512007);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: bh1yBHA2BizGjrE7oa84Xllc3TZmYL7BF/9HyHBtdt3fEUJJzpgpojHfBBEW0kfuadRAa37/YzisWzqGeSHG0V5eYzPKaOo6hYpdXCel4cUtbm6XQvg6WzzwivqCJiBIDJEGIgkjxAi/G4DuBFnTH6O2eJzR73ukIX1tsrjrYypCoMRP36EwH2LFnY5zKgw941qVnP5Inc6/gMj8cmVB+sFHUc7VXtKykMY6niZ11S133LnMcHC1bdAe9G8o1Fj1l2Ehs9zHGlFTv3xNOLJhhNOQv4e0GLx8rf39gT1LWNt5v46SXHsApHUaW8JPl4uxHxPp9T1a5eIagviPzS1nSxpQKedVONg8+xHK8SUnEVN3+GwErJti7JXOs3q5M9bJc8hjfZwPcpOSj7risogRwTKqu7oPLh50FVAqRX+IseHUR02JUlptUo1hqRWv7TqbPVC3iAwQcLatiZlRDQalytUNKKGGBmdRJd5r2XRsL2bGywHTJPB3SJL+D8ogyaBs7Qq1nn5IrWhiD6h/NsVknu711cqSWx+FasKOyu9KvxFqUjjQd5NxjDWVbL1CQ/oVagfIH9vOauV56SZ9grWyO6dHeHPKsM/x87vdKNhQKixwLb4z0wPDFZxp98+gfSVTdCUKjsJFe1IFFuftHDo/tTj1cllGkqfCDBKuhwL+CrH5I6HnbxgVvCjhZj9421Y/c4QwmfUBeLOYe60iZ/qUQ9XVfSNggLBp6Z20AOYMXlRFvlV0Zt/ijtZWuTBh6WJtwSYazgM7uZU+r4ThCwk1HyvfMbVOBYDHNxnLs2rCtbZDUgRx4AxlmYDighfsOa+hGdCPx7WPmXmk8fToUnNfVuAAPM7ByKRX2qm/mk3hjwv67L9i6PPRyV50364L1ocvLDK1DpLCz/gofX9QbMex8WbmHo8TsZVwEjR36hH8xLxqqy9qPVgXfrN7ZK0szgMBX8dVozdGrgDwwUqWI9Ic9kSe/yZx4WialsFb5lewEoS77RYzvOFED5dF3JlHAGPq0PWzIDVHMC/b9IKQyhFTY7Ezf66jcetGhy2toQ8yB9wcmEUANki2zuEHy2YyKf3jmRqOG5KTkbIlGceEObrFM2C0P/OZdwUvylSDHeLWGJtf1kXcHcLsjb2uVTLkOKGrQMuZVRn3+C8sWfgyiZOlJs2WKkY2QklSapgcToNIA5s9ZmKiG4D0mnFAduMwU1C6x2OGT/HBHHxmoqlUk2SJr6SGkBA/4jwcdtI7NlLIsfhcD3PaaeL2VNkIeMA4JLSuT71pb11LLux9g9GjNIGj5hQZRrNLgrWd+uHIKux8F+EPB8iXhld85BgUhWEwOSIUTFDCVG+9fUpzbPon6mK2t78GlRjx0agN9ON4J7VvkMEkn3hDG0S7cTFUs8KmyTETI5BB0hV5NaZuexWk6EJy2aVbnRZXFbjQR0gZqjKdsnGT7UtSzhbLiIXkY7jFSAkBdvF/mEkegBgVCQPsZ4LHEfiXQKefHx8sLFtis8bXQSWfzyK745N0jzJAW/fdgcZgzBafE0J5ETSucFh2iCC1Fc+zvsrhSzYgLda7/V+KhVWhytdJBJ22l5ob8Vw2SujHeV9mh482WPxfUaYP8CcPXejkyaugU24ql05rfRXqkts= X-OriginatorOrg: in-advantage.com X-MS-Exchange-CrossTenant-Network-Message-Id: b5213f95-1d4e-4830-7eaf-08da98d547d2 X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2351.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Sep 2022 17:51:42.8810 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 48e842ca-fbd8-4633-a79d-0c955a7d3aae X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: BmoVvVGriPNoiHkC9ji3b70WtIf3InoOF+a7DySpsPhuFm9Qk79Vk+FqbF+TQPWnGUFp1swwhpmMnoNCU95tL/s2w1nRusAmf7Pz/QxXuIM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA2PR10MB4523 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org The ocelot_reset() function utilizes regmap_field_write() but wasn't checking return values. While this won't cause issues for the current MMIO regmaps, it could be an issue for externally controlled interfaces. Add checks for these return values. Signed-off-by: Colin Foster --- v2: Change "err = ...; return err" to just "return ..." --- drivers/net/ethernet/mscc/ocelot_vsc7514.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/mscc/ocelot_vsc7514.c b/drivers/net/ethernet/mscc/ocelot_vsc7514.c index 3fb9183c1159..6f22aea08a64 100644 --- a/drivers/net/ethernet/mscc/ocelot_vsc7514.c +++ b/drivers/net/ethernet/mscc/ocelot_vsc7514.c @@ -211,8 +211,13 @@ static int ocelot_reset(struct ocelot *ocelot) int err; u32 val; - regmap_field_write(ocelot->regfields[SYS_RESET_CFG_MEM_INIT], 1); - regmap_field_write(ocelot->regfields[SYS_RESET_CFG_MEM_ENA], 1); + err = regmap_field_write(ocelot->regfields[SYS_RESET_CFG_MEM_INIT], 1); + if (err) + return err; + + err = regmap_field_write(ocelot->regfields[SYS_RESET_CFG_MEM_ENA], 1); + if (err) + return err; /* MEM_INIT is a self-clearing bit. Wait for it to be cleared (should be * 100us) before enabling the switch core. @@ -222,10 +227,11 @@ static int ocelot_reset(struct ocelot *ocelot) if (err) return err; - regmap_field_write(ocelot->regfields[SYS_RESET_CFG_MEM_ENA], 1); - regmap_field_write(ocelot->regfields[SYS_RESET_CFG_CORE_ENA], 1); + err = regmap_field_write(ocelot->regfields[SYS_RESET_CFG_MEM_ENA], 1); + if (err) + return err; - return 0; + return regmap_field_write(ocelot->regfields[SYS_RESET_CFG_CORE_ENA], 1); } /* Watermark encode