From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 7347 invoked from network); 21 May 2023 17:11:17 -0000 Received: from 9front.inri.net (168.235.81.73) by inbox.vuxu.org with ESMTPUTF8; 21 May 2023 17:11:17 -0000 Received: from one.net.tachibana-labs.org ([78.141.198.89]) by 9front; Sun May 21 13:06:58 -0400 2023 Received: from kijetesantakalu (cpc99362-croy26-2-0-cust24.19-2.cable.virginm.net [80.195.49.25]) by one.net.tachibana-labs.org (OpenSMTPD) with ESMTPSA id bc5b7024 (TLSv1.2:ECDHE-RSA-CHACHA20-POLY1305:256:NO) for <9front@9front.org>; Sun, 21 May 2023 17:06:51 +0000 (UTC) Message-ID: <06E2394F1FB8B1194569FECED3765B58@tachibana-labs.org> To: 9front@9front.org Date: Sun, 21 May 2023 18:06:49 +0100 From: inbox@tachibana-labs.org MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="upas-cygzvhewsimrgmtfchjuuhedce" List-ID: <9front.9front.org> List-Help: X-Glyph: ➈ X-Bullshit: private general-purpose-oriented SVG over ORM strategy dependency-aware interface Subject: [9front] [PATCH] nusb/lib and nusb/ether fixes. Reply-To: 9front@9front.org Precedence: bulk This is a multi-part message in MIME format. --upas-cygzvhewsimrgmtfchjuuhedce Content-Disposition: inline Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit added setconf() to nusb/lib, and fixed findendpoints() in nusb/ether to set the correct configuration. this makes nusb/ether work for my rtl8156 adapter. --upas-cygzvhewsimrgmtfchjuuhedce Content-Disposition: attachment; filename=nusb-ether.diff Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit From: mia soweli Date: Sun, 21 May 2023 17:01:43 +0000 Subject: [PATCH] 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. --- diff daeb5b0ab6d6342dd7d4a25ee6380f67082cfbed 7df4a1cd04d3c77382fbe58062bfb95ed2fb2035 --- 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) --upas-cygzvhewsimrgmtfchjuuhedce Content-Disposition: attachment; filename=nusb-setconf.diff Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit From: mia soweli Date: Sat, 20 May 2023 19:15:57 +0000 Subject: [PATCH] nusb/lib: add setconf() to set the configuration --- diff f27164167a90a7bc8613375a2d90f2438625518b e3cd2bf512fee93d44d1f48c9813f15f81b21938 --- a/sys/src/cmd/nusb/lib/dev.c +++ b/sys/src/cmd/nusb/lib/dev.c @@ -483,6 +483,16 @@ } int +setconf(Dev *d, Conf *c) +{ + if(usbcmd(d, Rh2d|Rstd|Rdev, Rsetconf, c->cval, 0, nil, 0) > 0) { + werrstr("setconf: %s: %r", d->dir); + return -1; + } + return 0; +} + +int setalt(Dev *d, Iface *ifc) { if(usbcmd(d, Rh2d|Rstd|Riface, Rsetiface, ifc->alt, ifc->id, nil, 0) < 0){ --- a/sys/src/cmd/nusb/lib/usb.h +++ b/sys/src/cmd/nusb/lib/usb.h @@ -353,6 +353,7 @@ int unstall(Dev *dev, Dev *ep, int dir); int usbcmd(Dev *d, int type, int req, int value, int index, uchar *data, int count); Dev* getdev(char *devid); +int setconf(Dev *d, Conf *c); int setalt(Dev *d, Iface *ifc); extern int usbdebug; /* more messages for bigger values */ --upas-cygzvhewsimrgmtfchjuuhedce--