1
0
Fork 0
Commit Graph

20 Commits (45a706368d9b162dde2455c305158131af37131d)

Author SHA1 Message Date
Viresh Kumar 36e79dec96 greybus: create get_version() routines with the help of a macro
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>
2015-01-22 11:29:39 +08:00
Greg Kroah-Hartman 7422a1ec2e greybus: protocol: name protocols.
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>
2015-01-02 13:06:48 -08:00
Greg Kroah-Hartman 2c07817e72 greybus: i2c-gb: move i2c protocol into the gpbridge driver
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>
2015-01-02 13:05:42 -08:00
Greg Kroah-Hartman e1308c1fb6 greybus: gpb: Create a "GP Bridge" kernel module
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>
2015-01-02 13:05:42 -08:00
Greg Kroah-Hartman 7dd2626324 greybus: battery-gb: move the battery protocol out to a stand-alone module
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>
2015-01-02 13:05:42 -08:00
Greg Kroah-Hartman 66b676fd88 greybus: vibrator-gb: move vibrator protocol to a stand-alone module.
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>
2015-01-02 13:05:42 -08:00
Greg Kroah-Hartman 12a5dfc9ac greybus: protocol: add a module owner to a protocol
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>
2015-01-02 13:05:42 -08:00
Greg Kroah-Hartman 900ceba9e4 greybus: i2c-gb: split out into a stand-alone kernel module.
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>
2014-12-23 21:04:02 -08:00
Greg Kroah-Hartman 7c7d5b9a94 greybus: protocol: switch gb_protocol_register() to return an int
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>
2014-12-23 21:02:20 -08:00
Alex Elder a46e96719d greybus: add Linaro copyrights
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>
2014-12-12 14:15:55 -05:00
Greg Kroah-Hartman 615772aace greybus: usb-gb: import a "buildable" version of the usb-gb.c driver
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>
2014-12-01 20:38:58 -08:00
Greg Kroah-Hartman ac4029fb60 greybus: vibrator-gb: add vibrator driver
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>
2014-11-17 16:03:34 -08:00
Alex Elder c3cf278533 greybus: pass operation type on request receive
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>
2014-11-14 13:11:35 -08:00
Matt Porter 34c6507ca8 greybus: add pwm protocol driver
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>
2014-11-14 13:10:21 -08:00
Alex Elder f8fb05e2b8 greybus: add an incoming request receive method
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>
2014-11-05 14:23:50 -08:00
Alex Elder 5d9fd7e1ba greybus: move methods into protocol
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>
2014-11-05 14:23:50 -08:00
Alex Elder 19d03decd3 greybus: register preallocated protocols
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>
2014-11-05 14:23:50 -08:00
Alex Elder 0e44765743 greybus: count rather than list protocol users
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>
2014-11-05 14:21:24 -08:00
Alex Elder 6ae7fa4520 greybus: identify protocol by id *and* version
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>
2014-11-05 14:21:24 -08:00
Alex Elder 4ccb6b7abb greybus: introduce protocol abstraction
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>
2014-10-29 08:42:44 +08:00