Commit graph

891 commits

Author SHA1 Message Date
Viresh Kumar 4f4cc1bf07 greybus: endo: Add code to validate Endo ID
Endo is described by a 16 bit value. Which represents the properties of
modules, interface and ribs on front and back of endo.

This 16 bit value can be used to find all possible pairs of modules and
interfaces and creating modules based on that.

This patch provides helpers to parse 16 bit Endo ID.

(Based on original code written by Alex Elder.)

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-05-11 13:30:09 -07:00
Greg Kroah-Hartman 61c0926eec greybus: gb-audio: fix build breakage on 4.1-rc1
In commit 1efb53a220 ("ASoC: simple-card: Remove support for setting
differing DAI formats"), the .fmt field was removed from struct
asoc_simple_dai.  Fix this build breakage by not trying to set it.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Acked-by: John Stultz <john.stultz@linaro.org>
2015-05-11 13:26:44 -07:00
Greg Kroah-Hartman 7f3f356e45 greybus: gb-audio: fix build warning
sizeof wants %zu when on a 64bit build, so change the dev_err() call to
remove a build warning in the audio.c file.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Acked-by: John Stultz <john.stultz@linaro.org>
2015-05-11 13:26:44 -07:00
Bryan O'Donoghue 68fff9604b greybus: Support building greybus on host PC
Introduce INSTALL_MOD_PATH to allow for building and installing of the
greybus modules from a different location.

This lets you build the greybus modules on a PC and then install the
modules to an SD card in the appropriate location relative to the SD such
as /media/sdcard/lib/modules/version and subsequent running of depmod in
the same location. If INSTALL_MOD_PATH isn't specified the default
behaviour of installing and depmoding to /lib/modules/version is
maintained.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-05-08 23:09:01 +02:00
John Stultz a4749bbeee greybus: gb-audio: Add integrated greybus audio driver
So here's the current greybus audio driver, which I
wanted to send out for more serious review and
consideration for merging.

I've tried to integrate much of the feedback from the
last round and most of the hotplug issues that I've found
have been resolved. I've tested this via gbsim, and the
Android ARA HAL layer seems to work with it.

Mark has also successfully played audio with this driver,
adding a few hacks to get the codec's i2c connection to
probe.

Current issues:
* Hotplug problem - When gbsim is killed, or the module
  removed, the greybus driver gets stuck since the android
  mediaserver process is holding the audio device open.
  Killing the mediaserver allows things to clean up and
  allows greybus to accept new gbsim connections. I have
  a workaround patch to the soc-core.c logic which converts
  the snd_card_free() call to snd_card_free_when_closed()
  which allows the greybus connection cleanup to finish.

Remaining todos:
* Probably need to break apart the mgmt_setup function
  to integrate better with the constraint logic. I took
  a really basic stab at this, but more is probably
  needed.
* Figure out how to properly find and tie in the
  codec's I2C bus-id to the driver.

This code requires that the kernel support the following
config options, which I've enabled in a separate kernel
patch:
	CONFIG_SND_SIMPLE_CARD
	CONFIG_SND_SOC_SPDIF
	CONFIG_SND_SOC_RT5645

I really can't calim to be the sole author of this, since
many many fixes and tweaks that have been folded in have
come from Mark Greer. His analsysis and debugging is really
what has made this dummy-framework driver evolve into an
actual audio driver. So much credit and thanks to Mark!

Signed-off-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-05-08 22:23:58 +02:00
Alex Elder 6d653370c0 greybus: eliminate extra response flag definitions
All protocols use the same value to distinguish between request and
response message types.  This is a requirement.

Use GB_MESSAGE_TYPE_RESPONSE rather than GB_OPERATION_TYPE_RESPONSE
for the name of the flag used to distiguish between request and
response messages.

Get rid of the redundant response flag definitions that are
associated with specific protocols.

Describe the symbolic values as "operation types" rather than
"message types" where they are defined.  The message type for a
request is the same as the operation type; the message type for a
response is the operation type OR'd with GB_MESSAGE_TYPE_RESPONSE.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-05-07 22:57:31 +02:00
Alex Elder 5c58640d8d greybus: battery: use feature tag rather than kernel version
Conditionally define a new symbol DRIVER_OWNS_PSY_STRUCT, which is
set in "kernel_ver.h" based on on the kernel version.  Use it to
distinguish code used for kernels that differ in whether a power
supply structure is owned by the driver, or by the power supply
core.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-05-07 22:55:43 +02:00
Alex Elder 9ade6d3122 greybus: battery: free struct on error in caller
When a battery connection is initialized, a gb_battery structure for
it is allocated in gb_battery_connection_init().  Currently that
function ends by calling init_and_register(); in the event an error
occurs, init_and_register() is responsible for freeing the allocated
gb_battery structure.

Make the code a bit better balanced by having the function that
allocates the structure be responsible for freeing it in case of
error.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-05-07 22:55:43 +02:00
Rob Herring c13c8bf0cc greybus: es2: fix driver name collision with es1
Both ES1 and ES2 drivers cannot be loaded due to a driver name conflict.
Give ES2 driver the correct name.

Signed-off-by: Rob Herring <rob.herring@linaro.org>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-05-05 23:14:17 +02:00
Greg Kroah-Hartman e80d09af1e greybus: protocol.h: fix up long lines in define_get_version()
No need to go past 80 characters for the define_get_version macro, so
fix up the indentation to not do so.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
2015-05-05 11:11:04 +02:00
Greg Kroah-Hartman f487c802cb greybus: protocol.h: macros should not have a trailing ';'
Remove the trailing ';' character from the gb_protocol_driver() macro as
it's not needed and is bad coding style.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
2015-05-05 11:11:03 +02:00
Greg Kroah-Hartman 63ca78b9ab greybus: kernel_ver.h: add a blank line after a variable definition
checkpatch reminds us that a blank line should go after a variable
definition, so fix it up here.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
2015-05-05 11:11:03 +02:00
Greg Kroah-Hartman 3906a59c96 greybus: kernel_ver.h: add a ' ' character to KERNEL_VERSION()
You should always put a space after a ',', so do it for the
KERNEL_VERSION() macro as well.  This makes checkpatch.pl happy also.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
2015-05-05 11:11:03 +02:00
Greg Kroah-Hartman 99a4bd5902 greybus: kernel_ver.h: fix leading space coding style issues
When cutting and pasting some of the ATTR macros into kernel_ver.h, I
dropped the tabs.  Fix this up and make checkpatch.pl happy.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
2015-05-05 11:11:03 +02:00
Greg Kroah-Hartman a549be5186 greybus: battery: update for 4.1 power supply api changes
The 4.1-rc1 kernel changed the power supply apis such that the
structures are now owned by the power supply core, and not the
individual drivers.  This broke the greybus battery driver, so update it
to support both the old and the new apis.

The API changes were such that I can't "hide" them in kernel_ver.h, but
rather the driver itself needs to have ugly #ifdefs in it.  I tried to
keep it to a minimum, making a sub-function for initializing the power
supply device that is implemented differently for different kernel
versions.

When this is submitted upstream, or if we ever move our AP development
to 4.1 or greater, the support for older kernels can be removed.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
2015-05-05 11:09:56 +02:00
Viresh Kumar f03eec8772 greybus: Move id-field before bundle-field in CPort Descriptor.
Note that this also makes sure the id-field is naturally aligned in case
we ever were to remove the __packed attribute.

Reviewed-by: Alex Elder <elder@linaro.org>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-05-01 21:08:05 +02:00
Viresh Kumar 499ee955a1 greybus: Explicitly add pad-bytes to manifest descriptors
Explicitly add pad-bytes to manifest descriptors to match their layout
in greybus specification.

Reviewed-by: Alex Elder <elder@linaro.org>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-05-01 21:08:05 +02:00
Viresh Kumar b022515ee6 greybus: Remove class descriptor
We carry this information as part of bundle descriptor now and this can
be removed.

Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-05-01 21:08:05 +02:00
Viresh Kumar 20f087ec5c greybus: manifest: drop interface-version field
It is not required anymore. Drop it.

Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-05-01 21:08:05 +02:00
Viresh Kumar 8a5286ed2a greybus: manifest: Remove vendor, product and unique-id from interface descriptor
These should come from control protocol instead.

For now, initialize this statically with a FIXME to not forget it later.

Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-05-01 21:08:05 +02:00
Alex Elder 22fd2a8ade greybus: bundle: use kstrdup() for state file
The kernfs code guarantees we'll get a NUL-terminated buffer.
Use kstrdup() rather than kzalloc() + memcpy() in state_store()
making it slightly clearer what we're doing.  This has the added
benefit of guaranteeing that the stored string has no NUL character
inside it.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-05-01 16:41:11 +02:00
Viresh Kumar 55b930cd17 greybus: manifest: Warn if descriptor size > expected size
A descriptor passed to AP can be bigger than what AP expects, if
manifest's minor version is higher with same major number as the AP. As
it can have some extra data in descriptor.

But, if AP and manifest versions are identical, or if the AP's minor
version is greater than the manifest version, we should at least warn
(if not fail).

Doing this would require some changes to record the manifest version
somewhere reachable by identify_descriptor().

For now, just warn if descriptor is bigger than expected.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-04-29 15:55:21 +02:00
Viresh Kumar fa2fbf16f6 greybus: manifest: Account for padding in string descriptor
String descriptors are padded towards the end to align them to 4 byte
boundaries. Take that into account while calculating expected size.

Reviewed-by: Alex Elder <elder@linaro.org>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-04-29 15:53:18 +02:00
Viresh Kumar af6e8b4233 greybus: Explicitly mark structures as packed
These structures are already marked as __packed, as these are enclosed
within:

	#pragma pack(push, 1)
	#pragma pack(pop)

Lets mark them __packed explicitly.

Reviewed-by: Alex Elder <elder@linaro.org>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-04-29 15:51:38 +02:00
Viresh Kumar 8f8b2297c0 greybus: endo: Rename endo's 'type' as 'id'
There can be three Endo types: mini, medium and large. And that's what
Endo 'type' should refer to.

But we have named the 16 bit number that uniquely represents a valid
endo, as its type. 'id' seems to be a more suitable name to that instead
of 'type'. Lets rename it.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-04-29 15:48:32 +02:00
Viresh Kumar 58d674650b greybus: endo: Use a real endo id
0x0555 isn't a valid endo id, use a real one.

0x4755 should be the Endo id for the (medium) Spiral 2 prototype. Lets
use that.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-04-29 15:48:31 +02:00
Greg Kroah-Hartman 6cf42a447d greybus: MODULE_LICENSE cleanup
These are all GPLv2-only kernel modules, so properly set the correct
MODULE_LICENSE string to make static checkers happy.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-04-17 16:12:49 +02:00
Greg Kroah-Hartman 75052a5504 greybus: bundle: add state sysfs file
A bundle has a state file, that is managed by the endo userspace
process.  This file can be written to and any process that is polling on
the file will be woken up and can read the new value.  It's a "cheap"
IPC for programs that are not allowed to do anything other than
read/write to kernel sysfs files.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-04-17 16:12:49 +02:00
Johan Hovold 1ffc12be55 greybus: loopback: fix 64-bit divisions
The code uses 64-bit divisions, which should be avoided, and also
prevents the module from loading on 32-bit systems:

	gb_loopback: Unknown symbol __aeabi_uldivmod (err 0)

Fix by using the kernel's 64-bit by 32-bit division implementation
do_div.

Compile tested only. I did not look very closely at the code itself.
Perhaps this could be worked around in some other way, but this silences
the linker warning and allows the module to be loaded.

Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-04-16 10:26:33 +02:00
Greg Kroah-Hartman dcd1dadd7e greybus: gpbridge.h: remove BIT() define
It's up to other files to define this if it's not present, not this
file.

Reported-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-04-10 11:20:35 +02:00
Greg Kroah-Hartman 67c920b892 greybus: gpbridge.h: whitespace cleanups
Replace #define<TAB> with #define<SPACE>.

Also move the #ifdef block to below the initial comment block, like
other .h files are.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-04-10 11:18:49 +02:00
John Stultz 453bbea807 greybus: Move briged phy structure definitions into gpbridge.h
In order to facilitate re-use of the gpio, i2c, pwm and i2s
structures, split them out of independent files and add
them into a shared gpbridge.h

This will be a prereq to sharing these headers w/ gbsim.

Cc: Alex Elder <alex.elder@linaro.org>
Cc: Greg Kroah-Hartman <gregkh@google.com>
CC: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-04-10 11:17:20 +02:00
Greg Kroah-Hartman b0235b2263 greybus: Documentation/sysfs-bus-greybus: document module sysfs files
This documents the module slot sysfs files "epm", "power_control", and
"present".

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Reviewed-by: Alex Elder <elder@linaro.org>
2015-04-09 22:50:10 +02:00
Greg Kroah-Hartman 7baa184dbd greybus: Documentation/sysfs-bus-greybus: document the endo and SVC
This documents the endo device, and the SVC specific files that are
present in the sysfs device tree.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Reviewed-by: Alex Elder <elder@linaro.org>
2015-04-09 22:50:09 +02:00
Greg Kroah-Hartman f0b678709a greybus: Documentation/sysfs-bus-greybus: update kernel version and date
The kernel is now on the 4.XX numbering scheme, and it's going to be a
while before we merge this code, so pick a date sometime in the future
to be safe.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Reviewed-by: Alex Elder <elder@linaro.org>
2015-04-09 22:50:09 +02:00
Greg Kroah-Hartman a4d9150cba greybus: endo: hook up endos into the device tree
This hooks up the endo, and modules, into the device tree.  All modules
for a specific endo are created when the host device is initialized.
When an interface is registered, the correct module for it is found and
that module is used for the sysfs tree.  When the interface is removed,
the reference on the module is dropped.

When the host device goes away, the whole endo and modules are removed
at once.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Reviewed-by: Alex Elder <elder@linaro.org>
2015-04-09 22:50:09 +02:00
Greg Kroah-Hartman 0f035acded greybus: endo: add endo structures and logic
This adds endo.c and endo.h and provides functions to create an endo and
the initial 0x0555 set of modules.

But, it doesn't hook this logic up into the running code yet, that comes
next.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Reviewed-by: Alex Elder <elder@linaro.org>
2015-04-09 22:50:09 +02:00
Greg Kroah-Hartman 764e824e2f greybus: module.c: add attributes
This adds the attributes power_control and present to a module.  It also
removes the unneeded module_id attribute, as that comes from the name of
the module itself.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Reviewed-by: Alex Elder <elder@linaro.org>
2015-04-09 22:50:09 +02:00
Johan Hovold 24ef485398 greybus: drop host-driver buffer headroom
Drop the host-driver buffer headroom that was used to transfer the cport
id on ES1 and ES2.

Rather than transferring additional bytes on the wire and having to deal
with buffer-alignment issues (e.g. requiring the headroom to be a
multiple of 8 bytes) simply drop the headroom functionality.

Host drivers are expected set up their transfer descriptors separately
from the data buffers and any intermediate drivers (e.g. for Greybus
over USB) can (ab)use the operation message pad bytes for now.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-04-07 17:31:05 +02:00
Johan Hovold 491e60d63f greybus: es2: sync up with recent es1 changes
Fix transfer-buffer alignment of es2 as well.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-04-07 17:31:05 +02:00
Johan Hovold a9cf7da195 greybus: es1: fix transfer-buffer alignment
Fix transfer-buffer alignment of outgoing transfers which are currently
byte aligned.

Some USB host drivers cannot handle byte-aligned buffers and will
allocate temporary buffers, which the data is copied to or from on every
transfer. This affects for example musb (e.g. Beaglebone Black) and
ehci-tegra (e.g. Jetson).

Instead of transferring pad bytes on the wire, let's (ab)use the pad
bytes of the operation message header to transfer the cport id. This
gives us properly aligned buffers and more efficient transfers in both
directions.

By using both pad bytes, we can also remove the arbitrary limitation of
256 cports.

Note that the protocol between the host driver and the UniPro bridge is
not necessarily Greybus. As long as the firmware clears the pad bytes
before forwarding the data, and the host driver does the same before
passing received data up the stack, this should be considered "legal"
use.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-04-07 17:31:05 +02:00
Johan Hovold da9dd11943 greybus: operation: add explicit padding to message header
Add explicit pad bytes to the message header.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-04-07 17:31:05 +02:00
Johan Hovold 1e5613b4a6 greybus: operation: fix potential message corruption
Make sure to allocate the message transfer-buffer separately from the
containing message structure to avoid data corruption on systems without
DMA-coherent caches.

The message structure contains state that is updated while the buffer
may be used for DMA, something which could lead to data corruption due
to cache-line sharing on some architectures.

Use the (renamed) message cache for the message structure itself and
allocate the buffer separately.

If the additional allocation is a concern, the message structures
could eventually be allocated as part of the operation structure.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-04-07 17:31:05 +02:00
Johan Hovold 7cf7bca9ec greybus: pass messages to host drivers
Pass structured greybus messages rather than buffers to the host
drivers.

This will allow us to separate the transfer buffers from the message
structures.

Rename the related functions to reflect the new interface.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-04-07 17:31:05 +02:00
Johan Hovold ac67acd304 greybus: operation: move message-header definition to header file
Move operation message-header to operation.h so that it can be used
by host drivers.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-04-07 17:31:05 +02:00
Johan Hovold cbba76f5cd greybus: remove obsolete buffer-alignment requirement
Remove unused and unnecessary buffer-alignment define that host driver
were supposed to use.

We can handle unaligned incoming buffers just fine by accessing the
operation-message header via a copy in the receive path, rather than
requiring host drivers to make sure the alignment is correct.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-04-07 17:31:05 +02:00
Johan Hovold 564c72b1c6 greybus: operation: fix unaligned memory accesses in receive path
The buffer received from our current host driver is 1-byte aligned and
will therefore cause unaligned memory accesses if simply cast to an
operation-message header.

Fix this by making a properly aligned copy of the header in
gb_connection_recv_response before accessing its fields.

Note that this does not affect protocol drivers as the whole buffer is
copied when creating the corresponding request or response before being
forwarded.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-04-07 17:31:05 +02:00
Johan Hovold c15ccabe81 greybus: es2: sync up with recent es1 changes
Fix two bugs in es2 and do some minor clean up.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-04-07 14:32:42 +02:00
Johan Hovold bfd9a94d1a greybus: es1: fix buffer-size limit
The maximum buffer size does not include the headroom, so subtract the
headroom size from the actual buffer size.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-04-07 14:32:42 +02:00
Johan Hovold 79940cf875 greybus: es1: fix DMA-buffer on stack
A stack-allocated buffer is not generally DMA-able and must not be used
for USB control transfers.

Note that the memset and extra buffer byte were redundant as no more
than the bytes actually transferred was ever added to the fifo.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-04-07 14:32:42 +02:00