Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 27737
b: refs/heads/master
c: 954c242
h: refs/heads/master
i:
  27735: 55fb52c
v: v3
  • Loading branch information
Joern Engel authored and David Woodhouse committed Apr 19, 2006
1 parent 122c48e commit 292ade6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 373d5e71833978fe3d91264d86857762bb92cfe2
refs/heads/master: 954c24227318c166ec1925e1229db442e1f56f51
17 changes: 14 additions & 3 deletions trunk/drivers/mtd/devices/block2mtd.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* block2mtd.c - create an mtd from a block device
*
* Copyright (C) 2001,2002 Simon Evans <spse@secret.org.uk>
* Copyright (C) 2004,2005 Jörn Engel <joern@wh.fh-wedel.de>
* Copyright (C) 2004-2006 Jörn Engel <joern@wh.fh-wedel.de>
*
* Licence: GPL
*/
Expand Down Expand Up @@ -351,6 +351,12 @@ static struct block2mtd_dev *add_device(char *devname, int erase_size)
}


/* This function works similar to reguler strtoul. In addition, it
* allows some suffixes for a more human-readable number format:
* ki, Ki, kiB, KiB - multiply result with 1024
* Mi, MiB - multiply result with 1024^2
* Gi, GiB - multiply result with 1024^3
*/
static int ustrtoul(const char *cp, char **endp, unsigned int base)
{
unsigned long result = simple_strtoul(cp, endp, base);
Expand All @@ -359,11 +365,16 @@ static int ustrtoul(const char *cp, char **endp, unsigned int base)
result *= 1024;
case 'M':
result *= 1024;
case 'K':
case 'k':
result *= 1024;
/* By dwmw2 editorial decree, "ki", "Mi" or "Gi" are to be used. */
if ((*endp)[1] == 'i')
(*endp) += 2;
if ((*endp)[1] == 'i') {
if ((*endp)[2] == 'B')
(*endp) += 3;
else
(*endp) += 2;
}
}
return result;
}
Expand Down

0 comments on commit 292ade6

Please sign in to comment.