From: Ian Campbell <icampbell@arcomcontrols.com>
To: Linux MTD Mailing List <linux-mtd@lists.infradead.org>
Cc: David Woodhouse <dwmw2@infradead.org>
Subject: [PATCH] Add a map_sram driver to drivers/chips/
Date: 12 Nov 2002 11:05:25 +0000 [thread overview]
Message-ID: <1037099125.26491.81.camel@LinuxDev> (raw)
[-- Attachment #1: Type: text/plain, Size: 1194 bytes --]
Howdy,
The attached patch adds "map_sram" as a second chip driver in
drivers/mtd/chips/map_ram.c. The two are basically identical apart from
the use of the MTD_VOLATILE flag.
I have another patch which makes an entirely separate map_sram.c, but
there was so much code duplication with map_ram.c I didn't see the
point. I guess if you are using modules then you will need 'alias
map_sram map_ram' in /etc/modules.conf or something to get autoloading
to work.
The patch also includes a previous patch to set the state to
MTD_ERASE_DONE in mapram_erase. This is needed to mount a JFFS2 f/s on
an SRAM or RAM device.
Cheers,
Ian.
--
Ian Campbell
Design Engineer
Arcom Control Systems Ltd,
Clifton Road,
Cambridge CB1 7EA
United Kingdom
Tel: +44 (0)1223 403465
E-Mail: icampbell@arcomcontrols.com
Web: http://www.arcomcontrols.com
________________________________________________________________________
This email has been scanned for all viruses by the MessageLabs SkyScan
service. For more information on a proactive anti-virus service working
around the clock, around the globe, visit http://www.messagelabs.com
________________________________________________________________________
[-- Attachment #2: mtd.map_sram-2.patch --]
[-- Type: text/x-patch, Size: 3370 bytes --]
diff -urN kernel-2.4.18.orig/include/linux/mtd/mtd.h kernel-2.4.18/include/linux/mtd/mtd.h
--- kernel-2.4.18.orig/include/linux/mtd/mtd.h Tue Jun 12 18:30:27 2001
+++ kernel-2.4.18/include/linux/mtd/mtd.h Wed Nov 6 14:05:30 2002
@@ -39,5 +39,6 @@
#define MTD_NORFLASH 3
#define MTD_NANDFLASH 4
#define MTD_PEROM 5
+#define MTD_SRAM 6
#define MTD_OTHER 14
#define MTD_UNKNOWN 15
diff -urN kernel-2.4.18.orig/drivers/mtd/chips/Config.in kernel-2.4.18/drivers/mtd/chips/Config.in
--- kernel-2.4.18.orig/drivers/mtd/chips/Config.in Thu Oct 4 23:13:18 2001
+++ kernel-2.4.18/drivers/mtd/chips/Config.in Tue Nov 12 10:29:27 2002
@@ -44,7 +44,7 @@
dep_tristate ' Support for Intel/Sharp flash chips' CONFIG_MTD_CFI_INTELEXT $CONFIG_MTD_GEN_PROBE
dep_tristate ' Support for AMD/Fujitsu flash chips' CONFIG_MTD_CFI_AMDSTD $CONFIG_MTD_GEN_PROBE
-dep_tristate ' Support for RAM chips in bus mapping' CONFIG_MTD_RAM $CONFIG_MTD
+dep_tristate ' Support for RAM/SRAM chips in bus mapping' CONFIG_MTD_RAM $CONFIG_MTD
dep_tristate ' Support for ROM chips in bus mapping' CONFIG_MTD_ROM $CONFIG_MTD
dep_tristate ' Support for absent chips in bus mapping' CONFIG_MTD_ABSENT $CONFIG_MTD
diff -urN kernel-2.4.18.orig/drivers/mtd/chips/map_ram.c kernel-2.4.18/drivers/mtd/chips/map_ram.c
--- kernel-2.4.18.orig/drivers/mtd/chips/map_ram.c Thu Oct 4 23:14:59 2001
+++ kernel-2.4.18/drivers/mtd/chips/map_ram.c Tue Nov 12 10:52:11 2002
@@ -20,6 +20,7 @@
static int mapram_erase (struct mtd_info *, struct erase_info *);
static void mapram_nop (struct mtd_info *);
static struct mtd_info *map_ram_probe(struct map_info *map);
+static struct mtd_info *map_sram_probe(struct map_info *map);
static struct mtd_chip_driver mapram_chipdrv = {
@@ -27,6 +28,11 @@
name: "map_ram",
module: THIS_MODULE
};
+static struct mtd_chip_driver mapsram_chipdrv = {
+ probe: map_sram_probe,
+ name: "map_sram",
+ module: THIS_MODULE
+};
static struct mtd_info *map_ram_probe(struct map_info *map)
{
@@ -78,6 +84,34 @@
return mtd;
}
+static struct mtd_info *map_sram_probe(struct map_info *map)
+{
+ struct mtd_info *mtd;
+
+ mtd = kmalloc(sizeof(*mtd), GFP_KERNEL);
+ if (!mtd)
+ return NULL;
+
+ memset(mtd, 0, sizeof(*mtd));
+
+ map->fldrv = &mapram_chipdrv;
+ mtd->priv = map;
+ mtd->name = map->name;
+ mtd->type = MTD_SRAM;
+ mtd->size = map->size;
+ mtd->erase = mapram_erase;
+ mtd->read = mapram_read;
+ mtd->write = mapram_write;
+ mtd->sync = mapram_nop;
+ mtd->flags = MTD_CAP_RAM;
+
+ mtd->erasesize = PAGE_SIZE;
+ while(mtd->size & (mtd->erasesize - 1))
+ mtd->erasesize >>= 1;
+
+ MOD_INC_USE_COUNT;
+ return mtd;
+}
static int mapram_read (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf)
{
@@ -107,6 +141,8 @@
for (i=0; i<instr->len; i++)
map->write8(map, 0xFF, instr->addr + i);
+ instr->state = MTD_ERASE_DONE;
+
if (instr->callback)
instr->callback(instr);
@@ -121,12 +157,14 @@
int __init map_ram_init(void)
{
register_mtd_chip_driver(&mapram_chipdrv);
+ register_mtd_chip_driver(&mapsram_chipdrv);
return 0;
}
static void __exit map_ram_exit(void)
{
unregister_mtd_chip_driver(&mapram_chipdrv);
+ unregister_mtd_chip_driver(&mapsram_chipdrv);
}
module_init(map_ram_init);
next reply other threads:[~2002-11-12 10:35 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-11-12 11:05 Ian Campbell [this message]
2002-11-12 16:02 ` [PATCH] Add a map_sram driver to drivers/chips/ Jörn Engel
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=1037099125.26491.81.camel@LinuxDev \
--to=icampbell@arcomcontrols.com \
--cc=dwmw2@infradead.org \
--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.