summaryrefslogtreecommitdiffstats
path: root/drivers/staging/greybus/module.c
Commit message (Collapse)AuthorAgeFilesLines
* staging: greybus: Parenthesis alignmentCristian Sicilia2018-11-261-10/+9Star
| | | | | | | | Some parameters are aligned with parentheses. Some parentheses was opened at end of line. Signed-off-by: Cristian Sicilia <sicilia.cristian@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* treewide: Use struct_size() for kmalloc()-familyKees Cook2018-06-061-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | One of the more common cases of allocation size calculations is finding the size of a structure that has a zero-sized array at the end, along with memory for some number of elements for that array. For example: struct foo { int stuff; void *entry[]; }; instance = kmalloc(sizeof(struct foo) + sizeof(void *) * count, GFP_KERNEL); Instead of leaving these open-coded and prone to type mistakes, we can now use the new struct_size() helper: instance = kmalloc(struct_size(instance, entry, count), GFP_KERNEL); This patch makes the changes for kmalloc()-family (and kvmalloc()-family) uses. It was done via automatic conversion with manual review for the "CHECKME" non-standard cases noted below, using the following Coccinelle script: // pkey_cache = kmalloc(sizeof *pkey_cache + tprops->pkey_tbl_len * // sizeof *pkey_cache->table, GFP_KERNEL); @@ identifier alloc =~ "kmalloc|kzalloc|kvmalloc|kvzalloc"; expression GFP; identifier VAR, ELEMENT; expression COUNT; @@ - alloc(sizeof(*VAR) + COUNT * sizeof(*VAR->ELEMENT), GFP) + alloc(struct_size(VAR, ELEMENT, COUNT), GFP) // mr = kzalloc(sizeof(*mr) + m * sizeof(mr->map[0]), GFP_KERNEL); @@ identifier alloc =~ "kmalloc|kzalloc|kvmalloc|kvzalloc"; expression GFP; identifier VAR, ELEMENT; expression COUNT; @@ - alloc(sizeof(*VAR) + COUNT * sizeof(VAR->ELEMENT[0]), GFP) + alloc(struct_size(VAR, ELEMENT, COUNT), GFP) // Same pattern, but can't trivially locate the trailing element name, // or variable name. @@ identifier alloc =~ "kmalloc|kzalloc|kvmalloc|kvzalloc"; expression GFP; expression SOMETHING, COUNT, ELEMENT; @@ - alloc(sizeof(SOMETHING) + COUNT * sizeof(ELEMENT), GFP) + alloc(CHECKME_struct_size(&SOMETHING, ELEMENT, COUNT), GFP) Signed-off-by: Kees Cook <keescook@chromium.org>
* staging: greybus: Remove redundant license textGreg Kroah-Hartman2017-11-111-2/+0Star
| | | | | | | | | | | | | | | | | | | | | | | | Now that the SPDX tag is in all greybus files, that identifies the license in a specific and legally-defined manner. So the extra GPL text wording can be removed as it is no longer needed at all. This is done on a quest to remove the 700+ different ways that files in the kernel describe the GPL license text. And there's unneeded stuff like the address (sometimes incorrect) for the FSF which is never needed. No copyright headers or other non-license-description text was removed. Cc: Vaibhav Hiremath <hvaibhav.linux@gmail.com> Reviewed-by: Alex Elder <elder@linaro.org> Acked-by: Vaibhav Agarwal <vaibhav.sr@gmail.com> Acked-by: David Lin <dtwlin@gmail.com> Acked-by: Johan Hovold <johan@kernel.org> Acked-by: Viresh Kumar <viresh.kumar@linaro.org> Acked-by: Mark Greer <mgreer@animalcreek.com> Acked-by: Rui Miguel Silva <rmfrfs@gmail.com> Acked-by: "Bryan O'Donoghue" <pure.logic@nexus-software.ie> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* staging: greybus: add SPDX identifiers to all greybus driver filesGreg Kroah-Hartman2017-11-111-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | It's good to have SPDX identifiers in all files to make it easier to audit the kernel tree for correct licenses. Update the drivers/staging/greybus files files with the correct SPDX license identifier based on the license text in the file itself. The SPDX identifier is a legally binding shorthand, which can be used instead of the full boiler plate text. This work is based on a script and data from Thomas Gleixner, Philippe Ombredanne, and Kate Stewart. Cc: Vaibhav Hiremath <hvaibhav.linux@gmail.com> Cc: "Bryan O'Donoghue" <pure.logic@nexus-software.ie> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Kate Stewart <kstewart@linuxfoundation.org> Cc: Philippe Ombredanne <pombredanne@nexb.com> Acked-by: Vaibhav Agarwal <vaibhav.sr@gmail.com> Acked-by: David Lin <dtwlin@gmail.com> Reviewed-by: Alex Elder <elder@linaro.org> Acked-by: Johan Hovold <johan@kernel.org> Acked-by: Viresh Kumar <viresh.kumar@linaro.org> Acked-by: Mark Greer <mgreer@animalcreek.com> Acked-by: Rui Miguel Silva <rmfrfs@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* greybus: fix a leak on error in gb_module_create()Dan Carpenter2016-10-241-1/+1
| | | | | | | | | | We should release ->interfaces[0] as well. Fixes: b15d97d77017 ("greybus: core: add module abstraction") Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Acked-by: Viresh Kumar <viresh.kumar@linaro.org> Acked-by: Johan Hovold <johan@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* greybus: interface: prevent reactivation during removalJohan Hovold2016-07-201-0/+1
| | | | | | | | | | | | | | | | | Make sure to prevent an interface that is going away from being reactivated. This is needed to preemptively close a race between the upcoming feature to reactivate a powered-down interface and physical removal (i.e. module_removed event processing) as well as logical removal (e.g. the current system-suspend hack). Reviewed-by: Sandeep Patil <sspatil@google.com> Signed-off-by: Johan Hovold <johan@hovoldconsulting.com> Reviewed-by: Alex Elder <elder@linaro.org> Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org> Reviewed-by: Patrick Titiano <ptitiano@baylibre.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
* greybus: interface: clean up ES3 activation-retry hackJohan Hovold2016-07-201-19/+1Star
| | | | | | | | | | | | | | | Clean up the ES3 activation retry-hack and isolate it in the interface code. This way the retry hack can be reused when we soon start allowing interfaces to be reactivated after having been powered down. Reviewed-by: Sandeep Patil <sspatil@google.com> Signed-off-by: Johan Hovold <johan@hovoldconsulting.com> Reviewed-by: Alex Elder <elder@linaro.org> Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org> Reviewed-by: Patrick Titiano <ptitiano@baylibre.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
* greybus: interface: use an enum for interface typeJohan Hovold2016-07-201-1/+1
| | | | | | | | | | | | | Use an enum for the interface type instead of using the SVC protocol values directly. Suggested-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Johan Hovold <johan@hovoldconsulting.com> Reviewed-by: Alex Elder <elder@linaro.org> Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org> Reviewed-by: Sandeep Patil <sspatil@google.com> Reviewed-by: Patrick Titiano <ptitiano@baylibre.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
* greybus: module: suppress activation error message for dummy interfacesJohan Hovold2016-07-201-2/+5
| | | | | | | | | We currently handle dummy interfaces by deactivating them using activation error paths, but we don't want the corresponding module_inserted error message to be printed. Signed-off-by: Johan Hovold <johan@hovoldconsulting.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
* greybus: fix tracepoint-related whitespace issuesJohan Hovold2016-05-271-1/+1
| | | | | | | Fix some whitespace issues introduced by the recent tracepoint changes. Signed-off-by: Johan Hovold <johan@hovoldconsulting.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
* greybus: tracing: add module tracesAlex Elder2016-05-271-0/+9
| | | | | | | | | | | Define a new gb_module trace point event class, used to trace events associated with the module abstraction. Define four basic trace points for this--creation time, drop of last reference, before registring interfaces and after de-registering them. Signed-off-by: Alex Elder <elder@linaro.org> Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
* greybus: interface: retry enumeration of UniPro-only modulesJeffrey Carlyle2016-05-191-1/+20
| | | | | | | | | | | | | | | Greybus modules will sometimes fail to send the mailbox poke and erroneously be enumerated as UniPro-only modules. The root cause for this on the module side is not fully understand, but it seems that this may be due to "the bootrom bug:" a known problem with the bootrom where linkup will occasionally fail because of a race condition. Before the new hotplug code was implemented in the firmware, the SVC would retry enumeration of modules that did not send the mailbox poke; this patch ports that functionality to the AP. Signed-off-by: Jeffrey Carlyle <jcarlyle@google.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
* greybus: module: implement controlled module removalJohan Hovold2016-04-251-1/+47
| | | | | | | | | | | | | | | | | | | Implement controlled module removal through a new module attribute "eject". When a non-zero argument is written to the attribute, all interfaces of the module are disabled (e.g. bundles are deregistered) and deactivated (e.g. powered off) before instructing the SVC to physically eject the module. Note that the module device is not deregistered until the SVC has reported the physical removal of all of its interfaces. A new interface mutex is added to enforce interface state-change serialisation. Signed-off-by: Johan Hovold <johan@hovoldconsulting.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
* greybus: core: add module abstractionJohan Hovold2016-04-251-0/+178
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add Greybus module abstraction that will be used to implement controlled module removal (eject) and represent module geometry. Greybus module devices correspond to physical modules and have one or more interfaces. Modules have an id that is identical to the id of their primary interface, which in turn is the interface with lowest numbered id. The module name is constructed from the bus and module id: <bus_id>-<module_id> Interfaces, bundles, and control devices are consequently renamed as <bus_id>-<module_id>.<interface_id> <bus_id>-<module_id>.<interface_id>.<bundle_id> <bus_id>-<module_id>.<interface_id>.ctrl As before, interface ids (and therefore in a sense now also module ids) correspond to physical interface positions on the frame. Modules have the following attributes: module_id num_interfaces where module_id is the id of the module and num_interface the number of interfaces the module has. Note that until SVC module-size detection has been implemented, all interfaces are considered to be part of 1x2 modules. Specifically, the two interfaces of a 2x2 module will be presented as two 1x2 modules for now. Signed-off-by: Johan Hovold <johan@hovoldconsulting.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
* greybus: kill the endoJohan Hovold2015-11-261-178/+0Star
| | | | | | | | | | Remove the now unused endo and module code. Note that the never-implemented serial and version attributes of the endo can be implemented as svc attributes if needed. Signed-off-by: Johan Hovold <johan@hovoldconsulting.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
* greybus: hd: rename host-device structureJohan Hovold2015-11-051-1/+1
| | | | | | | | | Rename host-device structure gb_host_device to match our other structures. Signed-off-by: Johan Hovold <johan@hovoldconsulting.com> Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
* greybus: module: fix double freeing of module structureViresh Kumar2015-10-221-1/+0Star
| | | | | | | | | | The module will be released by gb_module_release() once all references for the module are dropped. And so there is no need to free it in the error path specially. Reviewed-by: Johan Hovold <johan@hovoldconsulting.com> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
* greybus: Prefix module-id with endo idViresh Kumar2015-06-091-1/+1
| | | | | | | | | 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>
* greybus: module: name routines consistentlyViresh Kumar2015-05-211-2/+2
| | | | | | | | | 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>
* greybus: endo: Create modules after validating Endo IDViresh Kumar2015-05-111-11/+3Star
| | | | | | | | | 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>
* greybus: endo: hook up endos into the device treeGreg Kroah-Hartman2015-04-091-24/+28
| | | | | | | | | | | | | | 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>
* greybus: module.c: add attributesGreg Kroah-Hartman2015-04-091-16/+41
| | | | | | | | | This adds the attributes power_control and present to a module. It also removes the unneeded module_id attribute, as that comes from the name of the module itself. Signed-off-by: Greg Kroah-Hartman <gregkh@google.com> Reviewed-by: Alex Elder <elder@linaro.org>
* greybus: interface: Fetch interface id instead of module id during setupViresh Kumar2015-04-051-0/+11
| | | | | | | | | | | | | | | | | | There can be more than one interface on a module and we need to know the interface for which the event has occurred. But at the same time we may not need the module id at all. During initial phase when AP is probed, the AP will receive the unique Endo id which shall be enough to draw relationships between interface and module ids. Code for that isn't available today and so lets create another routine to get module id (which needs to be fixed separately), which will simply return interface id passed to it. Now that we have interface id, update rest of the code to use it. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
* greybus: Unregister devices to get them freedViresh Kumar2015-04-051-1/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Devices registered with the device-core needs to be freed by calling device_unregister(). For module we are calling just put_device() and for bundle, connection and interface we are calling device_del(). All of these are incomplete and so none of them get freed, i.e. the .release() routine is never called for their devices. Module being a special case that it needs to maintain a refcount or a list of interfaces to trace its usage count. I have chosen refcount. And so once the refcount is zero, we can Unregister the device and module will get free as well. Because of this bug in freeing devices, their sysfs directories were not getting removed properly and after a manifest is parsed with the help of gbsim, removing modules was creating problems. The sysfs directory 'greybus' wasn't getting removed. And inserting the modules again resulted in warnings and insmod failure. WARNING: CPU: 3 PID: 4277 at /build/buildd/linux-3.13.0/fs/sysfs/dir.c:486 sysfs_warn_dup+0x86/0xa0() Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
* greybus: module: get rid of global list of modulesGreg Kroah-Hartman2015-01-021-27/+22Star
| | | | | | | | | Use the list that the driver core keeps of our structure, no need to duplicate it with a local list as well. This gets rid of a static lock too, always a nice thing to do. Signed-off-by: Greg Kroah-Hartman <greg@kroah.com> Reviewed-by: Alex Elder <elder@linaro.org>
* greybus: add module supportGreg Kroah-Hartman2014-12-241-0/+140
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Modules in the greybus system sit above the interface, so insert them early in the sysfs tree. We dynamically create them when we have an interface that references a module, as we don't get a "module create" message directly. They also dynamically go away when the last interface associated with a module is removed. Naming scheme for modules/interfaces/bundles/connections is bumped up by one ':', and now looks like the following: /sys/bus/greybus $ tree . ├── devices │   ├── 7 -> ../../../devices/pci0000:00/0000:00:14.0/usb1/1-1/7 │   ├── 7:7 -> ../../../devices/pci0000:00/0000:00:14.0/usb1/1-1/7/7:7 │   ├── 7:7:0 -> ../../../devices/pci0000:00/0000:00:14.0/usb1/1-1/7/7:7/7:7:0 │   └── 7:7:0:1 -> ../../../devices/pci0000:00/0000:00:14.0/usb1/1-1/7/7:7/7:7:0/7:7:0:1 ├── drivers ├── drivers_autoprobe ├── drivers_probe └── uevent 6 directories, 3 files /sys/bus/greybus $ grep . devices/*/uevent devices/7/uevent:DEVTYPE=greybus_module devices/7:7/uevent:DEVTYPE=greybus_interface devices/7:7:0/uevent:DEVTYPE=greybus_bundle devices/7:7:0:1/uevent:DEVTYPE=greybus_connection We still have some "confusion" about interface ids and module ids, which will be cleaned up later when the svc control protocol changes die down, right now we just name a module after the interface as we don't have any modules that have multiple interfaces in our systems. This has been tested with gbsim. Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
* greybus: interface_block: rename module.[c|h] to interface_block.[c|h]Greg Kroah-Hartman2014-12-121-201/+0Star
| | | | | | | | | "modules" in the driver model here, are really "interface blocks" as that is what they are physically tied to. So rename the files before we start changing the code to make it obvious what is going on. Reviewed-by: Alex Elder <elder@linaro.org> Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
* greybus: module: remove obsolete gb_tty pointerGreg Kroah-Hartman2014-12-121-2/+0Star
| | | | | | | We aren't using this anymore, so remove gb_tty from struct gb_module. Reviewed-by: Alex Elder <elder@linaro.org> Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
* greybus: Random spell fixesViresh Kumar2014-11-211-1/+1
| | | | | | Reviewed-by: Alex Elder <elder@linaro.org> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
* greybus: skeleton for future uevents.Greg Kroah-Hartman2014-11-151-1/+1
| | | | | | | | | | Implement a skeleton for the uevent framework, to be filled in later when we figure out what type of module "matching" we want to do for things (connections, interfaces, modules, etc.) Based on a patch from Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
* greybus: interface: move gb_module_interface_init() to interface.cViresh Kumar2014-11-141-31/+0Star
| | | | | | | | That's where it belong to. Also rename it in a similar way to: gb_interface_create() and gb_interface_destroy(). Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
* greybus: module: move module specific code to module.cViresh Kumar2014-11-141-0/+59
| | | | | | | | Some of module specific routines were present in core.c instead of module.c. Move them to the right place. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
* greybus: module: move gb_module_find() to a more logical locationViresh Kumar2014-11-141-11/+11
| | | | | Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
* greybus: module: free resources properly on failuresViresh Kumar2014-11-141-4/+5
| | | | | | 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>
* greybus: don't set ->dev.driver to NULL when it is already NULLViresh Kumar2014-11-141-1/+0Star
| | | | | | | | Parent objects of 'dev' are allocated with kzalloc() and so all of their fields are initialized with 0. Hence no need of marking them NULL again. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
* greybus: improve some error messagesAlex Elder2014-11-051-0/+2
| | | | | | | | 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>
* greybus: drop a redundant assignmentAlex Elder2014-11-051-1/+0Star
| | | | | | | 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>
* greybus: module: set device_id when initializing an interfaceMatt Porter2014-10-291-0/+1
| | | | | | | | | | 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>
* greybus: module: remove unneeded XXX comment about module id valuesGreg Kroah-Hartman2014-10-271-1/+1
| | | | | | | | 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>
* greybus: module: don't create duplicate module idsGreg Kroah-Hartman2014-10-241-0/+7
| | | | | | | | | | | | 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>
* greybus: hook up greybus to the driver modelGreg Kroah-Hartman2014-10-241-10/+26
| | | | | | | | | | | | | | | | | | 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>
* greybus: set route before sending packetsAlex Elder2014-10-221-1/+9
| | | | | | | | The route for a connection needs to be set *before* we initialize the connection. Signed-off-by: Alex Elder <elder@linaro.org> Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
* greybus: only initialize interfaces when upAlex Elder2014-10-221-7/+17
| | | | | | | | | Rather than bringing up all interfaces described in the manifest, wait until we get a link up message, and at that time go initialize the link. Signed-off-by: Alex Elder <elder@linaro.org> Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
* greybus: module: add gb_module_find()Matt Porter2014-10-221-0/+11
| | | | | | | | Add support for getting a struct gb_module from a Module ID. Signed-off-by: Matt Porter <mporter@linaro.org> Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
* greybus: improve module cleanup codeAlex Elder2014-10-211-4/+19
| | | | | | | | | When a module gets destroyed all of its state and the state of its interfaces and connections (etc.) need to be torn down. This is not now being done properly. Add this teardown code. Signed-off-by: Alex Elder <elder@linaro.org> Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
* greybus: add device initializationAlex Elder2014-10-171-14/+27
| | | | | | | | Set up the infrastructure for initializing connections based on their protocol. Signed-off-by: Alex Elder <elder@linaro.org> Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
* greybus: October 1 updatesAlex Elder2014-10-031-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | Update the definitions in "greybus_manifest.h" to reflect the changes to the Greybus specification made on October 1. They are: - renaming "device" to be "interface" - renumbering greybus descriptor type - eliminating the notion of a "function" - defining a CPort's protocol in the CPort descriptor - having a "class" take on the types previously used for "function" - renaming "serial number" to be "unique id" (for now) - relying on an interface's maximum cport id to determine how much device+cport address space the interface consumes - adding a simple class descriptor - renaming gb_interface->interface_id to be gb_interface->id This also reorders some things to match ordering in the document, and adds some commentary for the various structures. Since greybus_function_type is gone, we eliminate the "type" field from a function structure. (Functions are going away, next.) Signed-off-by: Alex Elder <elder@linaro.org> Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
* greybus: start improving manifest parsingAlex Elder2014-10-031-7/+6Star
| | | | | | | | | | | | | | | | | | | | | | | | | | | Currently the module manifest parsing code is sort of representative only and is not really very useful. This patch begins doing "real" parsing of the module manifest. It scans the module manifest to identify the descriptors it holds. It then verifies there's only one module descriptor found, and initializes new some fields in the gb_module structure based on what it contains (converting what's found to native byte order). Note that if anything unexpected is found or other errors occur when parsing the manifest, the parse fails. Because we now save this converted information when it's parsed we no longer have a greybus_descriptor_module struct within a struct gb_module. And because we've already converted these values, we can do a little less work displaying values in sysfs. (We also now show vendor, product, and version values in the right byte order.) This eliminates the need for greybus_string(), so get rid of it. It also slightly simplifies the greybus module matching code. Move some existing parsing code into a new file, "manifest.c". Signed-off-by: Alex Elder <elder@linaro.org> Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
* greybus: define greybus interface abstractionAlex Elder2014-10-031-0/+1
| | | | | | | | | | | Define new source files "interface.h" and "interface.c" to contain the definitions of the Greybus interface abstraction. A Greybus interface represents a UniPro device present in a UniPro module. For Project Ara, each interface block on a module implements a UniPro interface. Signed-off-by: Alex Elder <elder@linaro.org> Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
* greybus: isolate greybus module codeAlex Elder2014-10-031-0/+93
Define new source files "module.h" and "module.c" to separate the definitions of the Greybus module abstraction from other code. Rename "greybus_module" to be "gb_module", for brevity. Do the same for a few other symbols with "greybus_module" in their names. A few (like greybus_module_id) are more visible outside this kernel module so we'll keep their names more descriptive. Add a definition for U8_MAX in "kernel_ver.h" (it appeared in 3.14). Signed-off-by: Alex Elder <elder@linaro.org> Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>