* [PATCH] mtd: phram: Make phram 64-bit compatible
@ 2013-10-02 16:42 Alexander Sverdlin
2013-10-04 22:02 ` Jörn Engel
2013-10-07 17:49 ` Brian Norris
0 siblings, 2 replies; 10+ messages in thread
From: Alexander Sverdlin @ 2013-10-02 16:42 UTC (permalink / raw)
To: linux-mtd, Joern Engel, David Woodhouse
mtd: phram: Make phram 64-bit compatible
phram was 32-bit limited by design. Machines are growing up, but phram
module is still useful. Update it. The patch is bigger than minimum,
because simple_strtoul() is obsolete.
Tested on MIPS64 and compile-tested for PPC (32 bit).
Signed-off-by: Alexander Sverdlin <alexander.sverdlin@nsn.com>
---
--- linux.orig/drivers/mtd/devices/phram.c
+++ linux/drivers/mtd/devices/phram.c
@@ -94,7 +94,7 @@ static void unregister_devices(void)
}
}
-static int register_device(char *name, unsigned long start, unsigned long len)
+static int register_device(char *name, phys_addr_t start, size_t len)
{
struct phram_mtd_list *new;
int ret = -ENOMEM;
@@ -141,35 +141,35 @@ out0:
return ret;
}
-static int ustrtoul(const char *cp, char **endp, unsigned int base)
+static int parse_num64(uint64_t *num64, char *token)
{
- unsigned long result = simple_strtoul(cp, endp, base);
+ size_t len;
+ int shift = 0;
+ int ret;
- switch (**endp) {
- case 'G':
- result *= 1024;
- case 'M':
- result *= 1024;
- case 'k':
- result *= 1024;
+ len = strlen(token);
/* By dwmw2 editorial decree, "ki", "Mi" or "Gi" are to be used. */
- if ((*endp)[1] == 'i')
- (*endp) += 2;
+ if (len > 2) {
+ if (token[len - 1] == 'i') {
+ switch (token[len - 2]) {
+ case 'G':
+ shift += 10;
+ case 'M':
+ shift += 10;
+ case 'k':
+ shift += 10;
+ token[len - 2] = 0;
+ break;
+ default:
+ return -EINVAL;
+ }
+ }
}
- return result;
-}
-
-static int parse_num32(uint32_t *num32, const char *token)
-{
- char *endp;
- unsigned long n;
- n = ustrtoul(token, &endp, 0);
- if (*endp)
- return -EINVAL;
+ ret = kstrtou64(token, 0, num64);
+ *num64 <<= shift;
- *num32 = n;
- return 0;
+ return ret;
}
static int parse_name(char **pname, const char *token)
@@ -209,19 +209,19 @@ static inline void kill_final_newline(ch
* This shall contain the module parameter if any. It is of the form:
* - phram=<device>,<address>,<size> for module case
* - phram.phram=<device>,<address>,<size> for built-in case
- * We leave 64 bytes for the device name, 12 for the address and 12 for the
+ * We leave 64 bytes for the device name, 20 for the address and 20 for the
* size.
* Example: phram.phram=rootfs,0xa0000000,512Mi
*/
-static __initdata char phram_paramline[64+12+12];
+static __initdata char phram_paramline[64 + 20 + 20];
static int __init phram_setup(const char *val)
{
- char buf[64+12+12], *str = buf;
+ char buf[64 + 20 + 20], *str = buf;
char *token[3];
char *name;
- uint32_t start;
- uint32_t len;
+ uint64_t start;
+ uint64_t len;
int i, ret;
if (strnlen(val, sizeof(buf)) >= sizeof(buf))
@@ -243,13 +243,13 @@ static int __init phram_setup(const char
if (ret)
return ret;
- ret = parse_num32(&start, token[1]);
+ ret = parse_num64(&start, token[1]);
if (ret) {
kfree(name);
parse_err("illegal start address\n");
}
- ret = parse_num32(&len, token[2]);
+ ret = parse_num64(&len, token[2]);
if (ret) {
kfree(name);
parse_err("illegal device length\n");
@@ -257,7 +257,7 @@ static int __init phram_setup(const char
ret = register_device(name, start, len);
if (!ret)
- pr_info("%s device: %#x at %#x\n", name, len, start);
+ pr_info("%s device: %#llx at %#llx\n", name, len, start);
else
kfree(name);
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] mtd: phram: Make phram 64-bit compatible
2013-10-02 16:42 [PATCH] mtd: phram: Make phram 64-bit compatible Alexander Sverdlin
@ 2013-10-04 22:02 ` Jörn Engel
2013-10-07 17:49 ` Brian Norris
1 sibling, 0 replies; 10+ messages in thread
From: Jörn Engel @ 2013-10-04 22:02 UTC (permalink / raw)
To: Alexander Sverdlin; +Cc: Joern Engel, linux-mtd, David Woodhouse
On Wed, 2 October 2013 18:42:29 +0200, Alexander Sverdlin wrote:
>
> mtd: phram: Make phram 64-bit compatible
>
> phram was 32-bit limited by design. Machines are growing up, but phram
> module is still useful. Update it. The patch is bigger than minimum,
> because simple_strtoul() is obsolete.
>
> Tested on MIPS64 and compile-tested for PPC (32 bit).
>
> Signed-off-by: Alexander Sverdlin <alexander.sverdlin@nsn.com>
Reviewed-by: Joern Engel <joern@logfs.org>
I quite like it.
Jörn
--
Antivirus is homeopathy for computers: This software was in contact with
malware in the past, so it’ll recognize other malware in the future.
$79
-- thegrugq
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] mtd: phram: Make phram 64-bit compatible
2013-10-07 17:49 ` Brian Norris
@ 2013-10-07 16:53 ` Jörn Engel
-1 siblings, 0 replies; 10+ messages in thread
From: Jörn Engel @ 2013-10-07 16:53 UTC (permalink / raw)
To: Brian Norris
Cc: Alexander Sverdlin, linux-mtd, Joern Engel, David Woodhouse,
Linux Kernel
On Mon, 7 October 2013 10:49:43 -0700, Brian Norris wrote:
>
> [After more research:] It looks like this topic may be the subject of
> some long-past flame wars. If I am digging up past demons, then I'd
> prefer to let sleeping Balrogs lie.
Most of the time it is obvious from context whether you want base-1000
or base-1024 numbers. So in the common case the extra letter is plain
annoying. In less common cases it matters a lot and lack of the extra
letter is rather irritating.
One possible solution would be to have three suffixes. Ki for
base-1024, Kd for base-1000 and K for "I don't care, you decide for
me". But I am sure that would simply cause another round of
flamewars.
It is not a hard technical problem. As a result, noone on this list
has the required expertise to solve it.
Jörn
--
Money can buy bandwidth, but latency is forever.
-- John R. Mashey
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] mtd: phram: Make phram 64-bit compatible
@ 2013-10-07 16:53 ` Jörn Engel
0 siblings, 0 replies; 10+ messages in thread
From: Jörn Engel @ 2013-10-07 16:53 UTC (permalink / raw)
To: Brian Norris
Cc: Joern Engel, Alexander Sverdlin, linux-mtd, David Woodhouse,
Linux Kernel
On Mon, 7 October 2013 10:49:43 -0700, Brian Norris wrote:
>
> [After more research:] It looks like this topic may be the subject of
> some long-past flame wars. If I am digging up past demons, then I'd
> prefer to let sleeping Balrogs lie.
Most of the time it is obvious from context whether you want base-1000
or base-1024 numbers. So in the common case the extra letter is plain
annoying. In less common cases it matters a lot and lack of the extra
letter is rather irritating.
One possible solution would be to have three suffixes. Ki for
base-1024, Kd for base-1000 and K for "I don't care, you decide for
me". But I am sure that would simply cause another round of
flamewars.
It is not a hard technical problem. As a result, noone on this list
has the required expertise to solve it.
Jörn
--
Money can buy bandwidth, but latency is forever.
-- John R. Mashey
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] mtd: phram: Make phram 64-bit compatible
2013-10-02 16:42 [PATCH] mtd: phram: Make phram 64-bit compatible Alexander Sverdlin
@ 2013-10-07 17:49 ` Brian Norris
2013-10-07 17:49 ` Brian Norris
1 sibling, 0 replies; 10+ messages in thread
From: Brian Norris @ 2013-10-07 17:49 UTC (permalink / raw)
To: Alexander Sverdlin; +Cc: linux-mtd, Joern Engel, David Woodhouse, Linux Kernel
+ LKML
On Wed, Oct 02, 2013 at 06:42:29PM +0200, Alexander Sverdlin wrote:
> mtd: phram: Make phram 64-bit compatible
>
> phram was 32-bit limited by design. Machines are growing up, but phram
> module is still useful. Update it. The patch is bigger than minimum,
> because simple_strtoul() is obsolete.
>
> Tested on MIPS64 and compile-tested for PPC (32 bit).
>
> Signed-off-by: Alexander Sverdlin <alexander.sverdlin@nsn.com>
Pushed to l2-mtd.git. Thanks!
Can this driver use the library memparse() function instead of
open-coding it?
[To answer myself:] I noticed this in drivers/mtd/devices/phram.c, which
prevents us from using memparse():
/* By dwmw2 editorial decree, "ki", "Mi" or "Gi" are to be used. */
Are we (MTD) holding a revolutionary position against the standard
kernel libraries, which recognize [KkMmGg] prefixes, but not [kMG]i
prefixes? Should we extend memparse() to accept either form? Or would
doing so simply pollute the library and not really satisfy anyone?
[After more research:] It looks like this topic may be the subject of
some long-past flame wars. If I am digging up past demons, then I'd
prefer to let sleeping Balrogs lie.
Brian
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] mtd: phram: Make phram 64-bit compatible
@ 2013-10-07 17:49 ` Brian Norris
0 siblings, 0 replies; 10+ messages in thread
From: Brian Norris @ 2013-10-07 17:49 UTC (permalink / raw)
To: Alexander Sverdlin; +Cc: Joern Engel, linux-mtd, David Woodhouse, Linux Kernel
+ LKML
On Wed, Oct 02, 2013 at 06:42:29PM +0200, Alexander Sverdlin wrote:
> mtd: phram: Make phram 64-bit compatible
>
> phram was 32-bit limited by design. Machines are growing up, but phram
> module is still useful. Update it. The patch is bigger than minimum,
> because simple_strtoul() is obsolete.
>
> Tested on MIPS64 and compile-tested for PPC (32 bit).
>
> Signed-off-by: Alexander Sverdlin <alexander.sverdlin@nsn.com>
Pushed to l2-mtd.git. Thanks!
Can this driver use the library memparse() function instead of
open-coding it?
[To answer myself:] I noticed this in drivers/mtd/devices/phram.c, which
prevents us from using memparse():
/* By dwmw2 editorial decree, "ki", "Mi" or "Gi" are to be used. */
Are we (MTD) holding a revolutionary position against the standard
kernel libraries, which recognize [KkMmGg] prefixes, but not [kMG]i
prefixes? Should we extend memparse() to accept either form? Or would
doing so simply pollute the library and not really satisfy anyone?
[After more research:] It looks like this topic may be the subject of
some long-past flame wars. If I am digging up past demons, then I'd
prefer to let sleeping Balrogs lie.
Brian
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] mtd: phram: Make phram 64-bit compatible
2013-10-07 17:49 ` Brian Norris
@ 2013-10-08 7:46 ` Alexander Sverdlin
-1 siblings, 0 replies; 10+ messages in thread
From: Alexander Sverdlin @ 2013-10-08 7:46 UTC (permalink / raw)
To: ext Brian Norris; +Cc: linux-mtd, Joern Engel, David Woodhouse, Linux Kernel
Hi!
On 10/07/2013 07:49 PM, ext Brian Norris wrote:
> Are we (MTD) holding a revolutionary position against the standard
> kernel libraries, which recognize [KkMmGg] prefixes, but not [kMG]i
> prefixes? Should we extend memparse() to accept either form? Or would
> doing so simply pollute the library and not really satisfy anyone?
I was also irritated re-inventing the wheel here, but the problem is --
millions of people out there have their startup scripts and uboot environments
for phram, who expect this just to work with the next kernel upgrade...
--
Best regards,
Alexander Sverdlin.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] mtd: phram: Make phram 64-bit compatible
@ 2013-10-08 7:46 ` Alexander Sverdlin
0 siblings, 0 replies; 10+ messages in thread
From: Alexander Sverdlin @ 2013-10-08 7:46 UTC (permalink / raw)
To: ext Brian Norris; +Cc: Joern Engel, linux-mtd, David Woodhouse, Linux Kernel
Hi!
On 10/07/2013 07:49 PM, ext Brian Norris wrote:
> Are we (MTD) holding a revolutionary position against the standard
> kernel libraries, which recognize [KkMmGg] prefixes, but not [kMG]i
> prefixes? Should we extend memparse() to accept either form? Or would
> doing so simply pollute the library and not really satisfy anyone?
I was also irritated re-inventing the wheel here, but the problem is --
millions of people out there have their startup scripts and uboot environments
for phram, who expect this just to work with the next kernel upgrade...
--
Best regards,
Alexander Sverdlin.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] mtd: phram: Make phram 64-bit compatible
2013-10-07 16:53 ` Jörn Engel
@ 2013-10-08 16:36 ` Geert Uytterhoeven
-1 siblings, 0 replies; 10+ messages in thread
From: Geert Uytterhoeven @ 2013-10-08 16:36 UTC (permalink / raw)
To: Jörn Engel
Cc: Brian Norris, Alexander Sverdlin, MTD Maling List, Joern Engel,
David Woodhouse, Linux Kernel
On Mon, Oct 7, 2013 at 6:53 PM, Jörn Engel <joern@logfs.org> wrote:
> One possible solution would be to have three suffixes. Ki for
> base-1024, Kd for base-1000 and K for "I don't care, you decide for
> me". But I am sure that would simply cause another round of
> flamewars.
Indeed. Why deviate from SI with "Kd" (a new invention)??
That should just be "k".
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] mtd: phram: Make phram 64-bit compatible
@ 2013-10-08 16:36 ` Geert Uytterhoeven
0 siblings, 0 replies; 10+ messages in thread
From: Geert Uytterhoeven @ 2013-10-08 16:36 UTC (permalink / raw)
To: Jörn Engel
Cc: Joern Engel, Linux Kernel, Alexander Sverdlin, MTD Maling List,
Brian Norris, David Woodhouse
On Mon, Oct 7, 2013 at 6:53 PM, Jörn Engel <joern@logfs.org> wrote:
> One possible solution would be to have three suffixes. Ki for
> base-1024, Kd for base-1000 and K for "I don't care, you decide for
> me". But I am sure that would simply cause another round of
> flamewars.
Indeed. Why deviate from SI with "Kd" (a new invention)??
That should just be "k".
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2013-10-08 16:36 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-02 16:42 [PATCH] mtd: phram: Make phram 64-bit compatible Alexander Sverdlin
2013-10-04 22:02 ` Jörn Engel
2013-10-07 17:49 ` Brian Norris
2013-10-07 17:49 ` Brian Norris
2013-10-07 16:53 ` Jörn Engel
2013-10-07 16:53 ` Jörn Engel
2013-10-08 16:36 ` Geert Uytterhoeven
2013-10-08 16:36 ` Geert Uytterhoeven
2013-10-08 7:46 ` Alexander Sverdlin
2013-10-08 7:46 ` Alexander Sverdlin
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.