2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2024-12-18 18:23:53 +08:00

greybus: bundle: s/gb_interface/gb_bundle/g

Rename struct gb_interface to struct gb_bundle

It's a lot of renaming, some structures got renamed and also some
fields, but the goal was to rename things to make sense with the new
naming of how the system is put together in the 'driver model' view.

Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
This commit is contained in:
Greg Kroah-Hartman 2014-12-12 17:10:17 -05:00
parent f9b1df64a9
commit 1db0a5ff3a
12 changed files with 144 additions and 150 deletions

View File

@ -59,4 +59,4 @@ Date: December 2014
KernelVersion: 3.XX
Contact: Greg Kroah-Hartman <greg@kroah.com>
Description:
The device id of a Greybus interface.
The device id of a Greybus bundle.

View File

@ -61,7 +61,7 @@ static int svc_msg_send(struct svc_msg *svc_msg, struct greybus_host_device *hd)
}
int svc_set_route_send(struct gb_interface *interface,
int svc_set_route_send(struct gb_bundle *bundle,
struct greybus_host_device *hd)
{
struct svc_msg *svc_msg;
@ -73,7 +73,7 @@ int svc_set_route_send(struct gb_interface *interface,
svc_msg->header.message_type = SVC_MSG_DATA;
svc_msg->header.payload_length =
cpu_to_le16(sizeof(struct svc_function_unipro_set_route));
svc_msg->management.set_route.device_id = interface->device_id;
svc_msg->management.set_route.device_id = bundle->device_id;
return svc_msg_send(svc_msg, hd);
}
@ -145,12 +145,12 @@ static void svc_management(struct svc_function_unipro_management *management,
management->link_up.module_id);
return;
}
ret = gb_interface_init(gb_ib,
ret = gb_bundle_init(gb_ib,
management->link_up.interface_id,
management->link_up.device_id);
if (ret)
dev_err(hd->parent, "error %d initializing "
"interface block %hhu interface %hhu\n",
"interface block %hhu bundle %hhu\n",
ret, management->link_up.module_id,
management->link_up.interface_id);
break;

View File

@ -341,7 +341,7 @@ static int gb_battery_connection_init(struct gb_connection *connection)
b->num_properties = ARRAY_SIZE(battery_props),
b->get_property = get_property,
retval = power_supply_register(&connection->interface->gb_ib->dev, b);
retval = power_supply_register(&connection->bundle->gb_ib->dev, b);
if (retval) {
kfree(gb);
return retval;

View File

@ -1,5 +1,5 @@
/*
* Greybus interfaces
* Greybus bundles
*
* Copyright 2014 Google Inc.
* Copyright 2014 Linaro Ltd.
@ -9,131 +9,128 @@
#include "greybus.h"
static void gb_bundle_connections_exit(struct gb_bundle *bundle);
static int gb_bundle_connections_init(struct gb_bundle *bundle);
static ssize_t device_id_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
struct gb_interface *interface = to_gb_interface(dev);
struct gb_bundle *bundle = to_gb_bundle(dev);
return sprintf(buf, "%d", interface->device_id);
return sprintf(buf, "%d", bundle->device_id);
}
static DEVICE_ATTR_RO(device_id);
static struct attribute *interface_attrs[] = {
static struct attribute *bundle_attrs[] = {
&dev_attr_device_id.attr,
NULL,
};
ATTRIBUTE_GROUPS(interface);
ATTRIBUTE_GROUPS(bundle);
static void gb_interface_release(struct device *dev)
static void gb_bundle_release(struct device *dev)
{
struct gb_interface *interface = to_gb_interface(dev);
struct gb_bundle *bundle = to_gb_bundle(dev);
kfree(interface);
kfree(bundle);
}
struct device_type greybus_interface_type = {
.name = "greybus_interface",
.release = gb_interface_release,
struct device_type greybus_bundle_type = {
.name = "greybus_bundle",
.release = gb_bundle_release,
};
/* XXX This could be per-host device or per-module */
static DEFINE_SPINLOCK(gb_interfaces_lock);
static DEFINE_SPINLOCK(gb_bundles_lock);
/*
* A Greybus interface represents a UniPro device present on a
* module. For Project Ara, each active Interface Block on a module
* implements a UniPro device, and therefore a Greybus interface. A
* Greybus module has at least one interface, but can have two (or
* even more).
*
* Create a gb_interface structure to represent a discovered
* interface. Returns a pointer to the new interface or a null
* Create a gb_bundle structure to represent a discovered
* bundle. Returns a pointer to the new bundle or a null
* pointer if a failure occurs due to memory exhaustion.
*/
struct gb_interface *
gb_interface_create(struct gb_interface_block *gb_ib, u8 interface_id)
struct gb_bundle *gb_bundle_create(struct gb_interface_block *gb_ib, u8 interface_id)
{
struct gb_interface *interface;
struct gb_bundle *bundle;
int retval;
interface = kzalloc(sizeof(*interface), GFP_KERNEL);
if (!interface)
bundle = kzalloc(sizeof(*bundle), GFP_KERNEL);
if (!bundle)
return NULL;
interface->gb_ib = gb_ib;
interface->id = interface_id;
interface->device_id = 0xff; /* Invalid device id to start with */
INIT_LIST_HEAD(&interface->connections);
bundle->gb_ib = gb_ib;
bundle->id = interface_id;
bundle->device_id = 0xff; /* Invalid device id to start with */
INIT_LIST_HEAD(&bundle->connections);
/* Build up the interface device structures and register it with the
/* Build up the bundle device structures and register it with the
* driver core */
interface->dev.parent = &gb_ib->dev;
interface->dev.bus = &greybus_bus_type;
interface->dev.type = &greybus_interface_type;
interface->dev.groups = interface_groups;
device_initialize(&interface->dev);
dev_set_name(&interface->dev, "%d:%d", gb_ib->module_id, interface_id);
bundle->dev.parent = &gb_ib->dev;
bundle->dev.bus = &greybus_bus_type;
bundle->dev.type = &greybus_bundle_type;
bundle->dev.groups = bundle_groups;
device_initialize(&bundle->dev);
dev_set_name(&bundle->dev, "%d:%d", gb_ib->module_id, interface_id);
retval = device_add(&interface->dev);
retval = device_add(&bundle->dev);
if (retval) {
pr_err("failed to add interface device for id 0x%02hhx\n",
pr_err("failed to add bundle device for id 0x%02hhx\n",
interface_id);
put_device(&interface->dev);
kfree(interface);
put_device(&bundle->dev);
kfree(bundle);
return NULL;
}
spin_lock_irq(&gb_interfaces_lock);
list_add_tail(&interface->links, &gb_ib->interfaces);
spin_unlock_irq(&gb_interfaces_lock);
spin_lock_irq(&gb_bundles_lock);
list_add_tail(&bundle->links, &gb_ib->interfaces);
spin_unlock_irq(&gb_bundles_lock);
return interface;
return bundle;
}
/*
* Tear down a previously set up interface.
* Tear down a previously set up bundle.
*/
void gb_interface_destroy(struct gb_interface_block *gb_ib)
void gb_bundle_destroy(struct gb_interface_block *gb_ib)
{
struct gb_interface *interface;
struct gb_interface *temp;
struct gb_bundle *bundle;
struct gb_bundle *temp;
if (WARN_ON(!gb_ib))
return;
spin_lock_irq(&gb_interfaces_lock);
list_for_each_entry_safe(interface, temp, &gb_ib->interfaces, links) {
list_del(&interface->links);
gb_interface_connections_exit(interface);
device_del(&interface->dev);
spin_lock_irq(&gb_bundles_lock);
list_for_each_entry_safe(bundle, temp, &gb_ib->interfaces, links) {
list_del(&bundle->links);
gb_bundle_connections_exit(bundle);
device_del(&bundle->dev);
}
spin_unlock_irq(&gb_interfaces_lock);
spin_unlock_irq(&gb_bundles_lock);
}
int gb_interface_init(struct gb_interface_block *gb_ib, u8 interface_id, u8 device_id)
int gb_bundle_init(struct gb_interface_block *gb_ib, u8 bundle_id, u8 device_id)
{
struct gb_interface *interface;
struct gb_bundle *bundle;
int ret;
interface = gb_interface_find(gb_ib, interface_id);
if (!interface) {
dev_err(gb_ib->hd->parent, "module %hhu not found\n",
interface_id);
bundle = gb_bundle_find(gb_ib, bundle_id);
if (!bundle) {
dev_err(gb_ib->hd->parent, "bundle %hhu not found\n",
bundle_id);
return -ENOENT;
}
interface->device_id = device_id;
bundle->device_id = device_id;
ret = svc_set_route_send(interface, gb_ib->hd);
ret = svc_set_route_send(bundle, gb_ib->hd);
if (ret) {
dev_err(gb_ib->hd->parent, "failed to set route (%d)\n", ret);
return ret;
}
ret = gb_interface_connections_init(interface);
ret = gb_bundle_connections_init(bundle);
if (ret) {
dev_err(gb_ib->hd->parent, "module interface init error %d\n",
dev_err(gb_ib->hd->parent, "interface bundle init error %d\n",
ret);
/* XXX clear route */
return ret;
@ -142,29 +139,27 @@ int gb_interface_init(struct gb_interface_block *gb_ib, u8 interface_id, u8 devi
return 0;
}
struct gb_interface *gb_interface_find(struct gb_interface_block *gb_ib,
u8 interface_id)
struct gb_bundle *gb_bundle_find(struct gb_interface_block *gb_ib, u8 bundle_id)
{
struct gb_interface *interface;
struct gb_bundle *bundle;
spin_lock_irq(&gb_interfaces_lock);
list_for_each_entry(interface, &gb_ib->interfaces, links)
if (interface->id == interface_id) {
spin_unlock_irq(&gb_interfaces_lock);
return interface;
spin_lock_irq(&gb_bundles_lock);
list_for_each_entry(bundle, &gb_ib->interfaces, links)
if (bundle->id == bundle_id) {
spin_unlock_irq(&gb_bundles_lock);
return bundle;
}
spin_unlock_irq(&gb_interfaces_lock);
spin_unlock_irq(&gb_bundles_lock);
return NULL;
}
int gb_interface_connections_init(struct gb_interface *interface)
static int gb_bundle_connections_init(struct gb_bundle *bundle)
{
struct gb_connection *connection;
int ret = 0;
list_for_each_entry(connection, &interface->connections,
interface_links) {
list_for_each_entry(connection, &bundle->connections, bundle_links) {
ret = gb_connection_init(connection);
if (ret)
break;
@ -173,13 +168,13 @@ int gb_interface_connections_init(struct gb_interface *interface)
return ret;
}
void gb_interface_connections_exit(struct gb_interface *interface)
static void gb_bundle_connections_exit(struct gb_bundle *bundle)
{
struct gb_connection *connection;
struct gb_connection *next;
list_for_each_entry_safe(connection, next, &interface->connections,
interface_links) {
list_for_each_entry_safe(connection, next, &bundle->connections,
bundle_links) {
gb_connection_exit(connection);
gb_connection_destroy(connection);
}

View File

@ -1,5 +1,5 @@
/*
* Greybus interfaces
* Greybus bundles
*
* Copyright 2014 Google Inc.
* Copyright 2014 Linaro Ltd.
@ -7,29 +7,28 @@
* Released under the GPLv2 only.
*/
#ifndef __INTERFACE_H
#define __INTERFACE_H
#ifndef __BUNDLE_H
#define __BUNDLE_H
#include <linux/list.h>
struct gb_interface {
/* Greybus "public" definitions" */
struct gb_bundle {
struct device dev;
struct gb_interface_block *gb_ib;
u8 id;
u8 device_id;
struct list_head connections;
struct list_head links; /* module->interfaces */
struct list_head links; /* interface->bundles */
};
#define to_gb_interface(d) container_of(d, struct gb_interface, dev)
#define to_gb_bundle(d) container_of(d, struct gb_bundle, dev)
struct gb_interface *gb_interface_create(struct gb_interface_block *gb_ib, u8 module_id);
void gb_interface_destroy(struct gb_interface_block *gb_ib);
int gb_interface_init(struct gb_interface_block *gb_ib, u8 module_id, u8 device_id);
/* Greybus "private" definitions" */
struct gb_bundle *gb_bundle_create(struct gb_interface_block *gb_ib, u8 module_id);
void gb_bundle_destroy(struct gb_interface_block *gb_ib);
int gb_bundle_init(struct gb_interface_block *gb_ib, u8 module_id, u8 device_id);
struct gb_interface *gb_interface_find(struct gb_interface_block *gb_ib, u8 interface_id);
struct gb_bundle *gb_bundle_find(struct gb_interface_block *gb_ib, u8 bundle_id);
int gb_interface_connections_init(struct gb_interface *interface);
void gb_interface_connections_exit(struct gb_interface *interface);
#endif /* __INTERFACE_H */
#endif /* __BUNDLE_H */

View File

@ -32,7 +32,7 @@ struct gb_connection *gb_hd_connection_find(struct greybus_host_device *hd,
/*
* Callback from the host driver to let us know that data has been
* received on the interface.
* received on the bundle.
*/
void greybus_data_rcvd(struct greybus_host_device *hd, u16 cport_id,
u8 *data, size_t length)
@ -135,7 +135,7 @@ struct device_type greybus_connection_type = {
* Returns a pointer to the new connection if successful, or a null
* pointer otherwise.
*/
struct gb_connection *gb_connection_create(struct gb_interface *interface,
struct gb_connection *gb_connection_create(struct gb_bundle *bundle,
u16 cport_id, u8 protocol_id)
{
struct gb_connection *connection;
@ -156,7 +156,7 @@ struct gb_connection *gb_connection_create(struct gb_interface *interface,
return NULL;
}
hd = interface->gb_ib->hd;
hd = bundle->gb_ib->hd;
connection->hd = hd;
if (!gb_connection_hd_cport_id_alloc(connection)) {
gb_protocol_put(connection->protocol);
@ -164,17 +164,17 @@ struct gb_connection *gb_connection_create(struct gb_interface *interface,
return NULL;
}
connection->interface = interface;
connection->interface_cport_id = cport_id;
connection->bundle = bundle;
connection->bundle_cport_id = cport_id;
connection->state = GB_CONNECTION_STATE_DISABLED;
connection->dev.parent = &interface->dev;
connection->dev.parent = &bundle->dev;
connection->dev.bus = &greybus_bus_type;
connection->dev.type = &greybus_connection_type;
connection->dev.groups = connection_groups;
device_initialize(&connection->dev);
dev_set_name(&connection->dev, "%s:%d",
dev_name(&interface->dev), cport_id);
dev_name(&bundle->dev), cport_id);
retval = device_add(&connection->dev);
if (retval) {
@ -189,7 +189,7 @@ struct gb_connection *gb_connection_create(struct gb_interface *interface,
spin_lock_irq(&gb_connections_lock);
list_add_tail(&connection->hd_links, &hd->connections);
list_add_tail(&connection->interface_links, &interface->connections);
list_add_tail(&connection->bundle_links, &bundle->connections);
spin_unlock_irq(&gb_connections_lock);
atomic_set(&connection->op_cycle, 0);
@ -216,7 +216,7 @@ void gb_connection_destroy(struct gb_connection *connection)
gb_operation_cancel(operation, -ESHUTDOWN);
}
spin_lock_irq(&gb_connections_lock);
list_del(&connection->interface_links);
list_del(&connection->bundle_links);
list_del(&connection->hd_links);
spin_unlock_irq(&gb_connections_lock);
@ -237,9 +237,9 @@ void gb_connection_err(struct gb_connection *connection, const char *fmt, ...)
vaf.va = &args;
pr_err("greybus: [%hhu:%hhu:%hu]: %pV\n",
connection->interface->gb_ib->module_id,
connection->interface->id,
connection->interface_cport_id, &vaf);
connection->bundle->gb_ib->module_id,
connection->bundle->id,
connection->bundle_cport_id, &vaf);
va_end(args);
}

View File

@ -24,13 +24,13 @@ enum gb_connection_state {
struct gb_connection {
struct greybus_host_device *hd;
struct gb_interface *interface;
struct gb_bundle *bundle;
struct device dev;
u16 hd_cport_id;
u16 interface_cport_id;
u16 bundle_cport_id;
struct list_head hd_links;
struct list_head interface_links;
struct list_head bundle_links;
struct gb_protocol *protocol;
@ -43,7 +43,7 @@ struct gb_connection {
};
#define to_gb_connection(d) container_of(d, struct gb_connection, dev)
struct gb_connection *gb_connection_create(struct gb_interface *interface,
struct gb_connection *gb_connection_create(struct gb_bundle *bundle,
u16 cport_id, u8 protocol_id);
void gb_connection_destroy(struct gb_connection *connection);

View File

@ -47,18 +47,18 @@ static int greybus_module_match(struct device *dev, struct device_driver *drv)
static int greybus_uevent(struct device *dev, struct kobj_uevent_env *env)
{
struct gb_interface_block *gb_ib = NULL;
struct gb_interface *interface = NULL;
struct gb_bundle *bundle = NULL;
struct gb_connection *connection = NULL;
if (is_gb_interface_block(dev)) {
gb_ib = to_gb_interface_block(dev);
} else if (is_gb_interface(dev)) {
interface = to_gb_interface(dev);
gb_ib = interface->gb_ib;
} else if (is_gb_bundle(dev)) {
bundle = to_gb_bundle(dev);
gb_ib = bundle->gb_ib;
} else if (is_gb_connection(dev)) {
connection = to_gb_connection(dev);
interface = connection->interface;
gb_ib = interface->gb_ib;
bundle = connection->bundle;
gb_ib = bundle->gb_ib;
} else {
dev_WARN(dev, "uevent for unknown greybus device \"type\"!\n");
return -EINVAL;
@ -70,9 +70,9 @@ static int greybus_uevent(struct device *dev, struct kobj_uevent_env *env)
return 0;
}
if (interface) {
if (bundle) {
// FIXME
// add a uevent that can "load" a interface type
// add a uevent that can "load" a bundle type
// This is what we need to bind a driver to so use the info
// in gmod here as well
return 0;

View File

@ -172,11 +172,11 @@ extern struct bus_type greybus_bus_type;
int gb_uart_device_init(struct gb_connection *connection);
void gb_uart_device_exit(struct gb_connection *connection);
int svc_set_route_send(struct gb_interface *interface,
int svc_set_route_send(struct gb_bundle *bundle,
struct greybus_host_device *hd);
extern struct device_type greybus_interface_block_type;
extern struct device_type greybus_interface_type;
extern struct device_type greybus_bundle_type;
extern struct device_type greybus_connection_type;
static inline int is_gb_interface_block(const struct device *dev)
@ -184,9 +184,9 @@ static inline int is_gb_interface_block(const struct device *dev)
return dev->type == &greybus_interface_block_type;
}
static inline int is_gb_interface(const struct device *dev)
static inline int is_gb_bundle(const struct device *dev)
{
return dev->type == &greybus_interface_type;
return dev->type == &greybus_bundle_type;
}
static inline int is_gb_connection(const struct device *dev)

View File

@ -106,13 +106,13 @@ struct greybus_descriptor_interface {
};
/*
* A CPort descriptor indicates the id of the interface within the
* A CPort descriptor indicates the id of the bundle within the
* module it's associated with, along with the CPort id used to
* address the CPort. The protocol id defines the format of messages
* exchanged using the CPort.
*/
struct greybus_descriptor_cport {
__u8 interface;
__u8 bundle;
__le16 id;
__u8 protocol_id; /* enum greybus_protocol */
};

View File

@ -164,7 +164,7 @@ static void gb_ib_destroy(struct gb_interface_block *gb_ib)
list_del(&gb_ib->links);
spin_unlock_irq(&gb_modules_lock);
gb_interface_destroy(gb_ib);
gb_bundle_destroy(gb_ib);
kfree(gb_ib->product_string);
kfree(gb_ib->vendor_string);

View File

@ -172,10 +172,10 @@ static char *gb_string_get(u8 string_id)
/*
* Find cport descriptors in the manifest and set up data structures
* for the functions that use them. Returns the number of interfaces
* set up for the given module, or 0 if there is an error.
* for the functions that use them. Returns the number of bundles
* set up for the given interface, or 0 if there is an error.
*/
static u32 gb_manifest_parse_cports(struct gb_interface *interface)
static u32 gb_manifest_parse_cports(struct gb_bundle *bundle)
{
u32 count = 0;
@ -190,7 +190,7 @@ static u32 gb_manifest_parse_cports(struct gb_interface *interface)
list_for_each_entry(descriptor, &manifest_descs, links) {
if (descriptor->type == GREYBUS_TYPE_CPORT) {
desc_cport = descriptor->data;
if (desc_cport->interface == interface->id) {
if (desc_cport->bundle == bundle->id) {
found = true;
break;
}
@ -202,7 +202,7 @@ static u32 gb_manifest_parse_cports(struct gb_interface *interface)
/* Found one. Set up its function structure */
protocol_id = desc_cport->protocol_id;
cport_id = le16_to_cpu(desc_cport->id);
if (!gb_connection_create(interface, cport_id, protocol_id))
if (!gb_connection_create(bundle, cport_id, protocol_id))
return 0; /* Error */
count++;
@ -214,21 +214,21 @@ static u32 gb_manifest_parse_cports(struct gb_interface *interface)
}
/*
* Find interface descriptors in the manifest and set up their data
* structures. Returns the number of interfaces set up for the
* Find bundle descriptors in the manifest and set up their data
* structures. Returns the number of bundles set up for the
* given module.
*/
static u32 gb_manifest_parse_interfaces(struct gb_interface_block *gb_ib)
static u32 gb_manifest_parse_bundles(struct gb_interface_block *gb_ib)
{
u32 count = 0;
while (true) {
struct manifest_desc *descriptor;
struct greybus_descriptor_interface *desc_interface;
struct gb_interface *interface;
struct gb_bundle *bundle;
bool found = false;
/* Find an interface descriptor */
/* Find an bundle descriptor */
list_for_each_entry(descriptor, &manifest_descs, links) {
if (descriptor->type == GREYBUS_TYPE_INTERFACE) {
found = true;
@ -238,19 +238,19 @@ static u32 gb_manifest_parse_interfaces(struct gb_interface_block *gb_ib)
if (!found)
break;
/* Found one. Set up its interface structure*/
/* Found one. Set up its bundle structure*/
desc_interface = descriptor->data;
interface = gb_interface_create(gb_ib, desc_interface->id);
if (!interface)
bundle = gb_bundle_create(gb_ib, desc_interface->id);
if (!bundle)
return 0; /* Error */
/* Now go set up this interface's functions and cports */
if (!gb_manifest_parse_cports(interface))
/* Now go set up this bundle's functions and cports */
if (!gb_manifest_parse_cports(bundle))
return 0; /* Error parsing cports */
count++;
/* Done with this interface descriptor */
/* Done with this bundle descriptor */
release_manifest_descriptor(descriptor);
}
@ -279,9 +279,9 @@ static bool gb_manifest_parse_module(struct gb_interface_block *gb_ib,
/* Release the module descriptor, now that we're done with it */
release_manifest_descriptor(module_desc);
/* A module must have at least one interface descriptor */
if (!gb_manifest_parse_interfaces(gb_ib)) {
pr_err("manifest interface descriptors not valid\n");
/* An interface must have at least one bundle descriptor */
if (!gb_manifest_parse_bundles(gb_ib)) {
pr_err("manifest bundle descriptors not valid\n");
goto out_err;
}
@ -314,7 +314,7 @@ out_free_vendor_string:
* information it contains, and then remove that descriptor (and any
* string descriptors it refers to) from further consideration.
*
* After that we look for the module's interfaces--there must be at
* After that we look for the interface block's bundles--there must be at
* least one of those.
*
* Returns true if parsing was successful, false otherwise.