From: "Sudhakar Rajashekhara" <sudhakar.raj@ti.com>
To: "'David Woodhouse'" <dwmw2@infradead.org>
Cc: 'Bernd Schmidt' <bernd.schmidt@analog.com>,
'David Brownell' <david-b@pacbell.net>,
'David Brownell' <dbrownell@users.sourceforge.net>,
'Nicolas Pitre' <nico@fluxnic.net>,
'Kevin Hilman' <khilman@deeprootsystems.com>,
linux-kernel@vger.kernel.org,
'David Howells' <dhowells@redhat.com>,
linux-mtd@lists.infradead.org,
'Andrew Morton' <akpm@linux-foundation.org>
Subject: RE: [PATCH 1/2] mtdpart: memory accessor interface for MTD layer
Date: Mon, 9 Aug 2010 17:25:13 +0530 [thread overview]
Message-ID: <006e01cb37b9$b9d25d80$2d771880$@raj@ti.com> (raw)
In-Reply-To: <1281270198.19967.258.camel@macbook.infradead.org>
Hi David,
On Sun, Aug 08, 2010 at 17:53:18, David Woodhouse wrote:
> On Fri, 2010-08-06 at 12:18 +0530, Sudhakar Rajashekhara wrote:
> >
> > Thanks for the feedback. I'll be re-working on this patch and will
> > re-post
> > the updated patch soon.
>
> Start with this, perhaps...
>
> Subject: mtd/partitions: Add add_mtd_partitions_ret() function
>
> Some callers want access to the MTD devices which get registered for
> them when they call add_mtd_partitions(). Add a variant on the function
> which does that.
>
> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
>
> diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c
> index 4c539de..b9ee79b 100644
> --- a/drivers/mtd/mtdpart.c
> +++ b/drivers/mtd/mtdpart.c
> @@ -522,26 +522,36 @@ out_register:
> * for reasons of data integrity.
> */
>
> -int add_mtd_partitions(struct mtd_info *master,
> - const struct mtd_partition *parts,
> - int nbparts)
> +int add_mtd_partitions_ret(struct mtd_info *master,
> + const struct mtd_partition *parts,
> + int nbparts, struct mtd_info ***mtds_ret)
> {
> struct mtd_part *slave;
> uint64_t cur_offset = 0;
> + struct mtd_info **mtds = NULL;
> int i;
>
> printk(KERN_NOTICE "Creating %d MTD partitions on \"%s\":\n", nbparts, master->name);
>
> + if (mtds_ret) {
> + mtds = kmalloc(sizeof(*mtds) * nbparts, GFP_KERNEL);
> + if (!mtds)
> + return -ENOMEM;
> + }
> for (i = 0; i < nbparts; i++) {
> slave = add_one_partition(master, parts + i, i, cur_offset);
> - if (!slave)
> + if (!slave) {
> + kfree(mtds);
> return -ENOMEM;
> + }
> cur_offset = slave->offset + slave->mtd.size;
> }
>
> + if (mtds_ret)
> + *mtds_ret = mtds;
> return 0;
> }
> -EXPORT_SYMBOL(add_mtd_partitions);
> +EXPORT_SYMBOL_GPL(add_mtd_partitions_ret);
>
> static DEFINE_SPINLOCK(part_parser_lock);
> static LIST_HEAD(part_parsers);
> diff --git a/include/linux/mtd/partitions.h b/include/linux/mtd/partitions.h
> index 274b619..f7935fa 100644
> --- a/include/linux/mtd/partitions.h
> +++ b/include/linux/mtd/partitions.h
> @@ -49,9 +49,12 @@ struct mtd_partition {
>
> struct mtd_info;
>
> -int add_mtd_partitions(struct mtd_info *, const struct mtd_partition *, int);
> +int add_mtd_partitions_ret(struct mtd_info *, const struct mtd_partition *, int,
> + struct mtd_info ***);
> int del_mtd_partitions(struct mtd_info *);
>
> +#define add_mtd_partitions(m, p, n) add_mtd_partitions_ret(m, p, n, NULL)
> +
> /*
> * Functions dealing with the various ways of partitioning the space
> */
>
> --
Thanks very much for this piece of code, it reduced my work. But while working
on this, I found out that, for m25p80 device, the MTD device is available even
for the add_mtd_partitions() case. So the method to read the MAC address remains
same both for un-partitioned and partitioned MTD device. I'll post the modified
patch tomorrow. I'll be looking forward to hearing your comments on that patch
as well.
Thanks,
Sudhakar
next prev parent reply other threads:[~2010-08-09 12:00 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-16 20:41 [PATCH 1/2] mtdpart: memory accessor interface for MTD layer Kevin Hilman
2010-04-08 8:10 ` Artem Bityutskiy
2010-05-13 23:50 ` David Woodhouse
2010-07-07 10:56 ` Sudhakar Rajashekhara
2010-07-07 11:08 ` David Brownell
2010-07-08 15:10 ` Sudhakar Rajashekhara
2010-07-08 16:00 ` David Brownell
2010-08-04 10:12 ` David Woodhouse
2010-08-04 10:31 ` David Brownell
2010-08-04 11:08 ` David Woodhouse
2010-08-04 11:27 ` David Brownell
2010-08-06 6:48 ` Sudhakar Rajashekhara
2010-08-08 12:23 ` David Woodhouse
2010-08-09 11:55 ` Sudhakar Rajashekhara [this message]
-- strict thread matches above, loose matches on Subject: below --
2010-10-01 21:16 [patch " akpm
2010-10-02 14:09 ` Artem Bityutskiy
2010-10-02 14:44 ` David Woodhouse
2010-10-04 14:28 ` Sudhakar Rajashekhara
2010-10-02 19:09 ` Andrew Morton
2010-10-20 22:59 akpm
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='006e01cb37b9$b9d25d80$2d771880$@raj@ti.com' \
--to=sudhakar.raj@ti.com \
--cc=akpm@linux-foundation.org \
--cc=bernd.schmidt@analog.com \
--cc=david-b@pacbell.net \
--cc=dbrownell@users.sourceforge.net \
--cc=dhowells@redhat.com \
--cc=dwmw2@infradead.org \
--cc=khilman@deeprootsystems.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=nico@fluxnic.net \
/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).