From patchwork Wed Aug 24 22:04:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kamal Dasu X-Patchwork-Id: 9298415 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A560660459 for ; Wed, 24 Aug 2016 22:06:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 958EC29139 for ; Wed, 24 Aug 2016 22:06:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8A8CE2913B; Wed, 24 Aug 2016 22:06:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2FD7829139 for ; Wed, 24 Aug 2016 22:06:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757258AbcHXWGt (ORCPT ); Wed, 24 Aug 2016 18:06:49 -0400 Received: from mail-pf0-f195.google.com ([209.85.192.195]:35530 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757049AbcHXWGt (ORCPT ); Wed, 24 Aug 2016 18:06:49 -0400 Received: by mail-pf0-f195.google.com with SMTP id h186so1941098pfg.2 for ; Wed, 24 Aug 2016 15:06:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=e3W+fKlv/okHcowXEq81CZY0345I122SjtOUEYoiOuo=; b=cLOTaXYD0tiW0qqQNjSLVxLFJuJbH9Kdz6WkYcHtrw6exQRUfrH/Xe8pF/zrx0B+Uv kUAi9CcaMf1ADwLRGQNDPuGz7HXPTk6ESJTIotMtFy20SbmOQBMo1AXqcuaKZnTTefOf GCJ5aP6+r5SpDB0yG/JiBifD0Bbrd7XauOYIGnjI0fOHUY7LM7DHhK3H3p96GfQFsS6i Dkb2gets8N5Yo3Yvenlr2h/djNM4KoRd6msOXWP0kVdiaPL5xMee1Jt4vQjj9wAgq6Rq 0syy4DvAJOYahPazQF5oI4qmfIYhp1KANpOwRIODSi9ODFpJmMMkTEiQ7i8zBylaKnvw Q5dQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=e3W+fKlv/okHcowXEq81CZY0345I122SjtOUEYoiOuo=; b=f0YHEC6zPnOeBuISVUtA/eddPqj7dYO402QKb4AIiIrVfdJCZo3RjolqjaneDfeMsV 5RRpwibNcY4Bl3H+gR1LzRkNuiYXaKkcVPAiYK4ovlZ8MiF69CaecuX46cbtaoc6UP8M clbxMbsuyGj6rZetWhGqdD8dlFLpJ7LwhAUSFeZhX4U65WYkDWq6ppQL3EyUwIScjsL5 H67u29uZyBFovZqaLjGjG5rNIJf1B/Fn8VYRB12uGmwcrT6vByQzsjIce/teOwphOAiQ BwO39jcYpHoyS2yrQ9etIgZ1SQ1E3Oxof9ziLIazfL4njqwZWOOUyzRc+l5J4ay7pkp6 0U/Q== X-Gm-Message-State: AE9vXwMjaeDc7ZAXmT0L8F9Xrue2YDW1hlYHInIebG9jyriEO3DkVPAA1rvAY65xxMgrLg== X-Received: by 10.98.22.212 with SMTP id 203mr10067055pfw.74.1472076408707; Wed, 24 Aug 2016 15:06:48 -0700 (PDT) Received: from mail.broadcom.com ([216.31.219.19]) by smtp.gmail.com with ESMTPSA id wa9sm15966968pac.35.2016.08.24.15.06.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 24 Aug 2016 15:06:47 -0700 (PDT) From: Kamal Dasu To: broonie@kernel.org, linux-spi@vger.kernel.org, computersforpeace@gmail.com, linux-mtd@lists.infradead.org, vigneshr@ti.com, f.fainelli@gmail.com, yendapally.reddy@broadcom.com Cc: bcm-kernel-feedback-list@broadcom.com, jon.mason@broadcom.com, Kamal Dasu Subject: [PATCH v6, 5/8] mtd: m25p80: Let m25p80_read() fallback to spi transfer Date: Wed, 24 Aug 2016 18:04:26 -0400 Message-Id: <1472076269-4731-6-git-send-email-kdasu.kdev@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1472076269-4731-1-git-send-email-kdasu.kdev@gmail.com> References: <1472076269-4731-1-git-send-email-kdasu.kdev@gmail.com> Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In m25p80_read() even though spi_flash_read() is supported by some drivers, under certain circumstances like unaligned buffer, address or address range limitations on certain SoCs let it fallback to core spi reads. Such drivers are expected to return -EAGAIN so that the m25p80_read() uses standard spi transfer. Signed-off-by: Kamal Dasu --- drivers/mtd/devices/m25p80.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c index 9cf7fcd..77c2d2c 100644 --- a/drivers/mtd/devices/m25p80.c +++ b/drivers/mtd/devices/m25p80.c @@ -155,9 +155,16 @@ static ssize_t m25p80_read(struct spi_nor *nor, loff_t from, size_t len, msg.data_nbits = m25p80_rx_nbits(nor); ret = spi_flash_read(spi, &msg); - if (ret < 0) + + if (ret >= 0) + return msg.retlen; + + /* + * some spi master drivers might need to fallback to + * normal spi transfer + */ + if (ret != -EAGAIN) return ret; - return msg.retlen; } spi_message_init(&m);