All greybus_gbuf_finished() does is call the gbuf's complete method.
Currently, greybus_gbuf_finished() is only ever called in one place,
and that place can call the complete method directly instead. That
allows us to eliminate greybus_gbuf_finished().
Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
A gbuf now records a pointer to its operation. The only thing ever
stored in a gbuf context pointer is the gbuf's operation. Therefore
there's no longer any need to maintain the context pointer, so get
rid of it.
Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
Currently a gbuf records a pointer to the connection it's associated
with. We now know only use gbufs in operation messages, so we can
point a gbuf at its operation instead. This still gives access to
the connection where needed, but it also will provide all the
context we'll ever need for a gbuf, and this allows us (in the next
patch) to remove the gbuf->context field as well.
So switch to recording in a gbuf the operation rather than the
connection it is associated with.
Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
Right now, the actual_length field of a gbuf is only ever assigned,
never used. We now fill gbufs only with operation messages, and
they encode within them the amount of space "actually used" in a
buffer in a request-specific way. As a result, there's no need
for the gbuf->actual_length field, so we can remove it.
Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
Handling of incoming requests has been moved into the Greybus
connection and protocol layers. As a result, the original cport
oriented handler code is no longer used. So get rid of it.
Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
This file is an artifact of some early testing, but it is otherwise
unused. So get rid of it.
Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
Define a new protocol method intended to handle the receipt of an
incoming operation request. Most protocols have no expected
incoming requests and can leave this null. If a request arrives for
a protocol with no request receive handler an error is reported and
the request fails.
Get rid of the previous fixed array of receive handlers, it's
no longer needed.
Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
Get rid of the connection handler structure, and instead put the
methods that were there into the protocol structure.
Eliminate the big switch statement in connection_init() and just
call the connection's protocol's init function there directly.
Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
Set up protocol structures as static objects in each protocol source
file. Pass the address of that in--rather than the protocol id and
version information--to the protocol registration routine. Call a
central routine to register all our pre-defined protocols.
Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
Add protocols to the global list in sorted order, based on their
protocol id, and then their major and minor version number.
Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
We don't really need a list of protocol users, we can just keep
track of how many there are. Get rid of the list and use a count
instead.
Also, have gb_protocol_get() return the protocol rather than assigning
a passed-in connection pointer's protocol. Make a comparable change
to the gb_protocol_put() interface.
Get rid of gb_protocol_find() (the version that locks), because it
is no longer needed.
Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
Right now we only look up a protocol based on its protocol id.
Add support for maintaining a major and minor version as well, and
use them when looking up a protocol.
Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
Add a few error messages to help explain the reason for failures.
Add a missing space in a message in svc_management().
Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
There's a message that gets printed in gb_manifest_parse() if excess
descriptors are found in the manifest. This should only be printed
if the parse was successful. If it was not successful it's not
really very helpful.
Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
Get rid of a duplicate assignment of an interface's device id.
Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
The gbuf completion routine was using the request payload pointers
(which point at the area *past* the message header) rather than the
header. This didn't matter much for now, it was only used in the
error path.
Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
In order for 32bit arm devices using the android toolchain
to load the greybus module, I need to add -fno-pic in the
build arguments as well.
Signed-off-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
Once you have called device_initialize() you have to call put_device()
on the structure to clean it up on an error path, otherwise you will
leak memory.
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
Define a protocol structure that will allow protocols to be
registered dynamically. For now we just introduce a bookkeeping
data structure. Upcoming patches will move protocol-related methods
into the protocol structure, and will start registering protocol
handlers dynamically.
A list of connections using a given protocol is maintained so we can
tell when a protocol is no longer in use. This may not be necessary
(we could use a kref instead) but it may turn out to be a good way
to clean things up.
The interface is gb_protocol_get() and gb_protocol_put() for a
connection, allowing the protocol to be looked up and the connection
structure to be inserted into its list.
Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
Switch to using "protocol_id" to refer to a byte-sized numeric
protocol number. A "protocol" will represent a protocol structure
(created in the next patch).
Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
In gb_connection_create(), if an error occurs adding a connection's
device, the cport id assigned to the AP end of the connection is not
getting freed. Fix that.
Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
In gb_connection_init() we set the connection_handler for each supported
protocol, but we never call the connection_init hook after doing so. This
results in a failure being returned so fix it by calling the connection_init
hook to get a good return and the associated driver initialized.
Signed-off-by: Matt Porter <mporter@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
gb_module_interface_init() looks for the interface corresponding
to the supplied interface_id, but fails to configure the
device_id that goes with it. This results in a set route command
being set with an uninitialized and bogus value. Fix it.
Signed-off-by: Matt Porter <mporter@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
We don't need a callback for bulk out urbs to do anything except put the
urb back in the pool. Document why we do this and what is involved.
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
We aren't using an id_table for "drivers" at this moment, as the whole
driver model interaction is under heavy rework. So remove these for now
to keep things easier to understand for future patches.
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
No one is using sdio yet, but convert to the connection interface to
remove the last user of the "old" module interface.
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
We aren't going to have individual modules for the gb protocols, so just
remove this useless code, it was throwing up warnings in sparse.
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
This is part 1 of abstracting the connection operations into a set
of methods. This will avoid some big switch statements, but more
importantly this will be needed for supporting multiple versions of
each protocol.
For now only two methods are defined. The init method is used
to set up the device (or whatever the CPort represents) and the exit
method tears it down. There may need to be additional operations
added in the future, and once versioning is used we might stash
the version number in this structure as well.
The next patch adds dynamic registratration of these protocol
handlers, and will do away with the switch statement now found
in gb_connection_init().
Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
We do properly check for duplicate module ids, as fixed in
008d85d90ae1ab31f1f7b80f245f6ee2eb5aed49 "module: don't create duplicate
module ids", so remove the XXX marker.
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Now that we have proper reference counting for modules, interfaces, and
connections, no need to worry about grabbing a pointer to your "parent"
structure, all is good.
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
The uart-gb code needs to init the tty core before it can add devices.
Previously we hard-coded this in the greybus core, move this to be
"dynamic" and self-contained within the uart-gb.c file.
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
Move the uart code over to use the "new" connection interface, instead
of the "old" module interface.
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
We don't need to dynamically allocate the i2c adapter structure, we
can just embed it right in struct gb_i2c_device.
Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
This field is never used (and not needed) so get rid of it.
Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
An operation is what can timeout, not a connection itself. So notify
the operation timedout, and the connection can then do with it as it
sees fit, if necessary.
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
We can't do anything if killing a gbuf fails, so just make this function
"always" be successful.
At the same time, make the host controller function also be called
"kill_gbuf" to keep the terminology in sync.
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
Reviewed-by: Alex Elder <elder@linaro.org>
When registering a host controller, verify that all of the needed
callbacks are present, so we don't have to do the testing on any "hot"
paths when we want to send real data.
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
Reviewed-by: Alex Elder <elder@linaro.org.
Hook up gbuf_kill_gbuf() by implementing yet-another-host-controller
callback and a gbuf-specific pointer to hold the tracking data the hcd
needs in order to be able to abort a transfer.
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
Reviewed-by: Alex Elder <elder@linaro.org>
If we somehow get a hotplug event for a module id that we already have
created[1], don't try to create it again, or sysfs will complain loudly.
Instead, abort the creation properly.
[1] If, for example, you happened to run a script on a greybus emulator
twice in a row...
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
Reviewed-by: Alex Elder <elder@linaro.org>
We were thinking that module attributes were known at the time the
device was created in the system, so we could query them to know if the
sysfs file was present or not. Unfortunatly that's not the case, we
create the device before we parse the values, so just always show the
sysfs attributes. If there is no such attribute, the sysfs file will be
empty (i.e. for the string attributes.)
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
I screwed up the error handling in a patch the other day. If we get
an error on an input URB we should not re-submit it.
Signed-off-by: Alex Elder <elder@linaro.org>
This patch hooks up modules, interfaces, and connections to the driver
model. Now we have a correct hierarchy, and drivers can be correctly
bound to the proper portions in the future. Devices are correctly
reference counted and torn down in the proper order on removal of a
module.
Some basic sysfs attributes have been created for interfaces and
connections. Module attributes are not working properly, but that will
be fixed in future changes.
This has been tested on Alex's machine, with multiple hotplug and unplug
operations of a module working correctly.
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>