Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp888411pxk; Thu, 24 Sep 2020 23:55:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyxc2R4qju0lG0D9Ez3ddzzkRVns2g4b0TEM+b6VzuYswJ0BAQqrnEyEnShkPucrl+PwQOW X-Received: by 2002:a50:d591:: with SMTP id v17mr2585202edi.92.1601016958110; Thu, 24 Sep 2020 23:55:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601016958; cv=none; d=google.com; s=arc-20160816; b=LJjynXjwacCbqdPlKGujTmzy3oFNneuJ/wNcnzcYXg0gZ0t9ZnNdlzq/3LvoteHxhs 7YckUeRTFFyYEurOgFJ4dePM8dLCH8la+LlZIe8zbA2K3eMtq8d2zOxjEeYH838vk3Kh /Q5PPSttMc462fR5UY/KzM2MzwDGcjJJhudsAz4xMzJsMxoJEAP316EkqRHBO1b/mBPj X5c4pLHFJbJgubyaOfP+6OzU3p44WDqEkiaiI5wLUbgPobDkfNw3QEfZFkjIJwN7wL4l 0oRpwgiWBnGl4V3XN28efq6o4ZomTnCFWgnAEQ4HrxLd/bVQaEPpwx/MigEtKLJITiE8 37iQ== 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=X6A7I2+xa+JzqfUUJmmCkQYIIjfofSHKtXj6ieBn98k=; b=f015RsWHxHE0kFSb++8NA8JeVqR+s9iiOhdzEvrKuzEma8QXIpO7LCUOEZUdAyc4x5 A3ZfDKEo9+X+YHeXQFVgGeXWUcE1yRumWNpo8UTTv1hQ16GZiCjeLbMo+5oo2n3epFbI 0JGylCwkT+blVN50aDa+E5tV4IFgI77iAYMlLlzk5pmdRLZ7tRs8Z0gPRxOWf04aF45/ ntR8ruS7JzFlk0ioKKvh3k9KLxlYlM0SoMywVqjzmCki+wMUy5bhQ7pBn5zQ5iyTpSK+ FjcZJotXbXULmlZP7CfPkbkib3phwQP5yESXPJySO9wA0dRdwKvsrwhrUEw2eBfmq9UZ rLuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=X6OR+Kzr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h7si1212001ejl.266.2020.09.24.23.55.35; Thu, 24 Sep 2020 23:55:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=X6OR+Kzr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727286AbgIYGyf (ORCPT + 99 others); Fri, 25 Sep 2020 02:54:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39972 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727285AbgIYGyd (ORCPT ); Fri, 25 Sep 2020 02:54:33 -0400 Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6AC52C0613D3 for ; Thu, 24 Sep 2020 23:54:33 -0700 (PDT) Received: by mail-pg1-x544.google.com with SMTP id g29so1743039pgl.2 for ; Thu, 24 Sep 2020 23:54:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=X6A7I2+xa+JzqfUUJmmCkQYIIjfofSHKtXj6ieBn98k=; b=X6OR+Kzr1L29x1BQVGldMkJqu8KRWqcyEcYQJD+ya42lnml69EzPYF9ouzFHvDwXIU znn3F7jcsx24lM/hZxLfd6CZS9wcsK+YefmG7jjFFrsZna9EEaJzH1c2mMj55g4AQ1N9 JNTp73XgNucjtRN7dYa3pW6DP0JDe8gFoxuFc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=X6A7I2+xa+JzqfUUJmmCkQYIIjfofSHKtXj6ieBn98k=; b=FSnwArr8z8Ho8xPJZAyEgnyDq5F0HDBSaqppKwS3pFaF6xoFl2a1hX3b4qGlcDbYr8 Tm/zZ2Qzkp4x196X0mXBeWLlIL00pChbCFEV3vW0sXfW8VsCs3h3orOkElhJMWpkjgQh ZNYt/c4kk1Z85y2TQOEw9zGmIqrc4M8snJa3lyVm051Ywxa6ZjjTXdqcT+Np7BsJsOkw OPTHZEw/z/NCxuNHQSZAG1nRakROwMkdpU+KdKj561nr720HLmXOw4z272MA/P+F+X37 cSYUMsPVkBdTfrbN1iH7M6ahsjgdRPl1b1mEQTuuXIfI+UdKnZrcofQTTMc10Hpl3qlz +I6A== X-Gm-Message-State: AOAM532dNd97khQIJIO4LjeDAYkEPZu3zV1cM+O7LWgkKSER8k76J/46 YMyFWNB4lu+0IzQgIKw3/m2DRg== X-Received: by 2002:a17:902:d913:b029:d1:f388:9fa6 with SMTP id c19-20020a170902d913b02900d1f3889fa6mr2963337plz.67.1601016872951; Thu, 24 Sep 2020 23:54:32 -0700 (PDT) Received: from ikjn-p920.tpe.corp.google.com ([2401:fa00:1:10:f693:9fff:fef4:a8fc]) by smtp.gmail.com with ESMTPSA id x27sm1549612pfp.128.2020.09.24.23.54.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Sep 2020 23:54:32 -0700 (PDT) From: Ikjoon Jang To: Rob Herring , Mark Brown , devicetree@vger.kernel.org, linux-spi@vger.kernel.org, linux-mtd@lists.infradead.org Cc: Ikjoon Jang , Matthias Brugger , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org Subject: [PATCH v3 2/6] spi: spi-mtk-nor: fix mishandled logics in checking SPI memory operation Date: Fri, 25 Sep 2020 14:54:13 +0800 Message-Id: <20200925145255.v3.2.I48d59ef5398f3633c6ebbab093da6b4b06495780@changeid> X-Mailer: git-send-email 2.28.0.681.g6f77f65b4e-goog In-Reply-To: <20200925065418.1077472-1-ikjn@chromium.org> References: <20200925065418.1077472-1-ikjn@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Fix a bug which limits its protocol availability in supports_op(). Fixes: a59b2c7c56bf ("spi: spi-mtk-nor: support standard spi properties") Signed-off-by: Ikjoon Jang --- (no changes since v1) drivers/spi/spi-mtk-nor.c | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/drivers/spi/spi-mtk-nor.c b/drivers/spi/spi-mtk-nor.c index 6e6ca2b8e6c8..0f7d4ec68730 100644 --- a/drivers/spi/spi-mtk-nor.c +++ b/drivers/spi/spi-mtk-nor.c @@ -211,28 +211,24 @@ static bool mtk_nor_supports_op(struct spi_mem *mem, if (op->cmd.buswidth != 1) return false; + if (!spi_mem_default_supports_op(mem, op)) + return false; + if ((op->addr.nbytes == 3) || (op->addr.nbytes == 4)) { - switch(op->data.dir) { - case SPI_MEM_DATA_IN: - if (!mtk_nor_match_read(op)) - return false; - break; - case SPI_MEM_DATA_OUT: - if ((op->addr.buswidth != 1) || - (op->dummy.nbytes != 0) || - (op->data.buswidth != 1)) - return false; - break; - default: - break; - } + if ((op->data.dir == SPI_MEM_DATA_IN) && mtk_nor_match_read(op)) + return true; + else if (op->data.dir == SPI_MEM_DATA_OUT) + return (op->addr.buswidth == 1) && + (op->dummy.nbytes == 0) && + (op->data.buswidth == 1); } + len = op->cmd.nbytes + op->addr.nbytes + op->dummy.nbytes; if ((len > MTK_NOR_PRG_MAX_SIZE) || ((op->data.nbytes) && (len == MTK_NOR_PRG_MAX_SIZE))) return false; - return spi_mem_default_supports_op(mem, op); + return true; } static void mtk_nor_setup_bus(struct mtk_nor *sp, const struct spi_mem_op *op) -- 2.28.0.681.g6f77f65b4e-goog