From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qt1-f196.google.com ([209.85.160.196]) by ewsd; Thu Jun 11 21:28:37 EDT 2020 Received: by mail-qt1-f196.google.com with SMTP id j32so6001612qte.10 for <9front@9front.org>; Thu, 11 Jun 2020 18:28:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=AmgJ18Iu+1iDr9H4bS2JrgWVnfv4tfZupaqlh9z/oQg=; b=ZPGVgA4/zTuKcVZZ+AGe5hifhlple+RDL3z2c/uokwBuA4Fo8rZccbHxokcNsNcnBM qJr8UzFmrtUGzocu5rhLGLtP712RdKWWdYAM+BC0vCUGGHWAjpJzPPdNMTispXmmwOUP TykJ8z6gHZS16skOrJviR6JwnnDZrvZXuEecaFuQmfxAoo2U26s2jjx9nEESsXAIUsry uiKNFdMUclgowUIH43N+DQFB8eLC9AexWI84BSCq3GwjGYqBKYrbH6ji5LDDW15sD2Ji c9G8F16jHWu5xc0Pfa+FjROIqENpocXj1yEgagojx1Q4qCiyTE5ELEgK9QECI3nq2kgh 2e5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=AmgJ18Iu+1iDr9H4bS2JrgWVnfv4tfZupaqlh9z/oQg=; b=MGwe+mTkfvF/Dr2ByZnHakKhjyCnuZbl3OJUmac0G9VHJya2TlRkjxAWFrURMyG4Os wcKkhHMGv+jUZUKAhQPwvgbRTB+BaB6vI+GT5PhJWQPlJuQltpJVNcy/DOah9fzArkTC TUfwJ3HaSj1bPJ705HdBA0ilPF1MBddsN7PCntkN4srFNIDL4q7VHRjk7TTspkrltho3 F4wC0oECtv6OitZ/4CqLRBwvWaiaqckkctpyjB+fQX5e4u5Ahfq7v+EktHauetoq6SqH WO/waPS4rQD0PSyMBv3tJoTK1S9KAd/ObzTpIsTku2RCgovT5TgpvroWqto/YDvAFQKT yPww== X-Gm-Message-State: AOAM532hjUSXv38afBOl+/dqdd3gEeiqzv1y25cHIMiQhnk8eBuniPKO xnC9si/Zjpo5FV0JEPBLXFT7XzRQES5i5ttaK88eaDjF X-Google-Smtp-Source: ABdhPJwSYsxJsBUK/b63dvzQe0WB3OAl6A78Y0lEqIVcFmqJEn/5vXCw5MvEElK8rGO6tKxyD7MBiWFsO0w7M4EGq+A= X-Received: by 2002:ac8:3529:: with SMTP id y38mr751179qtb.315.1591925313901; Thu, 11 Jun 2020 18:28:33 -0700 (PDT) MIME-Version: 1.0 References: <46EFE19EBB1B74CCB387820F084840C6@felloff.net> In-Reply-To: <46EFE19EBB1B74CCB387820F084840C6@felloff.net> From: Eli Cohen Date: Thu, 11 Jun 2020 18:28:22 -0700 Message-ID: Subject: Re: [9front] new nusb/serial driver To: 9front@9front.org Content-Type: multipart/mixed; boundary="000000000000d83b3805a7d8feef" List-ID: <9front.9front.org> List-Help: X-Glyph: ➈ X-Bullshit: extensible proven CMS markup --000000000000d83b3805a7d8feef Content-Type: text/plain; charset="UTF-8" This driver still needs work. it's flaky, but I noticed the ftdi driver is too... > another issue: > > > if(epin == -1 || epout == -1 || (ser->hasepintr && epintr == -1)){ > > ifc++; > > if(ifc > 1) > > return -1; > > goto TOPFINDEPS; > > } > > i think this should not be done here. rather, we should do that in > the caller of findendendpoints(), and have it continue if it cant > open a interface. and only fail in the end when all interfaces > failed to be usable. > > the reason is the caller already iterates over the interfaces, > and the task of this function is to bring the interface up that > was passed to it. > The problem I was having was that with all the other drivers there was a 1:1 mapping of USB interfaces to serial port interfaces. see what I mean? ifc is the index of the serial port interface used directly to index the USB interface. I have changed the code to a loop at least. There are some other things that need work still. the openbsd umodem driver does some things this doesn't yet --000000000000d83b3805a7d8feef Content-Type: text/x-patch; charset="US-ASCII"; name="serial.patch" Content-Disposition: attachment; filename="serial.patch" Content-Transfer-Encoding: base64 Content-ID: X-Att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