* [PATCH 1/2] lib/cmdline: add new function get_option_ull()
@ 2021-01-11 16:33 Wesley Zhao
2021-01-11 16:33 ` [PATCH 2/2] resource: Make it possible to reserve memory on 64bit platform Wesley Zhao
2021-01-11 17:22 ` [PATCH 1/2] lib/cmdline: add new function get_option_ull() Andy Shevchenko
0 siblings, 2 replies; 5+ messages in thread
From: Wesley Zhao @ 2021-01-11 16:33 UTC (permalink / raw)
To: akpm
Cc: andriy.shevchenko, keescook, tglx, kerneldev, nivedita, joe,
gpiccoli, aquini, gustavoars, zhaowei1102, ojeda, ndesaulniers,
linux-kernel, david, dan.j.williams, guohanjun, mchehab+huawei
From: "Wesley.Zhao" <zhaowei1102@thundersoft.com>
In the future we would pass the unsigned long long parameter
like(0x123456781234) in cmdline on the 64bit platform, so add a new
option parse function get_option_ull()
Signed-off-by: Wesley.Zhao <zhaowei1102@thundersoft.com>
---
include/linux/kernel.h | 1 +
lib/cmdline.c | 35 +++++++++++++++++++++++++++++++++++
2 files changed, 36 insertions(+)
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index f7902d8..5568133 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -348,6 +348,7 @@ extern __scanf(2, 0)
int vsscanf(const char *, const char *, va_list);
extern int get_option(char **str, int *pint);
+extern int get_option_ull(char **str, unsigned long long *pull);
extern char *get_options(const char *str, int nints, int *ints);
extern unsigned long long memparse(const char *ptr, char **retptr);
extern bool parse_option_str(const char *str, const char *option);
diff --git a/lib/cmdline.c b/lib/cmdline.c
index b390dd0..2d089a2 100644
--- a/lib/cmdline.c
+++ b/lib/cmdline.c
@@ -80,6 +80,41 @@ int get_option(char **str, int *pint)
EXPORT_SYMBOL(get_option);
/**
+ * get_option_ull - Parse unsigned long long from an option string
+ * @str: option string
+ * @pull: (output) unsigned long long value parsed from @str
+ *
+ * Read an unsigned long long from an option string; if available accept a subsequent
+ * comma as well.
+ *
+ * Return values:
+ * 0 - no ull in string
+ * 1 - ull found, no subsequent comma
+ * 2 - ull found including a subsequent comma
+ * 3 - hyphen found to denote a range
+ */
+
+int get_option_ull(char **str, unsigned long long *pull)
+{
+ char *cur = *str;
+
+ if (!cur || !(*cur))
+ return 0;
+ *pull = simple_strtoull(cur, str, 0);
+ if (cur == *str)
+ return 0;
+ if (**str == ',') {
+ (*str)++;
+ return 2;
+ }
+ if (**str == '-')
+ return 3;
+
+ return 1;
+}
+EXPORT_SYMBOL(get_option_ull);
+
+/**
* get_options - Parse a string into a list of integers
* @str: String to be parsed
* @nints: size of integer array
--
2.7.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] resource: Make it possible to reserve memory on 64bit platform
2021-01-11 16:33 [PATCH 1/2] lib/cmdline: add new function get_option_ull() Wesley Zhao
@ 2021-01-11 16:33 ` Wesley Zhao
2021-01-11 17:24 ` David Hildenbrand
2021-01-11 17:22 ` [PATCH 1/2] lib/cmdline: add new function get_option_ull() Andy Shevchenko
1 sibling, 1 reply; 5+ messages in thread
From: Wesley Zhao @ 2021-01-11 16:33 UTC (permalink / raw)
To: akpm
Cc: andriy.shevchenko, keescook, tglx, kerneldev, nivedita, joe,
gpiccoli, aquini, gustavoars, zhaowei1102, ojeda, ndesaulniers,
linux-kernel, david, dan.j.williams, guohanjun, mchehab+huawei
From: "Wesley.Zhao" <zhaowei1102@thundersoft.com>
For now "reserve=" is limitied to 32bit,not available on 64bit
platform,so we change the get_option() to get_option_ull(added in
patch: commit 4b6bfe96265e ("lib/cmdline: add new function
get_option_ull()"))
Signed-off-by: Wesley.Zhao <zhaowei1102@thundersoft.com>
---
kernel/resource.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/kernel/resource.c b/kernel/resource.c
index 833394f..ee2a0e5 100644
--- a/kernel/resource.c
+++ b/kernel/resource.c
@@ -1567,13 +1567,13 @@ static int __init reserve_setup(char *str)
static struct resource reserve[MAXRESERVE];
for (;;) {
- unsigned int io_start, io_num;
+ unsigned long long io_start, io_num;
int x = reserved;
struct resource *parent;
- if (get_option(&str, &io_start) != 2)
+ if (get_option_ull(&str, &io_start) != 2)
break;
- if (get_option(&str, &io_num) == 0)
+ if (get_option_ull(&str, &io_num) == 0)
break;
if (x < MAXRESERVE) {
struct resource *res = reserve + x;
--
2.7.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] lib/cmdline: add new function get_option_ull()
2021-01-11 16:33 [PATCH 1/2] lib/cmdline: add new function get_option_ull() Wesley Zhao
2021-01-11 16:33 ` [PATCH 2/2] resource: Make it possible to reserve memory on 64bit platform Wesley Zhao
@ 2021-01-11 17:22 ` Andy Shevchenko
1 sibling, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2021-01-11 17:22 UTC (permalink / raw)
To: Wesley Zhao
Cc: akpm, keescook, tglx, kerneldev, nivedita, joe, gpiccoli, aquini,
gustavoars, ojeda, ndesaulniers, linux-kernel, david,
dan.j.williams, guohanjun, mchehab+huawei
On Mon, Jan 11, 2021 at 08:33:17AM -0800, Wesley Zhao wrote:
> From: "Wesley.Zhao" <zhaowei1102@thundersoft.com>
>
> In the future we would pass the unsigned long long parameter
> like(0x123456781234) in cmdline on the 64bit platform, so add a new
> option parse function get_option_ull()
No negative numbers?
No test cases?
No user?
Please, address above.
Besides that, consider to deduplicate (like it's done in simple_strto*() family
of functions), so we don't have two implementation that are basically do the
same, only put result to a different type of variable.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] resource: Make it possible to reserve memory on 64bit platform
2021-01-11 16:33 ` [PATCH 2/2] resource: Make it possible to reserve memory on 64bit platform Wesley Zhao
@ 2021-01-11 17:24 ` David Hildenbrand
2021-01-11 18:03 ` Andy Shevchenko
0 siblings, 1 reply; 5+ messages in thread
From: David Hildenbrand @ 2021-01-11 17:24 UTC (permalink / raw)
To: Wesley Zhao, akpm
Cc: andriy.shevchenko, keescook, tglx, kerneldev, nivedita, joe,
gpiccoli, aquini, gustavoars, ojeda, linux-kernel,
dan.j.williams, guohanjun, mchehab+huawei
On 11.01.21 17:33, Wesley Zhao wrote:
> From: "Wesley.Zhao" <zhaowei1102@thundersoft.com>
>
> For now "reserve=" is limitied to 32bit,not available on 64bit
> platform,so we change the get_option() to get_option_ull(added in
> patch: commit 4b6bfe96265e ("lib/cmdline: add new function
> get_option_ull()"))
Curious, what's the target use case? (did not receive a cover letter,
maybe it's buried in there)
--
Thanks,
David / dhildenb
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] resource: Make it possible to reserve memory on 64bit platform
2021-01-11 17:24 ` David Hildenbrand
@ 2021-01-11 18:03 ` Andy Shevchenko
0 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2021-01-11 18:03 UTC (permalink / raw)
To: David Hildenbrand
Cc: Wesley Zhao, akpm, keescook, tglx, kerneldev, nivedita, joe,
gpiccoli, aquini, gustavoars, ojeda, linux-kernel,
dan.j.williams, guohanjun, mchehab+huawei
On Mon, Jan 11, 2021 at 06:24:35PM +0100, David Hildenbrand wrote:
> On 11.01.21 17:33, Wesley Zhao wrote:
> > From: "Wesley.Zhao" <zhaowei1102@thundersoft.com>
> >
> > For now "reserve=" is limitied to 32bit,not available on 64bit
> > platform,so we change the get_option() to get_option_ull(added in
> > patch: commit 4b6bfe96265e ("lib/cmdline: add new function
> > get_option_ull()"))
>
> Curious, what's the target use case? (did not receive a cover letter,
> maybe it's buried in there)
Oh, I didn't received neither cover letter nor patch 2!
To author: please, address comments to patch 1 along with (re)sending cover
letter and include every stakeholder to the entire series.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-01-11 18:04 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-11 16:33 [PATCH 1/2] lib/cmdline: add new function get_option_ull() Wesley Zhao
2021-01-11 16:33 ` [PATCH 2/2] resource: Make it possible to reserve memory on 64bit platform Wesley Zhao
2021-01-11 17:24 ` David Hildenbrand
2021-01-11 18:03 ` Andy Shevchenko
2021-01-11 17:22 ` [PATCH 1/2] lib/cmdline: add new function get_option_ull() Andy Shevchenko
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.