This gets rid of lots of duplication of code.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
We want to be able to "blame" a protocol for things at times, so give
them a name we can refer to them by. Announce when they are added or
removed from the system so we have a chance to know what is going on
in the kernel logs.
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
Reviewed-by: Alex Elder <elder@linaro.org>
The i2c protocol belongs in the gpbridge driver, so move it
there.
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
Reviewed-by: Alex Elder <elder@linaro.org>
This bundles together the existing GP Bridged PHY protocols that were
part of the Greybus core: USB, UART, SDIO, PWM, and GPIO. This is now a
stand-alone kernel module. More logic will be moving here in the future
to handle bridged devices.
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
Reviewed-by: Alex Elder <elder@linaro.org>
This moves the battery class protocol to be a stand-alone kernel module.
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
Reviewed-by: Alex Elder <elder@linaro.org>
We can't use the gb_protocol_driver() macro here as we need to do some
init and exit logic when loading and removing, so "open code" the module
init and exit functions.
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
Reviewed-by: Alex Elder <elder@linaro.org>
Now that protocols can be in a module, we need to reference count them
to lock them into memory so they can't be removed while in use. So add
a module owner structure, and have it automatically be assigned when
registering the protocol.
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
Reviewed-by: Alex Elder <elder@linaro.org>
This splits the i2c-gb protocol into a stand-alone kernel module.
It's not going to stay in this fashion for long, this was done to test
the "can a protcol be loaded later" logic. Future refactoring is going
to move the gpbridge protocols to a separate kernel module, where this
protocol is going to live.
But for now, split it out, it is good to test with, and shows a bug in
gbsim at the moment.
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
We will want to return this value as a return value for module_init()
and bool does not play well with module_init(). So make it a "real"
error value and return int and fix up all callers of the function.
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
I was asked to add a Linaro copyright to all Greybus source files
that anyone at Linaro has modified. This patch does that.
Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
Based on Fabien's original driver, this version is converted (mostly) to
the new greybus operation apis. Lots of things still to do, not the
least being hooking up proper responses...
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
This driver implements the Greybus vibrator protocol, as defined in the
Greybus protocol specification. It interacts to userspace with a single
sysfs file, "timeout", and a separate "class" called "vibrator". That
interface can/should be changed in the future depending on what Android
wants for its HAL, but for now should be good enough to test with.
There are some changes needed to kernel_ver.h to support some
sysfs/driver core changes that happened after the 3.10 kernel was
released to try to make the code simpler. Even with those changes,
there are #ifdefs in the code to do different things depending on the
kernel version to implement the same userspace api.
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
When an incoming request is received, the operation type is encoded
in the header and is not available in the payload. Add the
operation type as a parameter to the request_recv method so the
request handler knows what to do.
Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Add a PWM driver that implements the Greybus PWM protocol.
Signed-off-by: Matt Porter <mporter@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>
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>
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>