From patchwork Fri Jun 17 21:03:53 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kamal Dasu X-Patchwork-Id: 9184997 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 A8C506075F for ; Fri, 17 Jun 2016 21:04:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 785B71FFC7 for ; Fri, 17 Jun 2016 21:04:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6A8FF2714B; Fri, 17 Jun 2016 21:04:43 +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 0A57225D97 for ; Fri, 17 Jun 2016 21:04:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751219AbcFQVEi (ORCPT ); Fri, 17 Jun 2016 17:04:38 -0400 Received: from mail-pf0-f193.google.com ([209.85.192.193]:32800 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753222AbcFQVEg (ORCPT ); Fri, 17 Jun 2016 17:04:36 -0400 Received: by mail-pf0-f193.google.com with SMTP id c74so6857242pfb.0 for ; Fri, 17 Jun 2016 14:04:36 -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=NQyjZg+lHmGnI6cag8EBYIeH4LBb103OvGrKYfhQfGk=; b=D34H2p58s4vGhwLntE8CAO85IANW4XxYz9/odPZDncK90F9KB7lMROOPhnHmt41Pso cLHib4muo+KyPQWRZaOBtAEOMzCnLhOAxRm55LLjDbp1ouAXRy3EDxd5zfiJRpujOk7o PQXH3JR5s42vNiKE+XZDTQYLT+aEC+ae6cvHPN/XY/ht4moiOz6kYxX/gi/dajw2Sy3g nWuLSK0CeGA0gA9LiDFrgafTa6oL8ah4N7FLjqc081TrMfaEDnGEt+ge+7ZGEhuGwk0Z 93+20aJLpdSWhFtlLcoAVaIke1l1mcNEguNNnLhYNFeH/Wif1H8d1iyQA4rNwdrgZZET Z4vg== 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=NQyjZg+lHmGnI6cag8EBYIeH4LBb103OvGrKYfhQfGk=; b=Zs3xNOdBuNT3G3oHaYG6DAhmdV27R+ShRxb0OHPYRwIPT/4UBKiRWFJhQ0G9RR9QRd baHE/h0Kgk/6ObwW/Hk2RVBEy6s5D4nO8YQF5i7tshlUNXZC3zARWUBcoO30J+W+F08c qXLLbhvexGEjoV0Yaj7V0ImxCsBN8ECEuNnAbo+7EbPczlw7tAVQAm2/8pZnNwULmlZ5 PuOiGf3FSYPT0JAz4EF5Du2ZbnCL6q3Qk+zHP4zBNXFPtfC0SvxBA18/KgIkfhul2RT1 rTHEaNmr8+QHeoVvQLTuOXeLDPP39C+qZuYRAlxKaUBAtwxKTAQk79YlrDGeC0X3rbdO 3yrw== X-Gm-Message-State: ALyK8tIpBe2fhwYsAyttpKSMGKk9Edyf0WWcnDREuYmyZ2uXcsIWaGXxicOw28YnDnX0tQ== X-Received: by 10.98.105.138 with SMTP id e132mr4599863pfc.59.1466197475664; Fri, 17 Jun 2016 14:04:35 -0700 (PDT) Received: from mail.broadcom.com ([216.31.219.19]) by smtp.gmail.com with ESMTPSA id fl1sm70364206pab.43.2016.06.17.14.04.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 17 Jun 2016 14:04:34 -0700 (PDT) From: Kamal Dasu To: linux-spi@vger.kernel.org, f.fainelli@gmail.com, broonie@kernel.org Cc: bcm-kernel-feedback-list@broadcom.com, vikram.prakash@broadcom.com, andy.fung@broadcom.com, jon.mason@broadcom.com, Kamal Dasu Subject: [PATCH, V4, 5/5] mtd: m25p80: Let m25p80_read() fallback to spi transfer Date: Fri, 17 Jun 2016 17:03:53 -0400 Message-Id: <1466197433-11290-5-git-send-email-kdasu.kdev@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1466197433-11290-1-git-send-email-kdasu.kdev@gmail.com> References: <1466197433-11290-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 | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c index 9d68544..3f90542 100644 --- a/drivers/mtd/devices/m25p80.c +++ b/drivers/mtd/devices/m25p80.c @@ -149,8 +149,11 @@ static int 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); - *retlen = msg.retlen; - return ret; + /* some drivers might need to fallback to spi transfer */ + if (ret != -EAGAIN) { + *retlen = msg.retlen; + return ret; + } } spi_message_init(&m);