From patchwork Tue Aug 10 09:05:04 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rajashekhara, Sudhakar" X-Patchwork-Id: 61367 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 85D20B6EEC for ; Tue, 10 Aug 2010 19:30:46 +1000 (EST) Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.72 #1 (Red Hat Linux)) id 1Oil8q-0001XP-Ba; Tue, 10 Aug 2010 09:29:04 +0000 Received: from devils.ext.ti.com ([198.47.26.153]) by bombadil.infradead.org with esmtps (Exim 4.72 #1 (Red Hat Linux)) id 1Oil8m-0001Vw-Vs; Tue, 10 Aug 2010 09:29:01 +0000 Received: from dflp53.itg.ti.com ([128.247.5.6]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id o7A9Sx9V011288 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 10 Aug 2010 04:28:59 -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 o7A9Su9T021954; Tue, 10 Aug 2010 04:28:57 -0500 (CDT) Received: from symphonyindia.ti.com (symphony-ftp [192.168.247.11]) by tidmzi-ftp.india.ext.ti.com (Postfix) with SMTP id 8A2153887B; Tue, 10 Aug 2010 14:55:09 +0530 (IST) Received: from localhost.localdomain ([192.168.247.76]) by symphonyindia.ti.com (8.13.1/8.12.10) with ESMTP id o7A9KKkK003771; Tue, 10 Aug 2010 14:50:20 +0530 From: Sudhakar Rajashekhara To: linux-mtd@lists.infradead.org Subject: [PATCH v2] m25p80: add support for a callback to platform code on successful device probe Date: Tue, 10 Aug 2010 14:35:04 +0530 Message-Id: <1281431104-17546-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_052901_142680_2B311AC7 X-CRM114-Status: GOOD ( 19.09 ) 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 , 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. Ethernet driver on this platform needs MAC address to be passed through platform data. The callback function can be used to read the MAC address. The callback has to be invoked after the MTD device is setup. 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 --- Since v1: Updated the changelog 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 */ };