Commit Graph

50 Commits

Author SHA1 Message Date
Mateusz Guzik
9dd3156e54 usb: clean up empty lines in .c and .h files 2020-09-01 21:26:44 +00:00
Pedro F. Giffuni
718cf2ccb9 sys/dev: further adoption of SPDX licensing ID tags.
Mainly focus on files that use BSD 2-Clause license, however the tool I
was using misidentified many licenses so this was mostly a manual - error
prone - task.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.
2017-11-27 14:52:40 +00:00
Hans Petter Selasky
0eb8d46232 Improve USB polling mode by not locking any mutexes, asserting any
mutexes or using any callouts when active.

Trying to lock a mutex when KDB is active or the scheduler is stopped
can result in infinite wait loops. The same goes for calling callout
related functions which in turn lock mutexes.

If the USB controller at which a USB keyboard is connected is idle
when KDB is entered, polling the USB keyboard via USB will always
succeed. Else polling may fail depending on which state the USB
subsystem and USB interrupt handler is in. This is unavoidable unless
KDB can wait for USB interrupt threads to complete before stalling the
CPU(s).

Tested by:	Bruce Evans <bde@freebsd.org>
MFC after:	4 weeks
2016-09-14 12:07:34 +00:00
Hans Petter Selasky
94bceb529a Revert r290327. The compiler warnings seems to be specific to clang v3.5 only. 2015-11-03 09:38:39 +00:00
Hans Petter Selasky
b4f0cda47b Fix some clang compile warnings.
MFC after:	1 week
2015-11-03 08:52:06 +00:00
Hans Petter Selasky
415bcd89a6 Add support for DYMO LabelWriter PnP.
MFC after:		2 weeks
2015-05-07 12:54:27 +00:00
Hans Petter Selasky
c3871e6426 Separate out detection of prevent and allow medium removal quirk.
PR:		185747
MFC after:	1 week
2015-02-02 18:20:10 +00:00
Hans Petter Selasky
9f21f476bf Increase the maximum number of dynamic USB quirks. USB memory stick
devices which don't support the synchronize cache SCSI command are
likely to also not support the prevent-allow medium removal SCSI
command.

PR:		185747
MFC after:	1 week
2015-01-12 06:34:23 +00:00
Nick Hibma
dc26b3369f Return USB_ERR_INVAL if the eject method is not known.
PR:		145319
Submitted by:	rozhuk.im gmail.com
2014-08-05 09:59:16 +00:00
Nick Hibma
c5377460ea Add a second Huawei SCSI eject command as USB mode switch config files
sometimes use one or the other. Maybe newer Huawei modems switched.

Add a quirk for it as well.

PR:		145319
Submitted by:	rozhuk.im gmail.com
2014-08-05 09:35:25 +00:00
Nick Hibma
e28d2b2275 Reset the error value in the softc before starting a BBB transfer.
PR:		145319
Submitted by:	rozhuk.im gmail.com
MFC after:	3 days
2014-08-05 08:48:24 +00:00
Hans Petter Selasky
ce19294c0e Make driver detach code in USB mass storage test optional.
Sponsored by:	DARPA, AFRL
2014-05-30 13:45:20 +00:00
Hans Petter Selasky
e045de0740 Add support for basic read, write and read capacity disk operations to
the USB mass storage test utility file.

Sponsored by:	DARPA, AFRL
2014-05-30 07:30:24 +00:00
Hans Petter Selasky
273c749c93 Fix some statical clang analyzer warnings. 2013-05-25 17:09:58 +00:00
Hans Petter Selasky
6950c75f40 - Move scratch data from the USB bus structure to the USB device structure
so that simultaneous access cannot happen. Protect scratch area using
the enumeration lock. Also reduce stack usage in usbd_transfer_setup()
by moving some big stack members to the scratch area. This saves around
200 bytes of stack.
- Fix a whitespace.

MFC after:	1 week
2013-02-10 10:56:13 +00:00
Hans Petter Selasky
ff182db6c8 Fix some nits. 2013-02-05 13:30:07 +00:00
Hans Petter Selasky
d2b99310b1 Modify the FreeBSD USB kernel code so that it can be compiled directly
into the FreeBSD boot loader, typically for non-USB aware BIOSes, EFI systems
or embedded platforms. This is also useful for out of the system compilation
of the FreeBSD USB stack for various purposes. The USB kernel files can
now optionally include a global header file which should include all needed
definitions required to compile the FreeBSD USB stack. When the global USB
header file is included, no other USB header files will be included by
default.

