From 778c69c9e2fbb7462e5ebffe42845c9cdf75b1e2 Mon Sep 17 00:00:00 2001 From: Alex Elder Date: Mon, 22 Sep 2014 19:19:03 -0500 Subject: [PATCH] greybus: rename struct greybus_device The greybus_device structure represents an Ara phone module. It does *not* (necessarily) represent a UniPro device, nor any device (like an i2c adapter) that might reside on an Ara module. As such, rename struct greybus_device to be struct greybus_module. Rename all symbols having that type to be "gmod" rather than "gdev". Signed-off-by: Alex Elder Signed-off-by: Greg Kroah-Hartman --- drivers/staging/greybus/battery-gb.c | 12 +-- drivers/staging/greybus/core.c | 196 +++++++++++++++++------------------ drivers/staging/greybus/es1-ap-usb.c | 2 +- drivers/staging/greybus/gbuf.c | 30 +++--- drivers/staging/greybus/gpio-gb.c | 14 +-- drivers/staging/greybus/greybus.h | 64 ++++++------ drivers/staging/greybus/greybus_id.h | 2 +- drivers/staging/greybus/i2c-gb.c | 22 ++-- drivers/staging/greybus/sdio-gb.c | 10 +- drivers/staging/greybus/sysfs.c | 44 ++++---- drivers/staging/greybus/test_sink.c | 4 +- drivers/staging/greybus/uart-gb.c | 20 ++-- 12 files changed, 210 insertions(+), 210 deletions(-) diff --git a/drivers/staging/greybus/battery-gb.c b/drivers/staging/greybus/battery-gb.c index 7d124331..5f1bf00 100644 --- a/drivers/staging/greybus/battery-gb.c +++ b/drivers/staging/greybus/battery-gb.c @@ -18,7 +18,7 @@ struct gb_battery { // we will want to keep the battery stats in here as we will be getting // updates from the SVC "on the fly" so we don't have to always go ask // the battery for some information. Hopefully... - struct greybus_device *gdev; + struct greybus_module *gmod; }; #define to_gb_battery(x) container_of(x, struct gb_battery, bat) @@ -100,7 +100,7 @@ static enum power_supply_property battery_props[] = { POWER_SUPPLY_PROP_VOLTAGE_NOW, }; -int gb_battery_probe(struct greybus_device *gdev, +int gb_battery_probe(struct greybus_module *gmod, const struct greybus_module_id *id) { struct gb_battery *gb; @@ -120,21 +120,21 @@ int gb_battery_probe(struct greybus_device *gdev, b->num_properties = ARRAY_SIZE(battery_props), b->get_property = get_property, - retval = power_supply_register(&gdev->dev, b); + retval = power_supply_register(&gmod->dev, b); if (retval) { kfree(gb); return retval; } - gdev->gb_battery = gb; + gmod->gb_battery = gb; return 0; } -void gb_battery_disconnect(struct greybus_device *gdev) +void gb_battery_disconnect(struct greybus_module *gmod) { struct gb_battery *gb; - gb = gdev->gb_battery; + gb = gmod->gb_battery; power_supply_unregister(&gb->bat); diff --git a/drivers/staging/greybus/core.c b/drivers/staging/greybus/core.c index e4a78b4..296ff61 100644 --- a/drivers/staging/greybus/core.c +++ b/drivers/staging/greybus/core.c @@ -30,14 +30,14 @@ int greybus_disabled(void) } EXPORT_SYMBOL_GPL(greybus_disabled); -static int greybus_match_one_id(struct greybus_device *gdev, +static int greybus_match_one_id(struct greybus_module *gmod, const struct greybus_module_id *id) { struct greybus_descriptor_module_id *module_id; struct greybus_descriptor_serial_number *serial_num; - module_id = &gdev->module_id; - serial_num = &gdev->serial_number; + module_id = &gmod->module_id; + serial_num = &gmod->serial_number; if ((id->match_flags & GREYBUS_DEVICE_ID_MATCH_VENDOR) && (id->vendor != le16_to_cpu(module_id->vendor))) @@ -55,7 +55,7 @@ static int greybus_match_one_id(struct greybus_device *gdev, } static const struct greybus_module_id *greybus_match_id( - struct greybus_device *gdev, + struct greybus_module *gmod, const struct greybus_module_id *id) { if (id == NULL) @@ -63,20 +63,20 @@ static const struct greybus_module_id *greybus_match_id( for (; id->vendor || id->product || id->serial_number || id->driver_info ; id++) { - if (greybus_match_one_id(gdev, id)) + if (greybus_match_one_id(gmod, id)) return id; } return NULL; } -static int greybus_device_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(dev->driver); - struct greybus_device *gdev = to_greybus_device(dev); + struct greybus_module *gmod = to_greybus_module(dev); const struct greybus_module_id *id; - id = greybus_match_id(gdev, driver->id_table); + id = greybus_match_id(gmod, driver->id_table); if (id) return 1; /* FIXME - Dyanmic ids? */ @@ -85,7 +85,7 @@ static int greybus_device_match(struct device *dev, struct device_driver *drv) static int greybus_uevent(struct device *dev, struct kobj_uevent_env *env) { - /* struct greybus_device *gdev = to_greybus_device(dev); */ + /* struct greybus_module *gmod = to_greybus_module(dev); */ /* FIXME - add some uevents here... */ return 0; @@ -93,23 +93,23 @@ static int greybus_uevent(struct device *dev, struct kobj_uevent_env *env) static struct bus_type greybus_bus_type = { .name = "greybus", - .match = greybus_device_match, + .match = greybus_module_match, .uevent = greybus_uevent, }; static int greybus_probe(struct device *dev) { struct greybus_driver *driver = to_greybus_driver(dev->driver); - struct greybus_device *gdev = to_greybus_device(dev); + struct greybus_module *gmod = to_greybus_module(dev); const struct greybus_module_id *id; int retval; /* match id */ - id = greybus_match_id(gdev, driver->id_table); + id = greybus_match_id(gmod, driver->id_table); if (!id) return -ENODEV; - retval = driver->probe(gdev, id); + retval = driver->probe(gmod, id); if (retval) return retval; @@ -119,9 +119,9 @@ static int greybus_probe(struct device *dev) static int greybus_remove(struct device *dev) { struct greybus_driver *driver = to_greybus_driver(dev->driver); - struct greybus_device *gdev = to_greybus_device(dev); + struct greybus_module *gmod = to_greybus_module(dev); - driver->disconnect(gdev); + driver->disconnect(gmod); return 0; } @@ -157,27 +157,27 @@ EXPORT_SYMBOL_GPL(greybus_deregister); static void greybus_module_release(struct device *dev) { - struct greybus_device *gdev = to_greybus_device(dev); + struct greybus_module *gmod = to_greybus_module(dev); int i; - for (i = 0; i < gdev->num_strings; ++i) - kfree(gdev->string[i]); - for (i = 0; i < gdev->num_cports; ++i) - kfree(gdev->cport[i]); - kfree(gdev); + for (i = 0; i < gmod->num_strings; ++i) + kfree(gmod->string[i]); + for (i = 0; i < gmod->num_cports; ++i) + kfree(gmod->cport[i]); + kfree(gmod); } -const u8 *greybus_string(struct greybus_device *gdev, int id) +const u8 *greybus_string(struct greybus_module *gmod, int id) { int i; - struct gdev_string *string; + struct gmod_string *string; - if (!gdev) + if (!gmod) return NULL; - for (i = 0; i < gdev->num_strings; ++i) { - string = gdev->string[i]; + for (i = 0; i < gmod->num_strings; ++i) { + string = gmod->string[i]; if (string->id == id) return &string->string[0]; } @@ -189,44 +189,44 @@ static struct device_type greybus_module_type = { .release = greybus_module_release, }; -static int gb_init_subdevs(struct greybus_device *gdev, +static int gb_init_subdevs(struct greybus_module *gmod, const struct greybus_module_id *id) { int retval; /* Allocate all of the different "sub device types" for this device */ - retval = gb_i2c_probe(gdev, id); + retval = gb_i2c_probe(gmod, id); if (retval) goto error_i2c; - retval = gb_gpio_probe(gdev, id); + retval = gb_gpio_probe(gmod, id); if (retval) goto error_gpio; - retval = gb_sdio_probe(gdev, id); + retval = gb_sdio_probe(gmod, id); if (retval) goto error_sdio; - retval = gb_tty_probe(gdev, id); + retval = gb_tty_probe(gmod, id); if (retval) goto error_tty; - retval = gb_battery_probe(gdev, id); + retval = gb_battery_probe(gmod, id); if (retval) goto error_battery; return 0; error_battery: - gb_tty_disconnect(gdev); + gb_tty_disconnect(gmod); error_tty: - gb_sdio_disconnect(gdev); + gb_sdio_disconnect(gmod); error_sdio: - gb_gpio_disconnect(gdev); + gb_gpio_disconnect(gmod); error_gpio: - gb_i2c_disconnect(gdev); + gb_i2c_disconnect(gmod); error_i2c: return retval; @@ -236,106 +236,106 @@ static const struct greybus_module_id fake_gb_id = { GREYBUS_DEVICE(0x42, 0x42) }; -static int create_function(struct greybus_device *gdev, +static int create_function(struct greybus_module *gmod, struct greybus_descriptor_function *function, size_t desc_size) { if (desc_size != sizeof(*function)) { - dev_err(gdev->dev.parent, "invalid function header size %zu\n", + dev_err(gmod->dev.parent, "invalid function header size %zu\n", desc_size); return -EINVAL; } - memcpy(&gdev->function, function, desc_size); + memcpy(&gmod->function, function, desc_size); return 0; } -static int create_module_id(struct greybus_device *gdev, +static int create_module_id(struct greybus_module *gmod, struct greybus_descriptor_module_id *module_id, size_t desc_size) { if (desc_size != sizeof(*module_id)) { - dev_err(gdev->dev.parent, "invalid module header size %zu\n", + dev_err(gmod->dev.parent, "invalid module header size %zu\n", desc_size); return -EINVAL; } - memcpy(&gdev->module_id, module_id, desc_size); + memcpy(&gmod->module_id, module_id, desc_size); return 0; } -static int create_serial_number(struct greybus_device *gdev, +static int create_serial_number(struct greybus_module *gmod, struct greybus_descriptor_serial_number *serial_num, size_t desc_size) { if (desc_size != sizeof(*serial_num)) { - dev_err(gdev->dev.parent, "invalid serial number header size %zu\n", + dev_err(gmod->dev.parent, "invalid serial number header size %zu\n", desc_size); return -EINVAL; } - memcpy(&gdev->serial_number, serial_num, desc_size); + memcpy(&gmod->serial_number, serial_num, desc_size); return 0; } -static int create_string(struct greybus_device *gdev, +static int create_string(struct greybus_module *gmod, struct greybus_descriptor_string *string, size_t desc_size) { int string_size; - struct gdev_string *gdev_string; + struct gmod_string *gmod_string; - if ((gdev->num_strings + 1) >= MAX_STRINGS_PER_MODULE) { - dev_err(gdev->dev.parent, + if ((gmod->num_strings + 1) >= MAX_STRINGS_PER_MODULE) { + dev_err(gmod->dev.parent, "too many strings for this module!\n"); return -EINVAL; } if (desc_size < sizeof(*string)) { - dev_err(gdev->dev.parent, "invalid string header size %zu\n", + dev_err(gmod->dev.parent, "invalid string header size %zu\n", desc_size); return -EINVAL; } string_size = le16_to_cpu(string->length); - gdev_string = kzalloc(sizeof(*gdev_string) + string_size + 1, GFP_KERNEL); - if (!gdev_string) + gmod_string = kzalloc(sizeof(*gmod_string) + string_size + 1, GFP_KERNEL); + if (!gmod_string) return -ENOMEM; - gdev_string->length = string_size; - gdev_string->id = string->id; - memcpy(&gdev_string->string, &string->string, string_size); + gmod_string->length = string_size; + gmod_string->id = string->id; + memcpy(&gmod_string->string, &string->string, string_size); - gdev->string[gdev->num_strings] = gdev_string; - gdev->num_strings++; + gmod->string[gmod->num_strings] = gmod_string; + gmod->num_strings++; return 0; } -static int create_cport(struct greybus_device *gdev, +static int create_cport(struct greybus_module *gmod, struct greybus_descriptor_cport *cport, size_t desc_size) { - struct gdev_cport *gdev_cport; + struct gmod_cport *gmod_cport; - if ((gdev->num_cports + 1) >= MAX_CPORTS_PER_MODULE) { - dev_err(gdev->dev.parent, "too many cports for this module!\n"); + if ((gmod->num_cports + 1) >= MAX_CPORTS_PER_MODULE) { + dev_err(gmod->dev.parent, "too many cports for this module!\n"); return -EINVAL; } if (desc_size != sizeof(*cport)) { - dev_err(gdev->dev.parent, + dev_err(gmod->dev.parent, "invalid serial number header size %zu\n", desc_size); return -EINVAL; } - gdev_cport = kzalloc(sizeof(*gdev_cport), GFP_KERNEL); - if (!gdev_cport) + gmod_cport = kzalloc(sizeof(*gmod_cport), GFP_KERNEL); + if (!gmod_cport) return -ENOMEM; - gdev_cport->number = le16_to_cpu(cport->number); - gdev_cport->size = le16_to_cpu(cport->size); - gdev_cport->speed = cport->speed; + gmod_cport->number = le16_to_cpu(cport->number); + gmod_cport->size = le16_to_cpu(cport->size); + gmod_cport->speed = cport->speed; - gdev->cport[gdev->num_cports] = gdev_cport; - gdev->num_cports++; + gmod->cport[gmod->num_cports] = gmod_cport; + gmod->num_cports++; return 0; } @@ -349,7 +349,7 @@ static int create_cport(struct greybus_device *gdev, void gb_add_module(struct greybus_host_device *hd, u8 module_id, u8 *data, int size) { - struct greybus_device *gdev; + struct greybus_module *gmod; struct greybus_manifest *manifest; int retval; int overall_size; @@ -360,19 +360,19 @@ void gb_add_module(struct greybus_host_device *hd, u8 module_id, if (size <= sizeof(manifest->header)) return; - gdev = kzalloc(sizeof(*gdev), GFP_KERNEL); - if (!gdev) + gmod = kzalloc(sizeof(*gmod), GFP_KERNEL); + if (!gmod) return; - gdev->module_number = module_id; - gdev->dev.parent = hd->parent; - gdev->dev.driver = NULL; - gdev->dev.bus = &greybus_bus_type; - gdev->dev.type = &greybus_module_type; - gdev->dev.groups = greybus_module_groups; - gdev->dev.dma_mask = hd->parent->dma_mask; - device_initialize(&gdev->dev); - dev_set_name(&gdev->dev, "%d", module_id); + gmod->module_number = module_id; + gmod->dev.parent = hd->parent; + gmod->dev.driver = NULL; + gmod->dev.bus = &greybus_bus_type; + gmod->dev.type = &greybus_module_type; + gmod->dev.groups = greybus_module_groups; + gmod->dev.dma_mask = hd->parent->dma_mask; + device_initialize(&gmod->dev); + dev_set_name(&gmod->dev, "%d", module_id); manifest = (struct greybus_manifest *)data; overall_size = le16_to_cpu(manifest->header.size); @@ -418,27 +418,27 @@ void gb_add_module(struct greybus_host_device *hd, u8 module_id, switch (le16_to_cpu(desc->header.type)) { case GREYBUS_TYPE_FUNCTION: - retval = create_function(gdev, &desc->function, + retval = create_function(gmod, &desc->function, data_size); break; case GREYBUS_TYPE_MODULE_ID: - retval = create_module_id(gdev, &desc->module_id, + retval = create_module_id(gmod, &desc->module_id, data_size); break; case GREYBUS_TYPE_SERIAL_NUMBER: - retval = create_serial_number(gdev, + retval = create_serial_number(gmod, &desc->serial_number, data_size); break; case GREYBUS_TYPE_STRING: - retval = create_string(gdev, &desc->string, data_size); + retval = create_string(gmod, &desc->string, data_size); break; case GREYBUS_TYPE_CPORT: - retval = create_cport(gdev, &desc->cport, data_size); + retval = create_cport(gmod, &desc->cport, data_size); break; case GREYBUS_TYPE_INVALID: @@ -453,17 +453,17 @@ void gb_add_module(struct greybus_host_device *hd, u8 module_id, data += desc_size; } - retval = gb_init_subdevs(gdev, &fake_gb_id); + retval = gb_init_subdevs(gmod, &fake_gb_id); if (retval) goto error; - // FIXME device_add(&gdev->dev); + // FIXME device_add(&gmod->dev); - //return gdev; + //return gmod; return; error: - put_device(&gdev->dev); - greybus_module_release(&gdev->dev); + put_device(&gmod->dev); + greybus_module_release(&gmod->dev); } void gb_remove_module(struct greybus_host_device *hd, u8 module_id) @@ -471,16 +471,16 @@ void gb_remove_module(struct greybus_host_device *hd, u8 module_id) // FIXME should be the remove_device call... } -void greybus_remove_device(struct greybus_device *gdev) +void greybus_remove_device(struct greybus_module *gmod) { /* tear down all of the "sub device types" for this device */ - gb_i2c_disconnect(gdev); - gb_gpio_disconnect(gdev); - gb_sdio_disconnect(gdev); - gb_tty_disconnect(gdev); - gb_battery_disconnect(gdev); + gb_i2c_disconnect(gmod); + gb_gpio_disconnect(gmod); + gb_sdio_disconnect(gmod); + gb_tty_disconnect(gmod); + gb_battery_disconnect(gmod); - // FIXME - device_remove(&gdev->dev); + // FIXME - device_remove(&gmod->dev); } static DEFINE_MUTEX(hd_mutex); diff --git a/drivers/staging/greybus/es1-ap-usb.c b/drivers/staging/greybus/es1-ap-usb.c index eadbfc8..dfe96cb 100644 --- a/drivers/staging/greybus/es1-ap-usb.c +++ b/drivers/staging/greybus/es1-ap-usb.c @@ -92,7 +92,7 @@ static void cport_out_callback(struct urb *urb); */ static int alloc_gbuf_data(struct gbuf *gbuf, unsigned int size, gfp_t gfp_mask) { - struct es1_ap_dev *es1 = hd_to_es1(gbuf->gdev->hd); + struct es1_ap_dev *es1 = hd_to_es1(gbuf->gmod->hd); u8 *buffer; if (size > ES1_GBUF_MSG_SIZE) { diff --git a/drivers/staging/greybus/gbuf.c b/drivers/staging/greybus/gbuf.c index 40174b8..5655721b 100644 --- a/drivers/staging/greybus/gbuf.c +++ b/drivers/staging/greybus/gbuf.c @@ -22,8 +22,8 @@ static struct kmem_cache *gbuf_head_cache; -static struct gbuf *__alloc_gbuf(struct greybus_device *gdev, - struct gdev_cport *cport, +static struct gbuf *__alloc_gbuf(struct greybus_module *gmod, + struct gmod_cport *cport, gbuf_complete_t complete, gfp_t gfp_mask, void *context) @@ -35,7 +35,7 @@ static struct gbuf *__alloc_gbuf(struct greybus_device *gdev, return NULL; kref_init(&gbuf->kref); - gbuf->gdev = gdev; + gbuf->gmod = gmod; gbuf->cport = cport; gbuf->complete = complete; gbuf->context = context; @@ -46,7 +46,7 @@ static struct gbuf *__alloc_gbuf(struct greybus_device *gdev, /** * greybus_alloc_gbuf - allocate a greybus buffer * - * @gdev: greybus device that wants to allocate this + * @gmod: greybus device that wants to allocate this * @cport: cport to send the data to * @complete: callback when the gbuf is finished with * @size: size of the buffer @@ -58,8 +58,8 @@ static struct gbuf *__alloc_gbuf(struct greybus_device *gdev, * that the driver can then fill up with the data to be sent out. Curse * hardware designers for this issue... */ -struct gbuf *greybus_alloc_gbuf(struct greybus_device *gdev, - struct gdev_cport *cport, +struct gbuf *greybus_alloc_gbuf(struct greybus_module *gmod, + struct gmod_cport *cport, gbuf_complete_t complete, unsigned int size, gfp_t gfp_mask, @@ -68,14 +68,14 @@ struct gbuf *greybus_alloc_gbuf(struct greybus_device *gdev, struct gbuf *gbuf; int retval; - gbuf = __alloc_gbuf(gdev, cport, complete, gfp_mask, context); + gbuf = __alloc_gbuf(gmod, cport, complete, gfp_mask, context); if (!gbuf) return NULL; gbuf->direction = GBUF_DIRECTION_OUT; /* Host controller specific allocation for the actual buffer */ - retval = gbuf->gdev->hd->driver->alloc_gbuf_data(gbuf, size, gfp_mask); + retval = gbuf->gmod->hd->driver->alloc_gbuf_data(gbuf, size, gfp_mask); if (retval) { greybus_free_gbuf(gbuf); return NULL; @@ -93,7 +93,7 @@ static void free_gbuf(struct kref *kref) /* If the direction is "out" then the host controller frees the data */ if (gbuf->direction == GBUF_DIRECTION_OUT) { - gbuf->gdev->hd->driver->free_gbuf_data(gbuf); + gbuf->gmod->hd->driver->free_gbuf_data(gbuf); } else { /* we "own" this in data, so free it ourselves */ kfree(gbuf->transfer_buffer); @@ -120,7 +120,7 @@ EXPORT_SYMBOL_GPL(greybus_get_gbuf); int greybus_submit_gbuf(struct gbuf *gbuf, gfp_t gfp_mask) { - return gbuf->gdev->hd->driver->submit_gbuf(gbuf, gbuf->gdev->hd, gfp_mask); + return gbuf->gmod->hd->driver->submit_gbuf(gbuf, gbuf->gmod->hd, gfp_mask); } int greybus_kill_gbuf(struct gbuf *gbuf) @@ -169,8 +169,8 @@ static void cport_create_event(struct gbuf *gbuf) #define MAX_CPORTS 1024 struct gb_cport_handler { gbuf_complete_t handler; - struct gdev_cport cport; - struct greybus_device *gdev; + struct gmod_cport cport; + struct greybus_module *gmod; void *context; }; @@ -178,14 +178,14 @@ static struct gb_cport_handler cport_handler[MAX_CPORTS]; // FIXME - use a lock for this list of handlers, but really, for now we don't // need it, we don't have a dynamic system... -int gb_register_cport_complete(struct greybus_device *gdev, +int gb_register_cport_complete(struct greybus_module *gmod, gbuf_complete_t handler, int cport, void *context) { if (cport_handler[cport].handler) return -EINVAL; cport_handler[cport].context = context; - cport_handler[cport].gdev = gdev; + cport_handler[cport].gmod = gmod; cport_handler[cport].cport.number = cport; cport_handler[cport].handler = handler; return 0; @@ -212,7 +212,7 @@ void greybus_cport_in_data(struct greybus_host_device *hd, int cport, u8 *data, return; } - gbuf = __alloc_gbuf(ch->gdev, &ch->cport, ch->handler, GFP_ATOMIC, + gbuf = __alloc_gbuf(ch->gmod, &ch->cport, ch->handler, GFP_ATOMIC, ch->context); if (!gbuf) { /* Again, something bad went wrong, log it... */ diff --git a/drivers/staging/greybus/gpio-gb.c b/drivers/staging/greybus/gpio-gb.c index 485480d..4b71866 100644 --- a/drivers/staging/greybus/gpio-gb.c +++ b/drivers/staging/greybus/gpio-gb.c @@ -14,7 +14,7 @@ struct gb_gpio_device { struct gpio_chip chip; - struct greybus_device *gdev; + struct greybus_module *gmod; struct gpio_chip *gpio; // FIXME - some lock? }; @@ -49,18 +49,18 @@ static void gpio_set(struct gpio_chip *gpio, unsigned nr, int val) // FIXME - do something there } -int gb_gpio_probe(struct greybus_device *gdev, +int gb_gpio_probe(struct greybus_module *gmod, const struct greybus_module_id *id) { struct gb_gpio_device *gb_gpio; struct gpio_chip *gpio; - struct device *dev = &gdev->dev; + struct device *dev = &gmod->dev; int retval; gb_gpio = kzalloc(sizeof(*gb_gpio), GFP_KERNEL); if (!gb_gpio) return -ENOMEM; - gb_gpio->gdev = gdev; + gb_gpio->gmod = gmod; gpio = &gb_gpio->chip; @@ -75,7 +75,7 @@ int gb_gpio_probe(struct greybus_device *gdev, gpio->ngpio = 42; // FIXME!!! gpio->can_sleep = false; // FIXME!!! - gdev->gb_gpio_dev = gb_gpio; + gmod->gb_gpio_dev = gb_gpio; retval = gpiochip_add(gpio); if (retval) { @@ -86,12 +86,12 @@ int gb_gpio_probe(struct greybus_device *gdev, return 0; } -void gb_gpio_disconnect(struct greybus_device *gdev) +void gb_gpio_disconnect(struct greybus_module *gmod) { struct gb_gpio_device *gb_gpio_dev; int retval; - gb_gpio_dev = gdev->gb_gpio_dev; + gb_gpio_dev = gmod->gb_gpio_dev; retval = gpiochip_remove(&gb_gpio_dev->chip); kfree(gb_gpio_dev); diff --git a/drivers/staging/greybus/greybus.h b/drivers/staging/greybus/greybus.h index 1f996b9..59f9b98 100644 --- a/drivers/staging/greybus/greybus.h +++ b/drivers/staging/greybus/greybus.h @@ -101,14 +101,14 @@ struct gbuf; -struct gdev_cport { +struct gmod_cport { u16 number; u16 size; u8 speed; // valid??? // FIXME, what else? }; -struct gdev_string { +struct gmod_string { u16 length; u8 id; u8 string[0]; @@ -120,8 +120,8 @@ struct gbuf { struct kref kref; void *hdpriv; - struct greybus_device *gdev; - struct gdev_cport *cport; + struct greybus_module *gmod; + struct gmod_cport *cport; int status; void *transfer_buffer; u32 transfer_flags; /* flags for the transfer buffer */ @@ -148,7 +148,7 @@ struct gbuf { * same module as the gpio pins, etc.) * * So, put the "private" data structures here in greybus.h and link to them off - * of the "main" greybus_device structure. + * of the "main" greybus_module structure. */ struct gb_i2c_device; @@ -195,7 +195,7 @@ void greybus_gbuf_finished(struct gbuf *gbuf); #define MAX_CPORTS_PER_MODULE 10 #define MAX_STRINGS_PER_MODULE 10 -struct greybus_device { +struct greybus_module { struct device dev; u16 module_number; struct greybus_descriptor_function function; @@ -203,8 +203,8 @@ struct greybus_device { struct greybus_descriptor_serial_number serial_number; int num_cports; int num_strings; - struct gdev_cport *cport[MAX_CPORTS_PER_MODULE]; - struct gdev_string *string[MAX_STRINGS_PER_MODULE]; + struct gmod_cport *cport[MAX_CPORTS_PER_MODULE]; + struct gmod_string *string[MAX_STRINGS_PER_MODULE]; struct greybus_host_device *hd; @@ -215,10 +215,10 @@ struct greybus_device { struct gb_usb_device *gb_usb_dev; struct gb_battery *gb_battery; }; -#define to_greybus_device(d) container_of(d, struct greybus_device, dev) +#define to_greybus_module(d) container_of(d, struct greybus_module, dev) -struct gbuf *greybus_alloc_gbuf(struct greybus_device *gdev, - struct gdev_cport *cport, +struct gbuf *greybus_alloc_gbuf(struct greybus_module *gmod, + struct gmod_cport *cport, gbuf_complete_t complete, unsigned int size, gfp_t gfp_mask, @@ -234,12 +234,12 @@ int greybus_kill_gbuf(struct gbuf *gbuf); struct greybus_driver { const char *name; - int (*probe)(struct greybus_device *gdev, + int (*probe)(struct greybus_module *gmod, const struct greybus_module_id *id); - void (*disconnect)(struct greybus_device *gdev); + void (*disconnect)(struct greybus_module *gmod); - int (*suspend)(struct greybus_device *gdev, pm_message_t message); - int (*resume)(struct greybus_device *gdev); + int (*suspend)(struct greybus_module *gmod, pm_message_t message); + int (*resume)(struct greybus_module *gmod); const struct greybus_module_id *id_table; @@ -247,14 +247,14 @@ struct greybus_driver { }; #define to_greybus_driver(d) container_of(d, struct greybus_driver, driver) -static inline void greybus_set_drvdata(struct greybus_device *gdev, void *data) +static inline void greybus_set_drvdata(struct greybus_module *gmod, void *data) { - dev_set_drvdata(&gdev->dev, data); + dev_set_drvdata(&gmod->dev, data); } -static inline void *greybus_get_drvdata(struct greybus_device *gdev) +static inline void *greybus_get_drvdata(struct greybus_module *gmod) { - return dev_get_drvdata(&gdev->dev); + return dev_get_drvdata(&gmod->dev); } /* Don't call these directly, use the module_greybus_driver() macro instead */ @@ -279,9 +279,9 @@ void greybus_deregister(struct greybus_driver *driver); int greybus_disabled(void); -void greybus_remove_device(struct greybus_device *gdev); +void greybus_remove_device(struct greybus_module *gmod); -const u8 *greybus_string(struct greybus_device *gdev, int id); +const u8 *greybus_string(struct greybus_module *gmod, int id); /* Internal functions to gb module, move to internal .h file eventually. */ @@ -297,7 +297,7 @@ void gb_debugfs_cleanup(void); int gb_gbuf_init(void); void gb_gbuf_exit(void); -int gb_register_cport_complete(struct greybus_device *gdev, +int gb_register_cport_complete(struct greybus_module *gmod, gbuf_complete_t handler, int cport, void *context); void gb_deregister_cport_complete(int cport); @@ -309,16 +309,16 @@ extern const struct attribute_group *greybus_module_groups[]; * we have static functions for this, not "dynamic" drivers like we really * should in the end. */ -int gb_i2c_probe(struct greybus_device *gdev, const struct greybus_module_id *id); -void gb_i2c_disconnect(struct greybus_device *gdev); -int gb_gpio_probe(struct greybus_device *gdev, const struct greybus_module_id *id); -void gb_gpio_disconnect(struct greybus_device *gdev); -int gb_sdio_probe(struct greybus_device *gdev, const struct greybus_module_id *id); -void gb_sdio_disconnect(struct greybus_device *gdev); -int gb_tty_probe(struct greybus_device *gdev, const struct greybus_module_id *id); -void gb_tty_disconnect(struct greybus_device *gdev); -int gb_battery_probe(struct greybus_device *gdev, const struct greybus_module_id *id); -void gb_battery_disconnect(struct greybus_device *gdev); +int gb_i2c_probe(struct greybus_module *gmod, const struct greybus_module_id *id); +void gb_i2c_disconnect(struct greybus_module *gmod); +int gb_gpio_probe(struct greybus_module *gmod, const struct greybus_module_id *id); +void gb_gpio_disconnect(struct greybus_module *gmod); +int gb_sdio_probe(struct greybus_module *gmod, const struct greybus_module_id *id); +void gb_sdio_disconnect(struct greybus_module *gmod); +int gb_tty_probe(struct greybus_module *gmod, const struct greybus_module_id *id); +void gb_tty_disconnect(struct greybus_module *gmod); +int gb_battery_probe(struct greybus_module *gmod, const struct greybus_module_id *id); +void gb_battery_disconnect(struct greybus_module *gmod); int gb_tty_init(void); void gb_tty_exit(void); diff --git a/drivers/staging/greybus/greybus_id.h b/drivers/staging/greybus/greybus_id.h index 83c4d05..8b3bce6 100644 --- a/drivers/staging/greybus/greybus_id.h +++ b/drivers/staging/greybus/greybus_id.h @@ -19,7 +19,7 @@ struct greybus_module_id { __attribute__((aligned(sizeof(kernel_ulong_t)))); }; -/* Used to match the greybus_device_id */ +/* Used to match the greybus_module_id */ #define GREYBUS_DEVICE_ID_MATCH_VENDOR BIT(0) #define GREYBUS_DEVICE_ID_MATCH_PRODUCT BIT(1) #define GREYBUS_DEVICE_ID_MATCH_SERIAL BIT(2) diff --git a/drivers/staging/greybus/i2c-gb.c b/drivers/staging/greybus/i2c-gb.c index 3c1d947..bd03f19 100644 --- a/drivers/staging/greybus/i2c-gb.c +++ b/drivers/staging/greybus/i2c-gb.c @@ -14,7 +14,7 @@ struct gb_i2c_device { struct i2c_adapter *adapter; - struct greybus_device *gdev; + struct greybus_module *gmod; }; static const struct greybus_module_id id_table[] = { @@ -33,10 +33,10 @@ static s32 i2c_gb_access(struct i2c_adapter *adap, u16 addr, int size, union i2c_smbus_data *data) { struct gb_i2c_device *gb_i2c_dev; - struct greybus_device *gdev; + struct greybus_module *gmod; gb_i2c_dev = i2c_get_adapdata(adap); - gdev = gb_i2c_dev->gdev; + gmod = gb_i2c_dev->gmod; // FIXME - do the actual work of sending a i2c message here... switch (size) { @@ -50,7 +50,7 @@ static s32 i2c_gb_access(struct i2c_adapter *adap, u16 addr, case I2C_SMBUS_BLOCK_PROC_CALL: case I2C_SMBUS_I2C_BLOCK_DATA: default: - dev_err(&gdev->dev, "Unsupported transaction %d\n", size); + dev_err(&gmod->dev, "Unsupported transaction %d\n", size); return -EOPNOTSUPP; } @@ -75,7 +75,7 @@ static const struct i2c_algorithm smbus_algorithm = { .functionality = i2c_gb_func, }; -int gb_i2c_probe(struct greybus_device *gdev, +int gb_i2c_probe(struct greybus_module *gmod, const struct greybus_module_id *id) { struct gb_i2c_device *gb_i2c_dev; @@ -95,19 +95,19 @@ int gb_i2c_probe(struct greybus_device *gdev, adapter->owner = THIS_MODULE; adapter->class = I2C_CLASS_HWMON | I2C_CLASS_SPD; adapter->algo = &smbus_algorithm; - adapter->dev.parent = &gdev->dev; + adapter->dev.parent = &gmod->dev; adapter->retries = 3; /* we have to pick something... */ snprintf(adapter->name, sizeof(adapter->name), "Greybus i2c adapter"); retval = i2c_add_adapter(adapter); if (retval) { - dev_err(&gdev->dev, "Can not add SMBus adapter\n"); + dev_err(&gmod->dev, "Can not add SMBus adapter\n"); goto error; } - gb_i2c_dev->gdev = gdev; + gb_i2c_dev->gmod = gmod; gb_i2c_dev->adapter = adapter; - gdev->gb_i2c_dev = gb_i2c_dev; + gmod->gb_i2c_dev = gb_i2c_dev; return 0; error: kfree(adapter); @@ -115,11 +115,11 @@ error: return retval; } -void gb_i2c_disconnect(struct greybus_device *gdev) +void gb_i2c_disconnect(struct greybus_module *gmod) { struct gb_i2c_device *gb_i2c_dev; - gb_i2c_dev = gdev->gb_i2c_dev; + gb_i2c_dev = gmod->gb_i2c_dev; i2c_del_adapter(gb_i2c_dev->adapter); kfree(gb_i2c_dev->adapter); kfree(gb_i2c_dev); diff --git a/drivers/staging/greybus/sdio-gb.c b/drivers/staging/greybus/sdio-gb.c index 665767d..3cf258a 100644 --- a/drivers/staging/greybus/sdio-gb.c +++ b/drivers/staging/greybus/sdio-gb.c @@ -45,13 +45,13 @@ static const struct mmc_host_ops gb_sd_ops = { .get_ro = gb_sd_get_ro, }; -int gb_sdio_probe(struct greybus_device *gdev, +int gb_sdio_probe(struct greybus_module *gmod, const struct greybus_module_id *id) { struct mmc_host *mmc; struct gb_sdio_host *host; - mmc = mmc_alloc_host(sizeof(struct gb_sdio_host), &gdev->dev); + mmc = mmc_alloc_host(sizeof(struct gb_sdio_host), &gmod->dev); if (!mmc) return -ENOMEM; @@ -61,16 +61,16 @@ int gb_sdio_probe(struct greybus_device *gdev, mmc->ops = &gb_sd_ops; // FIXME - set up size limits we can handle. - gdev->gb_sdio_host = host; + gmod->gb_sdio_host = host; return 0; } -void gb_sdio_disconnect(struct greybus_device *gdev) +void gb_sdio_disconnect(struct greybus_module *gmod) { struct mmc_host *mmc; struct gb_sdio_host *host; - host = gdev->gb_sdio_host; + host = gmod->gb_sdio_host; mmc = host->mmc; mmc_remove_host(mmc); diff --git a/drivers/staging/greybus/sysfs.c b/drivers/staging/greybus/sysfs.c index 074fcfe..b503d2c 100644 --- a/drivers/staging/greybus/sysfs.c +++ b/drivers/staging/greybus/sysfs.c @@ -26,8 +26,8 @@ static ssize_t function_##field##_show(struct device *dev, \ struct device_attribute *attr, \ char *buf) \ { \ - struct greybus_device *gdev = to_greybus_device(dev); \ - return sprintf(buf, "%d\n", gdev->function.field); \ + struct greybus_module *gmod = to_greybus_module(dev); \ + return sprintf(buf, "%d\n", gmod->function.field); \ } \ static DEVICE_ATTR_RO(function_##field) @@ -49,15 +49,15 @@ static struct attribute *function_attrs[] = { static umode_t function_attrs_are_visible(struct kobject *kobj, struct attribute *a, int n) { - struct greybus_device *gdev = to_greybus_device(kobj_to_dev(kobj)); + struct greybus_module *gmod = to_greybus_module(kobj_to_dev(kobj)); // FIXME - make this a dynamic structure to "know" if it really is here // or not easier? - if (gdev->function.number || - gdev->function.cport || - gdev->function.class || - gdev->function.subclass || - gdev->function.protocol) + if (gmod->function.number || + gmod->function.cport || + gmod->function.class || + gmod->function.subclass || + gmod->function.protocol) return a->mode; return 0; } @@ -73,8 +73,8 @@ static ssize_t module_##field##_show(struct device *dev, \ struct device_attribute *attr, \ char *buf) \ { \ - struct greybus_device *gdev = to_greybus_device(dev); \ - return sprintf(buf, "%x\n", gdev->module_id.field); \ + struct greybus_module *gmod = to_greybus_module(dev); \ + return sprintf(buf, "%x\n", gmod->module_id.field); \ } \ static DEVICE_ATTR_RO(module_##field) @@ -86,10 +86,10 @@ static ssize_t module_vendor_string_show(struct device *dev, struct device_attribute *attr, char *buf) { - struct greybus_device *gdev = to_greybus_device(dev); + struct greybus_module *gmod = to_greybus_module(dev); return sprintf(buf, "%s", - greybus_string(gdev, gdev->module_id.vendor_stringid)); + greybus_string(gmod, gmod->module_id.vendor_stringid)); } static DEVICE_ATTR_RO(module_vendor_string); @@ -97,10 +97,10 @@ static ssize_t module_product_string_show(struct device *dev, struct device_attribute *attr, char *buf) { - struct greybus_device *gdev = to_greybus_device(dev); + struct greybus_module *gmod = to_greybus_module(dev); return sprintf(buf, "%s", - greybus_string(gdev, gdev->module_id.product_stringid)); + greybus_string(gmod, gmod->module_id.product_stringid)); } static DEVICE_ATTR_RO(module_product_string); @@ -116,20 +116,20 @@ static struct attribute *module_attrs[] = { static umode_t module_attrs_are_visible(struct kobject *kobj, struct attribute *a, int n) { - struct greybus_device *gdev = to_greybus_device(kobj_to_dev(kobj)); + struct greybus_module *gmod = to_greybus_module(kobj_to_dev(kobj)); if ((a == &dev_attr_module_vendor_string.attr) && - (gdev->module_id.vendor_stringid)) + (gmod->module_id.vendor_stringid)) return a->mode; if ((a == &dev_attr_module_product_string.attr) && - (gdev->module_id.product_stringid)) + (gmod->module_id.product_stringid)) return a->mode; // FIXME - make this a dynamic structure to "know" if it really is here // or not easier? - if (gdev->module_id.vendor || - gdev->module_id.product || - gdev->module_id.version) + if (gmod->module_id.vendor || + gmod->module_id.product || + gmod->module_id.version) return a->mode; return 0; } @@ -144,10 +144,10 @@ static struct attribute_group module_attr_grp = { static ssize_t serial_number_show(struct device *dev, struct device_attribute *attr, char *buf) { - struct greybus_device *gdev = to_greybus_device(dev); + struct greybus_module *gmod = to_greybus_module(dev); return sprintf(buf, "%llX\n", - (unsigned long long)le64_to_cpu(gdev->serial_number.serial_number)); + (unsigned long long)le64_to_cpu(gmod->serial_number.serial_number)); } static DEVICE_ATTR_RO(serial_number); diff --git a/drivers/staging/greybus/test_sink.c b/drivers/staging/greybus/test_sink.c index 932c169..9dbf6ee 100644 --- a/drivers/staging/greybus/test_sink.c +++ b/drivers/staging/greybus/test_sink.c @@ -12,10 +12,10 @@ #include "greybus.h" struct test_device { - struct greybus_device *gdev; + struct greybus_module *gmod; }; -int gb_register_cport_complete(struct greybus_device *gdev, +int gb_register_cport_complete(struct greybus_module *gmod, gbuf_complete_t handler, int cport, void *context); void gb_deregister_cport_complete(int cport); diff --git a/drivers/staging/greybus/uart-gb.c b/drivers/staging/greybus/uart-gb.c index 75ddd18..2021f27 100644 --- a/drivers/staging/greybus/uart-gb.c +++ b/drivers/staging/greybus/uart-gb.c @@ -33,7 +33,7 @@ struct gb_tty { struct tty_port port; - struct greybus_device *gdev; + struct greybus_module *gmod; int cport; unsigned int minor; unsigned char clocal; @@ -384,7 +384,7 @@ static const struct tty_operations gb_ops = { }; -int gb_tty_probe(struct greybus_device *gdev, +int gb_tty_probe(struct greybus_module *gmod, const struct greybus_module_id *id) { struct gb_tty *gb_tty; @@ -399,14 +399,14 @@ int gb_tty_probe(struct greybus_device *gdev, minor = alloc_minor(gb_tty); if (minor < 0) { if (minor == -ENOSPC) { - dev_err(&gdev->dev, "no more free minor numbers\n"); + dev_err(&gmod->dev, "no more free minor numbers\n"); return -ENODEV; } return minor; } gb_tty->minor = minor; - gb_tty->gdev = gdev; + gb_tty->gmod = gmod; spin_lock_init(&gb_tty->write_lock); spin_lock_init(&gb_tty->read_lock); init_waitqueue_head(&gb_tty->wioctl); @@ -414,10 +414,10 @@ int gb_tty_probe(struct greybus_device *gdev, /* FIXME - allocate gb buffers */ - gdev->gb_tty = gb_tty; + gmod->gb_tty = gb_tty; tty_dev = tty_port_register_device(&gb_tty->port, gb_tty_driver, minor, - &gdev->dev); + &gmod->dev); if (IS_ERR(tty_dev)) { retval = PTR_ERR(tty_dev); goto error; @@ -425,14 +425,14 @@ int gb_tty_probe(struct greybus_device *gdev, return 0; error: - gdev->gb_tty = NULL; + gmod->gb_tty = NULL; release_minor(gb_tty); return retval; } -void gb_tty_disconnect(struct greybus_device *gdev) +void gb_tty_disconnect(struct greybus_module *gmod) { - struct gb_tty *gb_tty = gdev->gb_tty; + struct gb_tty *gb_tty = gmod->gb_tty; struct tty_struct *tty; if (!gb_tty) @@ -442,7 +442,7 @@ void gb_tty_disconnect(struct greybus_device *gdev) gb_tty->disconnected = true; wake_up_all(&gb_tty->wioctl); - gdev->gb_tty = NULL; + gmod->gb_tty = NULL; mutex_unlock(&gb_tty->mutex); tty = tty_port_tty_get(&gb_tty->port); -- 2.7.4