9front - general discussion about 9front
 help / color / mirror / Atom feed
From: Nick Owens <mischief@offblast.org>
To: 9front@9front.org
Subject: Re: [9front] bug: nusb fails to set report protocol with a stall error
Date: Fri, 20 Nov 2020 14:19:44 -0800	[thread overview]
Message-ID: <20201120221944.bayqfjwceqp55x6s@wololo.home.arpa> (raw)
In-Reply-To: <26C61BE088AB556C851A08493C15610F@smtp.pobox.com>

On Fri, Nov 20, 2020 at 01:43:04PM -0800, Romano wrote:
> The patch to kb.c compiled fine, but the patch for joy.c didn't compile for me:
> 
> cpu% mk
> 7c -I../lib -FTVw joy.c
> joy.c:228 name not declared: iface
> mk: 7c -I../lib -FTVw joy.c  : exit status=rc 2880351: 7c 2880353: error
> 
> Just to see if it would compile I replaced "iface" with "f->dev->usb->ep[eid]->iface" and it did. Did you have iface referring to something else?

m( thats what i get for hasty copypasta. you are correct. update patch
below, uses Subclass macro to access subclass.

diff --git a/sys/src/cmd/nusb/joy/joy.c b/sys/src/cmd/nusb/joy/joy.c
--- a/sys/src/cmd/nusb/joy/joy.c
+++ b/sys/src/cmd/nusb/joy/joy.c
@@ -222,6 +222,12 @@ setproto(KDev *f, int eid)
 		proto = Reportproto;
 	}else
 		kbfatal(f, "no report");
+
+	// if a HID's subclass code is 0, it may not support setproto,
+	// and is always initialized in report mode.
+	if(Subclass(f->dev->usb->ep[eid]->iface->csp) == 0)
+		return 0;
+
 	return usbcmd(f->dev, Rh2d|Rclass|Riface, Setproto, proto, id, nil, 0);
 }
 
diff --git a/sys/src/cmd/nusb/kb/kb.c b/sys/src/cmd/nusb/kb/kb.c
--- a/sys/src/cmd/nusb/kb/kb.c
+++ b/sys/src/cmd/nusb/kb/kb.c
@@ -368,6 +368,12 @@ setproto(Hiddev *f, int eid)
 		}
 		proto = Bootproto;
 	}
+
+	// if a HID's subclass code is 0, it may not support setproto,
+	// and is always initialized in report mode.
+	if(Subclass(iface->csp) == 0)
+		return 0;
+
 	return usbcmd(f->dev, Rh2d|Rclass|Riface, Setproto, proto, iface->id, nil, 0);
 }



  reply	other threads:[~2020-11-20 22:19 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-20 21:43 Romano
2020-11-20 22:19 ` Nick Owens [this message]
2020-11-21 12:48 ` cinap_lenrek
  -- strict thread matches above, loose matches on Subject: below --
2020-11-20 12:58 Nick Owens
2020-11-20 20:57 ` [9front] " Romano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201120221944.bayqfjwceqp55x6s@wololo.home.arpa \
    --to=mischief@offblast.org \
    --cc=9front@9front.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).