]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - drivers/auxdisplay/charlcd.c
Merge tag 'for-linus-5.6-rc1-tag' of git://git.kernel.org/pub/scm/linux/kernel/git...
[linux.git] / drivers / auxdisplay / charlcd.c
index bef6b85778b6e2e04056fac1de5f1e9e56f834c4..874c259a88291880d368440437444dcf7e7b625d 100644 (file)
@@ -287,31 +287,6 @@ static int charlcd_init_display(struct charlcd *lcd)
        return 0;
 }
 
-/*
- * Parses an unsigned integer from a string, until a non-digit character
- * is found. The empty string is not accepted. No overflow checks are done.
- *
- * Returns whether the parsing was successful. Only in that case
- * the output parameters are written to.
- *
- * TODO: If the kernel adds an inplace version of kstrtoul(), this function
- * could be easily replaced by that.
- */
-static bool parse_n(const char *s, unsigned long *res, const char **next_s)
-{
-       if (!isdigit(*s))
-               return false;
-
-       *res = 0;
-       while (isdigit(*s)) {
-               *res = *res * 10 + (*s - '0');
-               ++s;
-       }
-
-       *next_s = s;
-       return true;
-}
-
 /*
  * Parses a movement command of the form "(.*);", where the group can be
  * any number of subcommands of the form "(x|y)[0-9]+".
@@ -336,6 +311,7 @@ static bool parse_xy(const char *s, unsigned long *x, unsigned long *y)
 {
        unsigned long new_x = *x;
        unsigned long new_y = *y;
+       char *p;
 
        for (;;) {
                if (!*s)
@@ -345,11 +321,15 @@ static bool parse_xy(const char *s, unsigned long *x, unsigned long *y)
                        break;
 
                if (*s == 'x') {
-                       if (!parse_n(s + 1, &new_x, &s))
+                       new_x = simple_strtoul(s + 1, &p, 10);
+                       if (p == s + 1)
                                return false;
+                       s = p;
                } else if (*s == 'y') {
-                       if (!parse_n(s + 1, &new_y, &s))
+                       new_y = simple_strtoul(s + 1, &p, 10);
+                       if (p == s + 1)
                                return false;
+                       s = p;
                } else {
                        return false;
                }