Commit 4b74271f authored by David Woodhouse's avatar David Woodhouse

MTD: Make phram work again

o Add simple usage example.
o Fix up unit handling (k, M. G).
o Use correct size limit for setup string.
o Remove pointless printk message.
o Fix mtdblock to not allocate a read-modify-write buffer for CAP_RAM
  devices (and fail to do so, returning an error).
Signed-off-by: default avatarJörn Engel <joern@wohnheim.fh-wedel.de>
Signed-off-by: default avatarDavid Woodhouse <dwmw2@infradead.org>
parent 7ae4b1e9
/**
*
* $Id: phram.c,v 1.3 2004/11/16 18:29:01 dwmw2 Exp $
* $Id: phram.c,v 1.6 2004/11/25 16:51:09 joern Exp $
*
* Copyright (c) Jochen Schaeuble <psionic@psionic.de>
* 07/2003 rewritten by Joern Engel <joern@wh.fh-wedel.de>
......@@ -15,9 +15,12 @@
* phram=<name>,<start>,<len>
* <name> may be up to 63 characters.
* <start> and <len> can be octal, decimal or hexadecimal. If followed
* by "k", "M" or "G", the numbers will be interpreted as kilo, mega or
* by "ki", "Mi" or "Gi", the numbers will be interpreted as kilo, mega or
* gigabytes.
*
* Example:
* phram=swap,896Mi,110Mi phram=test,1006Mi,1Mi
*
*/
#include <asm/io.h>
......@@ -184,7 +187,9 @@ static int ustrtoul(const char *cp, char **endp, unsigned int base)
result *= 1024;
case 'k':
result *= 1024;
endp++;
/* By dwmw2 editorial decree, "ki", "Mi" or "Gi" are to be used. */
if ((*endp)[1] == 'i')
(*endp) += 2;
}
return result;
}
......@@ -235,7 +240,7 @@ static int phram_setup(const char *val, struct kernel_param *kp)
uint32_t len;
int i, ret;
if (strnlen(val, sizeof(str)) >= sizeof(str))
if (strnlen(val, sizeof(buf)) >= sizeof(buf))
parse_err("parameter too long\n");
strcpy(str, val);
......@@ -283,7 +288,7 @@ static int __init slram_setup(const char *val, struct kernel_param *kp)
if (!val || !val[0])
parse_err("no arguments to \"slram=\"\n");
if (strnlen(val, sizeof(str)) >= sizeof(str))
if (strnlen(val, sizeof(buf)) >= sizeof(buf))
parse_err("parameter too long\n");
strcpy(str, val);
......@@ -342,7 +347,6 @@ MODULE_PARM_DESC(slram, "List of memory regions to map. \"map=<name>,<start><len
static int __init init_phram(void)
{
printk(KERN_ERR "phram loaded\n");
return 0;
}
......
/*
* Direct MTD block device access
*
* $Id: mtdblock.c,v 1.65 2004/11/16 18:28:59 dwmw2 Exp $
* $Id: mtdblock.c,v 1.66 2004/11/25 13:52:52 joern Exp $
*
* (C) 2000-2003 Nicolas Pitre <nico@cam.org>
* (C) 1999-2003 David Woodhouse <dwmw2@infradead.org>
......@@ -248,7 +248,7 @@ static int mtdblock_writesect(struct mtd_blktrans_dev *dev,
unsigned long block, char *buf)
{
struct mtdblk_dev *mtdblk = mtdblks[dev->devnum];
if (unlikely(!mtdblk->cache_data)) {
if (unlikely(!mtdblk->cache_data && mtdblk->cache_size)) {
mtdblk->cache_data = vmalloc(mtdblk->mtd->erasesize);
if (!mtdblk->cache_data)
return -EINTR;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment