mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Marek Belisko <marek.belisko@gmail.com>
To: Greg Kroah-Hartman <gregkh@suse.de>,
	Marek Belisko <marek.belisko@gmail.com>,
	Arnd Bergmann <arnd@arndb.de>,
	Vasiliy Kulikov <segooon@gmail.com>,
	devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org
Cc: Marek Belisko <marek.belisko@gmail.com>
Subject: [PATCH] staging:ft1000:Get rid of using atoi.
Date: Thu, 14 Oct 2010 14:14:33 +0200	[thread overview]
Message-ID: <1287058473-15285-1-git-send-email-marek.belisko@gmail.com> (raw)

Signed-off-by: Marek Belisko <marek.belisko@gmail.com>
---
 drivers/staging/ft1000/ft1000-usb/ft1000_hw.c |   36 +++++++++----------------
 1 files changed, 13 insertions(+), 23 deletions(-)

diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_hw.c b/drivers/staging/ft1000/ft1000-usb/ft1000_hw.c
index 507a248..8498538 100644
--- a/drivers/staging/ft1000/ft1000-usb/ft1000_hw.c
+++ b/drivers/staging/ft1000/ft1000-usb/ft1000_hw.c
@@ -55,28 +55,10 @@ static const struct net_device_ops ft1000net_ops = {
 //Jim
 
 static u8 tempbuffer[1600];
-static int gCardIndex;
+static unsigned long gCardIndex;
 
 #define MAX_RCV_LOOP   100
 
-
-static int atoi(const char *s)
-{
-        int k = 0;
-    int cnt;
-
-        k = 0;
-    cnt = 0;
-        while (*s != '\0' && *s >= '0' && *s <= '9') {
-                k = 10 * k + (*s - '0');
-                s++;
-        // Let's put a limit on this while loop to avoid deadlock scenario
-        if (cnt > 100)
-           break;
-        cnt++;
-        }
-        return k;
-}
 /****************************************************************
  *     ft1000_control_complete
  ****************************************************************/
@@ -966,8 +948,9 @@ u16 init_ft1000_netdev(struct ft1000_device *ft1000dev)
     struct net_device *netdev;
     FT1000_INFO *pInfo = NULL;
     PDPRAM_BLK pdpram_blk;
-    int i;
+	int i, ret_val;
 	struct list_head *cur, *tmp;
+	char card_nr[2];
 
 	gCardIndex=0; //mbelian
 
@@ -995,9 +978,16 @@ u16 init_ft1000_netdev(struct ft1000_device *ft1000dev)
     {
         DEBUG("init_ft1000_netdev: network device name is %s\n", netdev->name);
 
-        if ( strncmp(netdev->name,"eth", 3) == 0) {
-            //pInfo->CardNumber = atoi(&netdev->name[3]);
-            gCardIndex = atoi(&netdev->name[3]);
+	if ( strncmp(netdev->name,"eth", 3) == 0) {
+		card_nr[0] = netdev->name[3];
+		card_nr[1] = '\0';
+		ret_val = strict_strtoul(card_nr, 10, &gCardIndex);
+		if (ret_val) {
+			printk(KERN_ERR "Can't parse netdev\n");
+			free_netdev(netdev);
+			return STATUS_FAILURE;
+		}
+
             pInfo->CardNumber = gCardIndex;
             DEBUG("card number = %d\n", pInfo->CardNumber);
         }
-- 
1.7.1


                 reply	other threads:[~2010-10-14 14:54 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1287058473-15285-1-git-send-email-marek.belisko@gmail.com \
    --to=marek.belisko@gmail.com \
    --cc=arnd@arndb.de \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=segooon@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®