Add new file containing the USB stack configuration for the
FreeBSD loader build.

Replace some __FBSDID()'s by /* $FreeBSD$ */ comments. Now all
USB files follow the same style.

Use cases:
 - console in loader via USB
 - loading kernel via USB

Discussed with:		Hiroki Sato, hrs @ EuroBSDCon
2013-01-30 15:26:04 +00:00
Hans Petter Selasky
607bbcba30 Fix more regression issue after r244503.
usbd_transfer_setup() does not set a default length for USB transfers.
Only the number of frames is automatically setup.

MFC after:	1 week
2012-12-24 10:10:18 +00:00
Hans Petter Selasky
2691bc24f1 Fix regression issue after r244503.
MFC after:	1 week
2012-12-23 10:21:01 +00:00
Hans Petter Selasky
c180b3986d Make sure all USB drivers allocate buffer memory
through the USB API and/or busdma.

The following assumptions have been made:
umass - buffers passed from CAM/SCSI layer are OK
network - mbufs are OK.

Some other nits while at it.

MFC after:	1 week
Suggested by:	imp
2012-12-20 18:38:02 +00:00
Hans Petter Selasky
7a75e881d7 If a USB mass storage device doesn't respond properly
to the initial SCSI INQUIRY command, enable all quirks.
This fixes detection of some Transcend TS2GUFM devices.

MFC after:	1 week
Reported by:	Michael Dexter
2012-10-30 16:56:16 +00:00
Hans Petter Selasky
0cb5abc7ca Improve auto-quirks detection for certain Kingston memory sticks.
MFC after:	2 weeks
2012-08-13 18:00:34 +00:00
Hans Petter Selasky
6d917491f5 Fix compiler warnings, mostly signed issues,
when USB modules are compiled with WARNS=9.

MFC after:	1 weeks
2012-04-02 10:50:42 +00:00
Hans Petter Selasky
87812fcec3 Fix a compile warning with clang.
Reported by:	arundel @
MFC after:	3 days
2011-12-03 14:54:44 +00:00
Hans Petter Selasky
271ae033e9 Style change.
- Make it easier to port the USB code to other platforms by only using
one set of memory functions for clearing and copying memory. None of
the memory copies are overlapping. This means using bcopy() is not
required.
- Fix a compile warning when USB_HAVE_BUSDMA=0
- Add missing semicolon in avr32dci.
- Update some comments.

MFC after:	1 week
2011-11-12 08:16:45 +00:00
Hans Petter Selasky
9157ad4b17 Improve USB mass storage quirk auto detection.
MFC after:	3 days
2011-10-29 12:32:13 +00:00
Hans Petter Selasky
7cd72d8565 Reduce USB memory usage during enumeration.
We are allocating some kilobytes of extra memory during USB device enumeration.
This does not change alot under FreeBSD, but makes sense for various embedded
operating systems using the FreeBSD USB stack, which have less memory
resources available.

Approved by:	re (kib)
MFC after:	1 week
2011-09-14 15:16:53 +00:00
Hans Petter Selasky
d334432fd3 Some USB mass storage devices requires that the sense information
is retrieved after a failed SCSI command to continue normal
operation. Else this sense information is retrived at the next
SCSI command.

Approved by:	re (kib)
Reported by:	Alex Kozlov
MFC after:	1 week
PR:		usb/160299
2011-09-05 14:37:59 +00:00
Hans Petter Selasky
d46dc4ad74 This patch adds automatic detection of USB mass storage devices
which does not support the no synchronize cache SCSI command.

The __FreeBSD_version version macro has been bumped and
external kernel modules needs to be recompiled after
this patch.

Approved by:    re (kib)
MFC after:      1 week
PR:		usb/160299
2011-09-02 18:50:44 +00:00
Kevin Lo
ee6eac62f7 Remove duplicate header includes 2011-06-28 08:36:48 +00:00
Hans Petter Selasky
a6b6015063 - Move execution of event handlers into the probe and attach function so that
dynamically loaded device drivers get a chance to run their event hooks.

- Decouple the USB suspend and resume lock from witness. It produces some
false warnings due to reusing the lock name among multiple devices.

MFC after:	3 days
2011-06-24 18:14:43 +00:00
John Baldwin
58ccf5b41c Remove unneeded includes of <sys/linker_set.h>. Other headers that use
it internally contain nested includes.

