From patchwork Mon Aug 2 07:52:01 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hu Mingkai-B21284 X-Patchwork-Id: 116457 Received: from lists.sourceforge.net (lists.sourceforge.net [216.34.181.88]) by demeter.kernel.org (8.14.4/8.14.3) with ESMTP id o728MjHk023544 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Mon, 2 Aug 2010 08:23:21 GMT Received: from localhost ([127.0.0.1] helo=sfs-ml-4.v29.ch3.sourceforge.com) by sfs-ml-4.v29.ch3.sourceforge.com with esmtp (Exim 4.69) (envelope-from ) id 1OfqIH-0003i0-Aw; Mon, 02 Aug 2010 08:22:45 +0000 Received: from sog-mx-3.v43.ch3.sourceforge.com ([172.29.43.193] helo=mx.sourceforge.net) by sfs-ml-4.v29.ch3.sourceforge.com with esmtp (Exim 4.69) (envelope-from ) id 1OfqIG-0003hi-7r for spi-devel-general@lists.sourceforge.net; Mon, 02 Aug 2010 08:22:44 +0000 X-ACL-Warn: Received: from db3ehsobe005.messaging.microsoft.com ([213.199.154.143] helo=DB3EHSOBE005.bigfish.com) by sog-mx-3.v43.ch3.sourceforge.com with esmtps (TLSv1:RC4-MD5:128) (Exim 4.69) id 1OfqIF-0008OX-Cq for spi-devel-general@lists.sourceforge.net; Mon, 02 Aug 2010 08:22:44 +0000 Received: from mail26-db3-R.bigfish.com (10.3.81.240) by DB3EHSOBE005.bigfish.com (10.3.84.25) with Microsoft SMTP Server id 8.1.436.0; Mon, 2 Aug 2010 08:07:26 +0000 Received: from mail26-db3 (localhost.localdomain [127.0.0.1]) by mail26-db3-R.bigfish.com (Postfix) with ESMTP id E46088A01E9 for ; Mon, 2 Aug 2010 08:07:26 +0000 (UTC) X-SpamScore: 2 X-BigFish: VS2(zz936eMzz1202hzzz2dh2a8h465j419m61h) X-Spam-TCS-SCL: 0:0 Received: from mail26-db3 (localhost.localdomain [127.0.0.1]) by mail26-db3 (MessageSwitch) id 1280736446527003_17526; Mon, 2 Aug 2010 08:07:26 +0000 (UTC) Received: from DB3EHSMHS012.bigfish.com (unknown [10.3.81.253]) by mail26-db3.bigfish.com (Postfix) with ESMTP id 7B528448051 for ; Mon, 2 Aug 2010 08:07:26 +0000 (UTC) Received: from az33egw02.freescale.net (192.88.158.103) by DB3EHSMHS012.bigfish.com (10.3.87.112) with Microsoft SMTP Server (TLS) id 14.0.482.44; Mon, 2 Aug 2010 08:07:14 +0000 Received: from de01smr01.freescale.net (de01smr01.freescale.net [10.208.0.31]) by az33egw02.freescale.net (8.14.3/8.14.3) with ESMTP id o7287CaU012347 for ; Mon, 2 Aug 2010 01:07:12 -0700 (MST) Received: from zch01exm21.fsl.freescale.net (zch01exm21.ap.freescale.net [10.192.129.205]) by de01smr01.freescale.net (8.13.1/8.13.0) with ESMTP id o728JmSc021245 for ; Mon, 2 Aug 2010 03:19:54 -0500 (CDT) Received: from localhost ([10.193.20.106]) by zch01exm21.fsl.freescale.net with Microsoft SMTPSVC(6.0.3790.3959); Mon, 2 Aug 2010 16:07:05 +0800 From: Mingkai Hu To: linuxppc-dev@ozlabs.org, spi-devel-general@lists.sourceforge.net Date: Mon, 2 Aug 2010 15:52:01 +0800 Message-ID: <1280735524-17547-4-git-send-email-Mingkai.hu@freescale.com> X-Mailer: git-send-email 1.6.4 In-Reply-To: <1280735524-17547-3-git-send-email-Mingkai.hu@freescale.com> References: <1280735524-17547-1-git-send-email-Mingkai.hu@freescale.com> <1280735524-17547-2-git-send-email-Mingkai.hu@freescale.com> <1280735524-17547-3-git-send-email-Mingkai.hu@freescale.com> X-OriginalArrivalTime: 02 Aug 2010 08:07:05.0527 (UTC) FILETIME=[B2304470:01CB3219] MIME-Version: 1.0 X-Reverse-DNS: az33egw02.freescale.net X-Spam-Score: 0.2 (/) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. 0.4 SUBJECT_FUZZY_TION Attempt to obfuscate words in Subject: -0.2 AWL AWL: From: address is in the auto white-list X-Headers-End: 1OfqIF-0008OX-Cq Cc: kumar.gala@freescale.com, tie-fei.zang@freescale.com, Mingkai Hu Subject: [spi-devel-general] [PATCH v2 3/6] mtd: m25p80: add support to parse the SPI flash's partitions X-BeenThere: spi-devel-general@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list List-Id: Linux SPI core/device drivers discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: spi-devel-general-bounces@lists.sourceforge.net X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Mon, 02 Aug 2010 08:23:21 +0000 (UTC) diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c index 81e49a9..5f00075 100644 --- a/drivers/mtd/devices/m25p80.c +++ b/drivers/mtd/devices/m25p80.c @@ -752,6 +752,31 @@ static const struct spi_device_id *__devinit jedec_probe(struct spi_device *spi) return NULL; } +/* + * parse_flash_partition - Parse the flash partition on the SPI bus + * @spi: Pointer to spi_device device + */ +void parse_flash_partition(struct spi_device *spi) +{ + struct mtd_partition *parts; + struct flash_platform_data *pdata; + int nr_parts = 0; + struct device_node *np = spi->dev.of_node; + + nr_parts = of_mtd_parse_partitions(&spi->dev, np, &parts); + if (!nr_parts) + return; + + pdata = kzalloc(sizeof(*pdata), GFP_KERNEL); + if (!pdata) + return; + + pdata->parts = parts; + pdata->nr_parts = nr_parts; + spi->dev.platform_data = pdata; + + return; +} /* * board specific setup should have ensured the SPI clock used here @@ -771,6 +796,10 @@ static int __devinit m25p_probe(struct spi_device *spi) * a chip ID, try the JEDEC id commands; they'll work for most * newer chips, even if we don't recognize the particular chip. */ + + /* Parse the flash partition */ + parse_flash_partition(spi); + data = spi->dev.platform_data; if (data && data->type) { const struct spi_device_id *plat_id;