From patchwork Tue Aug 10 06:42:58 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rajashekhara, Sudhakar" X-Patchwork-Id: 61339 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [18.85.46.34]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 623B8B70E5 for ; Tue, 10 Aug 2010 17:08:48 +1000 (EST) Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.72 #1 (Red Hat Linux)) id 1OiivM-0003OO-24; Tue, 10 Aug 2010 07:07:00 +0000 Received: from bear.ext.ti.com ([192.94.94.41]) by bombadil.infradead.org with esmtps (Exim 4.72 #1 (Red Hat Linux)) id 1OiivE-0003NS-Vb for linux-mtd@lists.infradead.org; Tue, 10 Aug 2010 07:06:56 +0000 Received: from dflp53.itg.ti.com ([128.247.5.6]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id o7A76pWd022880 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 10 Aug 2010 02:06:51 -0500 Received: from tidmzi-ftp.india.ext.ti.com (localhost [127.0.0.1]) by dflp53.itg.ti.com (8.13.8/8.13.8) with SMTP id o7A76mkc019480; Tue, 10 Aug 2010 02:06:49 -0500 (CDT) Received: from symphonyindia.ti.com (symphony-ftp [192.168.247.11]) by tidmzi-ftp.india.ext.ti.com (Postfix) with SMTP id EA98E3887A; Tue, 10 Aug 2010 12:33:01 +0530 (IST) Received: from localhost.localdomain ([192.168.247.76]) by symphonyindia.ti.com (8.13.1/8.12.10) with ESMTP id o7A6wEMQ011688; Tue, 10 Aug 2010 12:28:14 +0530 From: Sudhakar Rajashekhara To: linux-mtd@lists.infradead.org Subject: [PATCH] m25p80: add support for a callback to platform code on successful device probe Date: Tue, 10 Aug 2010 12:12:58 +0530 Message-Id: <1281422578-20461-1-git-send-email-sudhakar.raj@ti.com> X-Mailer: git-send-email 1.5.6 X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20100810_030653_156506_83E143AE X-CRM114-Status: GOOD ( 19.36 ) X-Spam-Score: -0.0 (/) X-Spam-Report: SpamAssassin version 3.3.1 on bombadil.infradead.org summary: Content analysis details: (-0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay domain Cc: david-b@pacbell.net, davinci-linux-open-source@linux.davincidsp.com, Sudhakar Rajashekhara , --cc=dwmw2@infradead.org X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-mtd-bounces@lists.infradead.org Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org On some platforms, MTD device can hold MAC address, calibration data, serial numbers etc. On TI's DA850/OMAP-L138/AM18xx EVM, MAC address is stored on the last sector of the SPI flash, which is exported as an MTD device. This patch adds two new members to the 'flash_platform_data' structure, a function handler which will be called after add_mtd_device() and an argument to be passed to this function, for example: offset to read from. Signed-off-by: Sudhakar Rajashekhara --- drivers/mtd/devices/m25p80.c | 15 +++++++++++++-- include/linux/spi/flash.h | 2 ++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c index 81e49a9..b832091 100644 --- a/drivers/mtd/devices/m25p80.c +++ b/drivers/mtd/devices/m25p80.c @@ -765,6 +765,7 @@ static int __devinit m25p_probe(struct spi_device *spi) struct m25p *flash; struct flash_info *info; unsigned i; + int ret; /* Platform data helps sort out which chip type we have, as * well as how this board partitions it. If we don't have @@ -924,13 +925,23 @@ static int __devinit m25p_probe(struct spi_device *spi) (long long)(parts[i].size >> 10)); } flash->partitioned = 1; - return add_mtd_partitions(&flash->mtd, parts, nr_parts); + ret = add_mtd_partitions(&flash->mtd, parts, nr_parts); + if (!ret) + goto out; + + return ret; } } else if (data && data->nr_parts) dev_warn(&spi->dev, "ignoring %d default partitions on %s\n", data->nr_parts, data->name); - return add_mtd_device(&flash->mtd) == 1 ? -ENODEV : 0; + ret = add_mtd_device(&flash->mtd); + +out: + if (data->setup && !ret) + (data->setup)(&flash->mtd, (void *)data->context); + + return (ret == 1) ? -ENODEV : 0; } diff --git a/include/linux/spi/flash.h b/include/linux/spi/flash.h index 3f22932..daa4875 100644 --- a/include/linux/spi/flash.h +++ b/include/linux/spi/flash.h @@ -24,6 +24,8 @@ struct flash_platform_data { unsigned int nr_parts; char *type; + void (*setup)(struct mtd_info *, void *context); + void *context; /* we'll likely add more ... use JEDEC IDs, etc */ };