patch-2.4.6 linux/drivers/usb/pegasus.c

Next file: linux/drivers/usb/pegasus.h
Previous file: linux/drivers/usb/ov511.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.4.5/linux/drivers/usb/pegasus.c linux/drivers/usb/pegasus.c
@@ -53,8 +53,8 @@
 /*
  * Version Information
  */
-#define DRIVER_VERSION "v0.4.18 2001/03/18 (C) 1999-2000"
-#define DRIVER_AUTHOR "Petko Manolov <petkan@dce.bg>"
+#define DRIVER_VERSION "v0.4.19 2001/06/07 (C) 1999-2001"
+#define DRIVER_AUTHOR "Petko Manolov <pmanolov@lnxw.com>"
 #define DRIVER_DESC "ADMtek AN986 Pegasus USB Ethernet driver"
 
 #define	PEGASUS_USE_INTR
@@ -117,8 +117,7 @@
 			warn( __FUNCTION__ " status %d", urb->status);
 	}
 	pegasus->flags &= ~ETH_REGS_CHANGED;
-	if ( pegasus->flags & CTRL_URB_SLEEP ) {
-		pegasus->flags &= ~CTRL_URB_SLEEP;
+	if ( waitqueue_active(&pegasus->ctrl_wait) ) {
 		wake_up_interruptible( &pegasus->ctrl_wait );
 	}
 }
