From owner-freebsd-stable Tue Feb 12 2: 7:48 2002 Delivered-To: freebsd-stable@freebsd.org Received: from tao.org.uk (genius.tao.org.uk [212.135.162.51]) by hub.freebsd.org (Postfix) with ESMTP id 0E97337B402 for ; Tue, 12 Feb 2002 02:07:33 -0800 (PST) Received: by tao.org.uk (Postfix, from userid 100) id 1ACB62F6; Tue, 12 Feb 2002 10:02:52 +0000 (GMT) Date: Tue, 12 Feb 2002 10:02:52 +0000 From: Josef Karthauser To: FreeBSD Stable Mailing List Subject: Re: USB patchset available for testing. Message-ID: <20020212100252.A71842@genius.tao.org.uk> Mail-Followup-To: Josef Karthauser , FreeBSD Stable Mailing List References: <20020210204630.D16746@genius.tao.org.uk> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-md5; protocol="application/pgp-signature"; boundary="NDin8bjvE/0mNLFQ" Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <20020210204630.D16746@genius.tao.org.uk>; from joe@tao.org.uk on Sun, Feb 10, 2002 at 08:46:30PM +0000 Sender: owner-freebsd-stable@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG --NDin8bjvE/0mNLFQ Content-Type: multipart/mixed; boundary="4Ckj6UjgE2iN1+kY" Content-Disposition: inline --4Ckj6UjgE2iN1+kY Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, Feb 10, 2002 at 08:46:30PM +0000, Josef Karthauser wrote: > Dear USB users, >=20 > I've created a patch set containing improvements from -current for > USB controllers and devices. I'd be very interested in feedback > from interested parties. >=20 > http://www.josef-k.net:/misc/RELENG_4-USB-20020210.patch.gz >=20 > Please note that I've not tested this at all on -stable, other than to > make sure that it compiles. Please proceed with all due care and > caution. It should apply clean against /usr/src/sys/dev/usb/ on a > machine cvsup'd to RELENG_4 as of today. There's also a patch for usbd, which I've attached. Joe --4Ckj6UjgE2iN1+kY Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=patch-usbd Content-Transfer-Encoding: quoted-printable Index: usbd.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /home/ncvs/src/usr.sbin/usbd/usbd.c,v retrieving revision 1.10.2.3 retrieving revision 1.22 diff -u -r1.10.2.3 -r1.22 --- usbd.c 7 Aug 2000 02:09:43 -0000 1.10.2.3 +++ usbd.c 28 Jan 2002 01:03:19 -0000 1.22 @@ -109,8 +109,12 @@ } event_name_t; =20 event_name_t event_names[] =3D { - {USB_EVENT_ATTACH, "attach"}, - {USB_EVENT_DETACH, "detach"}, + {USB_EVENT_CTRLR_ATTACH, "ctrlr-attach"}, + {USB_EVENT_CTRLR_DETACH, "ctrlr-detach"}, + {USB_EVENT_DRIVER_ATTACH, "driver-attach"}, + {USB_EVENT_DRIVER_DETACH, "driver-detach"}, + {USB_EVENT_DEVICE_ATTACH, "device-attach"}, + {USB_EVENT_DEVICE_DETACH, "device-detach"}, {0, NULL} /* NULL indicates end of list, not 0 */ }; =20 @@ -560,7 +564,7 @@ { int i; struct timespec *timespec =3D &event->ue_time; - struct usb_device_info *devinfo =3D &event->ue_device; + struct usb_device_info *devinfo =3D &event->u.ue_device; =20 printf("%s: ", __progname); for (i =3D 0; event_names[i].name !=3D NULL; i++) { @@ -572,28 +576,42 @@ if (event_names[i].name =3D=3D NULL) printf("unknown event %d", event->ue_type); =20 - printf(" at %ld.%09ld, %s, %s:\n", - timespec->tv_sec, timespec->tv_nsec, - devinfo->product, devinfo->vendor); - - printf(" vndr=3D0x%04x prdct=3D0x%04x rlse=3D0x%04x " - "clss=3D0x%04x subclss=3D0x%04x prtcl=3D0x%04x\n", - devinfo->vendorNo, devinfo->productNo, devinfo->releaseNo, - devinfo->class, devinfo->subclass, devinfo->protocol); - - if (devinfo->devnames[0][0] !=3D '\0') { - char c =3D ' '; - - printf(" device names:"); - for (i =3D 0; i < MAXDEVNAMES; i++) { - if (devinfo->devnames[i][0] =3D=3D '\0') - break; + if (event->ue_type =3D=3D USB_EVENT_DEVICE_ATTACH || + event->ue_type =3D=3D USB_EVENT_DEVICE_DETACH) { + devinfo =3D &event->u.ue_device; + + printf(" at %ld.%09ld, %s, %s:\n", + timespec->tv_sec, timespec->tv_nsec, + devinfo->product, devinfo->vendor); + + printf(" vndr=3D0x%04x prdct=3D0x%04x rlse=3D0x%04x " + "clss=3D0x%04x subclss=3D0x%04x prtcl=3D0x%04x\n", + devinfo->vendorNo, devinfo->productNo, + devinfo->releaseNo, + devinfo->class, devinfo->subclass, devinfo->protocol); + + if (devinfo->devnames[0][0] !=3D '\0') { + char c =3D ' '; + + printf(" device names:"); + for (i =3D 0; i < USB_MAX_DEVNAMES; i++) { + if (devinfo->devnames[i][0] =3D=3D '\0') + break; =20 - printf("%c%s", c, devinfo->devnames[i]); - c =3D ','; + printf("%c%s", c, devinfo->devnames[i]); + c =3D ','; + } } - printf("\n"); + } else if (event->ue_type =3D=3D USB_EVENT_CTRLR_ATTACH || + event->ue_type =3D=3D USB_EVENT_CTRLR_DETACH) { + printf(" bus=3D%d", &event->u.ue_ctrlr.ue_bus); + } else if (event->ue_type =3D=3D USB_EVENT_DRIVER_ATTACH || + event->ue_type =3D=3D USB_EVENT_DRIVER_DETACH) { + printf(" cookie=3D%u devname=3D%s", + &event->u.ue_driver.ue_cookie.cookie, + &event->u.ue_driver.ue_devname); } + printf("\n"); } =20 void @@ -662,7 +680,7 @@ regmatch_t match; int error; =20 - for (i =3D 0; i < MAXDEVNAMES; i++) { + for (i =3D 0; i < USB_MAX_DEVNAMES; i++) { if (devinfo->devnames[i][0] =3D=3D '\0') break; =20 @@ -853,9 +871,17 @@ =20 /* handle the event appropriately */ switch (event.ue_type) { - case USB_EVENT_ATTACH: - case USB_EVENT_DETACH: - if (find_action(&event.ue_device, &action_match) =3D=3D 0) + case USB_EVENT_CTRLR_ATTACH: + if (verbose) + printf("USB_EVENT_CTRLR_ATTACH\n"); + break; + case USB_EVENT_CTRLR_DETACH: + if (verbose) + printf("USB_EVENT_CTRLR_DETACH\n"); + break; + case USB_EVENT_DEVICE_ATTACH: + case USB_EVENT_DEVICE_DETACH: + if (find_action(&event.u.ue_device, &action_match) =3D=3D 0) /* nothing found */ break; =20 @@ -873,11 +899,20 @@ __progname, action_match.devname, strerror(errno)); } =20 - if (event.ue_type =3D=3D USB_EVENT_ATTACH && action_match.action->attac= h) + if (USB_EVENT_IS_ATTACH(event.ue_type) && + action_match.action->attach)=20 execute_command(action_match.action->attach); - if (event.ue_type =3D=3D USB_EVENT_DETACH && action_match.action->detac= h) + if (USB_EVENT_IS_DETACH(event.ue_type) && + action_match.action->detach) execute_command(action_match.action->detach); - + break; + case USB_EVENT_DRIVER_ATTACH: + if (verbose) + printf("USB_EVENT_DRIVER_DETACH\n"); + break; + case USB_EVENT_DRIVER_DETACH: + if (verbose) + printf("USB_EVENT_DRIVER_DETACH\n"); break; default: printf("Unknown USB event %d\n", event.ue_type); @@ -902,9 +937,8 @@ int itimeout =3D TIMEOUT; /* timeout for select */ struct timeval tv; =20 - if (modfind(USB_OHCI) < 0 && modfind(USB_UHCI) < 0) { - if (kldload(USB_KLD) < 0 ||=20 - (modfind(USB_OHCI) < 0 && modfind(USB_UHCI) < 0)) { + if (modfind(USB_UHUB) < 0) { + if (kldload(USB_KLD) < 0 || modfind(USB_UHUB) < 0) { perror(USB_KLD ": Kernel module not available"); return 1; } @@ -914,6 +948,10 @@ switch(ch) { case 'c': configfile =3D strdup(optarg); + if (configfile =3D=3D NULL) { + fprintf(stderr, "strdup returned NULL\n"); + return 1; + } break; case 'd': debug++; @@ -950,6 +988,10 @@ fds[ndevs] =3D open(buf, O_RDWR); if (fds[ndevs] >=3D 0) { devs[ndevs] =3D strdup(buf); + if (devs[ndevs] =3D=3D NULL) { + fprintf(stderr, "strdup returned NULL\n"); + return 1; + } if (verbose) printf("%s: opened %s\n",=20 __progname, devs[ndevs]); --4Ckj6UjgE2iN1+kY-- --NDin8bjvE/0mNLFQ Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (FreeBSD) Comment: For info see http://www.gnupg.org iEYEARECAAYFAjxo6EsACgkQXVIcjOaxUBYHjgCg5GXOk7t2Ev17vgTq563zjBTm 2PAAn1oh/TZreUIxt7JbsEGzikKW2fww =9r16 -----END PGP SIGNATURE----- --NDin8bjvE/0mNLFQ-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-stable" in the body of the message