Commit graph

985 commits

Author SHA1 Message Date
Greg Kroah-Hartman 5c1ac69455 greybus: properly cleanup ida and idr structures when shutting down
idr and ida structures have internal memory allocated that needs to be
freed when modules are removed.  So call the proper idr_destroy() or
ida_destroy() functions on the module exit path to free the memory.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Reviewed-by: Alex Elder <elder@linaro.org>
2015-07-08 11:53:43 -07:00
Viresh Kumar 6ceb8fdeae greybus: svc: save pointer to struct gb_svc in struct gb_interface
Its another special protocol (just like control protocol) and is
required to be accessed from other files, lets save a pointer to it in
interface structure.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-07-08 11:44:25 -07:00
Viresh Kumar ab69c4cea3 greybus: svc: SVC is part of greybus core
Its an essential part of greybus core and shouldn't be present as a
separate module. Make it part of greybus.ko module.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-07-08 11:44:25 -07:00
Viresh Kumar 87c016ee90 greybus: connection: Use connection->dev for printing messages
We failed to bind a protocol for the connection, not for bundle. And so
connection's 'dev' must be used for printing message.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-07-08 11:40:53 -07:00
Viresh Kumar b950dc28bd greybus: interface: Fix comment mistake (s/add/init)
Function's name is gb_interface_init(), not gb_interface_add().

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-07-08 11:40:53 -07:00
Viresh Kumar 6fa1adbcdd greybus: connection: Exit connection before destroying it
gb_connection_create() can initialize a connection if bundle->device id
is valid. And so the connection must be destroyed by calling
gb_connection_exit() before gb_connection_destroy(). This wasn't done in
the code that is parsing the manifest.

Fix it.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-07-08 11:40:53 -07:00
Rui Miguel Silva 9ddf133371 greybus: sdio: fix transfer buffer handling and blocks counting
Fix copy to/from scatterlist destination buffer offset, fix
calculation of blocks to be transfer and make a more verbose out of
error when the blocks receive/send do not match.

Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-07-06 11:15:42 -07:00
Rui Miguel Silva f85451d8f5 greybus: sdio: add need poll to host caps
As we do not have, yet, a event callback to notify core about changes
we add the MMC_CAP_NEEDS_POLL capability to the rest of the caps
received from the module.

Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-07-06 11:15:42 -07:00
Rui Miguel Silva 73f4a52179 greybus: sdio: check number of blocks in transfer
Before initiating a transfers, check if the command (for single block)
match the number of blocks in the request.

While at it, fix also a missing break.

Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-07-06 11:15:42 -07:00
Rui Miguel Silva 882edf59fc greybus: sdio: pass only data pointer to tranfer funtion
No need to pass the all request to the transfer related funtctions.

Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-07-06 11:15:42 -07:00
Rui Miguel Silva 7a5cd5aea2 greybus: sdio: fix call to stop command if no data exist
If data is not available the stop command could dereference NULL.
Fetch the stop command directly from the request instead.

Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-07-06 11:15:42 -07:00
Rui Miguel Silva 08ccc9be68 greybus: sdio: fix return of get_cd and get_ro
Functions were returning the wrong flag for the expected value. Swap
them.

Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-07-06 11:15:42 -07:00
Rui Miguel Silva c36d31cbc5 greybus: sdio: rework of event handler
Between the time connection with module is up and the host is added,
we can receive events (card inserted/removed, write protection
switch), so until the setup is complete we queue the events received
and handle them after.

Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-07-06 11:15:42 -07:00
Rui Miguel Silva ef0cc0ec8d greybus: sdio: split cmd_flags to there meaning
Instead of using values in the command cmd_flags field use the real
flags in a bit mask.

Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-07-06 11:15:42 -07:00
Greg Kroah-Hartman df22363d2a greybus: Revert "examples: add manifest file for sdio"
This reverts commit 22690d72ae145cf12ae3df033670ed8ad7ecdde7.

