git: 9front

Download patch

ref: 4db42f5c867d32be8bcd0f5f5666eaa56fcb58fd
parent: 9cd8436874c1ea9ca29dc90a220a2eccd4c5a516
author: cinap_lenrek <cinap_lenrek@gmx.de>
date: Thu Dec 6 18:24:42 EST 2012

nusb/ether: remove vid check in smsc driver, cleanup cdc driver

--- a/sys/src/cmd/nusb/ether/cdc.c
+++ b/sys/src/cmd/nusb/ether/cdc.c
@@ -9,40 +9,12 @@
 #include <auth.h>
 #include <fcall.h>
 #include <9p.h>
+#include <ip.h>
 
 #include "usb.h"
 #include "dat.h"
 
 static int
-str2mac(uchar *m, char *s)
-{
-	int i;
-
-	if(strlen(s) != 12)
-		return -1;
-
-	for(i=0; i<12; i++){
-		uchar v;
-
-		if(s[i] >= 'A' && s[i] <= 'F'){
-			v = 10 + s[i] - 'A';
-		} else if(s[i] >= 'a' && s[i] <= 'f'){
-			v = 10 + s[i] - 'a';
-		} else if(s[i] >= '0' && s[i] <= '9'){
-			v = s[i] - '0';
-		} else {
-			v = 0;
-		}
-		if(i&1){
-			m[i/2] |= v;
-		} else {
-			m[i/2] = v<<4;
-		}
-	}
-	return 0;
-}
-
-static int
 cdcread(Dev *ep, uchar *p, int n)
 {
 	return read(ep->dfd, p, n);
@@ -84,7 +56,7 @@
 					mac = nil;
 				}
 				if(mac != nil){
-					str2mac(macaddr, mac);
+					parseether(macaddr, mac);
 					free(mac);
 
 					epread = cdcread;
--- a/sys/src/cmd/nusb/ether/ether.c
+++ b/sys/src/cmd/nusb/ether/ether.c
@@ -5,11 +5,10 @@
 #include <auth.h>
 #include <fcall.h>
 #include <9p.h>
+#include <ip.h>
 
 #include "usb.h"
 #include "dat.h"
-
-#include <ip.h>
 
 typedef struct Tab Tab;
 typedef struct Qbuf Qbuf;
--- a/sys/src/cmd/nusb/ether/smsc.c
+++ b/sys/src/cmd/nusb/ether/smsc.c
@@ -9,6 +9,7 @@
 #include <auth.h>
 #include <fcall.h>
 #include <9p.h>
+#include <ip.h>
 
 #include "usb.h"
 #include "dat.h"
@@ -257,8 +258,6 @@
 int
 smscinit(Dev *d)
 {
-	if(d->usb->vid != 0x0424)
-		return -1;
 	if(!doreset(d, Hwcfg, Lrst) || !doreset(d, Pmctrl, Phyrst))
 		return -1;
 	if(!setmac)
--