Commit graph

21 commits

Author SHA1 Message Date
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 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
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 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
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 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 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 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
Viresh Kumar 5ddf738e94 greybus: endo: name routines consistently
Routines should be named this way: gb_<object>_<operation>. Fix all
routines that don't match this.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-05-20 22:39:18 -07:00
Viresh Kumar 51e93aea65 greybus: endo: Create modules after validating Endo ID
We already have code to parse Endo ID, lets use it to create modules at
run time instead of creating them from a static array.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-05-11 13:30:09 -07:00
Viresh Kumar 4f4cc1bf07 greybus: endo: Add code to validate Endo ID
Endo is described by a 16 bit value. Which represents the properties of
modules, interface and ribs on front and back of endo.

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

This patch provides helpers to parse 16 bit Endo ID.

(Based on original code written by Alex Elder.)

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-05-11 13:30:09 -07:00
Viresh Kumar 8f8b2297c0 greybus: endo: Rename endo's 'type' as 'id'
There can be three Endo types: mini, medium and large. And that's what
Endo 'type' should refer to.

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

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

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

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

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

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

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

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Reviewed-by: Alex Elder <elder@linaro.org>
2015-04-09 22:50:09 +02:00