From: Ian Campbell <icampbell@arcom.com>
To: Linux MTD Mailing List <linux-mtd@lists.infradead.org>
Subject: Re: I have a NOR and NAND flash chips
Date: 07 Aug 2003 12:18:50 +0100 [thread overview]
Message-ID: <1060255130.13706.65.camel@linuxdev.icampbell.arcom.cc> (raw)
In-Reply-To: <1060253567.25209.56.camel@passion.cambridge.redhat.com>
[-- Attachment #1: Type: text/plain, Size: 1237 bytes --]
> You just have to be aware
> that they'll get assigned numbers in the order they get registered,
> that's all.
A long while ago I submitted a patch which added a function
add_mtd_device_full which allowed you to request a specific minor
number. We use it to ensure SRAM is always minor 15, no matter how many
partitions are in the main flash array, which can make things easier on
the support guys, for documentation purposes etc.
I've attached it again since it may be of interest, since your map
driver could then register the flash at a specific device. I can see how
a add_mtd_partition_full which allowed you to specify a starting minor
number would be useful too, but I haven't needed it myself.
Ian.
--
Ian Campbell, Senior Design Engineer
Arcom, Clifton Road, Direct: +44 (0)1223 403 465
Cambridge CB1 7EA, United Kingdom Phone: +44 (0)1223 411 200
________________________________________________________________________
This email has been scanned for all viruses by the MessageLabs Email
Security System. For more information on a proactive email security
service working around the clock, around the globe, visit
http://www.messagelabs.com
________________________________________________________________________
[-- Attachment #2: mtd-add_full.patch --]
[-- Type: text/plain, Size: 3442 bytes --]
%patch
Index: q/drivers/mtd/mtdcore.c
===================================================================
--- q.orig/drivers/mtd/mtdcore.c Tue Aug 5 16:46:21 2003
+++ q/drivers/mtd/mtdcore.c Tue Aug 5 16:46:38 2003
@@ -36,30 +36,39 @@
static LIST_HEAD(mtd_notifiers);
/**
- * add_mtd_device - register an MTD device
+ * add_mtd_device_full - register an MTD device at a particular minor number
* @mtd: pointer to new MTD device info structure
+ * @minor: requested minor number. -1 to for the first free.
*
- * Add a device to the list of MTD devices present in the system, and
- * notify each currently active MTD 'user' of its arrival. Returns
- * zero on success or 1 on failure, which currently will only happen
- * if the number of present devices exceeds MAX_MTD_DEVICES (i.e. 16)
+ * Add a device to the list of MTD devices present in the system,
+ * and notifies each currently active MTD 'user' of its
+ * arrival. Returns zero on success or 1 on failure, which
+ * currently only occurs if the requested minor number has
+ * already been allocated or if minor exceeds MAX_MTD_DEVICES
+ * (i.e. 16)
*/
-
-int add_mtd_device(struct mtd_info *mtd)
+int add_mtd_device_full(struct mtd_info *mtd, int minor)
{
- int i;
-
down(&mtd_table_mutex);
- for (i=0; i < MAX_MTD_DEVICES; i++)
- if (!mtd_table[i]) {
+ if ( minor == -1 ) {
+ for (minor = 0; minor < MAX_MTD_DEVICES; minor++)
+ if (!mtd_table[minor])
+ break;
+ }
+
+ if ( minor >= MAX_MTD_DEVICES || minor < 0 || mtd_table[minor] ) {
+ up(&mtd_table_mutex);
+ return 1;
+ }
+
struct list_head *this;
- mtd_table[i] = mtd;
- mtd->index = i;
+ mtd_table[minor] = mtd;
+ mtd->index = minor;
mtd->usecount = 0;
- DEBUG(0, "mtd: Giving out device %d to %s\n",i, mtd->name);
+ DEBUG(0, "mtd: Giving out device %d to %s\n",minor, mtd->name);
/* No need to get a refcount on the module containing
the notifier, since we hold the mtd_table_mutex */
list_for_each(this, &mtd_notifiers) {
@@ -76,8 +85,18 @@
return 0;
}
- up(&mtd_table_mutex);
- return 1;
+/**
+ * add_mtd_device - register an MTD device
+ * @mtd: pointer to new MTD device info structure
+ *
+ * Add a device to the list of MTD devices present in the system, and
+ * notify each currently active MTD 'user' of its arrival. Returns
+ * zero on success or 1 on failure, which currently will only happen
+ * if the number of present devices exceeds MAX_MTD_DEVICES (i.e. 16)
+ */
+int add_mtd_device(struct mtd_info *mtd)
+{
+ return add_mtd_device_full(mtd, -1);
}
/**
@@ -288,6 +307,7 @@
EXPORT_SYMBOL(add_mtd_device);
+EXPORT_SYMBOL(add_mtd_device_full);
EXPORT_SYMBOL(del_mtd_device);
EXPORT_SYMBOL(get_mtd_device);
EXPORT_SYMBOL(put_mtd_device);
Index: q/include/linux/mtd/mtd.h
===================================================================
--- q.orig/include/linux/mtd/mtd.h Tue Aug 5 16:46:22 2003
+++ q/include/linux/mtd/mtd.h Tue Aug 5 16:46:38 2003
@@ -238,6 +238,7 @@
/* Kernel-side ioctl definitions */
extern int add_mtd_device(struct mtd_info *mtd);
+extern int add_mtd_device_full(struct mtd_info *mtd, int minor);
extern int del_mtd_device (struct mtd_info *mtd);
extern struct mtd_info *get_mtd_device(struct mtd_info *mtd, int num);
%diffstat
drivers/mtd/mtdcore.c | 52 +++++++++++++++++++++++++++++++++---------------
include/linux/mtd/mtd.h | 1
2 files changed, 37 insertions(+), 16 deletions(-)
prev parent reply other threads:[~2003-08-07 11:25 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-08-07 8:22 I have a NOR and NAND flash chips Marcos Lois Bermúdez
2003-08-07 10:52 ` David Woodhouse
2003-08-07 11:18 ` Ian Campbell [this message]
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=1060255130.13706.65.camel@linuxdev.icampbell.arcom.cc \
--to=icampbell@arcom.com \
--cc=linux-mtd@lists.infradead.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.