Skip to contentSkip to conversation

Bunch of fixes related to custom atoi() implementation

PATCH New Andy Shevchenko 1 participant 4 messages Jan 14, 2010

Subsystems (5)
DRM drivers x86 DRM misc Staging +1 more subsystems
lore
Share & tools
lore
#0 lore raw

cover Bunch of fixes related to custom atoi() implementation

From: Andy Shevchenko <[email protected]>

There are few fixes that substitute custom implementation of atoi() by simple_strtol() kernel's method.

Andy Shevchenko (3):
Fix minor spelling error in comments
drm: Don't use own implementation of atoi()
staging: don't use custom implementation of atoi()

 arch/x86/mm/gup.c                       |    2 +-
 drivers/gpu/drm/drm_fb_helper.c         |   24 ++--------
 drivers/staging/wlags49_h2/wl_main.c    |    2 +-
 drivers/staging/wlags49_h2/wl_profile.c |   76 +++++++++++++++---------------
 drivers/staging/wlags49_h2/wl_util.c    |   49 --------------------
 drivers/staging/wlags49_h2/wl_util.h    |    2 -
 6 files changed, 45 insertions(+), 110 deletions(-)
#1 lore raw

PATCH 1/3 Fix minor spelling error in comments

From: Andy Shevchenko <[email protected]>

---
 arch/x86/mm/gup.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
arch/x86/mm/gup.c +1 -1
index 71da1bc..738e659 100644
@@ -18,7 +18,7 @@ static inline pte_t gup_get_pte(pte_t *ptep)
 #else
 	/*
 	 * With get_user_pages_fast, we walk down the pagetables without taking
-	 * any locks.  For this we would like to load the pointers atoimcally,
+	 * any locks.  For this we would like to load the pointers atomically,
 	 * but that is not possible (without expensive cmpxchg8b) on PAE.  What
 	 * we do have is the guarantee that a pte will only either go from not
 	 * present to present, or present to not present or both -- it will not
Signature · 1 line
1.5.6.5
#2 lore raw

PATCH 2/3 drm: Don't use own implementation of atoi()

From: Andy Shevchenko <[email protected]>

Kernel has simple_strtol() which would be used as atoi().

This is quite the same fix as in 2cb96f86628d6e97fcbda5fe4d8d74876239834c, because code in drivers/gpu/drm/drm_fb_helper.c is based on drivers/video/modedb.c.

---
 drivers/gpu/drm/drm_fb_helper.c |   24 +++++-------------------
 1 files changed, 5 insertions(+), 19 deletions(-)
drivers/gpu/drm/drm_fb_helper.c +5 -19
index 1c2b7d4..a3c0a33 100644
@@ -29,6 +29,7 @@
  */
 #include <linux/sysrq.h>
 #include <linux/fb.h>
+#include <linux/kernel.h>
 #include "drmP.h"
 #include "drm_crtc.h"
 #include "drm_fb_helper.h"
@@ -50,21 +51,6 @@ int drm_fb_helper_add_connector(struct drm_connector *connector)
 }
 EXPORT_SYMBOL(drm_fb_helper_add_connector);
 
-static int my_atoi(const char *name)
-{
-	int val = 0;
-
-	for (;; name++) {
-		switch (*name) {
-		case '0' ... '9':
-			val = 10*val+(*name-'0');
-			break;
-		default:
-			return val;
-		}
-	}
-}
-
 /**
  * drm_fb_helper_connector_parse_command_line - parse command line for connector
  * @connector - connector to parse line for
@@ -111,7 +97,7 @@ static bool drm_fb_helper_connector_parse_command_line(struct drm_connector *con
 			namelen = i;
 			if (!refresh_specified && !bpp_specified &&
 			    !yres_specified) {
-				refresh = my_atoi(&name[i+1]);
+				refresh = simple_strtol(&name[i+1], NULL, 10);
 				refresh_specified = 1;
 				if (cvt || rb)
 					cvt = 0;
@@ -121,7 +107,7 @@ static bool drm_fb_helper_connector_parse_command_line(struct drm_connector *con
 		case '-':
 			namelen = i;
 			if (!bpp_specified && !yres_specified) {
-				bpp = my_atoi(&name[i+1]);
+				bpp = simple_strtol(&name[i+1], NULL, 10);
 				bpp_specified = 1;
 				if (cvt || rb)
 					cvt = 0;
@@ -130,7 +116,7 @@ static bool drm_fb_helper_connector_parse_command_line(struct drm_connector *con
 			break;
 		case 'x':
 			if (!yres_specified) {
-				yres = my_atoi(&name[i+1]);
+				yres = simple_strtol(&name[i+1], NULL, 10);
 				yres_specified = 1;
 			} else
 				goto done;
@@ -170,7 +156,7 @@ static bool drm_fb_helper_connector_parse_command_line(struct drm_connector *con
 		}
 	}
 	if (i < 0 && yres_specified) {
-		xres = my_atoi(name);
+		xres = simple_strtol(name, NULL, 10);
 		res_specified = 1;
 	}
 done:
Signature · 1 line
1.5.6.5
#3 lore raw

PATCH 3/3 staging: don't use custom implementation of atoi()

From: Andy Shevchenko <[email protected]>

Kernel has its own method called simple_strtoul() to do such things.

Here we are using simple_strtoul(value, NULL, 0) because in original function the recognized base is 10 or 16 and input data is assumed to be unsigned.

Cc Greg Kroah-Hartman <[email protected]>
---
 drivers/staging/wlags49_h2/wl_main.c    |    2 +-
 drivers/staging/wlags49_h2/wl_profile.c |   76 +++++++++++++++---------------
 drivers/staging/wlags49_h2/wl_util.c    |   49 --------------------
 drivers/staging/wlags49_h2/wl_util.h    |    2 -
 4 files changed, 39 insertions(+), 90 deletions(-)
drivers/staging/wlags49_h2/wl_main.c +1 -1
index 16764a0..cf0c384 100644
@@ -3792,7 +3792,7 @@ static int write_int(struct file *file, const char *buffer, unsigned long count,
 	}
 	if  (count > 0 ) {
 		proc_number[count] = 0;
-		nr = wl_atoi( proc_number );
+		nr = simple_strtoul(proc_number , NULL, 0);
  		*(unsigned int *)data = nr;
 		if ( nr & 0x8000 ) {	//;?kludgy but it is unclear to me were else to place this
 #if DBG
drivers/staging/wlags49_h2/wl_profile.c +38 -38

293 lines not on this page · raw message

drivers/staging/wlags49_h2/wl_util.c +0 -49

52 lines not on this page · raw message

drivers/staging/wlags49_h2/wl_util.h +0 -2
index 16cd6c5..561e85b 100644
@@ -100,6 +100,4 @@ void wl_process_updated_record( struct wl_private *lp );
 void wl_process_assoc_status( struct wl_private *lp );
 void wl_process_security_status( struct wl_private *lp );
 
-unsigned int wl_atoi( char *string );
-
 #endif  // __WL_UTIL_H__
Signature · 1 line
1.5.6.5