Date: Fri, 21 Oct 2011 08:30:42 -0400 From: John Baldwin <jhb@freebsd.org> To: freebsd-drivers@freebsd.org Cc: Warner Losh <imp@freebsd.org> Subject: Re: Writing HID driver Message-ID: <201110210830.42285.jhb@freebsd.org> In-Reply-To: <4E9EBAEE.2070500@timon.net.nz> References: <4E9EBAEE.2070500@timon.net.nz>
next in thread | previous in thread | raw e-mail | index | archive | help
On Wednesday, October 19, 2011 7:56:30 am Alexandr Matveev wrote: > Hi, > > I'm writing the driver for the USB keyboard, which has two interfaces: > first is generic keyboard and second is HID device. If I load driver and > then attach the keyboard - everything is OK. But if I attach keyboard > and then kldload driver, it won't attach to the device because the default > uhid driver already attached to it first. To prevent this, driver > searches for > uhid devices after being loaded and compares a pnpinfo string to search > for suitable devices and detach them. > > Everything works fine, but I have two questions: > 1) Is there any simpler way to do the same thing? Not currently, no. > 2) Is there a way to get device vendor & product without using device > bus-specific functions? No, but you can probably implement lkbd_detach_uhid() a bit simpler by doing something like: devclass_t dc; device_t devices; int devcount, error, i; dc = devclass_find("uhid"); if (dc == NULL) return; error = devclass_get_devices(dc, &devices, &devcount); if (error) { printf("Unable to fetch uhid device list: %d\n", error); return; } for (i = 0; i < devcount; i++) { /* * Do the same checks you do in your probe routine and * detach the devices that match. */ } free(devlist, M_TEMP); -- John Baldwin
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201110210830.42285.jhb>