From patchwork Sat Dec 7 04:42:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1205405 X-Patchwork-Delegate: bmeng.cn@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="YAP1k70j"; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47VHLM3VCkz9sPL for ; Sat, 7 Dec 2019 15:59:23 +1100 (AEDT) Received: from phobos.denx.de (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3BDA68179F; Sat, 7 Dec 2019 05:51:28 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="YAP1k70j"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 247E581790; Sat, 7 Dec 2019 05:51:23 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd44.google.com (mail-io1-xd44.google.com [IPv6:2607:f8b0:4864:20::d44]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id E693381724 for ; Sat, 7 Dec 2019 05:51:19 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd44.google.com with SMTP id 2so6636232ion.0 for ; Fri, 06 Dec 2019 20:51:19 -0800 (PST) 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=A1Z1sSjNrhwvu4Z3cZRy2PgmcY1yfu1zBFLBL0uVvis=; b=YAP1k70jWdYaompZYfTao7ti92RZxk0IuNMPqXpa+VyGWuPq/+xuoZPKkXUzOHfAHS iEjcX3VY3IATUZXLpKm5VqIUSg/TG+etrH/lGYHwla0y0n36l0h7Lh+XIWOe4S6NaOPs wUOul8F7r0bUe28rOZdrZwHPGPRBE2UlCXpS8= 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=A1Z1sSjNrhwvu4Z3cZRy2PgmcY1yfu1zBFLBL0uVvis=; b=ODhygOgsBrk+YiRHtfiRvvTzB6t6q/Ho4eRzIynAY7fhykB7pyqu2su1hzqHz3uOjn T8ZzhcBla/3lKod0smX1W2DAq8h/Q9FsVVgzNOEvVn2T4+dQcvRBJUJyxDRJMJQ//jed izfBOl/quXhR/W5W5MmN4X/0tsA8xxlpbwCjQmH+hTSxRGLw/WQmrC8cgQJEK6HFwQTH +MT4cCIrwBNRKpVgZOneC7XGys7Ol/ErDJUxFUsuvLmeBSTGBkRzczakRlFsKWLniffr ZLk+LfNMymOZkz+WU+YAt3lB15Z+dib/AdGySyEMaZRivXMshJqm0BzfSWvQI4G62WpI V9Wg== X-Gm-Message-State: APjAAAXdUPV2bGoQo9Kza/1VoyaVVRtLvh2dpllC4j8oQpRWQwf1u5B1 wiGxc5ukiqtmKEH2QymXIt+5Dt9LRbU= X-Google-Smtp-Source: APXvYqyMvxC2c6/Gtyt4j78zJDMO/1sZgd2PatLCGBY/n6HJ1Ttzvvs2pn0C8NNHyKZI/jDjtLwGBA== X-Received: by 2002:a5d:9046:: with SMTP id v6mr13144592ioq.302.1575694278737; Fri, 06 Dec 2019 20:51:18 -0800 (PST) Received: from kiwi.bld.corp.google.com ([2620:15c:183:0:8223:87c:a681:66aa]) by smtp.gmail.com with ESMTPSA id o7sm4549410ilo.58.2019.12.06.20.51.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Dec 2019 20:51:18 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH v6 071/102] spi: ich: Correct max-size bug in ich_spi_adjust_size() Date: Fri, 6 Dec 2019 21:42:44 -0700 Message-Id: <20191207044315.51770-3-sjg@chromium.org> X-Mailer: git-send-email 2.24.0.393.g34dc348eaf-goog In-Reply-To: <20191207044315.51770-1-sjg@chromium.org> References: <20191207044315.51770-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.26 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jagannadha Sutradharudu Teki Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.101.4 at phobos.denx.de X-Virus-Status: Clean This incorrectly shortens read operations if there is a maximum write size but no maximum read size. Fix it. Signed-off-by: Simon Glass Reviewed-by: Bin Meng --- Changes in v6: None Changes in v5: None Changes in v4: None Changes in v3: None Changes in v2: None drivers/spi/ich.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/spi/ich.c b/drivers/spi/ich.c index 08c37ca4ab..17b7a0ba0b 100644 --- a/drivers/spi/ich.c +++ b/drivers/spi/ich.c @@ -425,9 +425,11 @@ static int ich_spi_adjust_size(struct spi_slave *slave, struct spi_mem_op *op) page_offset = do_div(aux, ICH_BOUNDARY); } - if (op->data.dir == SPI_MEM_DATA_IN && slave->max_read_size) { - op->data.nbytes = min(ICH_BOUNDARY - page_offset, - slave->max_read_size); + if (op->data.dir == SPI_MEM_DATA_IN) { + if (slave->max_read_size) { + op->data.nbytes = min(ICH_BOUNDARY - page_offset, + slave->max_read_size); + } } else if (slave->max_write_size) { op->data.nbytes = min(ICH_BOUNDARY - page_offset, slave->max_write_size);