All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dave Hansen <haveblue@us.ibm.com>
To: Kumar Gala <galak@kernel.crashing.org>
Cc: linuxppc-dev@ozlabs.org, Linus Torvalds <torvalds@osdl.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] powerpc: Fix mem= cmdline handling on arch/powerpc for !MULTIPLATFORM
Date: Sun, 26 Feb 2006 12:38:54 -0800	[thread overview]
Message-ID: <1140986335.8697.139.camel@localhost.localdomain> (raw)
In-Reply-To: <Pine.LNX.4.44.0602241054090.2981-100000@gate.crashing.org>

On Fri, 2006-02-24 at 10:54 -0600, Kumar Gala wrote:
> +       if (strstr(cmd_line, "mem=")) {
> +               char *p, *q;
> +               unsigned long maxmem = 0;
> +
> +               for (q = cmd_line; (p = strstr(q, "mem=")) != 0; ) {
> +                       q = p + 4;
> +                       if (p > cmd_line && p[-1] != ' ')
> +                               continue;
> +                       maxmem = simple_strtoul(q, &q, 0);
> +                       if (*q == 'k' || *q == 'K') {
> +                               maxmem <<= 10;
> +                               ++q;
> +                       } else if (*q == 'm' || *q == 'M') {
> +                               maxmem <<= 20;
> +                               ++q;
> +                       } else if (*q == 'g' || *q == 'G') {
> +                               maxmem <<= 30;
> +                               ++q;
> +                       }
> +               }
> +               memory_limit = maxmem;
> +       } 

You may want to check out lib/cmdline.c's memparse() function.  I think
it does this for you.

-- Dave

WARNING: multiple messages have this Message-ID (diff)
From: Dave Hansen <haveblue@us.ibm.com>
To: Kumar Gala <galak@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>,
	linuxppc-dev@ozlabs.org, Linus Torvalds <torvalds@osdl.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] powerpc: Fix mem= cmdline handling on arch/powerpc for !MULTIPLATFORM
Date: Sun, 26 Feb 2006 12:38:54 -0800	[thread overview]
Message-ID: <1140986335.8697.139.camel@localhost.localdomain> (raw)
In-Reply-To: <Pine.LNX.4.44.0602241054090.2981-100000@gate.crashing.org>

On Fri, 2006-02-24 at 10:54 -0600, Kumar Gala wrote:
> +       if (strstr(cmd_line, "mem=")) {
> +               char *p, *q;
> +               unsigned long maxmem = 0;
> +
> +               for (q = cmd_line; (p = strstr(q, "mem=")) != 0; ) {
> +                       q = p + 4;
> +                       if (p > cmd_line && p[-1] != ' ')
> +                               continue;
> +                       maxmem = simple_strtoul(q, &q, 0);
> +                       if (*q == 'k' || *q == 'K') {
> +                               maxmem <<= 10;
> +                               ++q;
> +                       } else if (*q == 'm' || *q == 'M') {
> +                               maxmem <<= 20;
> +                               ++q;
> +                       } else if (*q == 'g' || *q == 'G') {
> +                               maxmem <<= 30;
> +                               ++q;
> +                       }
> +               }
> +               memory_limit = maxmem;
> +       } 

You may want to check out lib/cmdline.c's memparse() function.  I think
it does this for you.

-- Dave


  parent reply	other threads:[~2006-02-26 20:39 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-02-24 16:54 [PATCH] powerpc: Fix mem= cmdline handling on arch/powerpc for !MULTIPLATFORM Kumar Gala
2006-02-24 16:54 ` Kumar Gala
2006-02-24 21:04 ` Segher Boessenkool
2006-02-24 21:04   ` Segher Boessenkool
2006-02-24 22:27 ` Michael Ellerman
2006-02-24 22:27   ` Michael Ellerman
2006-02-24 22:43   ` Kumar Gala
2006-02-24 22:43     ` Kumar Gala
2006-02-24 23:14     ` [PATCH][UPDATE] " Kumar Gala
2006-02-24 23:14       ` Kumar Gala
2006-02-24 23:25     ` [PATCH] " Michael Ellerman
2006-02-24 23:25       ` Michael Ellerman
2006-02-24 23:18       ` Kumar Gala
2006-02-24 23:18         ` Kumar Gala
2006-02-25  0:12         ` Michael Ellerman
2006-02-25  0:12           ` Michael Ellerman
2006-02-26 20:38 ` Dave Hansen [this message]
2006-02-26 20:38   ` Dave Hansen
2006-02-27 16:12   ` Kumar Gala
2006-02-27 16:12     ` Kumar Gala

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=1140986335.8697.139.camel@localhost.localdomain \
    --to=haveblue@us.ibm.com \
    --cc=galak@kernel.crashing.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=torvalds@osdl.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.