shithub: riscv

Download patch

ref: fdcf0addac46643c8924e57992adb7f66c992b33
parent: ce72cab0e49c08c71888c57cf616563b90d7497a
author: mia soweli <[email protected]>
date: Sun May 21 13:01:43 EDT 2023

nusb/ether: set configuration, and use the first interface that matches

before, we were parsing all configurations, to find the cdc union,
but we would not set the config. this means we would try to talk cdc ethernet to whatever the first configuration is.

this makes cdc ethernet work on my rtl8156.

--- a/sys/src/cmd/nusb/ether/ether.c
+++ b/sys/src/cmd/nusb/ether/ether.c
@@ -642,15 +642,18 @@
 		ctlif = datif = nil;
 		for(j = 0; j < nelem(c->iface); j++){
 			for(iface = c->iface[j]; iface != nil; iface = iface->next){
-				if(iface->id == ctlid)
+				if(ctlif == nil && iface->id == ctlid)
 					ctlif = iface;
-				if(iface->id == datid)
+				if(datif == nil && iface->id == datid)
 					datif = iface;
 			}
 			if(datif != nil && ctlif != nil){
-				if(Subclass(ctlif->csp) == Scether)
+				if(Subclass(ctlif->csp) == Scether) {
+					if(setconf(d, c) < 0)
+						break;
 					if(ifaceinit(d, datif, ein, eout) != -1)
 						return 0;
+				}
 				break;
 			}
 		}		
@@ -659,6 +662,8 @@
 	/* try any other one that seems to be ok */
 	for(i = 0; i < nelem(ud->conf); i++){
 		if((c = ud->conf[i]) != nil){
+			if(setconf(d, c) < 0)
+				break;
 			for(j = 0; j < nelem(c->iface); j++){
 				for(datif = c->iface[j]; datif != nil; datif = datif->next){
 					if(ifaceinit(d, datif, ein, eout) != -1)