summaryrefslogtreecommitdiffstats
path: root/sys/dev/usb/ugen.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Prevent that when ugen(4) tries to set an alternative configurationmglocker2021-02-051-1/+5
| | | | | | | | | | descriptor (usually doesn't happen), that we continue to use an outdated cdesc pointer which still refers to the previous cdesc. Instead update the cdesc pointer to the new configuration descriptor. Reported by Thomas Jeunet <cleptho AT gmail DOT com> ok phessler@
* Align the mixed naming for the variables used to reference tomglocker2021-02-011-8/+8
| | | | | | | | | bInterfaceNumber and bAlternateSetting as following: ifaceidx -> ifaceno altidx -> altno Suggested and ok mpi@
* Be consistent in not using parameter names for function prototypes;mglocker2021-01-281-3/+3
| | | | I've missed two more cases in the previous commit.
* The usb configuration descriptor parameter providing the number ofmglocker2021-01-271-3/+3
| | | | | | available device interfaces is called 'bNumInterfaces'. ok phessler@, thfr@ (who provided the man page diff)
* Be consistent in not using parameter names for function prototypes.mglocker2021-01-271-5/+5
|
* Resolve data toggle out of sync problem for ugen(4) and uhidev(4) devicesmglocker2021-01-251-1/+49
| | | | | | | | | | on xhci(4) controllers by clearing the interface endpoints before opening the pipes. Tested by Mikolaj Kucharski for ugen(4) and gnezdo@ for uhidev(4), plus myself for both. ok mpi@
* Refactor klist insertion and removalvisa2020-12-251-3/+3
| | | | | | | | | | | | Rename klist_{insert,remove}() to klist_{insert,remove}_locked(). These functions assume that the caller has locked the klist. The current state of locking remains intact because the kernel lock is still used with all klists. Add new functions klist_insert() and klist_remove() that lock the klist internally. This allows some code simplification. OK mpi@
* Set the correct length before copying to userland.mpi2020-09-291-1/+2
| | | | | | | Prevent copying a partial and corrupted descriptor or leaking kernel memory. ok kn@, deraadt@
* Don't rely on wTotalLength for usbd_get_cdesc() malloc/free but on themglocker2020-09-021-12/+17
| | | | | | | | actual length which has been allocated. We saw cases where the wTotalLength value is changing on a second read, e.g. when a USB device was waked up from sleep mode. ok mpi@
* Use seltrue_kqfilter() instead of hand-rolling it in multiple drivers.mpi2020-05-131-15/+4
| | | | ok visa@
* Abstract the head of knote lists. This allows extending the lists,visa2020-04-071-3/+3
| | | | | | for example, with locking assertions. OK mpi@, anton@
* Fix incoherencies of errors returned by various *kqfilter routines.mpi2020-04-031-2/+2
| | | | | | | | EOPNOTSUPP is returned when there's no "filterops" for a given fd. EINVAL when the requested filter isn't supported by the "filterops". ENXIO means the underlying device is no longer valid/present. ok visa@
* use the UE_GET_XFERTYPE macro where applicablejasper2020-02-221-8/+8
| | | | ok mpi@
* Replace field f_isfd with field f_flags in struct filterops to allowvisa2020-02-201-4/+4
| | | | | | adding more filter properties without cluttering the struct. OK mpi@, anton@
* Convert sleep to tsleep_nsec(9) and use unique sleeping identifiers.mpi2020-01-041-5/+5
| | | | ok bluhm@
* Use C99 designated initializers with struct filterops. In addition,visa2019-12-311-7/+19
| | | | | | make the structs const so that the data are put in .rodata. OK mpi@, deraadt@, anton@, bluhm@
* free(9) sizes for configuration descriptors.mpi2018-11-141-11/+10
| | | | ok tedu@, visa@
* Simplify/refactor the way vendor/product/serial informations arelandry2018-05-011-2/+2
| | | | | | | | | | | | | | | | | | gathered from usb devices. Cache them early in usbd_new_device() instead of querying the device several times (the content wont change anyway) and uselessly generating usb traffic (which could conflict with other access..) The heuristic stays the same, first look in the device descriptor, then try to match against usb_known_vendors/usb_known_products, then fallback to use the idVendor/idProduct codes. Remove the now useless 'usedev' parameter from usbd_fill_deviceinfo(). Tested from bsd & bsd.rd. suggested by and ok mpi@
* Don't pull in <sys/file.h> just to get fcntl.hguenther2017-12-301-2/+2
| | | | ok deraadt@ krw@
* Do not permit USB ioctl handler malloc(9)'s to block as this interferesians2017-07-211-2/+5
| | | | | | with expected behavior. OK mpi@ patrick@
* A pile of sizes to free(9). In test for a few days in snapshots.deraadt2017-04-081-12/+16
| | | | | Errors will result in nice clean panic messages so we know what's wrong. Reviewed by dhill visa natano jsg.
* Kill unused ioctl(2)s.mpi2016-05-241-12/+1
| | | | ok deraadt@
* 'miliseconds' -> 'milliseconds' in comments.krw2016-03-171-2/+2
| | | | if_atu.c noted by Michal Mazurek.
* Convert uiomovei to uiomove. Fixes a few integer truncations along thestefan2016-03-031-26/+27
| | | | | | way. ok natano@
* Revert transfer submission to r1.85. Seems to make okan@'s scannermpi2015-10-191-30/+15
| | | | work properly.
* Prevent a NULL-pointer dereference when closing a ugen(4) nodempi2015-10-131-4/+2
| | | | | | in case the kernel failed to change the interface of a device. Found the hardway by okan
* Fix kpanic I found the hard way while using pcsc-litedcoppa2015-09-151-3/+7
| | | | | From Grant Czajkowski <czajkow2 AT illinois DOT edu> OK mpi@
* Do not set USBD_NO_COPY for interrupt transfers, only bulk transfersmpi2015-09-071-2/+3
| | | | | | are converted for the moment. From Grant Czajkowski.
* Do not use an intermediary buffer on the stack of the caller whenmpi2015-09-041-7/+13
| | | | | | | | | | | submitting a bulk write request. This also means big bulk write requests are no longer split into multiple small transfers something that libusb consumers do not expect. From Grant Czajkowski <czajkow2 AT illinois DOT edu> as part of the GSoC 2015.
* Do not use an intermediary buffer on the stack of the caller whenmpi2015-09-031-8/+12
| | | | | | | | | | | | submitting a read request. This also means big read requests are no longer split into multiple small transfers something that libusb consumers do not expect. Tested by ajacatoutot@. Found by Grant Czajkowski <czajkow2 AT illinois DOT edu> during the GSoC 2015.
* Do not use usbd_endpoint_count() and usbd_interface_count(), thesesmpi2015-07-101-31/+18
| | | | | | | functions are almost unused and create confusion. Do like the rest of the drivers and simply get an interface or device descriptor. Tested by ajacoutot@ and Grant Czajkowski, thanks!
* Set the length of isochronous transfers as the sum of the frames lengths.mpi2015-06-151-7/+6
| | | | | | | | | | | | This reduces differences between non-isoch and isoch transfers submissions, makes the generic DMA buffer overrun check work with isoch transfers and will allow some code simplifications in HC drivers. Since short-transfers were never checked for isoch transfers, we now need to pass the USBD_SHORT_XFER_OK flag to not change this behavior. This might be revisited later. ok ratchov@
* Prevent a use after free in by closing all open endpoints upon detach.mpi2015-05-251-14/+30
| | | | | | Fix a panic reported by landry@ with Android's ADB. Tested and ok ajacoutot@
* Remove some includes include-what-you-use claims don'tjsg2015-03-141-2/+1
| | | | | | | have any direct symbols used. Tested for indirect use by compiling amd64/i386/sparc64 kernels. ok tedu@ deraadt@
* First step towards making uiomove() take a size_t size argument:miod2015-02-101-9/+9
| | | | | | | - rename uiomove() to uiomovei() and update all its users. - introduce uiomove(), which is similar to uiomovei() but with a size_t. - rewrite uiomovei() as an uiomove() wrapper. ok kettenis@
* use mallocarray()deraadt2015-01-111-2/+2
|
* tedu another bunch of DVACT_DEACTIVATE handlers that do nothing but setmpi2014-07-121-17/+2
| | | | the 'dying' flag.
* add a size argument to free. will be used soon, but for now default to 0.tedu2014-07-121-13/+13
| | | | after discussions with beck deraadt kettenis.
* Fix debug printf formating and kill some trailing whitespaces while here.mpi2014-07-111-20/+16
|
* Kill matchlvl usage throughout the usb stack.pirofti2013-11-191-5/+1
| | | | | | Allows us to move forward on cleaning. Okay mpi@
* Replace sc_dying in favour of usbd_is_dying() and usbd_deactivate().pirofti2013-11-061-13/+12
| | | | Okay mpi@
* Begin conversion of USB stack to return int instead of usbd_status,jeremy2013-11-021-7/+7
| | | | | | | | | | starting with usbd_endpoint_count and usbd_interface_count. usbd_status should only be used to indicate the status of a USB transfer, it should not be used for generic error codes. Idea from and much hand-holding by mpi@ OK mpi@
* Unify and document usbd_transfer(9).mpi2013-09-201-13/+24
| | | | | | | | | | | Get rid of the badly named usbd_bulk_transfer() and usbd_intr_transfer() they were two identical wrappers to submit a synchronous transfer. Now all synchronous transfers are submited using usbd_setup_xfer(9) and usbd_transfer(9) explicitly using the USBD_CATCH flag when signals must be checked. Previous version ok'd by mglocker@, with subtle inputs from miod@
* Don't leak information to userland in case the actual transfer length ismpi2013-05-171-1/+4
| | | | | | | | | | smaller than the requested one. From ws@NetBSD via miod@. This problem can only occur when the USBD_SHORT_XFER_OK flag is set, otherwise completed transfers with a length smaller than the one submitted are treated as errors. ok miod@
* Get rid of various 'typedef struct' definitions and use plain structuremglocker2013-04-151-21/+18
| | | | | | | | | definitions instead. We don't change usb.h for now to stay compatible with userland. Tested by mpi@ on macppc and myself on i386. ok mpi@
* Make ugen_get_cdesc() a generic function by renaming it to usbd_get_cdesc()mglocker2013-04-011-43/+6
| | | | | | and move it to usb_subr.c. OK mpi@
* proc.h is way too much header for usb to handle.tedu2013-03-281-2/+1
|
* Avoid kernel crash by removing double clfree() on endpoint closing formglocker2011-12-071-2/+1
| | | | | | ugen(4) devices. From NetBSD PR#37934 spotted by Logan Aden.
* Return EINVAL when there's no config descriptor for a given index.mpi2011-10-141-1/+3
| | | | | | Problem reported by ajacoutot@ ok deraadt@, kettenis@, krw@
* Remove config_activate() and DVACT_ACTIVATE. PCMCIA's the only thingmatthew2011-07-031-4/+1
| | | | | | | | that's ever used it, and it's long since been changed to use DVACT_{QUIESCE,SUSPEND,RESUME} instead. ok deraadt@, dlg@; miod@ also agreed with this idea when I brought it up a few weeks ago