* [PATCH 01/17] mtd: prepare to convert of_mtd_parse_partitions to partition parser
2011-06-09 14:22 [PATCH 00/17] mtd: last pile of MTD partition cleanup patches Dmitry Eremin-Solenikov
@ 2011-06-09 14:22 ` Dmitry Eremin-Solenikov
2011-06-09 14:26 ` Artem Bityutskiy
2011-06-09 14:22 ` [PATCH 02/17] mtd: physmap_of: use ofpart through generic parsing Dmitry Eremin-Solenikov
` (17 subsequent siblings)
18 siblings, 1 reply; 27+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-09 14:22 UTC (permalink / raw)
To: linux-mtd; +Cc: David Woodhouse, dedekind1
Prepare to convert of_mtd_parse_partitions() to usual partitions parser:
1) Register ofpart parser
2) Internally don't use passed device for error printing
3) Add device_node to mtd_info struct
4) Move of_mtd_parse_partitions from __devinit to common text section
5) add ofpart to the default list of partition parsers
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
drivers/mtd/mtdcore.c | 19 +++++++++++++++++++
drivers/mtd/mtdpart.c | 8 ++++++--
drivers/mtd/ofpart.c | 30 ++++++++++++++++++++++++++++--
include/linux/mtd/mtd.h | 5 +++++
include/linux/mtd/partitions.h | 2 +-
5 files changed, 59 insertions(+), 5 deletions(-)
diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
index 1326747..2d5b865 100644
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -36,6 +36,7 @@
#include <linux/idr.h>
#include <linux/backing-dev.h>
#include <linux/gfp.h>
+#include <linux/of.h>
#include <linux/mtd/mtd.h>
#include <linux/mtd/partitions.h>
@@ -446,6 +447,10 @@ int mtd_device_register(struct mtd_info *master,
const struct mtd_partition *parts,
int nr_parts)
{
+#ifdef CONFIG_OF
+ if (master->node)
+ of_node_get(master->node);
+#endif
return parts ? add_mtd_partitions(master, parts, nr_parts) :
add_mtd_device(master);
}
@@ -487,6 +492,11 @@ int mtd_device_parse_register(struct mtd_info *mtd, const char **types,
int err;
struct mtd_partition *real_parts;
+#ifdef CONFIG_OF
+ if (mtd->node)
+ of_node_get(mtd->node);
+#endif
+
err = parse_mtd_partitions(mtd, types, &real_parts, origin);
if (err <= 0 && nr_parts) {
real_parts = kmemdup(parts, sizeof(*parts) * nr_parts,
@@ -505,6 +515,11 @@ int mtd_device_parse_register(struct mtd_info *mtd, const char **types,
err = -ENODEV;
}
+#ifdef CONFIG_OF
+ if (err < 0 && mtd->node)
+ of_node_put(mtd->node);
+#endif
+
return err;
}
EXPORT_SYMBOL_GPL(mtd_device_parse_register);
@@ -519,6 +534,10 @@ int mtd_device_unregister(struct mtd_info *master)
{
int err;
+#ifdef CONFIG_OF
+ if (master->node)
+ of_node_put(master->node);
+#endif
err = del_mtd_partitions(master);
if (err)
return err;
diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c
index 2b71ccb..584fa56 100644
--- a/drivers/mtd/mtdpart.c
+++ b/drivers/mtd/mtdpart.c
@@ -729,7 +729,11 @@ EXPORT_SYMBOL_GPL(deregister_mtd_parser);
* Do not forget to update 'parse_mtd_partitions()' kerneldoc comment if you
* are changing this array!
*/
-static const char *default_mtd_part_types[] = {"cmdlinepart", NULL};
+static const char * const default_mtd_part_types[] = {
+ "cmdlinepart",
+ "ofpart",
+ NULL
+};
/**
* parse_mtd_partitions - parse MTD partitions
@@ -741,7 +745,7 @@ static const char *default_mtd_part_types[] = {"cmdlinepart", NULL};
* This function tries to find partition on MTD device @master. It uses MTD
* partition parsers, specified in @types. However, if @types is %NULL, then
* the default list of parsers is used. The default list contains only the
- * "cmdlinepart" parser ATM.
+ * "cmdlinepart" and "ofpart" parsers ATM.
*
* This function may return:
* o a negative error code in case of failure
diff --git a/drivers/mtd/ofpart.c b/drivers/mtd/ofpart.c
index a996718..4ac040e 100644
--- a/drivers/mtd/ofpart.c
+++ b/drivers/mtd/ofpart.c
@@ -20,7 +20,20 @@
#include <linux/slab.h>
#include <linux/mtd/partitions.h>
-int __devinit of_mtd_parse_partitions(struct device *dev,
+static int parse_ofpart_partitions(struct mtd_info *master,
+ struct mtd_partition **pparts,
+ unsigned long origin)
+{
+ struct device_node *node;
+
+ node = master->node;
+ if (!node)
+ return 0;
+
+ return of_mtd_parse_partitions(NULL, node, pparts);
+}
+
+int of_mtd_parse_partitions(struct device *dev,
struct device_node *node,
struct mtd_partition **pparts)
{
@@ -69,7 +82,7 @@ int __devinit of_mtd_parse_partitions(struct device *dev,
if (!i) {
of_node_put(pp);
- dev_err(dev, "No valid partition found on %s\n", node->full_name);
+ pr_err("No valid partition found on %s\n", node->full_name);
kfree(*pparts);
*pparts = NULL;
return -EINVAL;
@@ -79,4 +92,17 @@ int __devinit of_mtd_parse_partitions(struct device *dev,
}
EXPORT_SYMBOL(of_mtd_parse_partitions);
+static struct mtd_part_parser ofpart_parser = {
+ .owner = THIS_MODULE,
+ .parse_fn = parse_ofpart_partitions,
+ .name = "ofpart",
+};
+
+static int __init ofpart_parser_init(void)
+{
+ return register_mtd_parser(&ofpart_parser);
+}
+
+module_init(ofpart_parser_init);
+
MODULE_LICENSE("GPL");
diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
index d28a241..55fbb60 100644
--- a/include/linux/mtd/mtd.h
+++ b/include/linux/mtd/mtd.h
@@ -171,6 +171,11 @@ struct mtd_info {
// Kernel-only stuff starts here.
const char *name;
int index;
+#ifdef CONFIG_OF
+ /* Set by driver, reference counting handled by MTD registration/
+ * unregistration functions. */
+ struct device_node *node;
+#endif
/* ecc layout structure pointer - read only ! */
struct nand_ecclayout *ecclayout;
diff --git a/include/linux/mtd/partitions.h b/include/linux/mtd/partitions.h
index 1431cf2..a8bd193 100644
--- a/include/linux/mtd/partitions.h
+++ b/include/linux/mtd/partitions.h
@@ -74,7 +74,7 @@ struct device;
struct device_node;
#ifdef CONFIG_MTD_OF_PARTS
-int __devinit of_mtd_parse_partitions(struct device *dev,
+int of_mtd_parse_partitions(struct device *dev,
struct device_node *node,
struct mtd_partition **pparts);
#else
--
1.7.5.3
^ permalink raw reply related [flat|nested] 27+ messages in thread
* Re: [PATCH 01/17] mtd: prepare to convert of_mtd_parse_partitions to partition parser
2011-06-09 14:22 ` [PATCH 01/17] mtd: prepare to convert of_mtd_parse_partitions to partition parser Dmitry Eremin-Solenikov
@ 2011-06-09 14:26 ` Artem Bityutskiy
2011-06-09 14:37 ` Dmitry Eremin-Solenikov
0 siblings, 1 reply; 27+ messages in thread
From: Artem Bityutskiy @ 2011-06-09 14:26 UTC (permalink / raw)
To: Dmitry Eremin-Solenikov; +Cc: David Woodhouse, linux-mtd
On Thu, 2011-06-09 at 18:22 +0400, Dmitry Eremin-Solenikov wrote:
> Prepare to convert of_mtd_parse_partitions() to usual partitions parser:
> 1) Register ofpart parser
> 2) Internally don't use passed device for error printing
> 3) Add device_node to mtd_info struct
> 4) Move of_mtd_parse_partitions from __devinit to common text section
> 5) add ofpart to the default list of partition parsers
>
> Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
> ---
> drivers/mtd/mtdcore.c | 19 +++++++++++++++++++
> drivers/mtd/mtdpart.c | 8 ++++++--
> drivers/mtd/ofpart.c | 30 ++++++++++++++++++++++++++++--
> include/linux/mtd/mtd.h | 5 +++++
> include/linux/mtd/partitions.h | 2 +-
> 5 files changed, 59 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
> index 1326747..2d5b865 100644
> --- a/drivers/mtd/mtdcore.c
> +++ b/drivers/mtd/mtdcore.c
> @@ -36,6 +36,7 @@
> #include <linux/idr.h>
> #include <linux/backing-dev.h>
> #include <linux/gfp.h>
> +#include <linux/of.h>
>
> #include <linux/mtd/mtd.h>
> #include <linux/mtd/partitions.h>
> @@ -446,6 +447,10 @@ int mtd_device_register(struct mtd_info *master,
> const struct mtd_partition *parts,
> int nr_parts)
> {
> +#ifdef CONFIG_OF
> + if (master->node)
> + of_node_get(master->node);
> +#endif
These ifdefs are not very nice, do you have ideas how to avoid them?
Ideally, mtdcore should not know or bother about OF things. All
OF-specific things should be done in ofpart.c...
--
Best Regards,
Artem Bityutskiy (Артём Битюцкий)
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH 01/17] mtd: prepare to convert of_mtd_parse_partitions to partition parser
2011-06-09 14:26 ` Artem Bityutskiy
@ 2011-06-09 14:37 ` Dmitry Eremin-Solenikov
2011-06-09 15:02 ` Artem Bityutskiy
2011-06-09 15:25 ` Artem Bityutskiy
0 siblings, 2 replies; 27+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-09 14:37 UTC (permalink / raw)
To: dedekind1; +Cc: David Woodhouse, linux-mtd
On 09.06.2011 18:26, Artem Bityutskiy wrote:
> On Thu, 2011-06-09 at 18:22 +0400, Dmitry Eremin-Solenikov wrote:
>> Prepare to convert of_mtd_parse_partitions() to usual partitions parser:
>> 1) Register ofpart parser
>> 2) Internally don't use passed device for error printing
>> 3) Add device_node to mtd_info struct
>> 4) Move of_mtd_parse_partitions from __devinit to common text section
>> 5) add ofpart to the default list of partition parsers
>>
>> Signed-off-by: Dmitry Eremin-Solenikov<dbaryshkov@gmail.com>
>> ---
>> drivers/mtd/mtdcore.c | 19 +++++++++++++++++++
>> drivers/mtd/mtdpart.c | 8 ++++++--
>> drivers/mtd/ofpart.c | 30 ++++++++++++++++++++++++++++--
>> include/linux/mtd/mtd.h | 5 +++++
>> include/linux/mtd/partitions.h | 2 +-
>> 5 files changed, 59 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
>> index 1326747..2d5b865 100644
>> --- a/drivers/mtd/mtdcore.c
>> +++ b/drivers/mtd/mtdcore.c
>> @@ -36,6 +36,7 @@
>> #include<linux/idr.h>
>> #include<linux/backing-dev.h>
>> #include<linux/gfp.h>
>> +#include<linux/of.h>
>>
>> #include<linux/mtd/mtd.h>
>> #include<linux/mtd/partitions.h>
>> @@ -446,6 +447,10 @@ int mtd_device_register(struct mtd_info *master,
>> const struct mtd_partition *parts,
>> int nr_parts)
>> {
>> +#ifdef CONFIG_OF
>> + if (master->node)
>> + of_node_get(master->node);
>> +#endif
>
> These ifdefs are not very nice, do you have ideas how to avoid them?
> Ideally, mtdcore should not know or bother about OF things. All
> OF-specific things should be done in ofpart.c...
I know they aren't nice. OTOH ofpart.c also seems a bit non-logical: one
can have of node in the MTD, but doesn't (strangely) want to compile in
ofpart.c. Of course I can add separate small of-handling functions (to
do OF handling) to mtdcore.c to be replaced by empty functions in the
absence of CONFIG_OF, but this also look like overhead for me.
--
With best wishes
Dmitry
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH 01/17] mtd: prepare to convert of_mtd_parse_partitions to partition parser
2011-06-09 14:37 ` Dmitry Eremin-Solenikov
@ 2011-06-09 15:02 ` Artem Bityutskiy
2011-06-09 15:08 ` Dmitry Eremin-Solenikov
2011-06-09 15:25 ` Artem Bityutskiy
1 sibling, 1 reply; 27+ messages in thread
From: Artem Bityutskiy @ 2011-06-09 15:02 UTC (permalink / raw)
To: Dmitry Eremin-Solenikov; +Cc: David Woodhouse, linux-mtd
On Thu, 2011-06-09 at 18:37 +0400, Dmitry Eremin-Solenikov wrote:
> On 09.06.2011 18:26, Artem Bityutskiy wrote:
> > On Thu, 2011-06-09 at 18:22 +0400, Dmitry Eremin-Solenikov wrote:
> >> Prepare to convert of_mtd_parse_partitions() to usual partitions parser:
> >> 1) Register ofpart parser
> >> 2) Internally don't use passed device for error printing
> >> 3) Add device_node to mtd_info struct
> >> 4) Move of_mtd_parse_partitions from __devinit to common text section
> >> 5) add ofpart to the default list of partition parsers
> >>
> >> Signed-off-by: Dmitry Eremin-Solenikov<dbaryshkov@gmail.com>
> >> ---
> >> drivers/mtd/mtdcore.c | 19 +++++++++++++++++++
> >> drivers/mtd/mtdpart.c | 8 ++++++--
> >> drivers/mtd/ofpart.c | 30 ++++++++++++++++++++++++++++--
> >> include/linux/mtd/mtd.h | 5 +++++
> >> include/linux/mtd/partitions.h | 2 +-
> >> 5 files changed, 59 insertions(+), 5 deletions(-)
> >>
> >> diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
> >> index 1326747..2d5b865 100644
> >> --- a/drivers/mtd/mtdcore.c
> >> +++ b/drivers/mtd/mtdcore.c
> >> @@ -36,6 +36,7 @@
> >> #include<linux/idr.h>
> >> #include<linux/backing-dev.h>
> >> #include<linux/gfp.h>
> >> +#include<linux/of.h>
> >>
> >> #include<linux/mtd/mtd.h>
> >> #include<linux/mtd/partitions.h>
> >> @@ -446,6 +447,10 @@ int mtd_device_register(struct mtd_info *master,
> >> const struct mtd_partition *parts,
> >> int nr_parts)
> >> {
> >> +#ifdef CONFIG_OF
> >> + if (master->node)
> >> + of_node_get(master->node);
> >> +#endif
> >
> > These ifdefs are not very nice, do you have ideas how to avoid them?
> > Ideally, mtdcore should not know or bother about OF things. All
> > OF-specific things should be done in ofpart.c...
>
> I know they aren't nice. OTOH ofpart.c also seems a bit non-logical: one
> can have of node in the MTD, but doesn't (strangely) want to compile in
> ofpart.c. Of course I can add separate small of-handling functions (to
> do OF handling) to mtdcore.c to be replaced by empty functions in the
> absence of CONFIG_OF, but this also look like overhead for me.
How about turning the "origin" argument into "void *private" and
declaring that this is "parser-specific info". It then can become
"origin" for the RedBoot parser and the OF node pointer for the ofpart
parser?
--
Best Regards,
Artem Bityutskiy (Артём Битюцкий)
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH 01/17] mtd: prepare to convert of_mtd_parse_partitions to partition parser
2011-06-09 15:02 ` Artem Bityutskiy
@ 2011-06-09 15:08 ` Dmitry Eremin-Solenikov
2011-06-09 15:17 ` Artem Bityutskiy
0 siblings, 1 reply; 27+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-09 15:08 UTC (permalink / raw)
To: dedekind1; +Cc: David Woodhouse, linux-mtd
On 09.06.2011 19:02, Artem Bityutskiy wrote:
> On Thu, 2011-06-09 at 18:37 +0400, Dmitry Eremin-Solenikov wrote:
>> On 09.06.2011 18:26, Artem Bityutskiy wrote:
>>> On Thu, 2011-06-09 at 18:22 +0400, Dmitry Eremin-Solenikov wrote:
>>>> Prepare to convert of_mtd_parse_partitions() to usual partitions parser:
>>>> 1) Register ofpart parser
>>>> 2) Internally don't use passed device for error printing
>>>> 3) Add device_node to mtd_info struct
>>>> 4) Move of_mtd_parse_partitions from __devinit to common text section
>>>> 5) add ofpart to the default list of partition parsers
>>>>
>>>> Signed-off-by: Dmitry Eremin-Solenikov<dbaryshkov@gmail.com>
>>>> ---
>>>> drivers/mtd/mtdcore.c | 19 +++++++++++++++++++
>>>> drivers/mtd/mtdpart.c | 8 ++++++--
>>>> drivers/mtd/ofpart.c | 30 ++++++++++++++++++++++++++++--
>>>> include/linux/mtd/mtd.h | 5 +++++
>>>> include/linux/mtd/partitions.h | 2 +-
>>>> 5 files changed, 59 insertions(+), 5 deletions(-)
>>>>
>>>> diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
>>>> index 1326747..2d5b865 100644
>>>> --- a/drivers/mtd/mtdcore.c
>>>> +++ b/drivers/mtd/mtdcore.c
>>>> @@ -36,6 +36,7 @@
>>>> #include<linux/idr.h>
>>>> #include<linux/backing-dev.h>
>>>> #include<linux/gfp.h>
>>>> +#include<linux/of.h>
>>>>
>>>> #include<linux/mtd/mtd.h>
>>>> #include<linux/mtd/partitions.h>
>>>> @@ -446,6 +447,10 @@ int mtd_device_register(struct mtd_info *master,
>>>> const struct mtd_partition *parts,
>>>> int nr_parts)
>>>> {
>>>> +#ifdef CONFIG_OF
>>>> + if (master->node)
>>>> + of_node_get(master->node);
>>>> +#endif
>>>
>>> These ifdefs are not very nice, do you have ideas how to avoid them?
>>> Ideally, mtdcore should not know or bother about OF things. All
>>> OF-specific things should be done in ofpart.c...
>>
>> I know they aren't nice. OTOH ofpart.c also seems a bit non-logical: one
>> can have of node in the MTD, but doesn't (strangely) want to compile in
>> ofpart.c. Of course I can add separate small of-handling functions (to
>> do OF handling) to mtdcore.c to be replaced by empty functions in the
>> absence of CONFIG_OF, but this also look like overhead for me.
>
> How about turning the "origin" argument into "void *private" and
> declaring that this is "parser-specific info". It then can become
> "origin" for the RedBoot parser and the OF node pointer for the ofpart
> parser?
And what will happen when ixp4xx (the only user of redboot "exception")
will get OF support?
--
With best wishes
Dmitry
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH 01/17] mtd: prepare to convert of_mtd_parse_partitions to partition parser
2011-06-09 15:08 ` Dmitry Eremin-Solenikov
@ 2011-06-09 15:17 ` Artem Bityutskiy
2011-06-09 15:20 ` Artem Bityutskiy
0 siblings, 1 reply; 27+ messages in thread
From: Artem Bityutskiy @ 2011-06-09 15:17 UTC (permalink / raw)
To: Dmitry Eremin-Solenikov; +Cc: David Woodhouse, linux-mtd
On Thu, 2011-06-09 at 19:08 +0400, Dmitry Eremin-Solenikov wrote:
> >>>> +#ifdef CONFIG_OF
> >>>> + if (master->node)
> >>>> + of_node_get(master->node);
> >>>> +#endif
> >>>
> >>> These ifdefs are not very nice, do you have ideas how to avoid them?
> >>> Ideally, mtdcore should not know or bother about OF things. All
> >>> OF-specific things should be done in ofpart.c...
> >>
> >> I know they aren't nice. OTOH ofpart.c also seems a bit non-logical: one
> >> can have of node in the MTD, but doesn't (strangely) want to compile in
> >> ofpart.c. Of course I can add separate small of-handling functions (to
> >> do OF handling) to mtdcore.c to be replaced by empty functions in the
> >> absence of CONFIG_OF, but this also look like overhead for me.
> >
> > How about turning the "origin" argument into "void *private" and
> > declaring that this is "parser-specific info". It then can become
> > "origin" for the RedBoot parser and the OF node pointer for the ofpart
> > parser?
>
> And what will happen when ixp4xx (the only user of redboot "exception")
> will get OF support?
Hmm, may be introducing something like:
/**
* struct mtd_part_parser_data - used to pass data to MTD partition parsers.
* @origin: blah blah, RedBoot-specific
* @of_node: points to the OF node describing the partitions, ofpart-specific
*/
struct mtd_part_parser_data {
unsigned long origin;
struct device_node *of_node;
};
And change the current "origin" argument with a
"struct mtd_part_parser_data *data" pointer?
--
Best Regards,
Artem Bityutskiy (Артём Битюцкий)
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH 01/17] mtd: prepare to convert of_mtd_parse_partitions to partition parser
2011-06-09 15:17 ` Artem Bityutskiy
@ 2011-06-09 15:20 ` Artem Bityutskiy
0 siblings, 0 replies; 27+ messages in thread
From: Artem Bityutskiy @ 2011-06-09 15:20 UTC (permalink / raw)
To: Dmitry Eremin-Solenikov; +Cc: David Woodhouse, linux-mtd
On Thu, 2011-06-09 at 18:17 +0300, Artem Bityutskiy wrote:
> And change the current "origin" argument with a
> "struct mtd_part_parser_data *data" pointer?
Which of course can be NULL if there is nothing to say, as well as
of_node may be NULL, in which case the parsers which needs those things
can just return "no partitions" or something like that?
--
Best Regards,
Artem Bityutskiy (Артём Битюцкий)
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH 01/17] mtd: prepare to convert of_mtd_parse_partitions to partition parser
2011-06-09 14:37 ` Dmitry Eremin-Solenikov
2011-06-09 15:02 ` Artem Bityutskiy
@ 2011-06-09 15:25 ` Artem Bityutskiy
1 sibling, 0 replies; 27+ messages in thread
From: Artem Bityutskiy @ 2011-06-09 15:25 UTC (permalink / raw)
To: Dmitry Eremin-Solenikov; +Cc: David Woodhouse, linux-mtd
On Thu, 2011-06-09 at 18:37 +0400, Dmitry Eremin-Solenikov wrote:
> I know they aren't nice. OTOH ofpart.c also seems a bit non-logical: one
> can have of node in the MTD, but doesn't (strangely) want to compile in
> ofpart.c. Of course I can add separate small of-handling functions (to
> do OF handling) to mtdcore.c to be replaced by empty functions in the
> absence of CONFIG_OF, but this also look like overhead for me.
Anyway, if I understand correctly (correct me if I don't!) - this is
basically about passing parser-specific information to parsers. And if
this is right, your way of adding this parser-specific information to
'struct mtd_info *' is bad, and we need to invent something better.
Right?
--
Best Regards,
Artem Bityutskiy (Артём Битюцкий)
^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH 02/17] mtd: physmap_of: use ofpart through generic parsing
2011-06-09 14:22 [PATCH 00/17] mtd: last pile of MTD partition cleanup patches Dmitry Eremin-Solenikov
2011-06-09 14:22 ` [PATCH 01/17] mtd: prepare to convert of_mtd_parse_partitions to partition parser Dmitry Eremin-Solenikov
@ 2011-06-09 14:22 ` Dmitry Eremin-Solenikov
2011-06-09 14:22 ` [PATCH 03/17] mtd: m25p80: " Dmitry Eremin-Solenikov
` (16 subsequent siblings)
18 siblings, 0 replies; 27+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-09 14:22 UTC (permalink / raw)
To: linux-mtd; +Cc: David Woodhouse, dedekind1
Convert the driver to use ofpart partitions parsing through the generic
parse_mtd_partitions().
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
drivers/mtd/maps/physmap_of.c | 10 +++-------
1 files changed, 3 insertions(+), 7 deletions(-)
diff --git a/drivers/mtd/maps/physmap_of.c b/drivers/mtd/maps/physmap_of.c
index d251d1d..312eb17 100644
--- a/drivers/mtd/maps/physmap_of.c
+++ b/drivers/mtd/maps/physmap_of.c
@@ -165,7 +165,8 @@ static struct mtd_info * __devinit obsolete_probe(struct platform_device *dev,
specifies the list of partition probers to use. If none is given then the
default is use. These take precedence over other device tree
information. */
-static const char *part_probe_types_def[] = { "cmdlinepart", "RedBoot", NULL };
+static const char *part_probe_types_def[] = { "cmdlinepart", "RedBoot",
+ "ofpart", NULL };
static const char ** __devinit of_get_probes(struct device_node *dp)
{
const char *cp;
@@ -331,6 +332,7 @@ static int __devinit of_flash_probe(struct platform_device *dev)
if (err)
goto err_out;
+ info->cmtd->node = dp;
part_probe_types = of_get_probes(dp);
err = parse_mtd_partitions(info->cmtd, part_probe_types,
&info->parts, 0);
@@ -341,12 +343,6 @@ static int __devinit of_flash_probe(struct platform_device *dev)
of_free_probes(part_probe_types);
if (err == 0) {
- err = of_mtd_parse_partitions(&dev->dev, dp, &info->parts);
- if (err < 0)
- goto err_out;
- }
-
- if (err == 0) {
err = parse_obsolete_partitions(dev, info, dp);
if (err < 0)
goto err_out;
--
1.7.5.3
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH 03/17] mtd: m25p80: use ofpart through generic parsing
2011-06-09 14:22 [PATCH 00/17] mtd: last pile of MTD partition cleanup patches Dmitry Eremin-Solenikov
2011-06-09 14:22 ` [PATCH 01/17] mtd: prepare to convert of_mtd_parse_partitions to partition parser Dmitry Eremin-Solenikov
2011-06-09 14:22 ` [PATCH 02/17] mtd: physmap_of: use ofpart through generic parsing Dmitry Eremin-Solenikov
@ 2011-06-09 14:22 ` Dmitry Eremin-Solenikov
2011-06-09 14:22 ` [PATCH 04/17] mtd: fsl_elbc_nand: " Dmitry Eremin-Solenikov
` (15 subsequent siblings)
18 siblings, 0 replies; 27+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-09 14:22 UTC (permalink / raw)
To: linux-mtd; +Cc: David Woodhouse, dedekind1
Convert the driver to use ofpart partitions parsing through the generic
parse_mtd_partitions().
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
drivers/mtd/devices/m25p80.c | 8 +-------
1 files changed, 1 insertions(+), 7 deletions(-)
diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c
index 70d5fca..a1cdb52 100644
--- a/drivers/mtd/devices/m25p80.c
+++ b/drivers/mtd/devices/m25p80.c
@@ -928,6 +928,7 @@ static int __devinit m25p_probe(struct spi_device *spi)
if (info->flags & M25P_NO_ERASE)
flash->mtd.flags |= MTD_NO_ERASE;
+ flash->mtd.node = spi->dev.of_node;
flash->mtd.dev.parent = &spi->dev;
flash->page_size = info->page_size;
@@ -975,13 +976,6 @@ static int __devinit m25p_probe(struct spi_device *spi)
nr_parts = data->nr_parts;
}
-#ifdef CONFIG_MTD_OF_PARTS
- if (nr_parts <= 0 && spi->dev.of_node) {
- nr_parts = of_mtd_parse_partitions(&spi->dev,
- spi->dev.of_node, &parts);
- }
-#endif
-
if (nr_parts > 0) {
for (i = 0; i < nr_parts; i++) {
DEBUG(MTD_DEBUG_LEVEL2, "partitions[%d] = "
--
1.7.5.3
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH 04/17] mtd: fsl_elbc_nand: use ofpart through generic parsing
2011-06-09 14:22 [PATCH 00/17] mtd: last pile of MTD partition cleanup patches Dmitry Eremin-Solenikov
` (2 preceding siblings ...)
2011-06-09 14:22 ` [PATCH 03/17] mtd: m25p80: " Dmitry Eremin-Solenikov
@ 2011-06-09 14:22 ` Dmitry Eremin-Solenikov
2011-06-09 14:22 ` [PATCH 05/17] mtd: fsl_upm: " Dmitry Eremin-Solenikov
` (14 subsequent siblings)
18 siblings, 0 replies; 27+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-09 14:22 UTC (permalink / raw)
To: linux-mtd; +Cc: David Woodhouse, dedekind1
Convert the driver to use ofpart partitions parsing through the generic
parse_mtd_partitions().
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
drivers/mtd/nand/fsl_elbc_nand.c | 9 ++-------
1 files changed, 2 insertions(+), 7 deletions(-)
diff --git a/drivers/mtd/nand/fsl_elbc_nand.c b/drivers/mtd/nand/fsl_elbc_nand.c
index f3384fa..5236840 100644
--- a/drivers/mtd/nand/fsl_elbc_nand.c
+++ b/drivers/mtd/nand/fsl_elbc_nand.c
@@ -842,7 +842,7 @@ static int __devinit fsl_elbc_nand_probe(struct platform_device *pdev)
struct resource res;
struct fsl_elbc_fcm_ctrl *elbc_fcm_ctrl;
static const char *part_probe_types[]
- = { "cmdlinepart", "RedBoot", NULL };
+ = { "cmdlinepart", "RedBoot", "ofpart", NULL };
struct mtd_partition *parts;
int ret;
int bank;
@@ -910,6 +910,7 @@ static int __devinit fsl_elbc_nand_probe(struct platform_device *pdev)
goto err;
}
+ priv->mtd.node = pdev->dev.of_node;
priv->mtd.name = kasprintf(GFP_KERNEL, "%x.flash", (unsigned)res.start);
if (!priv->mtd.name) {
ret = -ENOMEM;
@@ -938,12 +939,6 @@ static int __devinit fsl_elbc_nand_probe(struct platform_device *pdev)
if (ret < 0)
goto err;
- if (ret == 0) {
- ret = of_mtd_parse_partitions(priv->dev, node, &parts);
- if (ret < 0)
- goto err;
- }
-
mtd_device_register(&priv->mtd, parts, ret);
printk(KERN_INFO "eLBC NAND device at 0x%llx, bank %d\n",
--
1.7.5.3
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH 05/17] mtd: fsl_upm: use ofpart through generic parsing
2011-06-09 14:22 [PATCH 00/17] mtd: last pile of MTD partition cleanup patches Dmitry Eremin-Solenikov
` (3 preceding siblings ...)
2011-06-09 14:22 ` [PATCH 04/17] mtd: fsl_elbc_nand: " Dmitry Eremin-Solenikov
@ 2011-06-09 14:22 ` Dmitry Eremin-Solenikov
2011-06-09 14:22 ` [PATCH 06/17] mtd: mpc5121_nfc: " Dmitry Eremin-Solenikov
` (13 subsequent siblings)
18 siblings, 0 replies; 27+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-09 14:22 UTC (permalink / raw)
To: linux-mtd; +Cc: David Woodhouse, dedekind1
Convert the driver to use ofpart partitions parsing through the generic
parse_mtd_partitions().
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
drivers/mtd/nand/fsl_upm.c | 8 +-------
1 files changed, 1 insertions(+), 7 deletions(-)
diff --git a/drivers/mtd/nand/fsl_upm.c b/drivers/mtd/nand/fsl_upm.c
index 7c782eb..253b8ff 100644
--- a/drivers/mtd/nand/fsl_upm.c
+++ b/drivers/mtd/nand/fsl_upm.c
@@ -175,6 +175,7 @@ static int __devinit fun_chip_init(struct fsl_upm_nand *fun,
fun->mtd.priv = &fun->chip;
fun->mtd.owner = THIS_MODULE;
+ fun->mtd.node = flash_np;
flash_np = of_get_next_child(upm_np, NULL);
if (!flash_np)
@@ -193,13 +194,6 @@ static int __devinit fun_chip_init(struct fsl_upm_nand *fun,
ret = parse_mtd_partitions(&fun->mtd, NULL, &fun->parts, 0);
-#ifdef CONFIG_MTD_OF_PARTS
- if (ret == 0) {
- ret = of_mtd_parse_partitions(fun->dev, flash_np, &fun->parts);
- if (ret < 0)
- goto err;
- }
-#endif
ret = mtd_device_register(&fun->mtd, fun->parts, ret);
err:
of_node_put(flash_np);
--
1.7.5.3
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH 06/17] mtd: mpc5121_nfc: use ofpart through generic parsing
2011-06-09 14:22 [PATCH 00/17] mtd: last pile of MTD partition cleanup patches Dmitry Eremin-Solenikov
` (4 preceding siblings ...)
2011-06-09 14:22 ` [PATCH 05/17] mtd: fsl_upm: " Dmitry Eremin-Solenikov
@ 2011-06-09 14:22 ` Dmitry Eremin-Solenikov
2011-06-09 14:22 ` [PATCH 07/17] mtd: ndfc: " Dmitry Eremin-Solenikov
` (12 subsequent siblings)
18 siblings, 0 replies; 27+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-09 14:22 UTC (permalink / raw)
To: linux-mtd; +Cc: David Woodhouse, dedekind1
Convert the driver to use ofpart partitions parsing through the generic
parse_mtd_partitions().
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
drivers/mtd/nand/mpc5121_nfc.c | 5 +----
1 files changed, 1 insertions(+), 4 deletions(-)
diff --git a/drivers/mtd/nand/mpc5121_nfc.c b/drivers/mtd/nand/mpc5121_nfc.c
index 0b61367..c4e8cb9 100644
--- a/drivers/mtd/nand/mpc5121_nfc.c
+++ b/drivers/mtd/nand/mpc5121_nfc.c
@@ -725,6 +725,7 @@ static int __devinit mpc5121_nfc_probe(struct platform_device *op)
}
mtd->name = "MPC5121 NAND";
+ mtd->node = dn;
chip->dev_ready = mpc5121_nfc_dev_ready;
chip->cmdfunc = mpc5121_nfc_command;
chip->read_byte = mpc5121_nfc_read_byte;
@@ -837,10 +838,6 @@ static int __devinit mpc5121_nfc_probe(struct platform_device *op)
/* Register device in MTD */
retval = parse_mtd_partitions(mtd, NULL, &parts, 0);
-#ifdef CONFIG_MTD_OF_PARTS
- if (retval == 0)
- retval = of_mtd_parse_partitions(dev, dn, &parts);
-#endif
if (retval < 0) {
dev_err(dev, "Error parsing MTD partitions!\n");
devm_free_irq(dev, prv->irq, mtd);
--
1.7.5.3
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH 07/17] mtd: ndfc: use ofpart through generic parsing
2011-06-09 14:22 [PATCH 00/17] mtd: last pile of MTD partition cleanup patches Dmitry Eremin-Solenikov
` (5 preceding siblings ...)
2011-06-09 14:22 ` [PATCH 06/17] mtd: mpc5121_nfc: " Dmitry Eremin-Solenikov
@ 2011-06-09 14:22 ` Dmitry Eremin-Solenikov
2011-06-09 14:22 ` [PATCH 08/17] mtd: socrates_nand: " Dmitry Eremin-Solenikov
` (11 subsequent siblings)
18 siblings, 0 replies; 27+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-09 14:22 UTC (permalink / raw)
To: linux-mtd; +Cc: David Woodhouse, dedekind1
Convert the driver to use ofpart partitions parsing through the generic
parse_mtd_partitions().
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
drivers/mtd/nand/ndfc.c | 8 +-------
1 files changed, 1 insertions(+), 7 deletions(-)
diff --git a/drivers/mtd/nand/ndfc.c b/drivers/mtd/nand/ndfc.c
index 70c04ff..1ae94f0 100644
--- a/drivers/mtd/nand/ndfc.c
+++ b/drivers/mtd/nand/ndfc.c
@@ -188,6 +188,7 @@ static int ndfc_chip_init(struct ndfc_controller *ndfc,
if (!flash_np)
return -ENODEV;
+ ndfc->mtd.node = flash_np;
ndfc->mtd.name = kasprintf(GFP_KERNEL, "%s.%s",
dev_name(&ndfc->ofdev->dev), flash_np->name);
if (!ndfc->mtd.name) {
@@ -203,13 +204,6 @@ static int ndfc_chip_init(struct ndfc_controller *ndfc,
if (ret < 0)
goto err;
- if (ret == 0) {
- ret = of_mtd_parse_partitions(&ndfc->ofdev->dev, flash_np,
- &ndfc->parts);
- if (ret < 0)
- goto err;
- }
-
ret = mtd_device_register(&ndfc->mtd, ndfc->parts, ret);
err:
--
1.7.5.3
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH 08/17] mtd: socrates_nand: use ofpart through generic parsing
2011-06-09 14:22 [PATCH 00/17] mtd: last pile of MTD partition cleanup patches Dmitry Eremin-Solenikov
` (6 preceding siblings ...)
2011-06-09 14:22 ` [PATCH 07/17] mtd: ndfc: " Dmitry Eremin-Solenikov
@ 2011-06-09 14:22 ` Dmitry Eremin-Solenikov
2011-06-09 14:22 ` [PATCH 09/17] mtd: drop of_mtd_parse_partitions() Dmitry Eremin-Solenikov
` (10 subsequent siblings)
18 siblings, 0 replies; 27+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-09 14:22 UTC (permalink / raw)
To: linux-mtd; +Cc: David Woodhouse, dedekind1
Convert the driver to use ofpart partitions parsing through the generic
parse_mtd_partitions().
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
drivers/mtd/nand/socrates_nand.c | 11 +----------
1 files changed, 1 insertions(+), 10 deletions(-)
diff --git a/drivers/mtd/nand/socrates_nand.c b/drivers/mtd/nand/socrates_nand.c
index 9023ac8..b256491 100644
--- a/drivers/mtd/nand/socrates_nand.c
+++ b/drivers/mtd/nand/socrates_nand.c
@@ -191,6 +191,7 @@ static int __devinit socrates_nand_probe(struct platform_device *ofdev)
mtd->name = "socrates_nand";
mtd->owner = THIS_MODULE;
mtd->dev.parent = &ofdev->dev;
+ mtd->node = ofdev->dev.of_node;
/*should never be accessed directly */
nand_chip->IO_ADDR_R = (void *)0xdeadbeef;
@@ -229,16 +230,6 @@ static int __devinit socrates_nand_probe(struct platform_device *ofdev)
goto release;
}
- if (num_partitions == 0) {
- num_partitions = of_mtd_parse_partitions(&ofdev->dev,
- ofdev->dev.of_node,
- &partitions);
- if (num_partitions < 0) {
- res = num_partitions;
- goto release;
- }
- }
-
res = mtd_device_register(mtd, partitions, num_partitions);
if (!res)
return res;
--
1.7.5.3
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH 09/17] mtd: drop of_mtd_parse_partitions()
2011-06-09 14:22 [PATCH 00/17] mtd: last pile of MTD partition cleanup patches Dmitry Eremin-Solenikov
` (7 preceding siblings ...)
2011-06-09 14:22 ` [PATCH 08/17] mtd: socrates_nand: " Dmitry Eremin-Solenikov
@ 2011-06-09 14:22 ` Dmitry Eremin-Solenikov
2011-06-09 14:22 ` [PATCH 10/17] physmap_of: move parse_obsolete_partitions to become separate parser Dmitry Eremin-Solenikov
` (9 subsequent siblings)
18 siblings, 0 replies; 27+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-09 14:22 UTC (permalink / raw)
To: linux-mtd; +Cc: David Woodhouse, dedekind1
All users have been converted to call of_mtd_parse_partitions through
parse_mtd_partitions() multiplexer. Drop obsolete API.
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
drivers/mtd/ofpart.c | 16 ++++------------
include/linux/mtd/partitions.h | 16 ----------------
2 files changed, 4 insertions(+), 28 deletions(-)
diff --git a/drivers/mtd/ofpart.c b/drivers/mtd/ofpart.c
index 4ac040e..bbcc269 100644
--- a/drivers/mtd/ofpart.c
+++ b/drivers/mtd/ofpart.c
@@ -25,22 +25,15 @@ static int parse_ofpart_partitions(struct mtd_info *master,
unsigned long origin)
{
struct device_node *node;
+ const char *partname;
+ struct device_node *pp;
+ int nr_parts, i;
+
node = master->node;
if (!node)
return 0;
- return of_mtd_parse_partitions(NULL, node, pparts);
-}
-
-int of_mtd_parse_partitions(struct device *dev,
- struct device_node *node,
- struct mtd_partition **pparts)
-{
- const char *partname;
- struct device_node *pp;
- int nr_parts, i;
-
/* First count the subnodes */
pp = NULL;
nr_parts = 0;
@@ -90,7 +83,6 @@ int of_mtd_parse_partitions(struct device *dev,
return nr_parts;
}
-EXPORT_SYMBOL(of_mtd_parse_partitions);
static struct mtd_part_parser ofpart_parser = {
.owner = THIS_MODULE,
diff --git a/include/linux/mtd/partitions.h b/include/linux/mtd/partitions.h
index a8bd193..cc9c577 100644
--- a/include/linux/mtd/partitions.h
+++ b/include/linux/mtd/partitions.h
@@ -70,22 +70,6 @@ extern int parse_mtd_partitions(struct mtd_info *master, const char **types,
#define put_partition_parser(p) do { module_put((p)->owner); } while(0)
-struct device;
-struct device_node;
-
-#ifdef CONFIG_MTD_OF_PARTS
-int of_mtd_parse_partitions(struct device *dev,
- struct device_node *node,
- struct mtd_partition **pparts);
-#else
-static inline int of_mtd_parse_partitions(struct device *dev,
- struct device_node *node,
- struct mtd_partition **pparts)
-{
- return 0;
-}
-#endif
-
int mtd_is_partition(struct mtd_info *mtd);
int mtd_add_partition(struct mtd_info *master, char *name,
long long offset, long long length);
--
1.7.5.3
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH 10/17] physmap_of: move parse_obsolete_partitions to become separate parser
2011-06-09 14:22 [PATCH 00/17] mtd: last pile of MTD partition cleanup patches Dmitry Eremin-Solenikov
` (8 preceding siblings ...)
2011-06-09 14:22 ` [PATCH 09/17] mtd: drop of_mtd_parse_partitions() Dmitry Eremin-Solenikov
@ 2011-06-09 14:22 ` Dmitry Eremin-Solenikov
2011-06-09 14:23 ` [PATCH 11/17] mtd: m25p80.c: use mtd_device_parse_register Dmitry Eremin-Solenikov
` (8 subsequent siblings)
18 siblings, 0 replies; 27+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-09 14:22 UTC (permalink / raw)
To: linux-mtd; +Cc: David Woodhouse, dedekind1
Move parse_obsolete_partitions() to ofpart.c and register it as an
ofoldpart partitions parser.
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
drivers/mtd/maps/physmap_of.c | 53 +-----------------------------
drivers/mtd/ofpart.c | 72 ++++++++++++++++++++++++++++++++++++++++-
2 files changed, 72 insertions(+), 53 deletions(-)
diff --git a/drivers/mtd/maps/physmap_of.c b/drivers/mtd/maps/physmap_of.c
index 312eb17..c953db3 100644
--- a/drivers/mtd/maps/physmap_of.c
+++ b/drivers/mtd/maps/physmap_of.c
@@ -40,51 +40,6 @@ struct of_flash {
};
#define OF_FLASH_PARTS(info) ((info)->parts)
-static int parse_obsolete_partitions(struct platform_device *dev,
- struct of_flash *info,
- struct device_node *dp)
-{
- int i, plen, nr_parts;
- const struct {
- __be32 offset, len;
- } *part;
- const char *names;
-
- part = of_get_property(dp, "partitions", &plen);
- if (!part)
- return 0; /* No partitions found */
-
- dev_warn(&dev->dev, "Device tree uses obsolete partition map binding\n");
-
- nr_parts = plen / sizeof(part[0]);
-
- info->parts = kzalloc(nr_parts * sizeof(*info->parts), GFP_KERNEL);
- if (!info->parts)
- return -ENOMEM;
-
- names = of_get_property(dp, "partition-names", &plen);
-
- for (i = 0; i < nr_parts; i++) {
- info->parts[i].offset = be32_to_cpu(part->offset);
- info->parts[i].size = be32_to_cpu(part->len) & ~1;
- if (be32_to_cpu(part->len) & 1) /* bit 0 set signifies read only partition */
- info->parts[i].mask_flags = MTD_WRITEABLE;
-
- if (names && (plen > 0)) {
- int len = strlen(names) + 1;
-
- info->parts[i].name = (char *)names;
- plen -= len;
- names += len;
- } else {
- info->parts[i].name = "unnamed";
- }
-
- part++;
- }
-
- return nr_parts;
-}
static int of_flash_remove(struct platform_device *dev)
{
@@ -166,7 +121,7 @@ static struct mtd_info * __devinit obsolete_probe(struct platform_device *dev,
default is use. These take precedence over other device tree
information. */
static const char *part_probe_types_def[] = { "cmdlinepart", "RedBoot",
- "ofpart", NULL };
+ "ofpart", "ofoldpart", NULL };
static const char ** __devinit of_get_probes(struct device_node *dp)
{
const char *cp;
@@ -342,12 +297,6 @@ static int __devinit of_flash_probe(struct platform_device *dev)
}
of_free_probes(part_probe_types);
- if (err == 0) {
- err = parse_obsolete_partitions(dev, info, dp);
- if (err < 0)
- goto err_out;
- }
-
mtd_device_register(info->cmtd, info->parts, err);
kfree(mtd_list);
diff --git a/drivers/mtd/ofpart.c b/drivers/mtd/ofpart.c
index bbcc269..311b248 100644
--- a/drivers/mtd/ofpart.c
+++ b/drivers/mtd/ofpart.c
@@ -90,9 +90,79 @@ static struct mtd_part_parser ofpart_parser = {
.name = "ofpart",
};
+static int parse_ofoldpart_partitions(struct mtd_info *master,
+ struct mtd_partition **pparts,
+ unsigned long origin)
+{
+ struct device_node *dp;
+ int i, plen, nr_parts;
+ const struct {
+ __be32 offset, len;
+ } *part;
+ const char *names;
+
+ dp = master->node;
+ if (!dp)
+ return 0;
+
+ part = of_get_property(dp, "partitions", &plen);
+ if (!part)
+ return 0; /* No partitions found */
+
+ pr_warning("Device tree uses obsolete partition map binding: %s\n",
+ dp->full_name);
+
+ nr_parts = plen / sizeof(part[0]);
+
+ *pparts = kzalloc(nr_parts * sizeof(*(*pparts)), GFP_KERNEL);
+ if (!pparts)
+ return -ENOMEM;
+
+ names = of_get_property(dp, "partition-names", &plen);
+
+ for (i = 0; i < nr_parts; i++) {
+ (*pparts)[i].offset = be32_to_cpu(part->offset);
+ (*pparts)[i].size = be32_to_cpu(part->len) & ~1;
+ /* bit 0 set signifies read only partition */
+ if (be32_to_cpu(part->len) & 1)
+ (*pparts)[i].mask_flags = MTD_WRITEABLE;
+
+ if (names && (plen > 0)) {
+ int len = strlen(names) + 1;
+
+ (*pparts)[i].name = (char *)names;
+ plen -= len;
+ names += len;
+ } else {
+ (*pparts)[i].name = "unnamed";
+ }
+
+ part++;
+ }
+
+ return nr_parts;
+}
+
+static struct mtd_part_parser ofoldpart_parser = {
+ .owner = THIS_MODULE,
+ .parse_fn = parse_ofoldpart_partitions,
+ .name = "ofoldpart",
+};
+
static int __init ofpart_parser_init(void)
{
- return register_mtd_parser(&ofpart_parser);
+ int rc;
+ rc = register_mtd_parser(&ofpart_parser);
+ if (rc)
+ goto out;
+
+ rc = register_mtd_parser(&ofoldpart_parser);
+ if (!rc)
+ return 0;
+
+ deregister_mtd_parser(&ofoldpart_parser);
+out:
+ return rc;
}
module_init(ofpart_parser_init);
--
1.7.5.3
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH 11/17] mtd: m25p80.c: use mtd_device_parse_register
2011-06-09 14:22 [PATCH 00/17] mtd: last pile of MTD partition cleanup patches Dmitry Eremin-Solenikov
` (9 preceding siblings ...)
2011-06-09 14:22 ` [PATCH 10/17] physmap_of: move parse_obsolete_partitions to become separate parser Dmitry Eremin-Solenikov
@ 2011-06-09 14:23 ` Dmitry Eremin-Solenikov
2011-06-09 14:23 ` [PATCH 11/17] mtd: physmap_of.c: " Dmitry Eremin-Solenikov
` (7 subsequent siblings)
18 siblings, 0 replies; 27+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-09 14:23 UTC (permalink / raw)
To: linux-mtd; +Cc: David Woodhouse, dedekind1
Replace custom invocations of parse_mtd_partitions and mtd_device_register
with common mtd_device_parse_register call. This would bring: standard
handling of all errors, fallback to default partitions, etc.
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
drivers/mtd/devices/m25p80.c | 28 +++-------------------------
1 files changed, 3 insertions(+), 25 deletions(-)
diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c
index a1cdb52..f76db1d 100644
--- a/drivers/mtd/devices/m25p80.c
+++ b/drivers/mtd/devices/m25p80.c
@@ -88,7 +88,6 @@ struct m25p {
struct spi_device *spi;
struct mutex lock;
struct mtd_info mtd;
- unsigned partitioned:1;
u16 page_size;
u16 addr_width;
u8 erase_opcode;
@@ -825,8 +824,6 @@ static int __devinit m25p_probe(struct spi_device *spi)
struct m25p *flash;
struct flash_info *info;
unsigned i;
- struct mtd_partition *parts = NULL;
- int nr_parts = 0;
/* Platform data helps sort out which chip type we have, as
* well as how this board partitions it. If we don't have
@@ -969,28 +966,9 @@ static int __devinit m25p_probe(struct spi_device *spi)
/* partitions should match sector boundaries; and it may be good to
* use readonly partitions for writeprotected sectors (BP2..BP0).
*/
- nr_parts = parse_mtd_partitions(&flash->mtd, NULL, &parts, 0);
-
- if (nr_parts <= 0 && data && data->parts) {
- parts = data->parts;
- nr_parts = data->nr_parts;
- }
-
- if (nr_parts > 0) {
- for (i = 0; i < nr_parts; i++) {
- DEBUG(MTD_DEBUG_LEVEL2, "partitions[%d] = "
- "{.name = %s, .offset = 0x%llx, "
- ".size = 0x%llx (%lldKiB) }\n",
- i, parts[i].name,
- (long long)parts[i].offset,
- (long long)parts[i].size,
- (long long)(parts[i].size >> 10));
- }
- flash->partitioned = 1;
- }
-
- return mtd_device_register(&flash->mtd, parts, nr_parts) == 1 ?
- -ENODEV : 0;
+ return mtd_device_parse_register(&flash->mtd, NULL, 0,
+ data ? data->parts : NULL,
+ data ? data->nr_parts : 0);
}
--
1.7.5.3
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH 11/17] mtd: physmap_of.c: use mtd_device_parse_register
2011-06-09 14:22 [PATCH 00/17] mtd: last pile of MTD partition cleanup patches Dmitry Eremin-Solenikov
` (10 preceding siblings ...)
2011-06-09 14:23 ` [PATCH 11/17] mtd: m25p80.c: use mtd_device_parse_register Dmitry Eremin-Solenikov
@ 2011-06-09 14:23 ` Dmitry Eremin-Solenikov
2011-06-09 14:23 ` [PATCH 12/17] mtd: m25p80.c: " Dmitry Eremin-Solenikov
` (6 subsequent siblings)
18 siblings, 0 replies; 27+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-09 14:23 UTC (permalink / raw)
To: linux-mtd; +Cc: David Woodhouse, dedekind1
Replace custom invocations of parse_mtd_partitions and mtd_device_register
with common mtd_device_parse_register call. This would bring: standard
handling of all errors, fallback to default partitions, etc.
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
drivers/mtd/maps/physmap_of.c | 18 +++---------------
1 files changed, 3 insertions(+), 15 deletions(-)
diff --git a/drivers/mtd/maps/physmap_of.c b/drivers/mtd/maps/physmap_of.c
index c953db3..779b184 100644
--- a/drivers/mtd/maps/physmap_of.c
+++ b/drivers/mtd/maps/physmap_of.c
@@ -34,13 +34,10 @@ struct of_flash_list {
struct of_flash {
struct mtd_info *cmtd;
- struct mtd_partition *parts;
int list_size; /* number of elements in of_flash_list */
struct of_flash_list list[0];
};
-#define OF_FLASH_PARTS(info) ((info)->parts)
-
static int of_flash_remove(struct platform_device *dev)
{
struct of_flash *info;
@@ -56,11 +53,8 @@ static int of_flash_remove(struct platform_device *dev)
mtd_concat_destroy(info->cmtd);
}
- if (info->cmtd) {
- if (OF_FLASH_PARTS(info))
- kfree(OF_FLASH_PARTS(info));
+ if (info->cmtd)
mtd_device_unregister(info->cmtd);
- }
for (i = 0; i < info->list_size; i++) {
if (info->list[i].mtd)
@@ -289,16 +283,10 @@ static int __devinit of_flash_probe(struct platform_device *dev)
info->cmtd->node = dp;
part_probe_types = of_get_probes(dp);
- err = parse_mtd_partitions(info->cmtd, part_probe_types,
- &info->parts, 0);
- if (err < 0) {
- of_free_probes(part_probe_types);
- goto err_out;
- }
+ mtd_device_parse_register(info->cmtd, part_probe_types, 0,
+ NULL, 0);
of_free_probes(part_probe_types);
- mtd_device_register(info->cmtd, info->parts, err);
-
kfree(mtd_list);
return 0;
--
1.7.5.3
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH 12/17] mtd: m25p80.c: use mtd_device_parse_register
2011-06-09 14:22 [PATCH 00/17] mtd: last pile of MTD partition cleanup patches Dmitry Eremin-Solenikov
` (11 preceding siblings ...)
2011-06-09 14:23 ` [PATCH 11/17] mtd: physmap_of.c: " Dmitry Eremin-Solenikov
@ 2011-06-09 14:23 ` Dmitry Eremin-Solenikov
2011-06-09 14:23 ` [PATCH 12/17] mtd: physmap_of.c: " Dmitry Eremin-Solenikov
` (5 subsequent siblings)
18 siblings, 0 replies; 27+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-09 14:23 UTC (permalink / raw)
To: linux-mtd; +Cc: David Woodhouse, dedekind1
Replace custom invocations of parse_mtd_partitions and mtd_device_register
with common mtd_device_parse_register call. This would bring: standard
handling of all errors, fallback to default partitions, etc.
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
drivers/mtd/devices/m25p80.c | 28 +++-------------------------
1 files changed, 3 insertions(+), 25 deletions(-)
diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c
index a1cdb52..f76db1d 100644
--- a/drivers/mtd/devices/m25p80.c
+++ b/drivers/mtd/devices/m25p80.c
@@ -88,7 +88,6 @@ struct m25p {
struct spi_device *spi;
struct mutex lock;
struct mtd_info mtd;
- unsigned partitioned:1;
u16 page_size;
u16 addr_width;
u8 erase_opcode;
@@ -825,8 +824,6 @@ static int __devinit m25p_probe(struct spi_device *spi)
struct m25p *flash;
struct flash_info *info;
unsigned i;
- struct mtd_partition *parts = NULL;
- int nr_parts = 0;
/* Platform data helps sort out which chip type we have, as
* well as how this board partitions it. If we don't have
@@ -969,28 +966,9 @@ static int __devinit m25p_probe(struct spi_device *spi)
/* partitions should match sector boundaries; and it may be good to
* use readonly partitions for writeprotected sectors (BP2..BP0).
*/
- nr_parts = parse_mtd_partitions(&flash->mtd, NULL, &parts, 0);
-
- if (nr_parts <= 0 && data && data->parts) {
- parts = data->parts;
- nr_parts = data->nr_parts;
- }
-
- if (nr_parts > 0) {
- for (i = 0; i < nr_parts; i++) {
- DEBUG(MTD_DEBUG_LEVEL2, "partitions[%d] = "
- "{.name = %s, .offset = 0x%llx, "
- ".size = 0x%llx (%lldKiB) }\n",
- i, parts[i].name,
- (long long)parts[i].offset,
- (long long)parts[i].size,
- (long long)(parts[i].size >> 10));
- }
- flash->partitioned = 1;
- }
-
- return mtd_device_register(&flash->mtd, parts, nr_parts) == 1 ?
- -ENODEV : 0;
+ return mtd_device_parse_register(&flash->mtd, NULL, 0,
+ data ? data->parts : NULL,
+ data ? data->nr_parts : 0);
}
--
1.7.5.3
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH 12/17] mtd: physmap_of.c: use mtd_device_parse_register
2011-06-09 14:22 [PATCH 00/17] mtd: last pile of MTD partition cleanup patches Dmitry Eremin-Solenikov
` (12 preceding siblings ...)
2011-06-09 14:23 ` [PATCH 12/17] mtd: m25p80.c: " Dmitry Eremin-Solenikov
@ 2011-06-09 14:23 ` Dmitry Eremin-Solenikov
2011-06-09 14:23 ` [PATCH 13/17] mtd: fsl_elbc_nand.c: " Dmitry Eremin-Solenikov
` (4 subsequent siblings)
18 siblings, 0 replies; 27+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-09 14:23 UTC (permalink / raw)
To: linux-mtd; +Cc: David Woodhouse, dedekind1
Replace custom invocations of parse_mtd_partitions and mtd_device_register
with common mtd_device_parse_register call. This would bring: standard
handling of all errors, fallback to default partitions, etc.
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
drivers/mtd/maps/physmap_of.c | 18 +++---------------
1 files changed, 3 insertions(+), 15 deletions(-)
diff --git a/drivers/mtd/maps/physmap_of.c b/drivers/mtd/maps/physmap_of.c
index c953db3..779b184 100644
--- a/drivers/mtd/maps/physmap_of.c
+++ b/drivers/mtd/maps/physmap_of.c
@@ -34,13 +34,10 @@ struct of_flash_list {
struct of_flash {
struct mtd_info *cmtd;
- struct mtd_partition *parts;
int list_size; /* number of elements in of_flash_list */
struct of_flash_list list[0];
};
-#define OF_FLASH_PARTS(info) ((info)->parts)
-
static int of_flash_remove(struct platform_device *dev)
{
struct of_flash *info;
@@ -56,11 +53,8 @@ static int of_flash_remove(struct platform_device *dev)
mtd_concat_destroy(info->cmtd);
}
- if (info->cmtd) {
- if (OF_FLASH_PARTS(info))
- kfree(OF_FLASH_PARTS(info));
+ if (info->cmtd)
mtd_device_unregister(info->cmtd);
- }
for (i = 0; i < info->list_size; i++) {
if (info->list[i].mtd)
@@ -289,16 +283,10 @@ static int __devinit of_flash_probe(struct platform_device *dev)
info->cmtd->node = dp;
part_probe_types = of_get_probes(dp);
- err = parse_mtd_partitions(info->cmtd, part_probe_types,
- &info->parts, 0);
- if (err < 0) {
- of_free_probes(part_probe_types);
- goto err_out;
- }
+ mtd_device_parse_register(info->cmtd, part_probe_types, 0,
+ NULL, 0);
of_free_probes(part_probe_types);
- mtd_device_register(info->cmtd, info->parts, err);
-
kfree(mtd_list);
return 0;
--
1.7.5.3
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH 13/17] mtd: fsl_elbc_nand.c: use mtd_device_parse_register
2011-06-09 14:22 [PATCH 00/17] mtd: last pile of MTD partition cleanup patches Dmitry Eremin-Solenikov
` (13 preceding siblings ...)
2011-06-09 14:23 ` [PATCH 12/17] mtd: physmap_of.c: " Dmitry Eremin-Solenikov
@ 2011-06-09 14:23 ` Dmitry Eremin-Solenikov
2011-06-09 14:23 ` [PATCH 14/17] mtd: fsl_upm.c: " Dmitry Eremin-Solenikov
` (3 subsequent siblings)
18 siblings, 0 replies; 27+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-09 14:23 UTC (permalink / raw)
To: linux-mtd; +Cc: David Woodhouse, dedekind1
Replace custom invocations of parse_mtd_partitions and mtd_device_register
with common mtd_device_parse_register call. This would bring: standard
handling of all errors, fallback to default partitions, etc.
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
drivers/mtd/nand/fsl_elbc_nand.c | 7 +------
1 files changed, 1 insertions(+), 6 deletions(-)
diff --git a/drivers/mtd/nand/fsl_elbc_nand.c b/drivers/mtd/nand/fsl_elbc_nand.c
index 5236840..73c8d87 100644
--- a/drivers/mtd/nand/fsl_elbc_nand.c
+++ b/drivers/mtd/nand/fsl_elbc_nand.c
@@ -843,7 +843,6 @@ static int __devinit fsl_elbc_nand_probe(struct platform_device *pdev)
struct fsl_elbc_fcm_ctrl *elbc_fcm_ctrl;
static const char *part_probe_types[]
= { "cmdlinepart", "RedBoot", "ofpart", NULL };
- struct mtd_partition *parts;
int ret;
int bank;
struct device *dev;
@@ -935,11 +934,7 @@ static int __devinit fsl_elbc_nand_probe(struct platform_device *pdev)
/* First look for RedBoot table or partitions on the command
* line, these take precedence over device tree information */
- ret = parse_mtd_partitions(&priv->mtd, part_probe_types, &parts, 0);
- if (ret < 0)
- goto err;
-
- mtd_device_register(&priv->mtd, parts, ret);
+ mtd_device_parse_register(&priv->mtd, part_probe_types, 0, NULL, 0);
printk(KERN_INFO "eLBC NAND device at 0x%llx, bank %d\n",
(unsigned long long)res.start, priv->bank);
--
1.7.5.3
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH 14/17] mtd: fsl_upm.c: use mtd_device_parse_register
2011-06-09 14:22 [PATCH 00/17] mtd: last pile of MTD partition cleanup patches Dmitry Eremin-Solenikov
` (14 preceding siblings ...)
2011-06-09 14:23 ` [PATCH 13/17] mtd: fsl_elbc_nand.c: " Dmitry Eremin-Solenikov
@ 2011-06-09 14:23 ` Dmitry Eremin-Solenikov
2011-06-09 14:23 ` [PATCH 15/17] mtd: mpc5121_nfc.c: " Dmitry Eremin-Solenikov
` (2 subsequent siblings)
18 siblings, 0 replies; 27+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-09 14:23 UTC (permalink / raw)
To: linux-mtd; +Cc: David Woodhouse, dedekind1
Replace custom invocations of parse_mtd_partitions and mtd_device_register
with common mtd_device_parse_register call. This would bring: standard
handling of all errors, fallback to default partitions, etc.
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
drivers/mtd/nand/fsl_upm.c | 4 +---
1 files changed, 1 insertions(+), 3 deletions(-)
diff --git a/drivers/mtd/nand/fsl_upm.c b/drivers/mtd/nand/fsl_upm.c
index 253b8ff..04be80a 100644
--- a/drivers/mtd/nand/fsl_upm.c
+++ b/drivers/mtd/nand/fsl_upm.c
@@ -192,9 +192,7 @@ static int __devinit fun_chip_init(struct fsl_upm_nand *fun,
if (ret)
goto err;
- ret = parse_mtd_partitions(&fun->mtd, NULL, &fun->parts, 0);
-
- ret = mtd_device_register(&fun->mtd, fun->parts, ret);
+ ret = mtd_device_parse_register(&fun->mtd, NULL, 0, NULL, 0);
err:
of_node_put(flash_np);
return ret;
--
1.7.5.3
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH 15/17] mtd: mpc5121_nfc.c: use mtd_device_parse_register
2011-06-09 14:22 [PATCH 00/17] mtd: last pile of MTD partition cleanup patches Dmitry Eremin-Solenikov
` (15 preceding siblings ...)
2011-06-09 14:23 ` [PATCH 14/17] mtd: fsl_upm.c: " Dmitry Eremin-Solenikov
@ 2011-06-09 14:23 ` Dmitry Eremin-Solenikov
2011-06-09 14:23 ` [PATCH 16/17] mtd: ndfc.c: " Dmitry Eremin-Solenikov
2011-06-09 14:23 ` [PATCH 17/17] mtd: socrates_nand.c: " Dmitry Eremin-Solenikov
18 siblings, 0 replies; 27+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-09 14:23 UTC (permalink / raw)
To: linux-mtd; +Cc: David Woodhouse, dedekind1
Replace custom invocations of parse_mtd_partitions and mtd_device_register
with common mtd_device_parse_register call. This would bring: standard
handling of all errors, fallback to default partitions, etc.
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
drivers/mtd/nand/mpc5121_nfc.c | 11 +----------
1 files changed, 1 insertions(+), 10 deletions(-)
diff --git a/drivers/mtd/nand/mpc5121_nfc.c b/drivers/mtd/nand/mpc5121_nfc.c
index c4e8cb9..e06bde7 100644
--- a/drivers/mtd/nand/mpc5121_nfc.c
+++ b/drivers/mtd/nand/mpc5121_nfc.c
@@ -654,7 +654,6 @@ static int __devinit mpc5121_nfc_probe(struct platform_device *op)
struct mpc5121_nfc_prv *prv;
struct resource res;
struct mtd_info *mtd;
- struct mtd_partition *parts;
struct nand_chip *chip;
unsigned long regs_paddr, regs_size;
const __be32 *chips_no;
@@ -837,15 +836,7 @@ static int __devinit mpc5121_nfc_probe(struct platform_device *op)
dev_set_drvdata(dev, mtd);
/* Register device in MTD */
- retval = parse_mtd_partitions(mtd, NULL, &parts, 0);
- if (retval < 0) {
- dev_err(dev, "Error parsing MTD partitions!\n");
- devm_free_irq(dev, prv->irq, mtd);
- retval = -EINVAL;
- goto error;
- }
-
- retval = mtd_device_register(mtd, parts, retval);
+ retval = mtd_device_parse_register(mtd, NULL, 0, NULL, 0);
if (retval) {
dev_err(dev, "Error adding MTD device!\n");
devm_free_irq(dev, prv->irq, mtd);
--
1.7.5.3
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH 16/17] mtd: ndfc.c: use mtd_device_parse_register
2011-06-09 14:22 [PATCH 00/17] mtd: last pile of MTD partition cleanup patches Dmitry Eremin-Solenikov
` (16 preceding siblings ...)
2011-06-09 14:23 ` [PATCH 15/17] mtd: mpc5121_nfc.c: " Dmitry Eremin-Solenikov
@ 2011-06-09 14:23 ` Dmitry Eremin-Solenikov
2011-06-09 14:23 ` [PATCH 17/17] mtd: socrates_nand.c: " Dmitry Eremin-Solenikov
18 siblings, 0 replies; 27+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-09 14:23 UTC (permalink / raw)
To: linux-mtd; +Cc: David Woodhouse, dedekind1
Replace custom invocations of parse_mtd_partitions and mtd_device_register
with common mtd_device_parse_register call. This would bring: standard
handling of all errors, fallback to default partitions, etc.
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
drivers/mtd/nand/ndfc.c | 7 +------
1 files changed, 1 insertions(+), 6 deletions(-)
diff --git a/drivers/mtd/nand/ndfc.c b/drivers/mtd/nand/ndfc.c
index 1ae94f0..24c449f 100644
--- a/drivers/mtd/nand/ndfc.c
+++ b/drivers/mtd/nand/ndfc.c
@@ -42,7 +42,6 @@ struct ndfc_controller {
struct nand_chip chip;
int chip_select;
struct nand_hw_control ndfc_control;
- struct mtd_partition *parts;
};
static struct ndfc_controller ndfc_ctrl[NDFC_MAX_CS];
@@ -200,11 +199,7 @@ static int ndfc_chip_init(struct ndfc_controller *ndfc,
if (ret)
goto err;
- ret = parse_mtd_partitions(&ndfc->mtd, NULL, &ndfc->parts, 0);
- if (ret < 0)
- goto err;
-
- ret = mtd_device_register(&ndfc->mtd, ndfc->parts, ret);
+ ret = mtd_device_parse_register(&ndfc->mtd, NULL, 0, NULL, 0);
err:
of_node_put(flash_np);
--
1.7.5.3
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH 17/17] mtd: socrates_nand.c: use mtd_device_parse_register
2011-06-09 14:22 [PATCH 00/17] mtd: last pile of MTD partition cleanup patches Dmitry Eremin-Solenikov
` (17 preceding siblings ...)
2011-06-09 14:23 ` [PATCH 16/17] mtd: ndfc.c: " Dmitry Eremin-Solenikov
@ 2011-06-09 14:23 ` Dmitry Eremin-Solenikov
18 siblings, 0 replies; 27+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-09 14:23 UTC (permalink / raw)
To: linux-mtd; +Cc: David Woodhouse, dedekind1
Replace custom invocations of parse_mtd_partitions and mtd_device_register
with common mtd_device_parse_register call. This would bring: standard
handling of all errors, fallback to default partitions, etc.
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
drivers/mtd/nand/socrates_nand.c | 11 +----------
1 files changed, 1 insertions(+), 10 deletions(-)
diff --git a/drivers/mtd/nand/socrates_nand.c b/drivers/mtd/nand/socrates_nand.c
index b256491..e409d33 100644
--- a/drivers/mtd/nand/socrates_nand.c
+++ b/drivers/mtd/nand/socrates_nand.c
@@ -164,8 +164,6 @@ static int __devinit socrates_nand_probe(struct platform_device *ofdev)
struct mtd_info *mtd;
struct nand_chip *nand_chip;
int res;
- struct mtd_partition *partitions = NULL;
- int num_partitions = 0;
/* Allocate memory for the device structure (and zero it) */
host = kzalloc(sizeof(struct socrates_nand_host), GFP_KERNEL);
@@ -224,17 +222,10 @@ static int __devinit socrates_nand_probe(struct platform_device *ofdev)
goto out;
}
- num_partitions = parse_mtd_partitions(mtd, NULL, &partitions, 0);
- if (num_partitions < 0) {
- res = num_partitions;
- goto release;
- }
-
- res = mtd_device_register(mtd, partitions, num_partitions);
+ res = mtd_device_parse_register(mtd, NULL, 0, NULL, 0);
if (!res)
return res;
-release:
nand_release(mtd);
out:
--
1.7.5.3
^ permalink raw reply related [flat|nested] 27+ messages in thread