Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750870AbWBZUjJ (ORCPT ); Sun, 26 Feb 2006 15:39:09 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1750901AbWBZUjJ (ORCPT ); Sun, 26 Feb 2006 15:39:09 -0500 Received: from e4.ny.us.ibm.com ([32.97.182.144]:56482 "EHLO e4.ny.us.ibm.com") by vger.kernel.org with ESMTP id S1750870AbWBZUjI (ORCPT ); Sun, 26 Feb 2006 15:39:08 -0500 Subject: Re: [PATCH] powerpc: Fix mem= cmdline handling on arch/powerpc for !MULTIPLATFORM From: Dave Hansen To: Kumar Gala Cc: Paul Mackerras , linuxppc-dev@ozlabs.org, Linus Torvalds , linux-kernel@vger.kernel.org In-Reply-To: References: Content-Type: text/plain Date: Sun, 26 Feb 2006 12:38:54 -0800 Message-Id: <1140986335.8697.139.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.4.1 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1344 Lines: 34 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 - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/