From patchwork Tue Aug 30 18:28:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 12959668 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2C5DEECAAA1 for ; Tue, 30 Aug 2022 18:29:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=US/zd2ZLebEpGE3ISfR5Lug7wXXaEDtIh6JqOOs2Muw=; b=gVpow4r9uki01F 6DvVAydEzki9sXh+PP/jN6wabv+1JMZ3LL5YK66YLTzND26KpQmDGy6pGut4VoxtDfi/vxhgHtACX FXze8cC+xHit2wEiBt2byirz4xcdJ/PFYFfyWFpwipbu9QTd/p7qHOkiGUa6HdnbBHALxGzp3GDXf pKSL7ByT5lZ1t79gARgHrajKCZ7P3xX7k1fPgwfBzG4a2MOW6oPa6Dcl33vCkFT8gQhZCdbwXoV9e iknookH+I+UvigzHnPtOSgwUqlfm+8ngMr0+gMm2BWpiPFXrm6sWJ9Z3us6dCCYin9X4p48Sle88g LZOYcdEyFKddocGNg9NA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oT5yR-001BxD-Bg; Tue, 30 Aug 2022 18:28:31 +0000 Received: from mga14.intel.com ([192.55.52.115]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oT5yC-001BqD-5Q for linux-arm-kernel@lists.infradead.org; Tue, 30 Aug 2022 18:28:17 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1661884096; x=1693420096; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=XsNRPNyfbCVjfMcNapRQOptYKGv4F/4Z6dpOZm0HvP0=; b=MCnIeUSO2m8pWXAX/rym9iRhwHbf7r74YqN8rxVepSVyC1a/7ZMSErAz MF4Vpmls/glMVMM4w0j85HmrBKCHHDixRVEBh7WVewsMidxO6RHspc6CA YwqHaBHrPKB4Rwe9Xl+z9fOZjveAuhc9GENgSq4yfsC0WjMIaGjKI0HMK zvDugdwONwqYzHgZtbXNQEwlSBSPoMdVuB8Ou3olDJrZ8EBPo7SofG4hw PfjLRY8dzyJtujHvzrI0Ii2OGt0Txh2HQspPOEi0gO1NZweHI0WYuRqMb T7DlIziSQ4ewceI/tBTV4DlEEgQGB323FfQXmZCcbOceOzs5xjwzp6+iW A==; X-IronPort-AV: E=McAfee;i="6500,9779,10455"; a="295272244" X-IronPort-AV: E=Sophos;i="5.93,275,1654585200"; d="scan'208";a="295272244" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Aug 2022 11:28:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,275,1654585200"; d="scan'208";a="611818348" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga002.jf.intel.com with ESMTP; 30 Aug 2022 11:28:10 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id BAFA119D; Tue, 30 Aug 2022 21:28:24 +0300 (EEST) From: Andy Shevchenko To: Mark Brown , Patrice Chotard , linux-spi@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Maxime Coquelin , Alexandre Torgue , Andy Shevchenko Subject: [PATCH v1 2/2] spi: stm32-qspi: Refactor dual flash mode enable check in ->setup() Date: Tue, 30 Aug 2022 21:28:21 +0300 Message-Id: <20220830182821.47919-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220830182821.47919-1-andriy.shevchenko@linux.intel.com> References: <20220830182821.47919-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220830_112816_264690_D522ED82 X-CRM114-Status: GOOD ( 14.90 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org gpiod_count() either returns positive number of the CS or negative error code. In the stm32_qspi_setup() we check that configuration has enough CS for the dual flash mode and SPI mode is not changing over the lines of the code. Taking all above into considertion, refactor dual flash mode enable check by dropping unneeded CS check and reusing local mode variable. Signed-off-by: Andy Shevchenko Reviewed-by: Patrice Chotard --- drivers/spi/spi-stm32-qspi.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/spi/spi-stm32-qspi.c b/drivers/spi/spi-stm32-qspi.c index 5858f5f9c758..9131660c1afb 100644 --- a/drivers/spi/spi-stm32-qspi.c +++ b/drivers/spi/spi-stm32-qspi.c @@ -680,8 +680,7 @@ static int stm32_qspi_setup(struct spi_device *spi) * Dual flash mode is only enable in case SPI_TX_OCTAL and SPI_TX_OCTAL * are both set in spi->mode and "cs-gpios" properties is found in DT */ - if (((spi->mode & (SPI_TX_OCTAL | SPI_RX_OCTAL)) == (SPI_TX_OCTAL | SPI_RX_OCTAL)) && - gpiod_count(qspi->dev, "cs")) { + if (mode == (SPI_TX_OCTAL | SPI_RX_OCTAL)) { qspi->cr_reg |= CR_DFM; dev_dbg(qspi->dev, "Dual flash mode enable"); }