@@ -127,12 +126,19 @@
 static int get_registers(pegasus_t *pegasus, __u16 indx, __u16 size, void *data)
 {
 	int	ret;
+	unsigned char *buffer;
 	DECLARE_WAITQUEUE(wait, current);
 
-	while ( pegasus->flags & ETH_REGS_CHANGED ) {
-		pegasus->flags |= CTRL_URB_SLEEP;
-		interruptible_sleep_on( &pegasus->ctrl_wait );
+	buffer = kmalloc(size,GFP_KERNEL);
+	if (!buffer) {
+		err("unable to allocate memory for configuration descriptors");
+		return 0;
 	}
+	memcpy(buffer,data,size);
+	
+	while ( pegasus->flags & ETH_REGS_CHANGED )
+		interruptible_sleep_on( &pegasus->ctrl_wait );
+
 	pegasus->dr.requesttype = PEGASUS_REQT_READ;
 	pegasus->dr.request = PEGASUS_REQ_GET_REGS;
 	pegasus->dr.value = cpu_to_le16 (0);
@@ -143,11 +149,10 @@
 	FILL_CONTROL_URB( &pegasus->ctrl_urb, pegasus->usb,
 			  usb_rcvctrlpipe(pegasus->usb,0),
 			  (char *)&pegasus->dr,
-			  data, size, ctrl_callback, pegasus );
+			  buffer, size, ctrl_callback, pegasus );
 
 	add_wait_queue( &pegasus->ctrl_wait, &wait );
 	set_current_state( TASK_INTERRUPTIBLE );
-	pegasus->flags |= CTRL_URB_SLEEP;
 
 	if ( (ret = usb_submit_urb( &pegasus->ctrl_urb )) ) {
 		err( __FUNCTION__ " BAD CTRLs %d", ret);
@@ -155,21 +160,31 @@
 	}
 
 	schedule();
-	remove_wait_queue( &pegasus->ctrl_wait, &wait );
 out:
-	return	ret;
+	remove_wait_queue( &pegasus->ctrl_wait, &wait );
+	memcpy(data,buffer,size);
+	kfree(buffer);
+
+	return ret;
 }
 
 
 static int set_registers(pegasus_t *pegasus, __u16 indx, __u16 size, void *data)
 {
 	int	ret;
+	unsigned char *buffer;
 	DECLARE_WAITQUEUE(wait, current);
 
-	while ( pegasus->flags & ETH_REGS_CHANGED ) {
-		pegasus->flags |= CTRL_URB_SLEEP ;
-		interruptible_sleep_on( &pegasus->ctrl_wait );
+	buffer = kmalloc(size, GFP_KERNEL);
+	if (!buffer) {
+		err("unable to allocate memory for configuration descriptors");
+		return 0;
 	}
+	memcpy(buffer, data, size);
+
+	while ( pegasus->flags & ETH_REGS_CHANGED )
+		interruptible_sleep_on( &pegasus->ctrl_wait );
+
 	pegasus->dr.requesttype = PEGASUS_REQT_WRITE;
 	pegasus->dr.request = PEGASUS_REQ_SET_REGS;
 	pegasus->dr.value = cpu_to_le16 (0);
@@ -180,34 +195,42 @@
 	FILL_CONTROL_URB( &pegasus->ctrl_urb, pegasus->usb,
 			  usb_sndctrlpipe(pegasus->usb,0),
 			  (char *)&pegasus->dr,
-			  data, size, ctrl_callback, pegasus );
+			  buffer, size, ctrl_callback, pegasus );
 			  
 	add_wait_queue( &pegasus->ctrl_wait, &wait );
 	set_current_state( TASK_INTERRUPTIBLE );
-	pegasus->flags |= CTRL_URB_SLEEP;
 
 	if ( (ret = usb_submit_urb( &pegasus->ctrl_urb )) ) {
 		err( __FUNCTION__ " BAD CTRL %d", ret);
-		return	ret;
+		goto out;
 	}
-
+	
 	schedule();
+out:
 	remove_wait_queue( &pegasus->ctrl_wait, &wait );
-
-	return	ret;
+	kfree(buffer);
+	
+	return ret;
 }
 
 
 static int set_register( pegasus_t *pegasus, __u16 indx, __u8 data )
 {
 	int	ret;
+	unsigned char *buffer;
 	__u16 dat = data;
 	DECLARE_WAITQUEUE(wait, current);
 	
-	while ( pegasus->flags & ETH_REGS_CHANGED ) {
-		pegasus->flags |= CTRL_URB_SLEEP;
-		interruptible_sleep_on( &pegasus->ctrl_wait );
+	buffer = kmalloc(1, GFP_KERNEL);
+	if (!buffer) {
+		err("unable to allocate memory for configuration descriptors");
+		return 0;
 	}
+	memcpy(buffer, &data, 1);
+
+	while ( pegasus->flags & ETH_REGS_CHANGED )
+		interruptible_sleep_on( &pegasus->ctrl_wait );
+
 	pegasus->dr.requesttype = PEGASUS_REQT_WRITE;
 	pegasus->dr.request = PEGASUS_REQ_SET_REG;
 	pegasus->dr.value = cpu_to_le16p( &dat);
@@ -218,21 +241,22 @@
 	FILL_CONTROL_URB( &pegasus->ctrl_urb, pegasus->usb,
 			  usb_sndctrlpipe(pegasus->usb,0),
 			  (char *)&pegasus->dr,
-			  &data, 1, ctrl_callback, pegasus );
+			  buffer, 1, ctrl_callback, pegasus );
 
 	add_wait_queue( &pegasus->ctrl_wait, &wait );
 	set_current_state( TASK_INTERRUPTIBLE );
-	pegasus->flags |= CTRL_URB_SLEEP;
 
 	if ( (ret = usb_submit_urb( &pegasus->ctrl_urb )) ) {
 		err( __FUNCTION__ " BAD CTRL %d", ret);
-		return	ret;
+		goto out;
 	}
 
 	schedule();
+out:
 	remove_wait_queue( &pegasus->ctrl_wait, &wait );
+	kfree(buffer);
 
-	return	ret;
+	return ret;
 }
 
 
@@ -421,7 +445,7 @@
 		return 1;
 
 	if ( usb_dev_id[pegasus->dev_index].vendor == VENDOR_LINKSYS ||
-	     usb_dev_id[pegasus->dev_index].vendor == VENDOR_DLINK1 ) {
+	     usb_dev_id[pegasus->dev_index].vendor == VENDOR_DLINK ) {
 		__u16	auxmode;
 
 		read_mii_word( pegasus, 0, 0x1b, &auxmode );
@@ -767,7 +791,6 @@
 	} else {
 		pegasus->eth_regs[EthCtrl0] &= ~RX_MULTICAST;
 		pegasus->eth_regs[EthCtrl2] &= ~RX_PROMISCUOUS;
-		info("%s: set Rx mode", net->name);
 	}
 
 	pegasus->flags |= ETH_REGS_CHANGE;
@@ -905,8 +928,7 @@
 
 int __init pegasus_init(void)
 {
-	info(DRIVER_VERSION " " DRIVER_AUTHOR);
-	info(DRIVER_DESC);
+	info(DRIVER_VERSION ":" DRIVER_DESC);
 	return usb_register( &pegasus_driver );
 }
 

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)