* [PATCH 1/1] mtd: m25p80 -- parse partitions from OF tree
@ 2010-10-15 12:53 Jonas Bonn
2010-10-15 15:31 ` Grant Likely
0 siblings, 1 reply; 2+ messages in thread
From: Jonas Bonn @ 2010-10-15 12:53 UTC (permalink / raw)
To: linux-mtd; +Cc: Jonas Bonn, devicetree-discuss
It needs to be possible to define the partitions of an MTD device from an OF
devicetree. This patch adds a call to of_mtd_parse_partitions if:
i) there are no commandline partitions defined
ii) there are no partitions set up by platform_data
iii) and an of_node is present on the device
This permits the following devicetree structure:
flash0: mtd@0 {
compatible = "st,m25p10";
reg = <0>;
spi-max-frequency = <100000000>;
#address-cells = <1>;
#size-cells = <1>;
partition@0 {
label = "bootloader";
reg = <0x00000000 0x00018000>;
read-only;
}
partition@18000 {
label = "data";
reg = <0x00018000 0x00008000>;
};
};
Signed-off-by: Jonas Bonn <jonas@southpole.se>
---
drivers/mtd/devices/m25p80.c | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c
index 6f512b5..a349498 100644
--- a/drivers/mtd/devices/m25p80.c
+++ b/drivers/mtd/devices/m25p80.c
@@ -924,6 +924,10 @@ static int __devinit m25p_probe(struct spi_device *spi)
nr_parts = data->nr_parts;
}
+ if (nr_parts <= 0 && spi->dev.of_node) {
+ nr_parts = of_mtd_parse_partitions(&spi->dev, spi->dev.of_node, &parts);
+ }
+
if (nr_parts > 0) {
for (i = 0; i < nr_parts; i++) {
DEBUG(MTD_DEBUG_LEVEL2, "partitions[%d] = "
--
1.7.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 1/1] mtd: m25p80 -- parse partitions from OF tree
2010-10-15 12:53 [PATCH 1/1] mtd: m25p80 -- parse partitions from OF tree Jonas Bonn
@ 2010-10-15 15:31 ` Grant Likely
0 siblings, 0 replies; 2+ messages in thread
From: Grant Likely @ 2010-10-15 15:31 UTC (permalink / raw)
To: Jonas Bonn; +Cc: devicetree-discuss, linux-mtd
On Fri, Oct 15, 2010 at 02:53:28PM +0200, Jonas Bonn wrote:
> It needs to be possible to define the partitions of an MTD device from an OF
> devicetree. This patch adds a call to of_mtd_parse_partitions if:
Thanks Jonas. I've actually already got a patch that does the exact
ame thing in my private tree. However, it requires an ugly #ifdef
statement because the of_node pointer is not available when CONFIG_OF
is not selected. Before I commit to this patch, I want to see if I
can come up with a cleaner way for drivers to reference of_node when
CONFIG_OF is not set. I could use a macro, but I'd rather not have to
wrap every reference with a macro.
Regardless, it is on my radar, and I hope to settle on a solution
sometime in the next week.
g.
>
> i) there are no commandline partitions defined
> ii) there are no partitions set up by platform_data
> iii) and an of_node is present on the device
>
> This permits the following devicetree structure:
>
> flash0: mtd@0 {
> compatible = "st,m25p10";
> reg = <0>;
> spi-max-frequency = <100000000>;
>
> #address-cells = <1>;
> #size-cells = <1>;
>
> partition@0 {
> label = "bootloader";
> reg = <0x00000000 0x00018000>;
> read-only;
> }
>
> partition@18000 {
> label = "data";
> reg = <0x00018000 0x00008000>;
> };
> };
>
> Signed-off-by: Jonas Bonn <jonas@southpole.se>
> ---
> drivers/mtd/devices/m25p80.c | 4 ++++
> 1 files changed, 4 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c
> index 6f512b5..a349498 100644
> --- a/drivers/mtd/devices/m25p80.c
> +++ b/drivers/mtd/devices/m25p80.c
> @@ -924,6 +924,10 @@ static int __devinit m25p_probe(struct spi_device *spi)
> nr_parts = data->nr_parts;
> }
>
> + if (nr_parts <= 0 && spi->dev.of_node) {
> + nr_parts = of_mtd_parse_partitions(&spi->dev, spi->dev.of_node, &parts);
> + }
> +
> if (nr_parts > 0) {
> for (i = 0; i < nr_parts; i++) {
> DEBUG(MTD_DEBUG_LEVEL2, "partitions[%d] = "
> --
> 1.7.1
>
> _______________________________________________
> devicetree-discuss mailing list
> devicetree-discuss@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/devicetree-discuss
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-10-15 15:31 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-15 12:53 [PATCH 1/1] mtd: m25p80 -- parse partitions from OF tree Jonas Bonn
2010-10-15 15:31 ` Grant Likely
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).