From patchwork Sat Jul 15 01:04:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabrizio Castro X-Patchwork-Id: 120719 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp2835871vqm; Fri, 14 Jul 2023 19:43:46 -0700 (PDT) X-Google-Smtp-Source: APBJJlH8H4QzCiRgtoa7BXCTZUxaWUjo1UiEHBfKdKFM7inrddgJ38/dBPrnAo1C2b9tZKBrtvgu X-Received: by 2002:a50:ed16:0:b0:51d:d41b:26a5 with SMTP id j22-20020a50ed16000000b0051dd41b26a5mr6373668eds.14.1689389026386; Fri, 14 Jul 2023 19:43:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689389026; cv=none; d=google.com; s=arc-20160816; b=t8eM71OxB1m0GBdEeFqW2OlAH7I3yzavFd77fKE3pYe0HqXRtN6dS6up2WOFKX+Uzr p9TgHiXFvTSyzakiyPl0XQkpMnrH2FJ53T1RoxuOXjf8GRW0+j7UO1QPAS/bPgVFLbwx yd/+neMOn8KjYEWE5GdVnsgr9he444G5Rq/vPdkiKh1npnsk3C4ZmZShlHaCo1Dg3+9q HAkwlDZu0e548mFEjbbOwsXoIkCb91mObbpBH+8Oid7CocSBTg9129ya8ZqqioONyN56 KSLyyYA5yYAyRCt42TyXv4JPBXgkHsnG95a3CBycoM1rpxhxnz7bVhC12wUbJ8FT2xzU D7AA== 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=yp+ETdNN2aAWyFDK3t0R4RWtFtgRgy2zVtOpW2ht8Ek=; fh=8SPOXdXcsbbrdLjCtKFrhdDDaSSTCLFzjvpt84tri9w=; b=yAZFtJGKk7HDouDF2CfDohccKgaR2EB9ohooE9Ylf5zN5Azmdxcw75go2VnEfkTDdb vJA/E8Cqmlaeo47+kbyLwJdypT3IVHPqSdHIf1i8FLD3ItyZipaCqNZIc3cAliq0haV4 X+06Ai7uvvBnrnpuv3iIqi+jxiLucbXIVPq+FMy8YisRj7nD7JmdqiQxle7mIAKESpuH smKqRJH8IiIg4dGpW9VdpdwMBHav2yGMsu1u0/sSyiaX1OOYmlIvXVhyJmqdKU6DckD+ p3oPrtyrKZFtEFIJMmfW2Xj7IRx6O7fHIOSyHoQwEgyouwl1t1qZV6jxterlJ9dvugsd jkrw== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=renesas.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k11-20020aa7d8cb000000b0051df47ad1f0si4116533eds.659.2023.07.14.19.43.15; Fri, 14 Jul 2023 19:43:46 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=renesas.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229513AbjGOBEj (ORCPT + 99 others); Fri, 14 Jul 2023 21:04:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39202 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230408AbjGOBEg (ORCPT ); Fri, 14 Jul 2023 21:04:36 -0400 Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 108933AB7; Fri, 14 Jul 2023 18:04:29 -0700 (PDT) X-IronPort-AV: E=Sophos;i="6.01,206,1684767600"; d="scan'208";a="169014721" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie5.idc.renesas.com with ESMTP; 15 Jul 2023 10:04:29 +0900 Received: from mulinux.home (unknown [10.226.92.194]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 6D12240C4DAF; Sat, 15 Jul 2023 10:04:26 +0900 (JST) From: Fabrizio Castro To: Mark Brown , Geert Uytterhoeven Cc: Fabrizio Castro , Andy Shevchenko , linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, Chris Paterson , Biju Das , Lad Prabhakar , linux-renesas-soc@vger.kernel.org Subject: [PATCH 04/10] spi: rzv2m-csi: Leave readl_poll_timeout calls for last Date: Sat, 15 Jul 2023 02:04:01 +0100 Message-Id: <20230715010407.1751715-5-fabrizio.castro.jz@renesas.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230715010407.1751715-1-fabrizio.castro.jz@renesas.com> References: <20230715010407.1751715-1-fabrizio.castro.jz@renesas.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771452787932847625 X-GMAIL-MSGID: 1771452787932847625 Both rzv2m_csi_sw_reset and rzv2m_csi_start_stop_operation call into readl_poll_timeout upon a certain condition, and return 0 otherwise. Flip the logic to improve readability. Signed-off-by: Fabrizio Castro Reviewed-by: Geert Uytterhoeven --- drivers/spi/spi-rzv2m-csi.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/drivers/spi/spi-rzv2m-csi.c b/drivers/spi/spi-rzv2m-csi.c index 621774949bde..1c65cd5f2039 100644 --- a/drivers/spi/spi-rzv2m-csi.c +++ b/drivers/spi/spi-rzv2m-csi.c @@ -131,13 +131,12 @@ static int rzv2m_csi_sw_reset(struct rzv2m_csi_priv *csi, int assert) rzv2m_csi_reg_write_bit(csi, CSI_CNT, CSI_CNT_CSIRST, assert); - if (assert) { - return readl_poll_timeout(csi->base + CSI_MODE, reg, - !(reg & CSI_MODE_CSOT), 0, - CSI_EN_DIS_TIMEOUT_US); - } + if (!assert) + return 0; - return 0; + return readl_poll_timeout(csi->base + CSI_MODE, reg, + !(reg & CSI_MODE_CSOT), 0, + CSI_EN_DIS_TIMEOUT_US); } static int rzv2m_csi_start_stop_operation(const struct rzv2m_csi_priv *csi, @@ -147,12 +146,12 @@ static int rzv2m_csi_start_stop_operation(const struct rzv2m_csi_priv *csi, rzv2m_csi_reg_write_bit(csi, CSI_MODE, CSI_MODE_CSIE, enable); - if (!enable && wait) - return readl_poll_timeout(csi->base + CSI_MODE, reg, - !(reg & CSI_MODE_CSOT), 0, - CSI_EN_DIS_TIMEOUT_US); + if (enable || !wait) + return 0; - return 0; + return readl_poll_timeout(csi->base + CSI_MODE, reg, + !(reg & CSI_MODE_CSOT), 0, + CSI_EN_DIS_TIMEOUT_US); } static int rzv2m_csi_fill_txfifo(struct rzv2m_csi_priv *csi)