__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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
'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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>