It was meant for the gbsim repo, not this one :(

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-07-05 18:11:21 -07:00
Rui Miguel Silva 513926501d greybus: examples: add manifest file for sdio
Add example manifest file for sdio.

Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-07-05 18:10:58 -07:00
Perry Hung 3a97cddfe8 greybus: makefile: fix unused cflags
The ccflags variable was spelled wrong, so no extra compilation flags
could be specified.

The proper flag is 'ccflags-y.'

Signed-off-by: Perry Hung <perry@leaflabs.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-07-05 18:04:52 -07:00
Johan Hovold 188f9785cf greybus: operation: fix cancellation of responses
An operation with a response in-flight will already have set the
operation result and would therefore never be cancelled by the current
implementation.

Note that the reference taken when sending the result will be dropped
in the message completion callback.

Also note that an incoming, non-unidirectional messages will always have
an allocated response if its result has been set.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-07-01 16:54:44 -07:00
Johan Hovold fde7382b47 greybus: operation: allocate response before setting result
Make sure to allocate a response message before setting the operation
result.

This is needed to handle cancellation of incoming operations.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-07-01 16:54:44 -07:00
Johan Hovold 1635304d63 greybus: operation: drop redundant oom message
Drop redundant OOM message, which would already have been logged by the
memory subsystem.

Also remove a FIXME about possibly sending a pre-allocated response,
which is neither possible or desirable. If we ever run out of memory we
have bigger problems then getting a response back to firmware.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-07-01 16:54:44 -07:00
Johan Hovold 2593261d5c greybus: operation: remove obsolete operation-field comments
Remove obsolete operation-field comments.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-07-01 16:54:44 -07:00
Johan Hovold e3398811c3 greybus: operation: add unidirectional-operation flag
Add flag to identify unidirectional operations.

Use convenience helper rather than open coding the identification when
suppressing response messages.

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>
2015-07-01 16:50:59 -07:00
Johan Hovold 710067e2ef greybus: operation: add incoming-operation flag
Add flag field to struct gb_operation, and a first flag
GB_OPERATION_FLAG_INCOMING to identify incoming operations.

Pass an initial set of flags when allocating new operations, and use
these to identify incoming operations rather than overloading the
meaning of GB_OPERATION_TYPE_INVALID. This also allows us to set the
type for all operations during allocation.

Also add convenience helper to identify incoming operations.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-07-01 16:50:59 -07:00
Johan Hovold 73f9d73f12 greybus: operation: fix cancellation use-after-free
The final reference of an operation will be put after its completion
handler has run, so we must not drop the reference if it has already
been scheduled to avoid use-after-free.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-07-01 16:50:59 -07:00
Johan Hovold abb722e79a greybus: operation: make response helper static
Since commit 46ce118a2678 ("operation: refactor response handling")
sending operation responses is handled by greybus core so there is
currently no need to export the response helper.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-07-01 16:50:59 -07:00
Johan Hovold a52c4352ae greybus: operation: allow atomic request submissions
Add gfp mask argument to gb_operation_request_send in order to allow
submissions from atomic context.

Note that responses are currently always sent from non-atomic context as
incoming requests are processed in a work queue.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-07-01 16:50:59 -07:00
Johan Hovold e420721b47 greybus: operation: allow atomic operation allocations
Add gfp mask argument to gb_operation_create to allow operations to be
allocated in atomic context.

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>
2015-07-01 16:45:39 -07:00
Johan Hovold 3e136cc9e0 greybus: operation/esx: fix message-cancellation lifetime bugs
The current host-controller message-cancellation implementation suffer
from a lifetime bug as dynamically allocated URBs would complete and be
deallocated while being unlinked as part of cancellation.

The current locking is also insufficient to prevent the related race
where the URB is deallocated before being unlinked.

Fix this by pushing the cancellation implementation from greybus core
down to the host-controller drivers, and replace the "cookie" pointer
with a hcpriv field that those drivers can use to maintain their state
with the required locking and reference counting in place.

Specifically the drivers need to acquire a reference to the URB under a
lock before calling usb_kill_urb as part of cancellation.

Note that this also removes the insufficient gb_message_mutex, which
also effectively prevented us from implementing support for submissions
from atomic context.

Instead the host-controller drivers must now explicitly make sure that
the pre-allocated URBs are not reused while cancellation is in progress.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-07-01 16:43:02 -07:00
Viresh Kumar 5677d48b97 greybus: bundles: remove gb_bundle(s)_init()
They aren't used anymore, remove them. This also gets rid of
gb_bundle_connections_init().

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-07-01 16:38:42 -07:00
Viresh Kumar c3add7883c greybus: interface: device_id belongs to the interface
While introducing bundles, the device_id also got moved to the bundle,
whereas it identifies an interface block to the AP.

Move it back to interface instead of bundle.

Calls to gb_bundle(s)_init() are dropped as connections will be
initialized while they are created now, as device_id will be valid.

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-07-01 16:38:42 -07:00
Viresh Kumar 7e9017d482 greybus: svc: Drop svc_set_route_send()
The responsibility of this routine is to configure ARA switch to
establish a connection between a cport on the AP and a cport on an
interface.

The SVC protocol is responsible for such requests and we already have
connection_{create|destroy}_operation() to take care of this.

Moreover, this request is not served by the firmware or gbsim today and
they just print a debug message on this request. And so it is safe to
drop svc_set_route_send() function and fix the required functionality of
configuring the switch in svc protocol driver later.

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-07-01 16:38:42 -07:00
Viresh Kumar c3a1617099 greybus: connection: intf_cport_id is local to an interface
intf_cport_id is local to an interface and same intf_cport_id can be
used for two separate interface blocks. For finding a connection for an
interface, we are matching intf_cport_id of the connection with
cport_id, passed as argument. This is wrong, as it can match for a
connection on a different interface block.

Fix it by also comparing interface block for which connection is
requested.

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-07-01 16:38:42 -07:00
Viresh Kumar b758d68618 greybus: connection: bind protocol after the connection is operational
We may bind protocol with a connection from gb_connection_create(), if
bundle's device_id is already set. That's not the case until now.

But if the protocol is initialized with a call to
protocol->connection_init() from this place, kernel will crash.

This will happen because the connection isn't fully initialized yet, for
example its operation list isn't initialized yet. And as soon as the
protocol driver tries to send a request to the module from its
connection_init() callback, we will add an operation to this
uninitialized list. And it will crash while doing:

        prev->next = new;

Try to bind the connection with a protocol only after the connection is
ready for operations.

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-07-01 16:34:55 -07:00
Viresh Kumar 463e8736a3 greybus: control: Use gb_builtin_protocol_driver()
No need to write simple init/exit routines, use
gb_builtin_protocol_driver().

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-07-01 16:34:55 -07:00
Viresh Kumar e18822e3d0 greybus: Rename gb_gpbridge_protocol_driver() as gb_builtin_protocol_driver()
This macro is also required by core protocols like control and svc, and
hence the 'gpbridge' name doesn't fit anymore.

Lets call this macro gb_builtin_protocol_driver().

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-07-01 16:34:55 -07:00
Viresh Kumar 06e305f1e3 greybus: svc: Use macro's for major/minor numbers
We have already defined macro's for SVC's major/minor numbers, lets use
them.

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-07-01 16:34:55 -07:00
Viresh Kumar 7eb8919b0f greybus: svc: Fix doc-style comment
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-07-01 16:34:55 -07:00
Bryan O'Donoghue ba4b099ca8 greybus: uart: Update UART to reflect field size changes
The greybus UART protocol specification was updated to reduce the size of
the control field in serial-state-request and line-state-request. This
patch updates the kernel protocol driver to reflect the specification
changes. Once applied gbsim changes will be also be updated automatically
since gbsim depends on the header being modified directly.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-06-30 19:34:47 -07:00
Bryan O'Donoghue 4c025cf416 greybus: uart: Add support for UART error signals
After reviewing the UART specification for greybus break, parity, framing
and over-run errors were moved to the receive-data message. This patch
implements that specification change in the UART protocol driver. Matching
code in gbsim has been tested with this change.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-06-30 19:34:47 -07:00
Bryan O'Donoghue 802362d4a6 greybus: uart: Relocate UART parity/overrun/framing/break signals
Parity/overrun/framing and break signals have been moved to the
receive-data message to more easily associate the signals with the TTY API.
Update the definitions in the protocol header and add a flags field to the
receive-data structure to facilitate transmission of those signal with the
receive-data message.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-06-30 19:34:47 -07:00
Viresh Kumar dccbe40ff9 greybus: define more greybus classes
There are new protocols defined which don't belong to any existing
class, add more classes to support them.

Reported-by: Alexandre Bailon <abailon@baylibre.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-06-30 19:34:47 -07:00
Phong Tran 93a99e8a10 greybus: sdio: correct the usage of mmc request in work queues handler
The mmc request should assigned before use. Then
It should avoid freeing before using in mmc_request_done().

Signed-off-by: Phong Tran <tranmanphong@gmail.com>
Reviewed-by: Rui Miguel Silva <rui.silva@linaro.org>
Reviewed-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-06-29 18:06:08 -07:00
Phong Tran 9b86bdf96e greybus: sdio: change the order of remove and free mmc host
The mmc host should be removed frist. Then it
will be freed.

Signed-off-by: Phong Tran <tranmanphong@gmail.com>
Reviewed-by: Rui Miguel Silva <rui.silva@linaro.org>
Reviewed-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-06-29 18:06:08 -07:00
Phong Tran 153f4784b4 greybus: sdio: remove the redefine of sdio major and minor
The macro of sdio version major and minor is defined twice.
This patch remove the redundant one.

Signed-off-by: Phong Tran <tranmanphong@gmail.com>
Reviewed-by: Rui Miguel Silva <rui.silva@linaro.org>
Reviewed-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-06-29 18:06:08 -07:00
Mark Greer f4706b848e greybus: gb-audio: Ensure i2c adapter struct exists before using
The current audio code uses i2c_get_adapter() without checking
that a non-NULL pointer is returned (i.e., that the i2c device
actually exists).  When that happens, the system panics.
Fix the potential panic by erroring out with -ENODEV when
i2c_get_adapter() returns NULL.

CC: John Stultz <john.stultz@linaro.com>
Signed-off-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-06-29 18:04:38 -07:00
Johan Hovold 86f918ee7f greybus: esx: fix null-deref on hotplug events
We must be prepared to receive hotplug events as soon as we submit the
SVC URB. Since commit 2eb8a6a947d7 ("core: don't set up endo until host
device is initialized") this is no longer the case as the endo would not
have been setup, something which may lead to a null-pointer dereference
in endo_get_module_id() when the interface is created (see oops below
with an added dev_dbg for hd->endo).

Fix this by setting up the endo before submitting the SVC URB.

[   28.810610] gb_interface_create - hd->endo =   (null)
[   28.816020] Unable to handle kernel NULL pointer dereference at virtual address 0000022b
[   28.824952] pgd = c0004000
[   28.827880] [0000022b] *pgd=00000000
[   28.831913] Internal error: Oops: 17 [#1] PREEMPT ARM
[   28.837183] Modules linked in: gb_es1(O+) greybus(O) netconsole
[   28.843419] CPU: 0 PID: 21 Comm: kworker/u2:1 Tainted: G           O    4.1.0-rc7 #12
[   28.851576] Hardware name: Generic AM33XX (Flattened Device Tree)
[   28.857978] Workqueue: greybus_ap ap_process_event [greybus]
[   28.863890] task: cf2961c0 ti: cf29c000 task.ti: cf29c000
[   28.869529] PC is at endo_get_module_id+0x18/0x88 [greybus]
[   28.875355] LR is at gb_interface_add+0x88/0x204 [greybus]
[   28.881070] pc : [<bf0052d4>]    lr : [<bf005dac>]    psr: 20070013
[   28.881070] sp : cf29de08  ip : cf29de18  fp : cf29de14
[   28.893021] r10: 00000001  r9 : 0000005a  r8 : cd813ec6
[   28.898461] r7 : 00000058  r6 : cf7fa200  r5 : 00000001  r4 : cf7fa20c
[   28.905261] r3 : 00000000  r2 : cf2961c0  r1 : 00000001  r0 : 00000000
[   28.912067] Flags: nzCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment kernel
[   28.919677] Control: 10c5387d  Table: 8f508019  DAC: 00000015
[   28.925663] Process kworker/u2:1 (pid: 21, stack limit = 0xcf29c210)
[   28.932279] Stack: (0xcf29de08 to 0xcf29e000)
[   28.936823] de00:                   cf29de44 cf29de18 bf005dac bf0052c8 00000058 cd813ec0
[   28.945349] de20: cf58b60c bf00afe0 cf7fa200 cf58b600 0000005a 00000001 cf29de84 cf29de48
[   28.953865] de40: bf004844 bf005d30 00000000 cf02d800 cf29de6c cf29de60 c00759a0 cf58b60c
[   28.962389] de60: cf2742c0 cf02d800 cf0c6000 cf29dea8 c07b745c 00000000 cf29dee4 cf29de88
[   28.970908] de80: c005943c bf004560 00000001 00000000 c0059354 cf02d800 c0059c0c 00000001
[   28.979426] dea0: 00000000 00000000 bf00b314 00000000 00000000 bf009144 c04e3710 cf02d800
[   28.987945] dec0: cf2742d8 cf02d830 00000088 c0059bd0 00000000 cf2742c0 cf29df24 cf29dee8
[   28.996464] dee0: c0059b78 c0059248 cf29c000 cf245d40 c0776890 c07b6bf3 00000000 00000000
[   29.004983] df00: cf245d40 cf2742c0 c0059b20 00000000 00000000 00000000 cf29dfac cf29df28
[   29.013502] df20: c005fe90 c0059b2c c07812d0 00000000 cf29df4c cf2742c0 00000000 00000001
[   29.022025] df40: dead4ead ffffffff ffffffff c07c86b0 00000000 00000000 c05fd8e8 cf29df5c
[   29.030542] df60: cf29df5c 00000000 00000001 dead4ead ffffffff ffffffff c07c86b0 00000000
[   29.039062] df80: 00000000 c05fd8e8 cf29df88 cf29df88 cf245d40 c005fd98 00000000 00000000
[   29.047581] dfa0: 00000000 cf29dfb0 c00108f8 c005fda4 00000000 00000000 00000000 00000000
[   29.056105] dfc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[   29.064623] dfe0: 00000000 00000000 00000000 00000000 00000013 00000000 ffff0000 ffff0000
[   29.073178] [<bf0052d4>] (endo_get_module_id [greybus]) from [<bf005dac>] (gb_interface_add+0x88/0x204 [greybus])
[   29.083887] [<bf005dac>] (gb_interface_add [greybus]) from [<bf004844>] (ap_process_event+0x2f0/0x4d8 [greybus])
[   29.094527] [<bf004844>] (ap_process_event [greybus]) from [<c005943c>] (process_one_work+0x200/0x8e4)
[   29.104228] [<c005943c>] (process_one_work) from [<c0059b78>] (worker_thread+0x58/0x500)
[   29.112668] [<c0059b78>] (worker_thread) from [<c005fe90>] (kthread+0xf8/0x110)
[   29.120295] [<c005fe90>] (kthread) from [<c00108f8>] (ret_from_fork+0x14/0x3c)
[   29.127825] Code: e24cb004 e52de004 e8bd4000 e3510000 (e5d0c22b)
[   29.137481] ---[ end trace ad95c3c26bdc98ce ]---

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-06-24 17:34:47 -07:00
Rui Miguel Silva 8a01b408a6 greybus: kernel_ver: add sg copy operations for kernel < 3.11
For older kernel, < 3.11, no copy to/from buffer with skip support was
defined. This could break builds for this versions of kernel.
Add them here.

Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Tested-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-06-24 17:34:46 -07:00
Rui Miguel Silva 5656ab99a0 greybus: sdio: fix defines for older kernels
Some of the options for mmc host, are not defined in older kernels.
MMC_CAP2_HS400_1_2V, MMC_CAP2_HS400_1_8V, MMC_TIMING_MMC_DDR52 and
MMC_TIMING_MMC_HS400.

To not use them for older versions.

Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Tested-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-06-24 17:34:46 -07:00
Viresh Kumar 730a2f6d10 greybus: control: Warn if non-control cport/bundles have control protocol/classes
It is possible that (by mistake) the manifest contains non-control
cports with their protocol set as control-protocol or non-control bundle
with their class set as control-class.

Catch such cases, WARN for them and finally ignore them.

Also WARN if the control cport doesn't have its protocol as
control-protocol and control bundle doesn't have its class as
control-class.

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-06-23 23:17:25 -07:00
Viresh Kumar f18327e8eb greybus: connection: send [dis]connected events over control CPort
The AP needs to send connected and disconnection events to all
interfaces, before a CPort (other than control CPort) can be used.

For now do it which we initialize the connection, but it should be moved
to operations code 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-06-23 23:17:25 -07:00
Viresh Kumar 87c8eb8d09 greybus: hotplug function doesn't need to contain manifest now
Manifest is fetched with control protocol now and so we don't need space
for it in hotplug data.

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-06-23 23:17:25 -07:00
Viresh Kumar 6c68da264b greybus: interface: Get manifest using Control protocol
Control protocol is ready to be used for fetching manifest. Lets do it.

This changes few things:
- Creates/initializes bundle/connection for control protocol initially
  and skips doing the same later.
- Manifest is parsed at link-up now, instead of hotplug which was the
  case earlier. This is because we need device_id (provided during
  link-up) for registering bundle.
- Manifest is fetched using control protocol.

So the sequence of events is:

Event                 Previously       Now
-----                 ----------       ---
Interface Hotplug     create intf      create intf
                      parse mfst

Interface Link Up     init bundles     create control conn
                                       get mfst size
                                       get mfst
                                       parse mfst
                                       init bundles

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-06-23 23:16:15 -07:00
Viresh Kumar cdee4f7505 greybus: Add control protocol support
Add control protocol driver that is responsible for handling operations
on control CPort. The AP also needs to support incoming requests on its
control port. Features not implemented yet are marked as TODO for now.

NOTE: This also fixes cport-bundle-id to 0 and cport-id to 2 for control
protocol.

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-06-23 23:16:15 -07:00
Viresh Kumar b08488bea5 greybus: manifest: Allow bundles/connections list to be non-empty at manifest parsing
A connection and a bundle will be created for interfaces at the very
beginning for control protocol's functioning. And so the list of bundles
and connections for a interface will be non-empty by the time manifest
is parsed.

Currently we are firing a WARN when these lists are found to be
non-empty. Lets fix that to contain single bundle and connection for
control protocol.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-06-23 23:16:15 -07:00
Rui Miguel Silva 3b6ecd6de6 greybus: sdio: extend sdio implementation
Extend sdio implementation, as it for now it was basically stubs.

This implementation is compile tested only since there is no fw or
simulation support yet.
Next step is to add sdio support to gbsim and test it with success
using the mmc_test facility.

Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-06-23 23:13:41 -07:00
Rui Miguel Silva 656f22e94e greybus: makefile: add MMC to the required option list
Add MMC to the list of options that shall be enable.

Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-06-23 23:13:41 -07:00
Bryan O'Donoghue cdb5781d9f greybus: uart: Fix sparse warning
Greg reported sparse picked up the following warning:
/home/gregkh/ara/greybus/uart.c:105:34: warning: cast to restricted __le16

This is due to the control variable in gb_uart_serial_state_request which
needs to be declared __le16 not __u16.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Reported-by: Greg Kroah-Hartman <gregkh@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-06-19 16:35:44 -07:00
Bryan O'Donoghue 3ee2266c72 greybus: uart: Latch modem control signals for tciomget
Latch signals coming from UART module for
- GB_UART_CTRL_DCD
- GB_UART_CTRL_DSR
- GB_UART_CTRL_RI

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-06-17 13:08:09 -07:00
Greg Kroah-Hartman fd7b435f21 greybus: Revert "greybus: reserve host cport id 0"
This reverts commit 698d4bd3e7541a660a3c3665f0af9e787650a239 as Alex
says it is broken.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-06-16 19:43:05 -07:00
Greg Kroah-Hartman 9df94499c4 greybus: Merge branch alex into Alexandre
This resolves a conflict with es2.c that I fixed up.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-06-15 16:53:23 -07:00
Alexandre Bailon fc1a536e60 greybus: es2.c: add a control request for endpoints mapping
ES2 give us more endpoints. Use them to map one cport to two endpoints
(in and out). Because there is more cports than endpoints, we still
need to mux other cports traffic on 2 endpoints.
Firmware currently assumes these endpoints are 2 and 3.

By default, all cports are muxed.
To map one cport to 2 endpoints, use map_cport_to_ep().

Signed-off-by: Alexandre Bailon <abailon@baylibre.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-06-15 16:51:44 -07:00
Alexandre Bailon 606addd284 greybus: es2.c: Increase the number of bulk endpoints
ES2 support 16 endpoints. Update es2.c to allocate endpoints, urbs
and buffers for these new endpoints.

Currently, they are not yet used and es2.c is working in legacy mode
(only original endpoints are used).

Signed-off-by: Alexandre Bailon <abailon@baylibre.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-06-15 16:51:44 -07:00
Alexandre Bailon ddc09acd46 greybus: es2.c: create dedicated struct for cport_in and cport_out
Instead of keep cport buffers, urbs and endpoints in es1_ap_dev,
move them in two dedicated struct (es1_cport_in and es1_cport_out),
in order to ease the migration to es2 (increase the number of endpoint).

Signed-off-by: Alexandre Bailon <abailon@baylibre.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-06-15 16:51:44 -07:00
Alexandre Bailon 611c17390e greybus: es2.c: Don't use magic value for USB control request
Signed-off-by: Alexandre Bailon <abailon@baylibre.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-06-15 16:51:44 -07:00
Alexandre Bailon 799baa24db greybus: es1.c: Don't use magic value for USB control request
Signed-off-by: Alexandre Bailon <abailon@baylibre.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-06-15 16:51:44 -07:00
Alex Elder 4bc1389de9 greybus: esX: use one byte to encode cport ids in header
We now limit the maximum value for both host and module CPort ids,
and we know they can always be represented in a single byte.

Make use of this by using only one of the two pad bytes for encoding
the CPort id in a message header.

(Note that we have never used a CPort higher than 255.  Encoding
such a small CPort id in little endian 2-byte format has the same
result as what is done here.)

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-06-15 16:49:00 -07:00
Alex Elder 88d18a975d greybus: reserve host cport id 0
For ES1 and ES2, we use pad bytes in an operation message header to
encode the CPort ID used for transferring the message.  The pad
bytes should otherwise be zero, and we ensure this as the message
is passed to or from the upper layer.

If host-side CPort ID 0 is used, we have no way of knowing whether
the CPort field has been "packed" into the header.

To allow detection of this, reserve host CPort id 0.  Update
cport_id_valid() to treat 0 as invalid.

(CPort ID 0 is reserved by one of the UniPro standards.  We'll
assume for now that we never use it for Greybus.)

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-06-15 16:49:00 -07:00
Alex Elder fb690ca96f greybus: rename HOST_DEV_CPORT_ID_MAX
We limit the number of host-side CPorts to a fixed maximum (which
is less than the 4096 that UniPro allows).  This patch imposes a
similar limit on the CPort IDs defined by modules (signaling an
error if one too large is found in a manifest).

It seems reasonable to use the same value for both limits.  Change
the name of the constant that defines the host limit and use it for
both.  Update cport_id_valid() to enforce the maximum.

(Ultimately we should impose a limit like this; this change is being
made in preparation for supporting multiple connections over a
single CPort.)

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-06-15 16:49:00 -07:00
Alex Elder d29b3d631e greybus: esX: encapsulate packing cport id into header
For the ES1 and ES2 host interfaces we encode the CPort ID over
which the message should be sent within the message itself.  The
CPort ID is recorded in unused pad bytes found in the operation
message header in order to avoid introducing misaligned messages.

This patch defines some helper routines to abstract this activity.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-06-15 16:49:00 -07:00
Alex Elder 821c620afa greybus: introduce cport_id_valid()
Define a public predicate that defines whether a CPort ID is valid.

Use it in the message_send() routine, and make the message reported
more accurately reflect the error.  Also use it to check whether the
CPort ID in a received message is valid; if it is not, just drop the
message.

Get rid of local variable "buffer" in message_send(); it adds no
value.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-06-15 16:49:00 -07:00
Alex Elder 2a64fb0e1e greybus: manifest: clean up properly when parsing bundles
Currently, if an error occurs creating a bundle, we simply
return an error without cleaning up any of the bundles that
had already been successfully set up.

Add code to destroy bundles that have been created in the event
an error occurs.  Add a check to ensure the interface's list of
bundles was empty before parsing for bundles begins.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-06-12 12:14:24 -07:00
Alex Elder fe53b45ca8 greybus: bundle: fix gb_bundle_destroy()
Currently gb_bundle_destroy() takes an interface as an argument,
and really doesn't do what a function by that name should do.

What it now does is delete all bundles associated with a given
interface.  What it should do is destroy a single bundle.

Move the looping logic out of gb_bundle_destroy() and into its
caller, gb_interface_destroy().  Pass each bundle in an interface to
gb_bundle_destroy(), which will do what's required to destroy a
single bundle (including removing it from its interface's bundle
list under protection of the lock).

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-06-12 12:14:24 -07:00
Alex Elder bc94208358 greybus: bundle: refactor gb_bundle_find()
Rearrange gb_bundle_find() so it follows the pattern used by
gb_connection_find().

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-06-12 12:14:24 -07:00
Alex Elder 52e8ce317f greybus: manifest: clean up properly when parsing cports
Currently, if an error occurs creating a connection, we simply
return an error without cleaning up any of the connections that
had already been successfully set up.

Add code to destroy connections that have been created in the event
an error occurs.  Add a check to ensure the bundle's list of
connections was empty before parsing for CPorts begins.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-06-12 12:14:24 -07:00
Alex Elder f9b0366f16 greybus: connection: un-abstract host cport id allocation
I did this recently for the endo id allocation code.

It's clearer now that the allocation of a CPort ID to use for
the AP side of a connection is not very complicated, and it
happens in a pretty controlled environment.  The functions that
abstract getting and releasing those ids don't really add that
much value.

This patch removes gb_connection_hd_cport_id_alloc() and
gb_connection_hd_cport_id_free(), and just open-codes their
activity in the few places they are called.

It is obvious now that the CPort ID allocation isn't done in
atomic context, so we can change the ida_simple_get() call to
use GFP_KERNEL.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-06-12 12:13:01 -07:00
Alex Elder deb58ca829 greybus: connection: drop unneeded gb_protocol_put() calls
Although a connection records its protocol id when it gets
created, its protocol handler doesn't actually get assigned
until gb_connection_bind_protocol() is called.

In gb_connection_create() there are some error paths in
which a reference to the connection's protocol is released
before the protocol handler has been associated with the
connection.

Get rid of those calls.

As a result, we will never pass a null protocol pointer to
gb_protocol_put().  Add a precautionary warning in that
function in the event that ever occurs.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-06-12 12:13:01 -07:00
Alex Elder 856618f3fb greybus: connection: remove extra kfree() call
When an error occurs in the device_add() call for a connection, the
device reference is dropped as required.  Because that's the device's
only reference, that will also lead to gb_connection_release() being
called, which frees the connection structure.

Right now we're then making an extra request to free the connection,
which is wrong.  Fix that.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-06-12 12:13:01 -07:00
Phong Tran 55a8e35503 greybus: uart: fix the clean up while uart initiates connection unsucessfully
There is lack of unregister and free the tty driver.
This patch fixes it.

Signed-off-by: Phong Tran <tranmanphong@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-06-11 15:57:44 -07:00
Greg Kroah-Hartman 3d0421e0ab greybus: remove __init from .h files
__init does not belong in a .h file, as it does not do anything there,
so remove all instances of it.

Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-06-11 09:35:00 -07:00
Viresh Kumar 0ffacf3b8a greybus: endo: Fix compilation warning
WARNING: /home/viresh/work/repos/ara/greybus/greybus.o(.init.text+0xb8):
Section mismatch in reference from the function init_module() to the
function .exit.text:gb_endo_exit()

The function __init init_module() references
a function __exit gb_endo_exit().

Fix it by removing __exit from endo_exit().

Fixes: cf64356c5151 ("endo: define endo_init() and endo_exit()")
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-06-11 09:18:45 -07:00
Alex Elder f5c2be9e9b greybus: connection: check for duplicate cport ids
Check at connection creation time for an attempt to create a
connection with an interface CPort ID that's the same as one that's
already been created.

Define a new helper function to look for such a duplicate.  The
check for a duplicate is only performed at initialization time,
and CPorts are initialized serially for each bundle, so there's
no need to acquire the list lock for this search.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-06-10 10:38:23 -07:00
Alex Elder 8267616b3e greybus: bundle: check for duplicate bundle ids
Check at bundle creation time to ensure we're not creating a bundle
with an id that's the same as one that's already been created.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-06-10 10:38:23 -07:00
Alex Elder c27a253fc0 greybus: manifest: rework bundle parsing
Rework the the code that parses the manifest for bundles so it only
touches each manifest descriptor once.  (Previously the list was
scanned from the beginning repeatedly until all bundles were found.)
Shorten the name of the descriptor variable, to avoid line wrap.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-06-10 10:38:23 -07:00
Alex Elder a6b13eb648 greybus: manifest: rework cport parsing
Rework the the code that parses the manifest for CPorts associated
with a bundle so it only touches each manifest descriptor once.
(Previously the list was scanned from the beginning repeatedly
until all bundle CPorts were found.)  Shorten the name of the
descriptor variable, to avoid line wrap.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-06-10 10:38:23 -07:00
Alex Elder c46839d1cc greybus: manifest: use bundle's embedded interface pointer
An initialized bundle structure contains a pointer to its
interface.  Because of this there's no need to provide
the interface pointer to gb_manifest_parse_cports().  This
also precludes the possibility of passing a bad interface
pointer.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-06-10 10:38:23 -07:00
Alex Elder d393c98f11 greybus: manifest: really minor cleanups
This patch incorporates some very small cleanups to "manifest.c":
    - Rearrange code a bit in gb_manifest_parse() that ensures a
      manifest is big enough to hold a header.  If the manifest is
      exactly the size of a header, the error reported will now be
      "...must have 1 interface..." rather than "short manifest".
    - Fix the function comment for gb_manifest_parse_cports().
    - Use "an interface," not "a interface," and don't capitalize.
    - Delete some braces when getting interface product string.
    - A few other minor changes to comments and white space.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-06-10 10:38:23 -07:00
Alex Elder 79dda60987 greybus: endo: clean up id assignment code
Recently code was added (back) to assign a unique id to each
endo, so satisfy uniqueness requirements of the Linux device
subsystem.  An ID allocator is used to manage the space of IDs.

Now that we have gb_endo_init(), we can initialize the map there,
and fully hide the ID map within "endo.c".

The original functions gb_endo_id_alloc() and gb_endo_id_free()
provided a nice abstract interface, but the direct ID allocation
calls are quite simple, so just call them directly.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-06-10 10:38:23 -07:00
Alex Elder f35ab903ef greybus: endo: define endo_init() and endo_exit()
Define init and exit functions to do one-time setup and teardown
of endo-related functionality.  Currently they're place holders;
the next patch will populate them.

Note that we now call gb_operation_exit() from gb_init(), so
we can no longer mark that function with __exit.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-06-10 10:38:23 -07:00
Alex Elder 47ed2c9240 greybus: tag core init and exit functions
The top-level functions gb_init() and gb_exit() are tagged with
__init and __exit, respectively.  These functions call a few
other functions that are similarly used only at initialization
and termination time.  So mark those functions accordingly.

Note that, because gb_ap_exit() and gb_debugfs_cleanup()
are called by gb_init() in error paths, these functions
cannot be declared with the __exit attribute.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-06-10 10:38:23 -07:00
Alex Elder 190241a362 greybus: drop some unnecessary headers
There's no need to include anything other than "greybus.h" in
"connection.c".  Same thing in "core.c" and "manifest.c" and
"svc.c".  Some files need headers included, but most come along
with "greybus.h".

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-06-10 10:38:23 -07:00
Mark Greer 45f427a02e greybus: gb-audio: Reset sample count when CPort deactivated
The sample count placed in Greybus I2S audio messages should be
reset every time a new audio stream is set up.  However, the
current code does not do the reset so make it so it does.

Signed-off-by: Mark Greer <mgreer@animalcreek.com>
Acked-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-06-10 10:35:03 -07:00
Greg Kroah-Hartman cce3103676 greybus: es?: decrease buffer size to 2k
The firmware is having a hard time with 4k buffers and memory
allocation, so decrease the size on the host side to 2k.  Also move away
from using PAGE_SIZE to denote 4k as that's not the case on all
architectures, and someone, someday, might get a rude surprise.

Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-06-10 10:35:03 -07:00
Phong Tran 61b65a394c greybus: uart: remove the redundant unregister chrdev
The unregister_chrdev_region() does twice here.
The chrdev region was unregistered
inside tty_unregister_driver().

Signed-off-by: Phong Tran <tranmanphong@gmail.com>
Reviewed-by: Alex Elder <elder@linaro.org>
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-06-09 13:35:47 -07:00
Phong Tran f2e2b06fef greybus: endo: move endo id map declaration to endo.h
There is a sparse warning. The endo id map is also
used in endo.c. Should define in endo.h

Signed-off-by: Phong Tran <tranmanphong@gmail.com>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-06-09 13:35:47 -07:00
Viresh Kumar 928f2abd5f greybus: Tear down devices in the reverse order
Normally, its a good practice to free resources in the reverse order in
which they are allocated, so that all the dependencies can be sorted out
properly.

This is true while creating/destroying devices as well. For example
consider this scenario (I faced a crash with control protocol due to
this). For a new module, we will first create a bundle+connection for
the control cport and then create other bundles/connections after
parsing manifest.

And while destroying interface on module hot unplug, we are removing the
devices in the order they are added. And so the bundle/connection for
the control cport are destroyed first. But, control cport was still
required while destroying other bundles/connections.

To solve this problem, lets destroy the resources in the reverse order
in which they are added.

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-06-09 13:31:23 -07:00
Alex Elder d51c0ffb5c greybus: manifest: clean up a few pr_err() calls
Provide a little more information in two pr_err() calls.
Also enclose a reported condition in parentheses, to match
the style used everywhere else in the file.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-06-08 15:19:56 -07:00
Alex Elder fd1c2e541c greybus: core: rename greybus_deregister()
Rename greybus_deregister() to be greybus_deregister_driver(), so
its name mirrors the greybus_register_driver() function it matches.
Define greybus_deregister() to be a trivial macro.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-06-08 15:19:56 -07:00
Alex Elder 81c3a77207 greybus: uart: properly interpret receive data size
In gb_uart_request_recv(), the receive data size is in little-endian
format.  Do the proper byte swapping of that value before using it.
Found by "make check".

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-06-08 15:19:56 -07:00
Alex Elder 8bd0ae6e72 greybus: connection: make gb_connection_hd_find() private
Give gb_connection_hd_find() static scope; it's never used
outside "connection.c".

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-06-08 15:19:56 -07:00
Alex Elder 0dac67c84c greybus: svc: driver is basic to Greybus (not GP Bridge)
The SVC protocol driver should have been defined as a basic
Greybus protocol driver, not a GP Bridge protocol driver.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-06-08 15:19:56 -07:00
Viresh Kumar cf6b62d904 greybus: Prefix module-id with endo id
Prefix module-id with endo-id to uniquely identify it for the entire
kernel.

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-06-08 15:18:02 -07:00
Viresh Kumar 4a04187008 greybus: Generate greybus wide unique ids for endo devices
Currently we name the endo device as "endo". And it shows up with the
same name in sysfs directory: /sys/bus/greybus/devices/.

But each device in kernel should be represented by a unique id in
kernel, and "endo" isn't unique.

Lets generate unique ids for endo devices. The ida mechanism for
allocating ids may be overkill but it works.

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-06-08 15:18:02 -07:00
Viresh Kumar d7353ceada greybus: s/bundle_cport_id/intf_cport_id
This isn't unique just for the bundle but the complete interface. Its
wrong to call it bundle_cport_id. Lets name it intf_cport_id to make
things clear.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-06-04 14:15:29 +09:00
Viresh Kumar 4cfabf09db greybus: operation: Remove unused variable 'buffer'
'buffer' isn't used in this function, remove it.

Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
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-06-04 14:15:29 +09:00
Bryan O'Donoghue 62229a1bda greybus: uart: Remove magic numbers make struct gb_tty variable names consistent
Use defines for the data format command.
Tidy up naming of gb_tty variables.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-06-04 14:11:05 +09:00
Bryan O'Donoghue 1c087015b9 greybus: uart: Add gb_uart_request_recv for receiving async UART data
gb_uart_request_recv job in life is to process unsolicited greybus
mesages from the UART.
Hook the incoming UART data and pass to the TTY layer.
Line-state changes still TBD.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-06-04 14:11:05 +09:00
Bryan O'Donoghue dd1c64ede9 greybus: uart: kmalloc for send_data once only
Make kmalloc for the send buffer a one time alloc based on the MTU for
a given greybus link.

The write_room for an gb_operation_sync then will be the size of the
buffer we use for a single operation.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-06-04 14:11:05 +09:00
Bryan O'Donoghue 563bd79b2d greybus: uart: send_data should return size or error
gb_operation_sync returns 0 on success but the calling function
expects the number of bytes written on success or a negative errno

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-06-04 14:08:22 +09:00
Bryan O'Donoghue f95ad78c72 greybus: uart: Update uart.c to register tty ports
For each new UART connection we need to do a tty_port_init else
we'll crash when trying to access the tty mutex later on.
Base the TTY major/minor numbers on non-zero values.
Supply an empty operations structure for the newly regitered port.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-06-04 14:08:22 +09:00
Bryan O'Donoghue f5537d46cb greybus: uart: Reduce UART count from 255 to 16
Arbitrary number 255 is both not aligned and probably too big.
Move the UART count down to 16 which is still large but, more realistic.
8 may be too few for future testing setups, 16 should accomodate any.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-06-04 14:08:21 +09:00
Bryan O'Donoghue 11fca140c9 greybus: uart: Tidy naming convention to more closely match spec
Update tabs and naming of structures to match the naming used in the greybus
specification more closely.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-06-04 14:05:48 +09:00
Bryan O'Donoghue 4ef53485c3 greybus: uart: Move UART protocol structs/defines to greybus_protocols.h
gbsim depends on the structures and defines in greybus_protocols.h
generally in order to simulate firmware. Move UART defines into this
header to facilitate.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-06-04 14:05:48 +09:00
Phong Tran 55f2291142 greybus: uart: Fix the memory leak in connection init
If alloc minor is error, gb_tty should free.

Signed-off-by: Phong Tran <tranmanphong@gmail.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-06-04 14:04:18 +09:00
Viresh Kumar 3cb494cd6c greybus: endo: Add missing '\n' sprintf() for sysfs files
Because of the missing '\n', this is how the output of reading endo
sysfs files looks:

root# cat /sys/bus/greybus/devices/endo/id
0x4755root#

Fix it by including \n to the end of the printed string.

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-06-04 14:02:38 +09:00
Johan Hovold 7ba864a19f greybus: gpio: add irq-type defines
Add Greybus GPIO IRQ-type defines rather than rely on the current
Linux implementation.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-05-28 14:48:30 -07:00
Johan Hovold 4bf3780982 greybus: gpio: remove unused debounce define
Remove unused debounce define from protocol header.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-05-28 14:48:14 -07:00
Alex Elder e6cebf8770 greybus: endo: delete "0xXXXX" portion in sysfs "endo" directory
With the Endo "id" attribute in place, there's no need to encode
the ID of an Endo in its sysfs path.  So get rid of it.

Signed-off-by: Alex Elder <elder@linaro.org>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-05-28 14:45:56 -07:00
Alex Elder 312bb84942 greybus: endo: drop redundant prefixes from sysfs basenames
This commit:
    7e761e2 endo: rework some attributes
added a new "endo_id" attribute, located under a new "Endo"
directory in sysfs.  The resulting path looks like:
    Documentation/sysfs/endo-TYPE/Endo/endo_id
There's no need to have a separate "Endo" subdirectory to contain
Endo-specific attributes.

That commit also added "svc_" to some other paths related to the
SVC, like:
    Documentation/sysfs/endo-TYPE/SVC/svc_version
The additional "svc_" is redundant.

This patch retouches those paths a bit, mainly to remove some
redundancy.  It also makes the pathname components all lower case.
As a result, the above two paths now look like:
    Documentation/sysfs/endo-TYPE/id
    Documentation/sysfs/endo-TYPE/svc/version

All other Endo sysfs files are updated similarly.

Signed-off-by: Alex Elder <elder@linaro.org>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-05-28 14:45:56 -07:00
Alex Elder 28e3cedcce greybus: update sysfs documentation files
Impose a few editorial conventions on the Greybus-related sysfs
files under "Documentation".
    - Capitalize "Endo" (except in path names)
    - Capitalize "ID" (except in path names)
    - Use "..." to indicate unspecified path components (because
      ".." means something else).
    - Add the "0x" prior to the "XXXX" representing the Endo ID.

Signed-off-by: Alex Elder <elder@linaro.org>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-05-28 14:45:56 -07:00
Alex Elder b4dbf1e132 greybus: add documentation for Endo sysfs files
Update the files documenting Greybus-related sysfs files under
Documentation/ to reflect the addition of the two recently-added
Endo attributes.

Signed-off-by: Alex Elder <elder@linaro.org>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-05-28 14:45:20 -07:00
Phong Tran df76422113 greybus: audio: Remove the MODULE_LICENSE()
This is not a kernel module. It should not use
the module license macro.

Signed-off-by: Phong Tran <tranmanphong@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-05-28 14:38:38 -07:00
Phong Tran bcd8215b49 greybus: audio: Fix typo for macro I2S data version minor
This macro should be DATA not MGMT.

Signed-off-by: Phong Tran <tranmanphong@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-05-28 14:38:38 -07:00
Alex Elder 012d7d4fbe greybus: greybus_protocols: fix guard tag
I neglected to update the "#ifndef/#define" when I renamed
"greybus_protocols.h".  Fix that.

Signed-off-by: Alex Elder <elder@linaro.org>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-05-28 14:04:08 -07:00
Johan Hovold 47bf0b4427 greybus: gpio: update operation types
Update the remaining operation types now that the ack operation is gone
to avoid leaving a hole in the type definitions.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-05-28 14:02:13 -07:00
Greg Kroah-Hartman 23bd25a798 greybus: Merge branch 'master' of github.com:gregkh/greybus 2015-05-28 14:02:02 -07:00
Phong Tran b61fa7bce4 greybus: svc: use macro for init and exit protocol
Change to gb_gpbridge_protocol_driver for
making the consitent with other drivers.

Signed-off-by: Phong Tran <tranmanphong@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-05-28 13:58:29 -07:00
Phong Tran ea15a40b32 greybus: svc: Fix endian of hotplug request data
data of hotplug request should exchange to native
CPU format before assignment.

Signed-off-by: Phong Tran <tranmanphong@gmail.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-05-28 13:58:29 -07:00
Johan Hovold 1409c4d6a8 greybus: gpio: fix interrupt protocol
The current interrupt implementation uses the simple irq-flow handler,
which means that the interrupt subsystem makes no irq-chip callbacks
when handling an interrupt. Specifically, no end-of-interrupt message is
sent when the threaded handler has run. This means that we may currently
re-enable an interrupt before it has been serviced (i.e. the irq-event
operation may complete before the threaded handler has run).

The simple flow handler also silently drops a second interrupt arriving
while a handler is running. This means that we may lose a second edge
interrupt with the current firmware.

Switch to a new one-shot interrupt protocol, where the primary handler
(firmware) always masks and acks an interrupt before sending an event to
the AP. The AP is responsible for unmasking the interrupt when it has
been handled. By having the firmware ack an edge interrupt before
sending the event, a second edge interrupt will no longer get lost.

This one-shot protocol can be implemented in the kernel by using the
level irq-flow handler, one-shot interrupts with threaded handlers and
bus-lock synchronisation for slow buses. Note that the same flow handler
is used for both edge and level interrupts.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-05-26 15:27:39 -07:00
Johan Hovold 25f11ed965 greybus: gpio: fix atomic sleep when using interrupts
The irq-chip callbacks are made in atomic context where we must not do
any synchronous greybus operations.

Fix the current gpio-interrupt implementation by using the bus-lock
functionality provided by the irq subsystem.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-05-26 15:26:08 -07:00
Johan Hovold 0cb918d72d greybus: gpio: rename irq mask and unmask callbacks
Rename irq mask and unmask functions to match the callback names.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-05-26 15:26:08 -07:00
Johan Hovold ec762115a5 greybus: gpio: use irq-domain lookups
Use irq_find_mapping directly rather than go through the legacy gpio
interface.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-05-26 15:25:17 -07:00
Johan Hovold 2611ebef83 greybus: gpio: don't call irq-flow handler directly
Use generic_handle_irq_desc rather than call a hardcoded irq-flow
handler directly.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-05-26 15:25:17 -07:00
Johan Hovold b8e3ffebac greybus: gpio: remove unused irq-ack operation
Remove unused irq-ack operation, which has never been called and does
not make sense for message-signalled interrupts over slow buses.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-05-26 15:25:17 -07:00
Johan Hovold c8d1ad8013 greybus: gpio: fix debugfs output
Fix debugfs output by removing the unimplemented, custom dbg_show
callback. The default implementation is perfectly sufficient.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-05-26 15:25:17 -07:00
Johan Hovold 1d771fe41e greybus: operation: add support for incoming unidirectional operations
Add support for incoming, unidirectional operations where the sender of
a request does not care about a response.

Unidirectional operations have an operation id of 0.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-05-26 15:25:17 -07:00
Greg Kroah-Hartman d67a39ab38 greybus: Merge branch 'master' of github.com:gregkh/greybus 2015-05-26 08:39:33 -07:00
Alex Elder 30c6d9d753 greybus: introduce SVC protocol
This patch adds support for the Greybus SVC protocol.  We may want
to rearrange protocol numbers at some point, since this is a pretty
fundamental protocol.

Note:  It has only been compile tested; no SVC CPorts have yet been
defined, so this code is not yet exercised.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-05-23 16:54:39 -07:00
Alex Elder 4441f4759c greybus: update copyrights
Update the copyright statements for recently-modified source files.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-05-23 16:47:56 -07:00
Alex Elder 2de1a8b1a9 greybus: add copyright statements
The Greybus audio source files included no copyright statements.
Add them.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-05-23 16:47:56 -07:00
Alex Elder eb765e4e91 greybus: core: don't set up endo until host device is initialized
Currently, the data structure representing an Endo is set up at the
time a host device gets created.  This is too early.

Once the control infrastructure is in place, there's no sense in
setting up the Endo utnil after we have heard from the SVC via a
probe operation on our control CPort.  And even then, there's
no real point until we've successfully authenticated with the SVC,
which will be indicated by the arrival of the Control protocol
"connected" operation request notifying us that our SVC CPort
is operational.

In addition to this logical argument, we also can't actually
receive any messages on the Control CPort until the host device
is set up and ready to receive messages.  At the point we're
currently setting up the Endo data structure, that has not yet
been done.

Define a new exported function greybus_endo_setup(), which will
be used (for now) as the entry point for setting up the Endo
data structure.  Arrange to call it in the host USB driver
probe method, *after* we are set up for handling messages.

Note: Once the control protocol has been implemented, this function
may no longer need to be exported.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-05-23 16:45:42 -07:00
Alex Elder 344943d2cd greybus: endo: record AP interface id
The AP resides in a particular position on an Endo, which is
identified by an interface ID.  (For now we'll assume the AP uses
just one interface.)  Record the this AP interface ID when creating
an Endo.  Add a sysfs attribute to display it as well.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-05-23 16:44:45 -07:00
Alex Elder e45524f849 greybus: endo: rework some attributes
The SVC is not the same as the Endo.  There are some attributes
(such as the Endo ID) that are independent of attributes of
the SVC (like its version).

The current "Endo attributes" are really SVC attributes.
Rename a few functions and variables to reflect that.

Add a new attribute group for Endo-specific attributes, and
populate it with the Endo ID.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-05-23 16:44:45 -07:00
Alex Elder 8a76043722 greybus: endo: encapsulate computing the max interface id
The maximum interface id on an Endo is the result of a non-trivial
calculation.  It'll be needed for an upcoming patch, so create a
macro to compute it.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-05-23 16:44:45 -07:00
Alex Elder 22e17edaa7 greybus: rename "gpbridge.h"
The file "gpbridge.h" is now used as a single place to define
all protocol message structures.  These protocols are not
necessarily related to the GP bridge, so the name of the
file is misleading.

Rename it "greybus_protocols.h".

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-05-23 16:34:50 -07:00
Alex Elder e9385e5d5a greybus: include "gpbridge.h" from "greybus.h"
Avoid the need for all the source files to include "gpbridge.h"
by just having "greybus.h" include it.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-05-23 16:34:39 -07:00
Alex Elder 8ea70fe049 greybus: core: return error code when creating host device
Return a pointer-coded error from greybus_create_hd() rather
than NULL in the event an error occurs.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-05-23 16:31:42 -07:00
Alex Elder 6b7d5a1f47 greybus: core: return error code when creating endo
Return a pointer-coded error from gb_endo_create() rather than just
a null pointer in the event an error occurs.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-05-23 16:31:42 -07:00
Alex Elder ee3ecf8028 greybus: endo: pass endo_id to gb_endo_create()
We are going to want to defer creating the endo until we receive a
probe operation from the SVC, which will supply the endo id.  Change
gb_endo_create() so it passes the endo_id value as an argument.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-05-23 16:31:42 -07:00
Alex Elder a702a09f20 greybus: endo: rename gb_svc
Change the name of "struct gb_svc" to be "struct svc_info".  The
structure now contains only the SVC's serial number and version (and
are place holders anyway).  We will be defining a structure that
represents the SVC for the SVC protocol connection, and I want to
take back that name.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-05-23 16:31:42 -07:00
Mark A. Greer 0d17e0c9f1 greybus: gb-audio: Set samples per message during init
A recent commit moved the I2S samples per message operation
to the PCM's 'hw_params' callback.  However, the 'hw_params'
callback is called numerous times while the samples per
message need only be done once (or seldom).  Eliminate the
unnecessary samples per message operations by doing it only
once at Greybus protocol init time.

Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Acked-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-05-23 16:26:41 -07:00