diff options
author | Eldad Zack <eldad@fogrefinery.com> | 2012-12-17 19:03:04 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-12-17 20:15:22 -0500 |
commit | 4c925d6031f719fad6ea8b1c94a636f4c0fea39b (patch) | |
tree | a27265311ff47951ab00d4df3b49350c1ae898ba /lib/kstrtox.c | |
parent | 543f56c19c3e926d33b50a6bcbc37c408631601e (diff) |
kstrto*: add documentation
As Bruce Fields pointed out, kstrto* is currently lacking kerneldoc
comments. This patch adds kerneldoc comments to common variants of
kstrto*: kstrto(u)l, kstrto(u)ll and kstrto(u)int.
Signed-off-by: Eldad Zack <eldad@fogrefinery.com>
Cc: J. Bruce Fields <bfields@fieldses.org>
Cc: Joe Perches <joe@perches.com>
Cc: Randy Dunlap <rdunlap@xenotime.net>
Cc: Alexey Dobriyan <adobriyan@gmail.com>
Cc: Rob Landley <rob@landley.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'lib/kstrtox.c')
-rw-r--r-- | lib/kstrtox.c | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/lib/kstrtox.c b/lib/kstrtox.c index c3615eab0cc3..f78ae0c0c4e2 100644 --- a/lib/kstrtox.c +++ b/lib/kstrtox.c | |||
@@ -104,6 +104,22 @@ static int _kstrtoull(const char *s, unsigned int base, unsigned long long *res) | |||
104 | return 0; | 104 | return 0; |
105 | } | 105 | } |
106 | 106 | ||
107 | /** | ||
108 | * kstrtoull - convert a string to an unsigned long long | ||
109 | * @s: The start of the string. The string must be null-terminated, and may also | ||
110 | * include a single newline before its terminating null. The first character | ||
111 | * may also be a plus sign, but not a minus sign. | ||
112 | * @base: The number base to use. The maximum supported base is 16. If base is | ||
113 | * given as 0, then the base of the string is automatically detected with the | ||
114 | * conventional semantics - If it begins with 0x the number will be parsed as a | ||
115 | * hexadecimal (case insensitive), if it otherwise begins with 0, it will be | ||
116 | * parsed as an octal number. Otherwise it will be parsed as a decimal. | ||
117 | * @res: Where to write the result of the conversion on success. | ||
118 | * | ||
119 | * Returns 0 on success, -ERANGE on overflow and -EINVAL on parsing error. | ||
120 | * Used as a replacement for the obsolete simple_strtoull. Return code must | ||
121 | * be checked. | ||
122 | */ | ||
107 | int kstrtoull(const char *s, unsigned int base, unsigned long long *res) | 123 | int kstrtoull(const char *s, unsigned int base, unsigned long long *res) |
108 | { | 124 | { |
109 | if (s[0] == '+') | 125 | if (s[0] == '+') |
@@ -112,6 +128,22 @@ int kstrtoull(const char *s, unsigned int base, unsigned long long *res) | |||
112 | } | 128 | } |
113 | EXPORT_SYMBOL(kstrtoull); | 129 | EXPORT_SYMBOL(kstrtoull); |
114 | 130 | ||
131 | /** | ||
132 | * kstrtoll - convert a string to a long long | ||
133 | * @s: The start of the string. The string must be null-terminated, and may also | ||
134 | * include a single newline before its terminating null. The first character | ||
135 | * may also be a plus sign or a minus sign. | ||
136 | * @base: The number base to use. The maximum supported base is 16. If base is | ||
137 | * given as 0, then the base of the string is automatically detected with the | ||
138 | * conventional semantics - If it begins with 0x the number will be parsed as a | ||
139 | * hexadecimal (case insensitive), if it otherwise begins with 0, it will be | ||
140 | * parsed as an octal number. Otherwise it will be parsed as a decimal. | ||
141 | * @res: Where to write the result of the conversion on success. | ||
142 | * | ||
143 | * Returns 0 on success, -ERANGE on overflow and -EINVAL on parsing error. | ||
144 | * Used as a replacement for the obsolete simple_strtoull. Return code must | ||
145 | * be checked. | ||
146 | */ | ||
115 | int kstrtoll(const char *s, unsigned int base, long long *res) | 147 | int kstrtoll(const char *s, unsigned int base, long long *res) |
116 | { | 148 | { |
117 | unsigned long long tmp; | 149 | unsigned long long tmp; |
@@ -168,6 +200,22 @@ int _kstrtol(const char *s, unsigned int base, long *res) | |||
168 | } | 200 | } |
169 | EXPORT_SYMBOL(_kstrtol); | 201 | EXPORT_SYMBOL(_kstrtol); |
170 | 202 | ||
203 | /** | ||
204 | * kstrtouint - convert a string to an unsigned int | ||
205 | * @s: The start of the string. The string must be null-terminated, and may also | ||
206 | * include a single newline before its terminating null. The first character | ||
207 | * may also be a plus sign, but not a minus sign. | ||
208 | * @base: The number base to use. The maximum supported base is 16. If base is | ||
209 | * given as 0, then the base of the string is automatically detected with the | ||
210 | * conventional semantics - If it begins with 0x the number will be parsed as a | ||
211 | * hexadecimal (case insensitive), if it otherwise begins with 0, it will be | ||
212 | * parsed as an octal number. Otherwise it will be parsed as a decimal. | ||
213 | * @res: Where to write the result of the conversion on success. | ||
214 | * | ||
215 | * Returns 0 on success, -ERANGE on overflow and -EINVAL on parsing error. | ||
216 | * Used as a replacement for the obsolete simple_strtoull. Return code must | ||
217 | * be checked. | ||
218 | */ | ||
171 | int kstrtouint(const char *s, unsigned int base, unsigned int *res) | 219 | int kstrtouint(const char *s, unsigned int base, unsigned int *res) |
172 | { | 220 | { |
173 | unsigned long long tmp; | 221 | unsigned long long tmp; |
@@ -183,6 +231,22 @@ int kstrtouint(const char *s, unsigned int base, unsigned int *res) | |||
183 | } | 231 | } |
184 | EXPORT_SYMBOL(kstrtouint); | 232 | EXPORT_SYMBOL(kstrtouint); |
185 | 233 | ||
234 | /** | ||
235 | * kstrtoint - convert a string to an int | ||
236 | * @s: The start of the string. The string must be null-terminated, and may also | ||
237 | * include a single newline before its terminating null. The first character | ||
238 | * may also be a plus sign or a minus sign. | ||
239 | * @base: The number base to use. The maximum supported base is 16. If base is | ||
240 | * given as 0, then the base of the string is automatically detected with the | ||
241 | * conventional semantics - If it begins with 0x the number will be parsed as a | ||
242 | * hexadecimal (case insensitive), if it otherwise begins with 0, it will be | ||
243 | * parsed as an octal number. Otherwise it will be parsed as a decimal. | ||
244 | * @res: Where to write the result of the conversion on success. | ||
245 | * | ||
246 | * Returns 0 on success, -ERANGE on overflow and -EINVAL on parsing error. | ||
247 | * Used as a replacement for the obsolete simple_strtoull. Return code must | ||
248 | * be checked. | ||
249 | */ | ||
186 | int kstrtoint(const char *s, unsigned int base, int *res) | 250 | int kstrtoint(const char *s, unsigned int base, int *res) |
187 | { | 251 | { |
188 | long long tmp; | 252 | long long tmp; |