Drop some unnecessary termios-flag debugging that have been faithfully
reproduced in a few old drivers, including the "clfag" typo and all.
This also addresses a compiler warning on sparc where tcflag_t is
unsigned long and would have required an explicit cast.
Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
Setup each port to use the first bulk-out endpoint in calc_num_ports so
that core allocates the corresponding port resources for us.
Signed-off-by: Johan Hovold <johan@kernel.org>
Setup each port to use the first bulk-out endpoint in calc_num_ports so
that core allocates the corresponding port resources for us.
Signed-off-by: Johan Hovold <johan@kernel.org>
Add an explicit sanity check to make sure we have the expected
endpoints. This will provide a descriptive error message in case an
expected endpoint is missing when probing.
Note that the driver already gracefully fails to probe (albeit with a
less descriptive error message) if a bulk-in endpoint is missing, and an
attempt to write to a port whose device lack a bulk-out endpoint would
fail with -ENODEV.
Signed-off-by: Johan Hovold <johan@kernel.org>
Print a message and register two ports for interfaces for which we do
not know how many ports there are instead of binding, allocating
resources, but not register any ports.
This provides a hint that anyone adding a dynamic device id must also
provide a reference id (driver info) from which the port count can be
retrieved, for example:
echo <vid> <pid> 0 0x110A 0x1410 > new_id
Signed-off-by: Johan Hovold <johan@kernel.org>
Use the new endpoint-remap functionality to configure the ports for
treo devices instead of poking around in the port structures after the
ports have been setup.
Signed-off-by: Johan Hovold <johan@kernel.org>
Use the new endpoint-remap functionality to configure the ports for
clie_5 devices.
Note that the same bulk-out endpoint is being used for both ports.
Signed-off-by: Johan Hovold <johan@kernel.org>
Drop the redundant calc_num_ports callback from the clie_5 type, for
which the callback always returns zero and hence falls back to the type
num_ports value (2).
Signed-off-by: Johan Hovold <johan@kernel.org>
These devices always require at least one bulk-out endpoint so let core
verify that.
This avoids attempting to send bulk data to the default pipe when
downloading firmware in boot mode.
Note that further endpoints are still needed when not in boot mode.
Signed-off-by: Johan Hovold <johan@kernel.org>
Now that the endpoint-port mapping has been properly set up during
probe, we can switch to using the more efficient generic write
implementation.
Note that this currently means that chars_in_buffer now overcounts
slightly as we always write a full endpoint-sized packet.
Also add a copyright entry.
Signed-off-by: Johan Hovold <johan@kernel.org>
These devices use the second bulk-out endpoint for writing. Instead of
using the resources of the second port structure setup by core, use the
new endpoint-remap functionality to simply ignore the first bulk-out
endpoint. This specifically avoids allocating resources for the unused
endpoint.
Note that the disconnect callback was always redundant as all URBs would
have been killed by USB core on disconnect.
Signed-off-by: Johan Hovold <johan@kernel.org>
Clean up the endpoint sanity check by letting core verify the single
interrupt endpoint, and verifying the bulk endpoints in calc_num_ports
after having determined the number of ports.
Note that the static type num_ports field was neither correct or used
(since calc_num_ports never returns zero).
Signed-off-by: Johan Hovold <johan@kernel.org>
This driver have treated the interrupt endpoint as optional despite it
always being present (according to the datasheet). Let's consider it
mandatory instead.
Signed-off-by: Johan Hovold <johan@kernel.org>
Clean up the mcs7715 port setup by using the new endpoint-remap
functionality provided by core. Instead of poking around in internal
port-structure fields, simply swap the endpoint descriptors of the two
ports in calc_num_ports before the port structures are even allocated.
Note that we still need to override the default interrupt completion
handler.
Signed-off-by: Johan Hovold <johan@kernel.org>
Drop the redundant read-urb check from open. The presence of a bulk-in
endpoint is now verified during probe and core has allocated the
corresponding resources.
Signed-off-by: Johan Hovold <johan@kernel.org>
Verify that the required interrupt endpoint is present at probe rather
than at open to avoid allocating resources for an unusable device.
Note that the endpoint is only required when in download mode.
Signed-off-by: Johan Hovold <johan@kernel.org>
These devices always require at least one bulk-out endpoint so let core
verify that.
This avoids attempting to send bulk data to the default pipe when
downloading firmware in boot mode.
Note that further endpoints are still needed when not in boot mode.
Signed-off-by: Johan Hovold <johan@kernel.org>
Use the calc_num_ports rather than attach callback to verify that the
required endpoints are present when in download mode.
This avoids allocating port resources for interfaces that won't be bound.
Signed-off-by: Johan Hovold <johan@kernel.org>
Use the calc_num_ports callback to ignore unused endpoints.
The driver binds to any interface with at least one bulk-in and one
bulk-out endpoint, but some devices can have three or more endpoints of
which only either the first or second pair of endpoints is needed.
This avoids allocating resources for unused endpoints, and specifically
a port is no longer registered for the unused first endpoint pair when
there are more than three endpoints.
Signed-off-by: Johan Hovold <johan@kernel.org>
Use the calc_num_ports rather than attach callback to determine which
interface to bind to in order to avoid allocating port-resources for
interfaces that won't be bound.
Signed-off-by: Johan Hovold <johan@kernel.org>
We can now abort probe early after an error in calc_num_ports by
returning an errno instead of attempting to continue probing but not
register any ports.
Signed-off-by: Johan Hovold <johan@kernel.org>
Simplify the endpoint sanity check by letting core verify that the
required endpoints are present and moving the max-packet check to
calc_num_ports.
Signed-off-by: Johan Hovold <johan@kernel.org>
Use the calc_num_ports rather than probe callback to determine which
interface to bind to.
This allows us to remove some duplicate code.
Signed-off-by: Johan Hovold <johan@kernel.org>
Implement the "horrible endpoint hack" for some legacy devices as a
quirk and clean up the code somewhat.
Note that the bulk-endpoint check can be removed as core will already
have verified this.
Signed-off-by: Johan Hovold <johan@kernel.org>
Some pl2303 devices require the use of the interrupt endpoint of an
unrelated interface. This has so far been dealt with in usb-serial core,
but can now be moved to a driver calc_num_ports callback.
Note that we relax the endpoint requirements checked by core and instead
verify that we have an interrupt-in endpoint in calc_num_ports for all
devices so that the hack can first be applied.
Signed-off-by: Johan Hovold <johan@kernel.org>
Relax the generic driver bulk-endpoint requirement. The driver handles
devices without bulk-out endpoints just fine these days.
Signed-off-by: Johan Hovold <johan@kernel.org>
Add a calc_num_ports callback to the generic driver and verify that the
device has the required endpoints there instead of in core.
Note that the generic driver num_ports field was never used.
Signed-off-by: Johan Hovold <johan@kernel.org>
Add a probe callback to the generic driver and print the
only-for-testing message there.
This is a first step in getting rid of the CONFIG_USB_SERIAL_GENERIC
ifdef from usb-serial core.
Signed-off-by: Johan Hovold <johan@kernel.org>
Allow subdrivers to modify the port-endpoint mapping by passing the
endpoint descriptors to calc_num_ports.
The callback can now also be used to verify that the required endpoints
exists and abort probing otherwise.
This will allow us to get rid of a few hacks in subdrivers that are
already modifying the port-endpoint mapping (or aborting probe due to
missing endpoints), but only after the port structures have been setup.
Signed-off-by: Johan Hovold <johan@kernel.org>
Simplify the endpoint sanity check by letting core verify that the
required endpoints are present.
Note that the driver registers four ports but uses five bulk-endpoint
pairs.
Signed-off-by: Johan Hovold <johan@kernel.org>
Simplify the endpoint sanity check by letting core verify that the
required endpoints are present.
Note that the driver uses the second bulk-out endpoint for writing.
Signed-off-by: Johan Hovold <johan@kernel.org>
Simplify the endpoint sanity check by letting core verify that the
required endpoints are present.
Note that the driver expects two bulk-endpoint pairs also for mcs7715
devices for which only one serial port is registered.
Signed-off-by: Johan Hovold <johan@kernel.org>
Simplify the endpoint sanity check by letting core verify that the
required endpoints are present.
Also require the presence of a bulk-out endpoint, something which
prevents the driver from trying to send bulk messages over the control
pipe should a bulk-out endpoint be missing.
Signed-off-by: Johan Hovold <johan@kernel.org>
Simplify the endpoint sanity check by letting core verify that the
required endpoints are present.
Note that this driver uses an additional bulk-endpoint pair as an
out-of-band port.
Signed-off-by: Johan Hovold <johan@kernel.org>
Allow drivers to specify a minimum number of endpoints per type, which
USB serial core will verify after subdriver probe has returned (where
the current alternate setting may have been changed).
Signed-off-by: Johan Hovold <johan@kernel.org>
Since commit 0a8fd13462 ("USB: fix problems with duplicate endpoint
addresses") USB core guarantees that there are no more than 15 endpoint
descriptors per type (and altsetting) so the corresponding overflow
checks can now be replaced with a compile-time check on the array sizes
(and indirectly the maximum number of ports).
Signed-off-by: Johan Hovold <johan@kernel.org>
Raise the arbitrary limit of how many ports a single device can claim
from eight to 16.
This specifically enables the upper eight ports of some mxuport devices.
Signed-off-by: Johan Hovold <johan@kernel.org>
Refactor and clean up endpoint handling.
This specifically moves the endpoint-descriptor arrays of the stack.
Note that an err_free_epds label is not yet added to avoid a compilation
warning when neither CONFIG_USB_SERIAL_PL2303 or
CONFIG_USB_SERIAL_GENERIC is selected.
Signed-off-by: Johan Hovold <johan@kernel.org>