Reviewed by:	bde
2011-01-11 13:59:06 +00:00
Gleb Smirnoff
19f5434963 We already have dummy receive buffer in sc->buffer.
Suggested by:	hselasky
2010-10-12 09:41:42 +00:00
Gleb Smirnoff
a4cd76e4a2 Remove extra assignment. 2010-10-06 14:29:50 +00:00
Gleb Smirnoff
fb7a4d496b Add support to Alcatel/TCTMobile X080S USB 3G modem. The device needs
special eject command to reappear as modem. It also requires DIR_IN flag
in the command message, so we supply some dummy data along with the command.

Feedback from X080S owners appreciated. I have not a pure Alcatel/TCTMobile
device, but another one under "Svyaznoy" (Связной) brand, and I didn't yet
managed to get it working. It is successfully recognized, it responds to
AT commands, but it shuts up right after successfull CONNECT response.

Reviewed by:	hps
2010-10-06 14:29:00 +00:00
Andrew Thompson
2386d71421 Add support for the E1752 3G modem and the required eject command.
Submitted by:	Milan Obuch
2010-02-14 20:05:12 +00:00
Andrew Thompson
e33b1a7e54 Fix debug printf on 64bit arches.
Spotted by:	b. f.
2010-01-07 02:25:19 +00:00
Andrew Thompson
d84a79e731 Improve u3g device ejecting by providing additional methods for the eject
command in the usb_msctest routines, as well as a general tidyup.

This now properly ejects the ZTE MF636, Option Gi0322 and Novatel MC950D
devices I have on my desk.
2010-01-06 22:14:05 +00:00
Andrew Thompson
767cb2e29d Remove overuse of exclamation marks in kernel printfs, there mere fact a
message has been printed is enough to get someones attention. Also remove the
line number for DPRINTF/DPRINTFN, it already prints the funtion name and a
unique message.
2009-11-26 00:43:17 +00:00
Andrew Thompson
ed6d949afd - Make struct usb_xfer opaque so that drivers can not access the internals
- Reduce the number of headers needed for a usb driver, the common case is just   usb.h and usbdi.h
2009-06-23 02:19:59 +00:00
Andrew Thompson
a593f6b8de s/usb2_/usb_|usbd_/ on all function names for the USB stack. 2009-06-15 01:02:43 +00:00
Andrew Thompson
8437751d86 Remove usb2_cv_* and just use the kernel condvar implementation, it was needed
earlier since condition variables didnt work with Giant but this was fixed 10
months ago.
2009-06-15 00:33:18 +00:00
Andrew Thompson
f9cb546c23 Revert the size_t part of the last commit for the moment, this blows up the
USB_ADD_BYTES macro.
2009-05-30 00:22:57 +00:00
Andrew Thompson
e0a69b51ac s/usb2_/usb_/ on all typedefs for the USB stack. 2009-05-29 18:46:57 +00:00
Andrew Thompson
760bc48e7e s/usb2_/usb_/ on all C structs for the USB stack. 2009-05-28 17:36:36 +00:00
Andrew Thompson
4eae601ebd MFp4 //depot/projects/usb@159909
- make usb2_power_mask_t 16-bit
- remove "usb2_config_sub" structure from "usb2_config". To compensate for this
  "usb2_config" has a new field called "usb_mode" which select for which mode
  the current xfer entry is active. Options are: a) Device mode only b) Host
  mode only (default-by-zero) c) Both modes.  This change was scripted using
  the following sed script: "s/\.mh\././g".
- the standard packet size table in "usb_transfer.c" is now a function, hence
  the code for the function uses less memory than the table itself.

Submitted by:	Hans Petter Selasky
2009-04-05 18:20:38 +00:00
Andrew Thompson
090f65a6f6 MFp4 //depot/projects/usb@159517
Fix warnings with the IAR compiler.

Submitted by:	Hans Petter Selasky
2009-03-20 22:10:36 +00:00
Andrew Thompson
578d0eff90 MFp4 //depot/projects/usb @159431,159437,159438
- start using the new USB typedefs in the USB core
- Remove usage of USB_ADD_BYTES()

Submitted by:	Hans Petter Selasky
2009-03-20 21:50:54 +00:00
Andrew Thompson
ab42e8b2df MFp4 //depot/projects/usb @159430
- Move tunable defines into usb_core.h and dependancy towards usb_defs.h
- Leave hardcoded defines in "usb_defs.h".
- Allow overriding all tunable defines.
- Add more customisable typedefs.
- Correct maximum device number.

Submitted by:	Hans Petter Selasky
2009-03-20 19:04:31 +00:00
Andrew Thompson
02ac645488 Move the new USB stack into its new home. 2009-02-23 18:31:00 +00:00