diff options
Diffstat (limited to 'include/linux/kernel.h')
-rw-r--r-- | include/linux/kernel.h | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/include/linux/kernel.h b/include/linux/kernel.h index d97ed5897447..d140e8fb075f 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h | |||
@@ -220,6 +220,23 @@ int __must_check _kstrtol(const char *s, unsigned int base, long *res); | |||
220 | 220 | ||
221 | int __must_check kstrtoull(const char *s, unsigned int base, unsigned long long *res); | 221 | int __must_check kstrtoull(const char *s, unsigned int base, unsigned long long *res); |
222 | int __must_check kstrtoll(const char *s, unsigned int base, long long *res); | 222 | int __must_check kstrtoll(const char *s, unsigned int base, long long *res); |
223 | |||
224 | /** | ||
225 | * kstrtoul - convert a string to an unsigned long | ||
226 | * @s: The start of the string. The string must be null-terminated, and may also | ||
227 | * include a single newline before its terminating null. The first character | ||
228 | * may also be a plus sign, but not a minus sign. | ||
229 | * @base: The number base to use. The maximum supported base is 16. If base is | ||
230 | * given as 0, then the base of the string is automatically detected with the | ||
231 | * conventional semantics - If it begins with 0x the number will be parsed as a | ||
232 | * hexadecimal (case insensitive), if it otherwise begins with 0, it will be | ||
233 | * parsed as an octal number. Otherwise it will be parsed as a decimal. | ||
234 | * @res: Where to write the result of the conversion on success. | ||
235 | * | ||
236 | * Returns 0 on success, -ERANGE on overflow and -EINVAL on parsing error. | ||
237 | * Used as a replacement for the obsolete simple_strtoull. Return code must | ||
238 | * be checked. | ||
239 | */ | ||
223 | static inline int __must_check kstrtoul(const char *s, unsigned int base, unsigned long *res) | 240 | static inline int __must_check kstrtoul(const char *s, unsigned int base, unsigned long *res) |
224 | { | 241 | { |
225 | /* | 242 | /* |
@@ -233,6 +250,22 @@ static inline int __must_check kstrtoul(const char *s, unsigned int base, unsign | |||
233 | return _kstrtoul(s, base, res); | 250 | return _kstrtoul(s, base, res); |
234 | } | 251 | } |
235 | 252 | ||
253 | /** | ||
254 | * kstrtol - convert a string to a long | ||
255 | * @s: The start of the string. The string must be null-terminated, and may also | ||
256 | * include a single newline before its terminating null. The first character | ||
257 | * may also be a plus sign or a minus sign. | ||
258 | * @base: The number base to use. The maximum supported base is 16. If base is | ||
259 | * given as 0, then the base of the string is automatically detected with the | ||
260 | * conventional semantics - If it begins with 0x the number will be parsed as a | ||
261 | * hexadecimal (case insensitive), if it otherwise begins with 0, it will be | ||
262 | * parsed as an octal number. Otherwise it will be parsed as a decimal. | ||
263 | * @res: Where to write the result of the conversion on success. | ||
264 | * | ||
265 | * Returns 0 on success, -ERANGE on overflow and -EINVAL on parsing error. | ||
266 | * Used as a replacement for the obsolete simple_strtoull. Return code must | ||
267 | * be checked. | ||
268 | */ | ||
236 | static inline int __must_check kstrtol(const char *s, unsigned int base, long *res) | 269 | static inline int __must_check kstrtol(const char *s, unsigned int base, long *res) |
237 | { | 270 | { |
238 | /* | 271 | /* |