Commit 4ab9b3c2 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

greybus: interface: s/gb_interface_block/gb_interface/g

Rename struct gb_interface_block to struct gb_interface

Lots of renaming, and variable renames as well (gb_ib->intf), but all
should be sane with regards to the new naming scheme we are using.
Reviewed-by: default avatarAlex Elder <elder@linaro.org>
Signed-off-by: default avatarGreg Kroah-Hartman <greg@kroah.com>
parent a93938a2
...@@ -124,7 +124,7 @@ static void svc_handshake(struct svc_function_handshake *handshake, ...@@ -124,7 +124,7 @@ static void svc_handshake(struct svc_function_handshake *handshake,
static void svc_management(struct svc_function_unipro_management *management, static void svc_management(struct svc_function_unipro_management *management,
int payload_length, struct greybus_host_device *hd) int payload_length, struct greybus_host_device *hd)
{ {
struct gb_interface_block *gb_ib; struct gb_interface *intf;
int ret; int ret;
if (payload_length != sizeof(*management)) { if (payload_length != sizeof(*management)) {
...@@ -139,18 +139,18 @@ static void svc_management(struct svc_function_unipro_management *management, ...@@ -139,18 +139,18 @@ static void svc_management(struct svc_function_unipro_management *management,
hd->device_id = management->ap_id.device_id; hd->device_id = management->ap_id.device_id;
break; break;
case SVC_MANAGEMENT_LINK_UP: case SVC_MANAGEMENT_LINK_UP:
gb_ib = gb_ib_find(hd, management->link_up.module_id); intf = gb_interface_find(hd, management->link_up.module_id);
if (!gb_ib) { if (!intf) {
dev_err(hd->parent, "Module ID %d not found\n", dev_err(hd->parent, "Module ID %d not found\n",
management->link_up.module_id); management->link_up.module_id);
return; return;
} }
ret = gb_bundle_init(gb_ib, ret = gb_bundle_init(intf,
management->link_up.interface_id, management->link_up.interface_id,
management->link_up.device_id); management->link_up.device_id);
if (ret) if (ret)
dev_err(hd->parent, "error %d initializing " dev_err(hd->parent,
"interface block %hhu bundle %hhu\n", "error %d initializing interface %hhu bundle %hhu\n",
ret, management->link_up.module_id, ret, management->link_up.module_id,
management->link_up.interface_id); management->link_up.interface_id);
break; break;
......
...@@ -341,7 +341,7 @@ static int gb_battery_connection_init(struct gb_connection *connection) ...@@ -341,7 +341,7 @@ static int gb_battery_connection_init(struct gb_connection *connection)
b->num_properties = ARRAY_SIZE(battery_props), b->num_properties = ARRAY_SIZE(battery_props),
b->get_property = get_property, b->get_property = get_property,
retval = power_supply_register(&connection->bundle->gb_ib->dev, b); retval = power_supply_register(&connection->bundle->intf->dev, b);
if (retval) { if (retval) {
kfree(gb); kfree(gb);
return retval; return retval;
......
...@@ -50,7 +50,7 @@ static DEFINE_SPINLOCK(gb_bundles_lock); ...@@ -50,7 +50,7 @@ static DEFINE_SPINLOCK(gb_bundles_lock);
* bundle. Returns a pointer to the new bundle or a null * bundle. Returns a pointer to the new bundle or a null
* pointer if a failure occurs due to memory exhaustion. * pointer if a failure occurs due to memory exhaustion.
*/ */
struct gb_bundle *gb_bundle_create(struct gb_interface_block *gb_ib, u8 interface_id) struct gb_bundle *gb_bundle_create(struct gb_interface *intf, u8 interface_id)
{ {
struct gb_bundle *bundle; struct gb_bundle *bundle;
int retval; int retval;
...@@ -59,19 +59,19 @@ struct gb_bundle *gb_bundle_create(struct gb_interface_block *gb_ib, u8 interfac ...@@ -59,19 +59,19 @@ struct gb_bundle *gb_bundle_create(struct gb_interface_block *gb_ib, u8 interfac
if (!bundle) if (!bundle)
return NULL; return NULL;
bundle->gb_ib = gb_ib; bundle->intf = intf;
bundle->id = interface_id; bundle->id = interface_id;
bundle->device_id = 0xff; /* Invalid device id to start with */ bundle->device_id = 0xff; /* Invalid device id to start with */
INIT_LIST_HEAD(&bundle->connections); INIT_LIST_HEAD(&bundle->connections);
/* Build up the bundle device structures and register it with the /* Build up the bundle device structures and register it with the
* driver core */ * driver core */
bundle->dev.parent = &gb_ib->dev; bundle->dev.parent = &intf->dev;
bundle->dev.bus = &greybus_bus_type; bundle->dev.bus = &greybus_bus_type;
bundle->dev.type = &greybus_bundle_type; bundle->dev.type = &greybus_bundle_type;
bundle->dev.groups = bundle_groups; bundle->dev.groups = bundle_groups;
device_initialize(&bundle->dev); device_initialize(&bundle->dev);
dev_set_name(&bundle->dev, "%d:%d", gb_ib->module_id, interface_id); dev_set_name(&bundle->dev, "%d:%d", intf->module_id, interface_id);
retval = device_add(&bundle->dev); retval = device_add(&bundle->dev);
if (retval) { if (retval) {
...@@ -83,7 +83,7 @@ struct gb_bundle *gb_bundle_create(struct gb_interface_block *gb_ib, u8 interfac ...@@ -83,7 +83,7 @@ struct gb_bundle *gb_bundle_create(struct gb_interface_block *gb_ib, u8 interfac
} }
spin_lock_irq(&gb_bundles_lock); spin_lock_irq(&gb_bundles_lock);
list_add_tail(&bundle->links, &gb_ib->bundles); list_add_tail(&bundle->links, &intf->bundles);
spin_unlock_irq(&gb_bundles_lock); spin_unlock_irq(&gb_bundles_lock);
return bundle; return bundle;
...@@ -92,16 +92,16 @@ struct gb_bundle *gb_bundle_create(struct gb_interface_block *gb_ib, u8 interfac ...@@ -92,16 +92,16 @@ struct gb_bundle *gb_bundle_create(struct gb_interface_block *gb_ib, u8 interfac
/* /*
* Tear down a previously set up bundle. * Tear down a previously set up bundle.
*/ */
void gb_bundle_destroy(struct gb_interface_block *gb_ib) void gb_bundle_destroy(struct gb_interface *intf)
{ {
struct gb_bundle *bundle; struct gb_bundle *bundle;
struct gb_bundle *temp; struct gb_bundle *temp;
if (WARN_ON(!gb_ib)) if (WARN_ON(!intf))
return; return;
spin_lock_irq(&gb_bundles_lock); spin_lock_irq(&gb_bundles_lock);
list_for_each_entry_safe(bundle, temp, &gb_ib->bundles, links) { list_for_each_entry_safe(bundle, temp, &intf->bundles, links) {
list_del(&bundle->links); list_del(&bundle->links);
gb_bundle_connections_exit(bundle); gb_bundle_connections_exit(bundle);
device_del(&bundle->dev); device_del(&bundle->dev);
...@@ -109,28 +109,27 @@ void gb_bundle_destroy(struct gb_interface_block *gb_ib) ...@@ -109,28 +109,27 @@ void gb_bundle_destroy(struct gb_interface_block *gb_ib)
spin_unlock_irq(&gb_bundles_lock); spin_unlock_irq(&gb_bundles_lock);
} }
int gb_bundle_init(struct gb_interface_block *gb_ib, u8 bundle_id, u8 device_id) int gb_bundle_init(struct gb_interface *intf, u8 bundle_id, u8 device_id)
{ {
struct gb_bundle *bundle; struct gb_bundle *bundle;
int ret; int ret;
bundle = gb_bundle_find(gb_ib, bundle_id); bundle = gb_bundle_find(intf, bundle_id);
if (!bundle) { if (!bundle) {
dev_err(gb_ib->hd->parent, "bundle %hhu not found\n", dev_err(intf->hd->parent, "bundle %hhu not found\n", bundle_id);
bundle_id);
return -ENOENT; return -ENOENT;
} }
bundle->device_id = device_id; bundle->device_id = device_id;
ret = svc_set_route_send(bundle, gb_ib->hd); ret = svc_set_route_send(bundle, intf->hd);
if (ret) { if (ret) {
dev_err(gb_ib->hd->parent, "failed to set route (%d)\n", ret); dev_err(intf->hd->parent, "failed to set route (%d)\n", ret);
return ret; return ret;
} }
ret = gb_bundle_connections_init(bundle); ret = gb_bundle_connections_init(bundle);
if (ret) { if (ret) {
dev_err(gb_ib->hd->parent, "interface bundle init error %d\n", dev_err(intf->hd->parent, "interface bundle init error %d\n",
ret); ret);
/* XXX clear route */ /* XXX clear route */
return ret; return ret;
...@@ -139,12 +138,12 @@ int gb_bundle_init(struct gb_interface_block *gb_ib, u8 bundle_id, u8 device_id) ...@@ -139,12 +138,12 @@ int gb_bundle_init(struct gb_interface_block *gb_ib, u8 bundle_id, u8 device_id)
return 0; return 0;
} }
struct gb_bundle *gb_bundle_find(struct gb_interface_block *gb_ib, u8 bundle_id) struct gb_bundle *gb_bundle_find(struct gb_interface *intf, u8 bundle_id)
{ {
struct gb_bundle *bundle; struct gb_bundle *bundle;
spin_lock_irq(&gb_bundles_lock); spin_lock_irq(&gb_bundles_lock);
list_for_each_entry(bundle, &gb_ib->bundles, links) list_for_each_entry(bundle, &intf->bundles, links)
if (bundle->id == bundle_id) { if (bundle->id == bundle_id) {
spin_unlock_irq(&gb_bundles_lock); spin_unlock_irq(&gb_bundles_lock);
return bundle; return bundle;
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
/* Greybus "public" definitions" */ /* Greybus "public" definitions" */
struct gb_bundle { struct gb_bundle {
struct device dev; struct device dev;
struct gb_interface_block *gb_ib; struct gb_interface *intf;
u8 id; u8 id;
u8 device_id; u8 device_id;
struct list_head connections; struct list_head connections;
...@@ -25,10 +25,10 @@ struct gb_bundle { ...@@ -25,10 +25,10 @@ struct gb_bundle {
#define to_gb_bundle(d) container_of(d, struct gb_bundle, dev) #define to_gb_bundle(d) container_of(d, struct gb_bundle, dev)
/* Greybus "private" definitions" */ /* Greybus "private" definitions" */
struct gb_bundle *gb_bundle_create(struct gb_interface_block *gb_ib, u8 module_id); struct gb_bundle *gb_bundle_create(struct gb_interface *intf, u8 module_id);
void gb_bundle_destroy(struct gb_interface_block *gb_ib); void gb_bundle_destroy(struct gb_interface *intf);
int gb_bundle_init(struct gb_interface_block *gb_ib, u8 module_id, u8 device_id); int gb_bundle_init(struct gb_interface *intf, u8 module_id, u8 device_id);
struct gb_bundle *gb_bundle_find(struct gb_interface_block *gb_ib, u8 bundle_id); struct gb_bundle *gb_bundle_find(struct gb_interface *intf, u8 bundle_id);
#endif /* __BUNDLE_H */ #endif /* __BUNDLE_H */
...@@ -156,7 +156,7 @@ struct gb_connection *gb_connection_create(struct gb_bundle *bundle, ...@@ -156,7 +156,7 @@ struct gb_connection *gb_connection_create(struct gb_bundle *bundle,
return NULL; return NULL;
} }
hd = bundle->gb_ib->hd; hd = bundle->intf->hd;
connection->hd = hd; connection->hd = hd;
if (!gb_connection_hd_cport_id_alloc(connection)) { if (!gb_connection_hd_cport_id_alloc(connection)) {
gb_protocol_put(connection->protocol); gb_protocol_put(connection->protocol);
...@@ -237,7 +237,7 @@ void gb_connection_err(struct gb_connection *connection, const char *fmt, ...) ...@@ -237,7 +237,7 @@ void gb_connection_err(struct gb_connection *connection, const char *fmt, ...)
vaf.va = &args; vaf.va = &args;
pr_err("greybus: [%hhu:%hhu:%hu]: %pV\n", pr_err("greybus: [%hhu:%hhu:%hu]: %pV\n",
connection->bundle->gb_ib->module_id, connection->bundle->intf->module_id,
connection->bundle->id, connection->bundle->id,
connection->bundle_cport_id, &vaf); connection->bundle_cport_id, &vaf);
......
...@@ -34,10 +34,10 @@ EXPORT_SYMBOL_GPL(greybus_disabled); ...@@ -34,10 +34,10 @@ EXPORT_SYMBOL_GPL(greybus_disabled);
static int greybus_module_match(struct device *dev, struct device_driver *drv) static int greybus_module_match(struct device *dev, struct device_driver *drv)
{ {
struct greybus_driver *driver = to_greybus_driver(drv); struct greybus_driver *driver = to_greybus_driver(drv);
struct gb_interface_block *gb_ib = to_gb_interface_block(dev); struct gb_interface *intf = to_gb_interface(dev);
const struct greybus_interface_block_id *id; const struct greybus_interface_block_id *id;
id = gb_ib_match_id(gb_ib, driver->id_table); id = gb_interface_match_id(intf, driver->id_table);
if (id) if (id)
return 1; return 1;
/* FIXME - Dynamic ids? */ /* FIXME - Dynamic ids? */
...@@ -46,19 +46,19 @@ static int greybus_module_match(struct device *dev, struct device_driver *drv) ...@@ -46,19 +46,19 @@ static int greybus_module_match(struct device *dev, struct device_driver *drv)
static int greybus_uevent(struct device *dev, struct kobj_uevent_env *env) static int greybus_uevent(struct device *dev, struct kobj_uevent_env *env)
{ {
struct gb_interface_block *gb_ib = NULL; struct gb_interface *intf = NULL;
struct gb_bundle *bundle = NULL; struct gb_bundle *bundle = NULL;
struct gb_connection *connection = NULL; struct gb_connection *connection = NULL;
if (is_gb_interface_block(dev)) { if (is_gb_interface(dev)) {
gb_ib = to_gb_interface_block(dev); intf = to_gb_interface(dev);
} else if (is_gb_bundle(dev)) { } else if (is_gb_bundle(dev)) {
bundle = to_gb_bundle(dev); bundle = to_gb_bundle(dev);
gb_ib = bundle->gb_ib; intf = bundle->intf;
} else if (is_gb_connection(dev)) { } else if (is_gb_connection(dev)) {
connection = to_gb_connection(dev); connection = to_gb_connection(dev);
bundle = connection->bundle; bundle = connection->bundle;
gb_ib = bundle->gb_ib; intf = bundle->intf;
} else { } else {
dev_WARN(dev, "uevent for unknown greybus device \"type\"!\n"); dev_WARN(dev, "uevent for unknown greybus device \"type\"!\n");
return -EINVAL; return -EINVAL;
...@@ -94,16 +94,16 @@ struct bus_type greybus_bus_type = { ...@@ -94,16 +94,16 @@ struct bus_type greybus_bus_type = {
static int greybus_probe(struct device *dev) static int greybus_probe(struct device *dev)
{ {
struct greybus_driver *driver = to_greybus_driver(dev->driver); struct greybus_driver *driver = to_greybus_driver(dev->driver);
struct gb_interface_block *gb_ib = to_gb_interface_block(dev); struct gb_interface *intf = to_gb_interface(dev);
const struct greybus_interface_block_id *id; const struct greybus_interface_block_id *id;
int retval; int retval;
/* match id */ /* match id */
id = gb_ib_match_id(gb_ib, driver->id_table); id = gb_interface_match_id(intf, driver->id_table);
if (!id) if (!id)
return -ENODEV; return -ENODEV;
retval = driver->probe(gb_ib, id); retval = driver->probe(intf, id);
if (retval) if (retval)
return retval; return retval;
...@@ -113,9 +113,9 @@ static int greybus_probe(struct device *dev) ...@@ -113,9 +113,9 @@ static int greybus_probe(struct device *dev)
static int greybus_remove(struct device *dev) static int greybus_remove(struct device *dev)
{ {
struct greybus_driver *driver = to_greybus_driver(dev->driver); struct greybus_driver *driver = to_greybus_driver(dev->driver);
struct gb_interface_block *gb_ib = to_gb_interface_block(dev); struct gb_interface *intf = to_gb_interface(dev);
driver->disconnect(gb_ib); driver->disconnect(intf);
return 0; return 0;
} }
......
...@@ -119,12 +119,12 @@ void greybus_remove_hd(struct greybus_host_device *hd); ...@@ -119,12 +119,12 @@ void greybus_remove_hd(struct greybus_host_device *hd);
struct greybus_driver { struct greybus_driver {
const char *name; const char *name;
int (*probe)(struct gb_interface_block *gb_ib, int (*probe)(struct gb_interface *intf,
const struct greybus_interface_block_id *id); const struct greybus_interface_block_id *id);
void (*disconnect)(struct gb_interface_block *gb_ib); void (*disconnect)(struct gb_interface *intf);
int (*suspend)(struct gb_interface_block *gb_ib, pm_message_t message); int (*suspend)(struct gb_interface *intf, pm_message_t message);
int (*resume)(struct gb_interface_block *gb_ib); int (*resume)(struct gb_interface *intf);
const struct greybus_interface_block_id *id_table; const struct greybus_interface_block_id *id_table;
...@@ -175,13 +175,13 @@ void gb_uart_device_exit(struct gb_connection *connection); ...@@ -175,13 +175,13 @@ void gb_uart_device_exit(struct gb_connection *connection);
int svc_set_route_send(struct gb_bundle *bundle, int svc_set_route_send(struct gb_bundle *bundle,
struct greybus_host_device *hd); 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_bundle_type;
extern struct device_type greybus_connection_type; extern struct device_type greybus_connection_type;
static inline int is_gb_interface_block(const struct device *dev) static inline int is_gb_interface(const struct device *dev)
{ {
return dev->type == &greybus_interface_block_type; return dev->type == &greybus_interface_type;
} }
static inline int is_gb_bundle(const struct device *dev) static inline int is_gb_bundle(const struct device *dev)
......
/* /*
* Greybus interface block code * Greybus interface code
* *
* Copyright 2014 Google Inc. * Copyright 2014 Google Inc.
* Copyright 2014 Linaro Ltd. * Copyright 2014 Linaro Ltd.
...@@ -9,24 +9,24 @@ ...@@ -9,24 +9,24 @@
#include "greybus.h" #include "greybus.h"
/* interface block sysfs attributes */ /* interface sysfs attributes */
#define gb_ib_attr(field, type) \ #define gb_interface_attr(field, type) \
static ssize_t field##_show(struct device *dev, \ static ssize_t field##_show(struct device *dev, \
struct device_attribute *attr, \ struct device_attribute *attr, \
char *buf) \ char *buf) \
{ \ { \
struct gb_interface_block *gb_ib = to_gb_interface_block(dev); \ struct gb_interface *intf = to_gb_interface(dev); \
return sprintf(buf, "%"#type"\n", gb_ib->field); \ return sprintf(buf, "%"#type"\n", intf->field); \
} \ } \
static DEVICE_ATTR_RO(field) static DEVICE_ATTR_RO(field)
gb_ib_attr(vendor, x); gb_interface_attr(vendor, x);
gb_ib_attr(product, x); gb_interface_attr(product, x);
gb_ib_attr(unique_id, llX); gb_interface_attr(unique_id, llX);
gb_ib_attr(vendor_string, s); gb_interface_attr(vendor_string, s);
gb_ib_attr(product_string, s); gb_interface_attr(product_string, s);
static struct attribute *interface_block_attrs[] = { static struct attribute *interface_attrs[] = {
&dev_attr_vendor.attr, &dev_attr_vendor.attr,
&dev_attr_product.attr, &dev_attr_product.attr,
&dev_attr_unique_id.attr, &dev_attr_unique_id.attr,
...@@ -34,143 +34,144 @@ static struct attribute *interface_block_attrs[] = { ...@@ -34,143 +34,144 @@ static struct attribute *interface_block_attrs[] = {
&dev_attr_product_string.attr, &dev_attr_product_string.attr,
NULL, NULL,
}; };
ATTRIBUTE_GROUPS(interface_block); ATTRIBUTE_GROUPS(interface);
/* XXX This could be per-host device */ /* XXX This could be per-host device */
static DEFINE_SPINLOCK(gb_modules_lock); static DEFINE_SPINLOCK(gb_modules_lock);
static int gb_ib_match_one_id(struct gb_interface_block *gb_ib, static int gb_interface_match_one_id(struct gb_interface *intf,
const struct greybus_interface_block_id *id) const struct greybus_interface_block_id *id)
{ {
if ((id->match_flags & GREYBUS_ID_MATCH_VENDOR) && if ((id->match_flags & GREYBUS_ID_MATCH_VENDOR) &&
(id->vendor != gb_ib->vendor)) (id->vendor != intf->vendor))
return 0; return 0;
if ((id->match_flags & GREYBUS_ID_MATCH_PRODUCT) && if ((id->match_flags & GREYBUS_ID_MATCH_PRODUCT) &&
(id->product != gb_ib->product)) (id->product != intf->product))
return 0; return 0;
if ((id->match_flags & GREYBUS_ID_MATCH_SERIAL) && if ((id->match_flags & GREYBUS_ID_MATCH_SERIAL) &&
(id->unique_id != gb_ib->unique_id)) (id->unique_id != intf->unique_id))
return 0; return 0;
return 1; return 1;
} }
const struct greybus_interface_block_id * const struct greybus_interface_block_id *
gb_ib_match_id(struct gb_interface_block *gb_ib, gb_interface_match_id(struct gb_interface *intf,
const struct greybus_interface_block_id *id) const struct greybus_interface_block_id *id)
{ {
if (id == NULL) if (id == NULL)
return NULL; return NULL;
for (; id->vendor || id->product || id->unique_id || for (; id->vendor || id->product || id->unique_id ||
id->driver_info; id++) { id->driver_info; id++) {
if (gb_ib_match_one_id(gb_ib, id)) if (gb_interface_match_one_id(intf, id))
return id; return id;
} }
return NULL; return NULL;
} }
struct gb_interface_block *gb_ib_find(struct greybus_host_device *hd, u8 module_id) struct gb_interface *gb_interface_find(struct greybus_host_device *hd,
u8 module_id)
{ {
struct gb_interface_block *gb_ib; struct gb_interface *intf;
list_for_each_entry(gb_ib, &hd->modules, links) list_for_each_entry(intf, &hd->modules, links)
if (gb_ib->module_id == module_id) if (intf->module_id == module_id)
return gb_ib; return intf;
return NULL; return NULL;
} }
static void greybus_ib_release(struct device *dev) static void greybus_interface_release(struct device *dev)
{ {
struct gb_interface_block *gb_ib = to_gb_interface_block(dev); struct gb_interface *intf = to_gb_interface(dev);
kfree(gb_ib); kfree(intf);
} }
struct device_type greybus_interface_block_type = { struct device_type greybus_interface_type = {
.name = "greybus_interface_block", .name = "greybus_interface",
.release = greybus_ib_release, .release = greybus_interface_release,
}; };
/* /*
* A Greybus module represents a user-replicable component on an Ara * A Greybus module represents a user-replicable component on an Ara
* phone. An interface block is the physical connection on that module. A * phone. An interface is the physical connection on that module. A
* module may have more than one interface block. * module may have more than one interface.
* *
* Create a gb_interface_block structure to represent a discovered module. * Create a gb_interface structure to represent a discovered module.
* The position within the Endo is encoded in the "module_id" argument. * The position within the Endo is encoded in the "module_id" argument.
* Returns a pointer to the new module or a null pointer if a * Returns a pointer to the new module or a null pointer if a
* failure occurs due to memory exhaustion. * failure occurs due to memory exhaustion.
*/ */
static struct gb_interface_block *gb_ib_create(struct greybus_host_device *hd, static struct gb_interface *gb_interface_create(struct greybus_host_device *hd,
u8 module_id) u8 module_id)
{ {
struct gb_interface_block *gb_ib; struct gb_interface *intf;
int retval; int retval;
gb_ib = gb_ib_find(hd, module_id); intf = gb_interface_find(hd, module_id);
if (gb_ib) { if (intf) {
dev_err(hd->parent, "Duplicate module id %d will not be created\n", dev_err(hd->parent, "Duplicate module id %d will not be created\n",
module_id); module_id);
return NULL; return NULL;
} }
gb_ib = kzalloc(sizeof(*gb_ib), GFP_KERNEL); intf = kzalloc(sizeof(*intf), GFP_KERNEL);
if (!gb_ib) if (!intf)
return NULL; return NULL;
gb_ib->hd = hd; /* XXX refcount? */ intf->hd = hd; /* XXX refcount? */
gb_ib->module_id = module_id; intf->module_id = module_id;
INIT_LIST_HEAD(&gb_ib->bundles); INIT_LIST_HEAD(&intf->bundles);
gb_ib->dev.parent = hd->parent; intf->dev.parent = hd->parent;
gb_ib->dev.bus = &greybus_bus_type; intf->dev.bus = &greybus_bus_type;
gb_ib->dev.type = &greybus_interface_block_type; intf->dev.type = &greybus_interface_type;
gb_ib->dev.groups = interface_block_groups; intf->dev.groups = interface_groups;
gb_ib->dev.dma_mask = hd->parent->dma_mask; intf->dev.dma_mask = hd->parent->dma_mask;
device_initialize(&gb_ib->dev); device_initialize(&intf->dev);
dev_set_name(&gb_ib->dev, "%d", module_id); dev_set_name(&intf->dev, "%d", module_id);
retval = device_add(&gb_ib->dev); retval = device_add(&intf->dev);
if (retval) { if (retval) {
pr_err("failed to add module device for id 0x%02hhx\n", pr_err("failed to add module device for id 0x%02hhx\n",
module_id); module_id);
put_device(&gb_ib->dev); put_device(&intf->dev);
kfree(gb_ib); kfree(intf);
return NULL; return NULL;
} }
spin_lock_irq(&gb_modules_lock); spin_lock_irq(&gb_modules_lock);
list_add_tail(&gb_ib->links, &hd->modules); list_add_tail(&intf->links, &hd->modules);
spin_unlock_irq(&gb_modules_lock); spin_unlock_irq(&gb_modules_lock);
return gb_ib; return intf;
} }
/* /*
* Tear down a previously set up module. * Tear down a previously set up module.
*/ */
static void gb_ib_destroy(struct gb_interface_block *gb_ib) static void gb_interface_destroy(struct gb_interface *intf)
{ {
if (WARN_ON(!gb_ib)) if (WARN_ON(!intf))
return; return;
spin_lock_irq(&gb_modules_lock); spin_lock_irq(&gb_modules_lock);
list_del(&gb_ib->links); list_del(&intf->links);
spin_unlock_irq(&gb_modules_lock); spin_unlock_irq(&gb_modules_lock);
gb_bundle_destroy(gb_ib); gb_bundle_destroy(intf);
kfree(gb_ib->product_string); kfree(intf->product_string);
kfree(gb_ib->vendor_string); kfree(intf->vendor_string);
/* kref_put(module->hd); */ /* kref_put(module->hd); */
device_del(&gb_ib->dev); device_del(&intf->dev);
} }
/** /**
...@@ -182,11 +183,11 @@ static void gb_ib_destroy(struct gb_interface_block *gb_ib) ...@@ -182,11 +183,11 @@ static void gb_ib_destroy(struct gb_interface_block *gb_ib)
void gb_add_module(struct greybus_host_device *hd, u8 module_id, void gb_add_module(struct greybus_host_device *hd, u8 module_id,
u8 *data, int size) u8 *data, int size)
{ {
struct gb_interface_block *gb_ib; struct gb_interface *intf;
gb_ib = gb_ib_create(hd, module_id); intf = gb_interface_create(hd, module_id);
if (!gb_ib) { if (!intf) {
dev_err(hd->parent, "failed to create interface block\n"); dev_err(hd->parent, "failed to create interface\n");
return; return;
} }
...@@ -194,7 +195,7 @@ void gb_add_module(struct greybus_host_device *hd, u8 module_id, ...@@ -194,7 +195,7 @@ void gb_add_module(struct greybus_host_device *hd, u8 module_id,
* Parse the manifest and build up our data structures * Parse the manifest and build up our data structures
* representing what's in it. * representing what's in it.
*/ */
if (!gb_manifest_parse(gb_ib, data, size)) { if (!gb_manifest_parse(intf, data, size)) {
dev_err(hd->parent, "manifest error\n"); dev_err(hd->parent, "manifest error\n");
goto err_module; goto err_module;
} }
...@@ -211,23 +212,23 @@ void gb_add_module(struct greybus_host_device *hd, u8 module_id, ...@@ -211,23 +212,23 @@ void gb_add_module(struct greybus_host_device *hd, u8 module_id,
return; return;
err_module: err_module:
gb_ib_destroy(gb_ib); gb_interface_destroy(intf);
} }
void gb_remove_module(struct greybus_host_device *hd, u8 module_id) void gb_remove_module(struct greybus_host_device *hd, u8 module_id)
{ {
struct gb_interface_block *gb_ib = gb_ib_find(hd, module_id); struct gb_interface *intf = gb_interface_find(hd, module_id);
if (gb_ib) if (intf)
gb_ib_destroy(gb_ib); gb_interface_destroy(intf);
else else
dev_err(hd->parent, "interface block id %d not found\n", module_id); dev_err(hd->parent, "interface id %d not found\n", module_id);
} }
void gb_remove_modules(struct greybus_host_device *hd) void gb_remove_modules(struct greybus_host_device *hd)
{ {
struct gb_interface_block *gb_ib, *temp; struct gb_interface *intf, *temp;
list_for_each_entry_safe(gb_ib, temp, &hd->modules, links) list_for_each_entry_safe(intf, temp, &hd->modules, links)
gb_ib_destroy(gb_ib); gb_interface_destroy(intf);
} }
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
/* Greybus "public" definitions" */ /* Greybus "public" definitions" */
struct gb_interface_block { struct gb_interface {
struct device dev; struct device dev;
struct list_head bundles; struct list_head bundles;
...@@ -32,27 +32,26 @@ struct gb_interface_block { ...@@ -32,27 +32,26 @@ struct gb_interface_block {
struct greybus_host_device *hd; struct greybus_host_device *hd;
}; };
#define to_gb_interface_block(d) container_of(d, struct gb_interface_block, dev) #define to_gb_interface(d) container_of(d, struct gb_interface, dev)
static inline void static inline void gb_interface_set_drvdata(struct gb_interface *intf,
gb_interface_block_set_drvdata(struct gb_interface_block *gb_ib, void *data) void *data)
{ {
dev_set_drvdata(&gb_ib->dev, data); dev_set_drvdata(&intf->dev, data);
} }
static inline void * static inline void * gb_interface__get_drvdata(struct gb_interface *intf)
gb_interface_block_get_drvdata(struct gb_interface_block *gb_ib)
{ {
return dev_get_drvdata(&gb_ib->dev); return dev_get_drvdata(&intf->dev);
} }
/* Greybus "private" definitions */ /* Greybus "private" definitions */
const struct greybus_interface_block_id * const struct greybus_interface_block_id *
gb_ib_match_id(struct gb_interface_block *gb_ib, gb_interface_match_id(struct gb_interface *intf,
const struct greybus_interface_block_id *id); const struct greybus_interface_block_id *id);
struct gb_interface_block *gb_ib_find(struct greybus_host_device *hd, struct gb_interface *gb_interface_find(struct greybus_host_device *hd,
u8 module_id); u8 module_id);
#endif /* __INTERFACE_H */ #endif /* __INTERFACE_H */
...@@ -218,7 +218,7 @@ static u32 gb_manifest_parse_cports(struct gb_bundle *bundle) ...@@ -218,7 +218,7 @@ static u32 gb_manifest_parse_cports(struct gb_bundle *bundle)
* structures. Returns the number of bundles set up for the * structures. Returns the number of bundles set up for the
* given module. * given module.
*/ */
static u32 gb_manifest_parse_bundles(struct gb_interface_block *gb_ib) static u32 gb_manifest_parse_bundles(struct gb_interface *intf)
{ {
u32 count = 0; u32 count = 0;
...@@ -240,7 +240,7 @@ static u32 gb_manifest_parse_bundles(struct gb_interface_block *gb_ib) ...@@ -240,7 +240,7 @@ static u32 gb_manifest_parse_bundles(struct gb_interface_block *gb_ib)
/* Found one. Set up its bundle structure*/ /* Found one. Set up its bundle structure*/
desc_interface = descriptor->data; desc_interface = descriptor->data;
bundle = gb_bundle_create(gb_ib, desc_interface->id); bundle = gb_bundle_create(intf, desc_interface->id);
if (!bundle) if (!bundle)
return 0; /* Error */ return 0; /* Error */
...@@ -257,41 +257,41 @@ static u32 gb_manifest_parse_bundles(struct gb_interface_block *gb_ib) ...@@ -257,41 +257,41 @@ static u32 gb_manifest_parse_bundles(struct gb_interface_block *gb_ib)
return count; return count;
} }
static bool gb_manifest_parse_module(struct gb_interface_block *gb_ib, static bool gb_manifest_parse_module(struct gb_interface *intf,
struct manifest_desc *module_desc) struct manifest_desc *module_desc)
{ {
struct greybus_descriptor_module *desc_module = module_desc->data; struct greybus_descriptor_module *desc_module = module_desc->data;
/* Handle the strings first--they can fail */ /* Handle the strings first--they can fail */
gb_ib->vendor_string = gb_string_get(desc_module->vendor_stringid); intf->vendor_string = gb_string_get(desc_module->vendor_stringid);
if (IS_ERR(gb_ib->vendor_string)) if (IS_ERR(intf->vendor_string))
return false; return false;
gb_ib->product_string = gb_string_get(desc_module->product_stringid); intf->product_string = gb_string_get(desc_module->product_stringid);
if (IS_ERR(gb_ib->product_string)) { if (IS_ERR(intf->product_string)) {
goto out_free_vendor_string; goto out_free_vendor_string;
} }
gb_ib->vendor = le16_to_cpu(desc_module->vendor); intf->vendor = le16_to_cpu(desc_module->vendor);
gb_ib->product = le16_to_cpu(desc_module->product); intf->product = le16_to_cpu(desc_module->product);
gb_ib->unique_id = le64_to_cpu(desc_module->unique_id); intf->unique_id = le64_to_cpu(desc_module->unique_id);
/* Release the module descriptor, now that we're done with it */ /* Release the module descriptor, now that we're done with it */
release_manifest_descriptor(module_desc); release_manifest_descriptor(module_desc);
/* An interface must have at least one bundle descriptor */ /* An interface must have at least one bundle descriptor */
if (!gb_manifest_parse_bundles(gb_ib)) { if (!gb_manifest_parse_bundles(intf)) {
pr_err("manifest bundle descriptors not valid\n"); pr_err("manifest bundle descriptors not valid\n");
goto out_err; goto out_err;
} }
return true; return true;
out_err: out_err:
kfree(gb_ib->product_string); kfree(intf->product_string);
gb_ib->product_string = NULL; intf->product_string = NULL;
out_free_vendor_string: out_free_vendor_string:
kfree(gb_ib->vendor_string); kfree(intf->vendor_string);
gb_ib->vendor_string = NULL; intf->vendor_string = NULL;
return false; return false;
} }
...@@ -314,12 +314,12 @@ static bool gb_manifest_parse_module(struct gb_interface_block *gb_ib, ...@@ -314,12 +314,12 @@ static bool gb_manifest_parse_module(struct gb_interface_block *gb_ib,
* information it contains, and then remove that descriptor (and any * information it contains, and then remove that descriptor (and any
* string descriptors it refers to) from further consideration. * string descriptors it refers to) from further consideration.
* *
* After that we look for the interface block's bundles--there must be at * After that we look for the interface's bundles--there must be at
* least one of those. * least one of those.
* *
* Returns true if parsing was successful, false otherwise. * Returns true if parsing was successful, false otherwise.
*/ */
bool gb_manifest_parse(struct gb_interface_block *gb_ib, void *data, size_t size) bool gb_manifest_parse(struct gb_interface *intf, void *data, size_t size)
{ {
struct greybus_manifest *manifest; struct greybus_manifest *manifest;
struct greybus_manifest_header *header; struct greybus_manifest_header *header;
...@@ -389,7 +389,7 @@ bool gb_manifest_parse(struct gb_interface_block *gb_ib, void *data, size_t size ...@@ -389,7 +389,7 @@ bool gb_manifest_parse(struct gb_interface_block *gb_ib, void *data, size_t size
} }
/* Parse the module manifest, starting with the module descriptor */ /* Parse the module manifest, starting with the module descriptor */
result = gb_manifest_parse_module(gb_ib, module_desc); result = gb_manifest_parse_module(intf, module_desc);
/* /*
* We really should have no remaining descriptors, but we * We really should have no remaining descriptors, but we
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
#ifndef __MANIFEST_H #ifndef __MANIFEST_H
#define __MANIFEST_H #define __MANIFEST_H
struct gb_interface_block; struct gb_interface;
bool gb_manifest_parse(struct gb_interface_block *gb_ib, void *data, size_t size); bool gb_manifest_parse(struct gb_interface *intf, void *data, size_t size);
#endif /* __MANIFEST_H */ #endif /* __MANIFEST_H */
...@@ -83,9 +83,8 @@ enum svc_function_hotplug_event { ...@@ -83,9 +83,8 @@ enum svc_function_hotplug_event {
}; };
/* XXX /* XXX
* Does a hotplug come from module insertion, or from detection * Does a hotplug come from module insertion, or from detection of each
* of each interface block (UniPro device) in a module? Assume * interface (UniPro device) in a module? Assume the former for now.
* the former for now.
*/ */
struct svc_function_hotplug { struct svc_function_hotplug {
__u8 hotplug_event; /* enum svc_function_hotplug_event */ __u8 hotplug_event; /* enum svc_function_hotplug_event */
...@@ -116,7 +115,7 @@ struct svc_function_power_battery_status_request { ...@@ -116,7 +115,7 @@ struct svc_function_power_battery_status_request {
}; };
/* XXX /* XXX
* Each interface block carries power, so it's possible these things * Each interface carries power, so it's possible these things
* are associated with each UniPro device and not just the module. * are associated with each UniPro device and not just the module.
* For now it's safe to assume it's per-module. * For now it's safe to assume it's per-module.
*/ */
...@@ -145,7 +144,7 @@ enum svc_function_suspend_command_type { ...@@ -145,7 +144,7 @@ enum svc_function_suspend_command_type {
SVC_SUSPEND_FIXME_2 = 0x01, SVC_SUSPEND_FIXME_2 = 0x01,
}; };
/* We'll want independent control for multi-interface block modules */ /* We'll want independent control for multi-interface modules */
struct svc_function_suspend { struct svc_function_suspend {
__u8 suspend_command_type; /* enum function_suspend_command_type */ __u8 suspend_command_type; /* enum function_suspend_command_type */
__u8 device_id; __u8 device_id;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment