Add missing sanity checks on get_firmware-request offset and size
parameters to fix potential information leaks.
This prevents remotely controlled information leaks as the requestor
currently controls both the 32-bit firmware-image offset and the amount
of data that is returned (up to host-device MTU).
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
If payload length of a transfer packet is 0, no response is allocated.
Send a well-formed response even in that case.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
The size of timestamps is not taken into account, which makes the
loopback driver in the firmware drop invalid packages.
Signed-off-by: Alexandre Bailon <abailon@baylibre.com>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
The descriptor list is walked in two points, in the bundle parsing and
cport parsing, this can make the next descriptor pointer in bundle to be
already removed by the cport remove descriptor and become invalid.
So, just get the next bundle until there no more left.
Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Allocate protocol and class values for the Audio Device Class
Protocol. Two values of each type are allocated: one for Audio
Management Connections and one for Audio Data Connections.
Signed-off-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
This was used by gbsim earlier, but not anymore. Lets remove it.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
This is a major rework and changes to the current implementation of the
battery protocol. The previous implementation lack the support of a more
dynamic handle of power supply properties and updating of status. Also,
reflect the actual state of the greybus specification
So, with this new approach a set of operations to fetch the battery
module configuration and properties is add, new methods to cache and
update the values of properties, new operation to set properties if
declared writable and an event operation that can be triggered by the
module to force an update read on the properties values.
Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Add check for POWER_SUPPLY config option to guarantee that it is enabled.
Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Rename protocol to POWER_SUPPLY and implementation details from battery
to power_supply.
Also fix some tabs between define and macro name.
Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Rename the battery.c to power_supply.c and update the makefile as the
Greybus protocol is being renamed from battery to power_supply.
Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
wIndex field has a special meaning, as that can be used by the core to
index into the possible USB interfaces. And that specifically broke with
gbsim, as it has a single USB interface.
Other similar requests (REQUEST_LATENCY_TAG_{EN|DIS}) are already using
wValue field for passing cport-id.
Fix cport_reset() by sending the cport-id in wValue field instead of
wIndex.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Tested-by: Fabien Parent <fparent@baylibre.com>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Fix up the few places where hexadecimal rather than decimal notation was
used for interface and cport ids.
Note that this includes the endo sysfs-attribute for the AP interface
id.
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Fix obsolete comment that was referring to "module" rather than
"interface".
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Fix resources (accessible through sysfs) being released before interface
is deregistered.
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Greybus bundle drivers should register their class devices as children
to the bundle device that they bind to.
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Greybus bundle drivers should register their class devices as children
to the bundle device that they bind to.
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
A bundle (protocol) driver has no business creating sysfs entries for an
ancestor device.
Move the sysfs entries to the bundle device for now.
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
HID is a stand-alone greybus protocol, not part of the bridged-phy
protocols, so make it a stand-alone kernel module.
Note, some hard-coded android init script might need to be changed to
load the gb-hid.ko kernel module now.
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Now that the host-device is deregistered separately from deallocation,
we can simplify the cport_to_ep-array deallocation.
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Fix host-device life time issues by separating host-device allocation
from registration.
This is needed both to make sure that all host-device resources are
available before registering the device and to prevent such resources
from being deallocated while the device is still in use during device
removal.
This specifically fixes the following warnings during es1 and es2
disconnect:
usb 1-1.1: No free CPort OUT urbs, having to dynamically allocate one!
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Add more structure to probe error handling rather than use the big
hammer and call disconnect directly.
This is needed to fix some host-device life-time issues.
Note that there was never any need to clear the USB interface data as
this will be done by driver core.
Compile-only tested.
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Add more structure to probe error handling rather than use the big
hammer and call disconnect directly.
This is needed to fix some host-device life-time issues.
Note that there was never any need to clear the USB interface data as
this will be done by driver core.
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Fix dentry leak due to failure to remove debugfs file.
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Fix dentry leak due to failure to remove debugfs file.
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Separate stopping and deallocating our in-urbs.
This will facilitate implementing proper host-device life-time management.
Compile-only tested.
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Separate stopping and deallocating our in-urbs.
This will facilitate implementing proper host-device life-time management.
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Separate in-urb allocation and submission.
This is needed for the driver-model rework.
Compile-tested only.
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Refactor in-urb submission, and make sure to separate allocation and
submission.
Eventually we'll be submitting the urbs at cport enable rather than at
probe, and this is also needed for the driver-model rework.
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
The current es2 implementation only checks for no IN or OUT bulk
endpoints, but still assumes there are precisely NUM_BULKS of each.
Specifically, urbs could be allocated and initialised to default values,
which amounts to bulk urbs being submitted to the control endpoint.
We should be able to handle any number of endpoints, but for now let's
just require NUM_BULKS of each.
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
The interface private data is released as part of host-device removal
and must not be accessed afterwards.
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
The Greybus I2S Bridged-PHY Protocol is deprecated so remove
all support for it from the Greybus code.
CC: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Signed-off-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
The Greybus I2S Bridged-PHY Protocol is now deprecated so remove
the audio driver that is based on it.
CC: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Signed-off-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Rename the exported functions using the common gb_-prefix.
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Rename host-driver structure to gb_hd_driver to more clearly separate it
from the host-device structure.
Also remove an outdated description of the struct.
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Move everything host-device related to hd.c and hd.h.
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Fix yet another ida memory leak due to failure to call the destructor.
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Connections are destroyed as part of interface tear down. If we fail to
do that properly it's a bug that should be fixed rather than papered
over by a fall-back clean up function.
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
We can have connections without bundles so we must not use the bundle
device for error messages when failing to look up a protocol.
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
We allow connections without bundles so we must not use the bundle
device for error messages after binding the protocol.
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Use parent of host device for error messages as the connections bundle
may be NULL.
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
It is safe to use the bundle device for error messages when we know we
have a bundle.
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
The connection device type is no longer used.
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Remove request handler for control protocol that makes no sense as we do
not have any incoming control requests defined.
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Remove unused time-stamp defines, that were left in when the time-stamp
fifo was removed.
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>