From patchwork Tue Nov 26 07:35:10 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Poddar, Sourav" X-Patchwork-Id: 3237221 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 92A409F3AE for ; Tue, 26 Nov 2013 07:36:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A86CE20219 for ; Tue, 26 Nov 2013 07:36:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9BB3C201CD for ; Tue, 26 Nov 2013 07:36:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754772Ab3KZHgk (ORCPT ); Tue, 26 Nov 2013 02:36:40 -0500 Received: from comal.ext.ti.com ([198.47.26.152]:46202 "EHLO comal.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754755Ab3KZHgj (ORCPT ); Tue, 26 Nov 2013 02:36:39 -0500 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id rAQ7aGXK001082; Tue, 26 Nov 2013 01:36:16 -0600 Received: from DLEE71.ent.ti.com (dlee71.ent.ti.com [157.170.170.114]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id rAQ7aGK3016944; Tue, 26 Nov 2013 01:36:16 -0600 Received: from dlep32.itg.ti.com (157.170.170.100) by DLEE71.ent.ti.com (157.170.170.114) with Microsoft SMTP Server id 14.2.342.3; Tue, 26 Nov 2013 01:36:16 -0600 Received: from a0131647.apr.dhcp.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep32.itg.ti.com (8.14.3/8.13.8) with ESMTP id rAQ7ZLY3030173; Tue, 26 Nov 2013 01:36:14 -0600 From: Sourav Poddar To: , , , CC: , , , , Sourav Poddar Subject: [PATCH 14/17] drivers: mtd: m25p80: Adapt driver to support memory mapped read. Date: Tue, 26 Nov 2013 13:05:10 +0530 Message-ID: <1385451313-1875-15-git-send-email-sourav.poddar@ti.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1385451313-1875-1-git-send-email-sourav.poddar@ti.com> References: <1385451313-1875-1-git-send-email-sourav.poddar@ti.com> MIME-Version: 1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Adapt driver to do a memory mapped read. Signed-off-by: Sourav Poddar --- drivers/mtd/devices/m25p80.c | 13 +++++++++++++ 1 files changed, 13 insertions(+), 0 deletions(-) diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c index 6a27677..b7ed4be 100644 --- a/drivers/mtd/devices/m25p80.c +++ b/drivers/mtd/devices/m25p80.c @@ -514,6 +514,7 @@ static int m25p80_read(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf) { struct m25p *flash = mtd_to_m25p(mtd); + struct spi_master *master = flash->spi->master; struct spi_transfer t[2]; struct spi_message m; uint8_t opcode; @@ -522,6 +523,14 @@ static int m25p80_read(struct mtd_info *mtd, loff_t from, size_t len, pr_debug("%s: %s from 0x%08x, len %zd\n", dev_name(&flash->spi->dev), __func__, (u32)from, len); + if (master->mmap) { + master->get_buf(master); + memcpy(buf, master->mem + from, len); + master->put_buf(master); + *retlen = len; + goto out; + } + spi_message_init(&m); memset(t, 0, (sizeof t)); @@ -559,6 +568,7 @@ static int m25p80_read(struct mtd_info *mtd, loff_t from, size_t len, mutex_unlock(&flash->lock); +out: return 0; } @@ -1285,6 +1295,9 @@ static int m25p_probe(struct spi_device *spi) flash->addr_width = 3; } + if (spi->master->configure_from_slave) + m25p80_fill_flash_information(flash); + dev_info(&spi->dev, "%s (%lld Kbytes)\n", id->name, (long long)flash->mtd.size >> 10);