Commit 778c69c9 authored by Alex Elder's avatar Alex Elder Committed by Greg Kroah-Hartman

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