linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Mingkai Hu <Mingkai.hu@freescale.com>
To: linuxppc-dev@ozlabs.org
Cc: Mingkai Hu <Mingkai.hu@freescale.com>
Subject: [PATCH 3/6] of/spi: add support to parse the SPI flash's partitions
Date: Tue, 20 Jul 2010 10:08:22 +0800	[thread overview]
Message-ID: <1279591705-7574-4-git-send-email-Mingkai.hu@freescale.com> (raw)
In-Reply-To: <1279591705-7574-3-git-send-email-Mingkai.hu@freescale.com>

Signed-off-by: Mingkai Hu <Mingkai.hu@freescale.com>
---
 drivers/of/of_spi.c       |   11 +++++++++++
 drivers/spi/spi_mpc8xxx.c |    1 +
 2 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/drivers/of/of_spi.c b/drivers/of/of_spi.c
index 5fed7e3..284ca0e 100644
--- a/drivers/of/of_spi.c
+++ b/drivers/of/of_spi.c
@@ -10,6 +10,8 @@
 #include <linux/device.h>
 #include <linux/spi/spi.h>
 #include <linux/of_spi.h>
+#include <linux/spi/flash.h>
+#include <linux/mtd/partitions.h>
 
 /**
  * of_register_spi_devices - Register child devices onto the SPI bus
@@ -26,6 +28,7 @@ void of_register_spi_devices(struct spi_master *master, struct device_node *np)
 	const __be32 *prop;
 	int rc;
 	int len;
+	struct flash_platform_data *pdata;
 
 	for_each_child_of_node(np, nc) {
 		/* Alloc an spi_device */
@@ -81,6 +84,14 @@ void of_register_spi_devices(struct spi_master *master, struct device_node *np)
 		of_node_get(nc);
 		spi->dev.of_node = nc;
 
+		/* Parse the mtd partitions */
+		pdata = kzalloc(sizeof(*pdata), GFP_KERNEL);
+		if (!pdata)
+			return;
+		pdata->nr_parts = of_mtd_parse_partitions(&master->dev,
+				nc, &pdata->parts);
+		spi->dev.platform_data = pdata;
+
 		/* Register the new device */
 		request_module(spi->modalias);
 		rc = spi_add_device(spi);
diff --git a/drivers/spi/spi_mpc8xxx.c b/drivers/spi/spi_mpc8xxx.c
index efed70e..0fadaeb 100644
--- a/drivers/spi/spi_mpc8xxx.c
+++ b/drivers/spi/spi_mpc8xxx.c
@@ -137,6 +137,7 @@ int mpc8xxx_spi_transfer(struct spi_device *spi,
 
 void mpc8xxx_spi_cleanup(struct spi_device *spi)
 {
+	kfree(spi->dev.platform_data);
 	kfree(spi->controller_state);
 }
 
-- 
1.6.4

  reply	other threads:[~2010-07-20  2:36 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-20  2:08 [PATCH 0/6] refactor spi_mpc8xxx.c and add eSPI controller support Mingkai Hu
2010-07-20  2:08 ` [PATCH 1/6] spi/mpc8xxx: refactor the common code for SPI/eSPI controller Mingkai Hu
2010-07-20  2:08   ` [PATCH 2/6] eSPI: add eSPI controller support Mingkai Hu
2010-07-20  2:08     ` Mingkai Hu [this message]
2010-07-20  2:08       ` [PATCH 4/6] mtd: m25p80: change the read function to read page by page Mingkai Hu
2010-07-20  2:08         ` [PATCH 5/6] powerpc/of: add eSPI controller dts bindings Mingkai Hu
2010-07-20  2:08           ` [PATCH 6/6] DTS: add SPI flash(s25fl128p01) support on p4080ds and mpc8536ds board Mingkai Hu
2010-07-26  0:35             ` Grant Likely
2010-07-26  7:39               ` Hu Mingkai-B21284
2010-07-26  7:59                 ` Grant Likely
2010-07-26  0:33           ` [PATCH 5/6] powerpc/of: add eSPI controller dts bindings Grant Likely
2010-07-26  7:35             ` Hu Mingkai-B21284
2010-07-26  0:30         ` [PATCH 4/6] mtd: m25p80: change the read function to read page by page Grant Likely
2010-07-26  7:33           ` Hu Mingkai-B21284
2010-07-26  7:55             ` Grant Likely
2010-07-26  0:28       ` [PATCH 3/6] of/spi: add support to parse the SPI flash's partitions Grant Likely
2010-07-26  7:25         ` Hu Mingkai-B21284
2010-07-26  7:52           ` Grant Likely
2010-07-26  8:20             ` Hu Mingkai-B21284
2010-07-27 19:24               ` Grant Likely
2010-07-26  0:25     ` [PATCH 2/6] eSPI: add eSPI controller support Grant Likely
2010-07-26  7:02       ` Hu Mingkai-B21284
2010-07-26  0:14   ` [PATCH 1/6] spi/mpc8xxx: refactor the common code for SPI/eSPI controller Grant Likely
2010-07-26  6:18     ` Hu Mingkai-B21284
2010-07-26  6:48       ` Grant Likely
2010-07-26  7:07     ` Zang Roy-R61911
2010-07-26  7:45       ` Grant Likely
2010-07-26  0:36 ` [PATCH 0/6] refactor spi_mpc8xxx.c and add eSPI controller support Grant Likely
2010-07-26  5:52   ` Hu Mingkai-B21284

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1279591705-7574-4-git-send-email-Mingkai.hu@freescale.com \
    --to=mingkai.hu@freescale.com \
    --cc=linuxppc-dev@ozlabs.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).