Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp2734601rwb; Fri, 20 Jan 2023 06:48:25 -0800 (PST) X-Google-Smtp-Source: AMrXdXu7e64m48cz1kVQykP9SBN1ljAGNvqlg7wderTeIah0pW9vgEQdXxfIho55R+sgT71aYYUh X-Received: by 2002:a05:6402:28cf:b0:499:b320:fc2d with SMTP id ef15-20020a05640228cf00b00499b320fc2dmr13836152edb.33.1674226105188; Fri, 20 Jan 2023 06:48:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674226105; cv=none; d=google.com; s=arc-20160816; b=uXeUZKV9WNM3TbS4eyyvC2AC+BprKtgOSPNILYWVh3lAIsG9TYdqqKzS9K79B/tNfQ l4WpdxGjn0GCeKF5FpyWiRjmpDhhUzx4b1Qz0AT7oPm1OleFRhBqBJL2YYFO07Fz0tc5 19OjcKZFt5UN8d3/DAngW/ai55EPrK13Om3RH2Ia6Ko/69iWEGRODX9MNgJpfwFebmmY Jw76bekRmov2i2OhHedMR6buFsKoiOtFDMapQ1qN3pSg+HQ1pBGB8j12mTwi5pT/RsO1 xnujuvrCctbTahI2KcWtjujK4gpJokOU3Rq1a0fWZGU1qWTEx9j0p6rHVC0EIKkAD7vE kvZg== 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 :dkim-signature; bh=JizcUNVmaaDLkp/9idMDMgEvGH8w0NyE/gV5ITdh1EQ=; b=rz53qhX5Uyo88iQtRYDnuMcSjbzpKYD4jDToXvdE1e2enmj01q5YYdrNnYVLAenbUe /ZQkoN3lbW6+Q8vm+lKCyDC0zeZ1KewCeYyMtbNLzmd3+vnFRpmG2zE09vxYx82hgJOS AhmIEp3igMD7pdnK2W3JKpM4eT7Ope86k2wHzTrVg7nQEZv3tMaWAJELbv/JZiPFquHo 3cEmOqXxoCIuUtEG5EWGIYT/Y8a0HQ7zk3lv6xeq+WZmkt7akz87duK3uD1ciht8dseK YIaDHOCtwRTlI2UhNoIZcb6Hi8Jh+rRcJvkCZ4oOxZ6UIKB28Wg/a9Dsn/JYyoD0xNfT xl+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=v+G4fhXR; 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; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r19-20020a05640251d300b00485220caa05si52851946edd.597.2023.01.20.06.48.12; Fri, 20 Jan 2023 06:48:25 -0800 (PST) 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; dkim=pass header.i=@microchip.com header.s=mchp header.b=v+G4fhXR; 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; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231221AbjATOlL (ORCPT + 49 others); Fri, 20 Jan 2023 09:41:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44586 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231191AbjATOlG (ORCPT ); Fri, 20 Jan 2023 09:41:06 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C915643446 for ; Fri, 20 Jan 2023 06:40:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1674225644; x=1705761644; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ETrCqr1esSdpLl/whNaGbQbj8ly4dFAvvv640kfUFd4=; b=v+G4fhXRROkNubAj9uB8lEyZjJ5c33z2Wv5dzL2pLaNfZPQWKvooQekl vOU8Sb5JtDL+Y1/KILRUGMEteQtygXX1mhKLSY0en621bcJHPBnqBe3eZ d1sY5EfQkDC7sWzp0nkWSvYvYpxkINvswm7tEXj3viC7MTARUsq8lXeon kOAVxKJPW2QaY09Z3yzrafqeS+fZrBGDCrAO0UOq6O23gM5RpGrHTWjXo U+kLTJsFoJ/R2pORqieSVfoYolu4RIpNQJC8QeiMbPMT+YkVBA86XFodj jYQtyWHrMAdegEZMtMCHNfd5jE8turwb+v3nHn+vEZ/V2PVeJMiamJ6m2 A==; X-IronPort-AV: E=Sophos;i="5.97,232,1669100400"; d="scan'208";a="208646938" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa1.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 20 Jan 2023 07:38:25 -0700 Received: from chn-vm-ex01.mchp-main.com (10.10.85.143) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Fri, 20 Jan 2023 07:38:18 -0700 Received: from wendy.microchip.com (10.10.115.15) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Fri, 20 Jan 2023 07:38:17 -0700 From: Conor Dooley To: Jassi Brar CC: Conor Dooley , Daire McNamara , , Subject: [PATCH v2 6/7] soc: microchip: mpfs: simplify error handling in mpfs_blocking_transaction() Date: Fri, 20 Jan 2023 14:37:34 +0000 Message-ID: <20230120143734.3438755-7-conor.dooley@microchip.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230120143734.3438755-1-conor.dooley@microchip.com> References: <20230120143734.3438755-1-conor.dooley@microchip.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham 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 The error handling has a kinda weird nested-if setup that is not really adding anything. Switch it to more of an early return arrangement as a predatory step for adding different handing for timeouts and failed services. Signed-off-by: Conor Dooley --- drivers/soc/microchip/mpfs-sys-controller.c | 28 ++++++++++----------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/drivers/soc/microchip/mpfs-sys-controller.c b/drivers/soc/microchip/mpfs-sys-controller.c index e76a5e38f655..da9cfeda6f78 100644 --- a/drivers/soc/microchip/mpfs-sys-controller.c +++ b/drivers/soc/microchip/mpfs-sys-controller.c @@ -36,28 +36,26 @@ struct mpfs_sys_controller { int mpfs_blocking_transaction(struct mpfs_sys_controller *sys_controller, struct mpfs_mss_msg *msg) { unsigned long timeout = msecs_to_jiffies(MPFS_SYS_CTRL_TIMEOUT_MS); - int ret, err; + int ret; - err = mutex_lock_interruptible(&transaction_lock); - if (err) - return err; + ret = mutex_lock_interruptible(&transaction_lock); + if (ret) + return ret; reinit_completion(&sys_controller->c); ret = mbox_send_message(sys_controller->chan, msg); - if (ret >= 0) { - if (wait_for_completion_timeout(&sys_controller->c, timeout)) { - ret = 0; - } else { - ret = -ETIMEDOUT; - dev_warn(sys_controller->client.dev, - "MPFS sys controller transaction timeout\n"); - } - } else { - dev_err(sys_controller->client.dev, - "mpfs sys controller transaction returned %d\n", ret); + if (ret < 0) + goto out; + + ret = 0; /* mbox_send_message returns positive integers on success */ + if (!wait_for_completion_timeout(&sys_controller->c, timeout)) { + ret = -ETIMEDOUT; + dev_warn(sys_controller->client.dev, + "MPFS sys controller transaction timeout\n"); } +out: mutex_unlock(&transaction_lock); return ret; -- 2.39.0