Alpha arch development list
 help / color / mirror / Atom feed
From: Magnus Lindholm <linmag7@gmail.com>
To: richard.henderson@linaro.org, mattst88@gmail.com,
	linux-kernel@vger.kernel.org, linux-alpha@vger.kernel.org
Cc: linmag7@gmail.com
Subject: [PATCH 12/14] alpha: use memparse for memory size options
Date: Tue,  3 Nov 2026 22:35:18 +0100	[thread overview]
Message-ID: <20261103214120.1099893-13-linmag7@gmail.com> (raw)
In-Reply-To: <20261103214120.1099893-1-linmag7@gmail.com>

Replace the private parser for mem= and gartsize= with memparse(),
preserving page rounding. This also accepts T/P/E suffixes and uses
memparse()'s saturating overflow handling.

Signed-off-by: Magnus Lindholm <linmag7@gmail.com>
---
 arch/alpha/kernel/setup.c | 24 ++----------------------
 1 file changed, 2 insertions(+), 22 deletions(-)

diff --git a/arch/alpha/kernel/setup.c b/arch/alpha/kernel/setup.c
index 4cbcfb1852d51e7aaf37b01a176f4a4280af6dae..28387786cb9f9ad4b587a22a3b0267b825b424c7 100644
--- a/arch/alpha/kernel/setup.c
+++ b/arch/alpha/kernel/setup.c
@@ -241,26 +241,6 @@ reserve_std_resources(void)
 	for ((_cluster) = (memdesc)->cluster, (i) = 0;		\
 	     (i) < (memdesc)->numclusters; (i)++, (_cluster)++)
 
-static unsigned long __init
-get_mem_size_limit(char *s)
-{
-        unsigned long end = 0;
-        char *from = s;
-
-        end = simple_strtoul(from, &from, 0);
-        if ( *from == 'K' || *from == 'k' ) {
-                end = end << 10;
-                from++;
-        } else if ( *from == 'M' || *from == 'm' ) {
-                end = end << 20;
-                from++;
-        } else if ( *from == 'G' || *from == 'g' ) {
-                end = end << 30;
-                from++;
-        }
-        return end >> PAGE_SHIFT; /* Return the PFN of the limit. */
-}
-
 #ifdef CONFIG_BLK_DEV_INITRD
 void * __init
 move_initrd(unsigned long mem_limit)
@@ -486,7 +466,7 @@ setup_arch(char **cmdline_p)
 			continue;
 		}
 		if (strncmp(p, "mem=", 4) == 0) {
-			mem_size_limit = get_mem_size_limit(p+4);
+			mem_size_limit = memparse(p + 4, NULL) >> PAGE_SHIFT;
 			continue;
 		}
 		if (strncmp(p, "srmcons", 7) == 0) {
@@ -499,7 +479,7 @@ setup_arch(char **cmdline_p)
 		}
 		if (strncmp(p, "gartsize=", 9) == 0) {
 			alpha_agpgart_size =
-				get_mem_size_limit(p+9) << PAGE_SHIFT;
+				memparse(p + 9, NULL) & PAGE_MASK;
 			continue;
 		}
 #ifdef CONFIG_VERBOSE_MCHECK
-- 
2.43.0


  parent reply	other threads:[~2026-11-03 21:43 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-03 21:35 [PATCH 00/14] alpha: fix entry bugs and consolidate generic helpers Magnus Lindholm
2026-11-03 21:35 ` [PATCH 01/14] alpha: fix saved registers in page-fault oops dumps Magnus Lindholm
2026-11-03 21:35 ` [PATCH 02/14] alpha: report syscall errors correctly to audit Magnus Lindholm
2026-11-03 21:35 ` [PATCH 03/14] alpha: preserve rolled-back registers for SIGSYS Magnus Lindholm
2026-11-03 21:35 ` [PATCH 04/14] alpha: fix syscall restart eligibility Magnus Lindholm
2026-11-03 21:35 ` [PATCH 05/14] alpha: distinguish skipped syscalls from invalid numbers Magnus Lindholm
2026-11-03 21:35 ` [PATCH 06/14] alpha: dispatch system calls from C Magnus Lindholm
2026-11-03 21:35 ` [PATCH 07/14] alpha: use generic entry helpers for interrupts and exceptions Magnus Lindholm
2026-11-03 21:35 ` [PATCH 08/14] alpha: use generic syscall exit for new tasks Magnus Lindholm
2026-11-03 21:35 ` [PATCH 09/14] alpha: remove obsolete core dump register hooks Magnus Lindholm
2026-11-03 21:35 ` [PATCH 10/14] alpha: use generic syscall audit classification Magnus Lindholm
2026-11-03 21:35 ` [PATCH 11/14] alpha: use generic ptrace memory writes Magnus Lindholm
2026-11-03 21:35 ` Magnus Lindholm [this message]
2026-11-03 21:35 ` [PATCH 13/14] alpha: use generic getrusage for OSF resource accounting Magnus Lindholm
2026-11-03 21:35 ` [PATCH 14/14] alpha: use generic CPU device registration Magnus Lindholm
2026-11-04 19:35 ` [PATCH 00/14] alpha: fix entry bugs and consolidate generic helpers Matt Turner

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=20261103214120.1099893-13-linmag7@gmail.com \
    --to=linmag7@gmail.com \
    --cc=linux-alpha@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mattst88@gmail.com \
    --cc=richard.henderson@linaro.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox