summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorSandeep Patil <patil_sandeep@projectara.com>2016-05-19 08:52:39 -0700
committerGreg Kroah-Hartman <gregkh@google.com>2016-05-19 10:09:13 -0700
commite54b106dd1be50377fe8365392466e080b659ab6 (patch)
tree42857d8b2a4088717d76a6daff6000bb66cd2080 /drivers
parente16715c135d80aafea867849f938b080d4f4eadb (diff)
greybus: gpbridge: rename 'gpbridge' to 'gbphy' everywhere
The 'gpbridge' name didn't relaly reflect what the bus is; which is a bus for bridged-phy devices. So, rename all instances of 'gpbridge' to more appropriate 'gbphy' Testing Done: Build and boot tested. 'lsgb' will stop displaying 'GPBridge' devices until I change the library to reflect this change. Signed-off-by: Sandeep Patil <patil_sandeep@projectara.com> Suggested-by: Greg Kroah-Hartman <gregkh@google.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/staging/greybus/Makefile4
-rw-r--r--drivers/staging/greybus/gbphy.c330
-rw-r--r--drivers/staging/greybus/gbphy.h71
-rw-r--r--drivers/staging/greybus/gpbridge.c330
-rw-r--r--drivers/staging/greybus/gpbridge.h71
-rw-r--r--drivers/staging/greybus/gpio.c54
-rw-r--r--drivers/staging/greybus/i2c.c38
-rw-r--r--drivers/staging/greybus/interface.c2
-rw-r--r--drivers/staging/greybus/loopback.c26
-rw-r--r--drivers/staging/greybus/pwm.c32
-rw-r--r--drivers/staging/greybus/sdio.c36
-rw-r--r--drivers/staging/greybus/spi.c30
-rw-r--r--drivers/staging/greybus/uart.c48
-rw-r--r--drivers/staging/greybus/usb.c38
14 files changed, 555 insertions, 555 deletions
diff --git a/drivers/staging/greybus/Makefile b/drivers/staging/greybus/Makefile
index 608bd51e7c0b..ae9a478d3dde 100644
--- a/drivers/staging/greybus/Makefile
+++ b/drivers/staging/greybus/Makefile
@@ -14,7 +14,7 @@ greybus-y := core.o \
operation.o \
legacy.o
-gb-gpbridge-y := gpbridge.o
+gb-gbphy-y := gbphy.o
# Prefix all modules with gb-
gb-vibrator-y := vibrator.o
@@ -43,7 +43,7 @@ gb-usb-y := usb.o
gb-spi-y := spi.o
obj-m += greybus.o
-obj-m += gb-gpbridge.o
+obj-m += gb-gbphy.o
obj-m += gb-vibrator.o
obj-m += gb-power-supply.o
obj-m += gb-loopback.o
diff --git a/drivers/staging/greybus/gbphy.c b/drivers/staging/greybus/gbphy.c
new file mode 100644
index 000000000000..c11a1368d073
--- /dev/null
+++ b/drivers/staging/greybus/gbphy.c
@@ -0,0 +1,330 @@
+/*
+ * Greybus Bridged-Phy Bus driver
+ *
+ * Copyright 2014 Google Inc.
+ * Copyright 2014 Linaro Ltd.
+ *
+ * Released under the GPLv2 only.
+ */
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
+#include <linux/types.h>
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/kernel.h>
+#include <linux/slab.h>
+#include <linux/device.h>
+
+#include "greybus.h"
+#include "gbphy.h"
+
+struct gbphy_host {
+ struct gb_bundle *bundle;
+ struct list_head devices;
+};
+
+static DEFINE_IDA(gbphy_id);
+
+static ssize_t protocol_id_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct gbphy_device *gbphy_dev = to_gbphy_dev(dev);
+
+ return sprintf(buf, "0x%02x\n", gbphy_dev->cport_desc->protocol_id);
+}
+static DEVICE_ATTR_RO(protocol_id);
+
+static struct attribute *gbphy_dev_attrs[] = {
+ &dev_attr_protocol_id.attr,
+ NULL,
+};
+
+ATTRIBUTE_GROUPS(gbphy_dev);
+
+static void gbphy_dev_release(struct device *dev)
+{
+ struct gbphy_device *gbphy_dev = to_gbphy_dev(dev);
+
+ ida_simple_remove(&gbphy_id, gbphy_dev->id);
+ kfree(gbphy_dev);
+}
+
+static struct device_type greybus_gbphy_dev_type = {
+ .name = "gbphy_device",
+ .release = gbphy_dev_release,
+};
+
+static int gbphy_dev_uevent(struct device *dev, struct kobj_uevent_env *env)
+{
+ struct gbphy_device *gbphy_dev = to_gbphy_dev(dev);
+ struct greybus_descriptor_cport *cport_desc = gbphy_dev->cport_desc;
+ struct gb_bundle *bundle = gbphy_dev->bundle;
+ struct gb_interface *intf = bundle->intf;
+ struct gb_module *module = intf->module;
+ struct gb_host_device *hd = intf->hd;
+
+ if (add_uevent_var(env, "BUS=%u", hd->bus_id))
+ return -ENOMEM;
+ if (add_uevent_var(env, "MODULE=%u", module->module_id))
+ return -ENOMEM;
+ if (add_uevent_var(env, "INTERFACE=%u", intf->interface_id))
+ return -ENOMEM;
+ if (add_uevent_var(env, "GREYBUS_ID=%08x/%08x",
+ intf->vendor_id, intf->product_id))
+ return -ENOMEM;
+ if (add_uevent_var(env, "BUNDLE=%u", gbphy_dev->bundle->id))
+ return -ENOMEM;
+ if (add_uevent_var(env, "BUNDLE_CLASS=%02x", bundle->class))
+ return -ENOMEM;
+ if (add_uevent_var(env, "GBPHY=%u", gbphy_dev->id))
+ return -ENOMEM;
+ if (add_uevent_var(env, "PROTOCOL_ID=%02x", cport_desc->protocol_id))
+ return -ENOMEM;
+
+ return 0;
+}
+
+static const struct gbphy_device_id *
+gbphy_dev_match_id(struct gbphy_device *gbphy_dev, struct gbphy_driver *gbphy_drv)
+{
+ const struct gbphy_device_id *id = gbphy_drv->id_table;
+
+ if (!id)
+ return NULL;
+
+ for (; id->protocol_id; id++)
+ if (id->protocol_id == gbphy_dev->cport_desc->protocol_id)
+ return id;
+
+ return NULL;
+}
+
+static int gbphy_dev_match(struct device *dev, struct device_driver *drv)
+{
+ struct gbphy_driver *gbphy_drv = to_gbphy_driver(drv);
+ struct gbphy_device *gbphy_dev = to_gbphy_dev(dev);
+ const struct gbphy_device_id *id;
+
+ id = gbphy_dev_match_id(gbphy_dev, gbphy_drv);
+ if (id)
+ return 1;
+
+ return 0;
+}
+
+static int gbphy_dev_probe(struct device *dev)
+{
+ struct gbphy_driver *gbphy_drv = to_gbphy_driver(dev->driver);
+ struct gbphy_device *gbphy_dev = to_gbphy_dev(dev);
+ const struct gbphy_device_id *id;
+
+ id = gbphy_dev_match_id(gbphy_dev, gbphy_drv);
+ if (!id)
+ return -ENODEV;
+
+ return gbphy_drv->probe(gbphy_dev, id);
+}
+
+static int gbphy_dev_remove(struct device *dev)
+{
+ struct gbphy_driver *gbphy_drv = to_gbphy_driver(dev->driver);
+ struct gbphy_device *gbphy_dev = to_gbphy_dev(dev);
+
+ gbphy_drv->remove(gbphy_dev);
+ return 0;
+}
+
+static struct bus_type gbphy_bus_type = {
+ .name = "gbphy",
+ .match = gbphy_dev_match,
+ .probe = gbphy_dev_probe,
+ .remove = gbphy_dev_remove,
+ .uevent = gbphy_dev_uevent,
+};
+
+int gb_gbphy_register_driver(struct gbphy_driver *driver,
+ struct module *owner, const char *mod_name)
+{
+ int retval;
+
+ if (greybus_disabled())
+ return -ENODEV;
+
+ driver->driver.bus = &gbphy_bus_type;
+ driver->driver.name = driver->name;
+ driver->driver.owner = owner;
+ driver->driver.mod_name = mod_name;
+
+ retval = driver_register(&driver->driver);
+ if (retval)
+ return retval;
+
+ pr_info("registered new driver %s\n", driver->name);
+ return 0;
+}
+EXPORT_SYMBOL_GPL(gb_gbphy_register_driver);
+
+void gb_gbphy_deregister_driver(struct gbphy_driver *driver)
+{
+ driver_unregister(&driver->driver);
+}
+EXPORT_SYMBOL_GPL(gb_gbphy_deregister_driver);
+
+int gb_gbphy_get_version(struct gb_connection *connection)
+{
+ struct gb_protocol_version_request request;
+ struct gb_protocol_version_response response;
+ int retval;
+
+ request.major = 1;
+ request.minor = 0;
+
+ retval = gb_operation_sync(connection, GB_REQUEST_TYPE_PROTOCOL_VERSION,
+ &request, sizeof(request), &response,
+ sizeof(response));
+ if (retval)
+ return retval;
+
+ /* FIXME - do proper version negotiation here someday... */
+
+ connection->module_major = response.major;
+ connection->module_minor = response.minor;
+
+ dev_dbg(&connection->hd->dev, "%s: v%u.%u\n", connection->name,
+ response.major, response.minor);
+
+ return 0;
+}
+EXPORT_SYMBOL_GPL(gb_gbphy_get_version);
+
+static struct gbphy_device *gb_gbphy_create_dev(struct gb_bundle *bundle,
+ struct greybus_descriptor_cport *cport_desc)
+{
+ struct gbphy_device *gbphy_dev;
+ int retval;
+ int id;
+
+ id = ida_simple_get(&gbphy_id, 1, 0, GFP_KERNEL);
+ if (id < 0)
+ return ERR_PTR(id);
+
+ gbphy_dev = kzalloc(sizeof(*gbphy_dev), GFP_KERNEL);
+ if (!gbphy_dev) {
+ ida_simple_remove(&gbphy_id, id);
+ return ERR_PTR(-ENOMEM);
+ }
+
+ gbphy_dev->id = id;
+ gbphy_dev->bundle = bundle;
+ gbphy_dev->cport_desc = cport_desc;
+ gbphy_dev->dev.parent = &bundle->dev;
+ gbphy_dev->dev.bus = &gbphy_bus_type;
+ gbphy_dev->dev.type = &greybus_gbphy_dev_type;
+ gbphy_dev->dev.groups = gbphy_dev_groups;
+ gbphy_dev->dev.dma_mask = bundle->dev.dma_mask;
+ dev_set_name(&gbphy_dev->dev, "gbphy%d", id);
+
+ retval = device_register(&gbphy_dev->dev);
+ if (retval) {
+ put_device(&gbphy_dev->dev);
+ return ERR_PTR(retval);
+ }
+
+ return gbphy_dev;
+}
+
+static void gb_gbphy_disconnect(struct gb_bundle *bundle)
+{
+ struct gbphy_host *gbphy_host = greybus_get_drvdata(bundle);
+ struct gbphy_device *gbphy_dev, *temp;
+
+ list_for_each_entry_safe(gbphy_dev, temp, &gbphy_host->devices, list) {
+ list_del(&gbphy_dev->list);
+ device_unregister(&gbphy_dev->dev);
+ }
+
+ kfree(gbphy_host);
+}
+
+static int gb_gbphy_probe(struct gb_bundle *bundle,
+ const struct greybus_bundle_id *id)
+{
+ struct gbphy_host *gbphy_host;
+ struct gbphy_device *gbphy_dev;
+ int i;
+
+ if (bundle->num_cports == 0)
+ return -ENODEV;
+
+ gbphy_host = kzalloc(sizeof(*gbphy_host), GFP_KERNEL);
+ if (!gbphy_host)
+ return -ENOMEM;
+
+ gbphy_host->bundle = bundle;
+ INIT_LIST_HEAD(&gbphy_host->devices);
+ greybus_set_drvdata(bundle, gbphy_host);
+
+ /*
+ * Create a bunch of children devices, one per cport, and bind the
+ * bridged phy drivers to them.
+ */
+ for (i = 0; i < bundle->num_cports; ++i) {
+ gbphy_dev = gb_gbphy_create_dev(bundle, &bundle->cport_desc[i]);
+ if (IS_ERR(gbphy_dev)) {
+ gb_gbphy_disconnect(bundle);
+ return PTR_ERR(gbphy_dev);
+ }
+ list_add(&gbphy_dev->list, &gbphy_host->devices);
+ }
+
+ return 0;
+}
+
+static const struct greybus_bundle_id gb_gbphy_id_table[] = {
+ { GREYBUS_DEVICE_CLASS(GREYBUS_CLASS_BRIDGED_PHY) },
+ { },
+};
+MODULE_DEVICE_TABLE(greybus, gb_gbphy_id_table);
+
+static struct greybus_driver gb_gbphy_driver = {
+ .name = "gbphy",
+ .probe = gb_gbphy_probe,
+ .disconnect = gb_gbphy_disconnect,
+ .id_table = gb_gbphy_id_table,
+};
+
+static int __init gbphy_init(void)
+{
+ int retval;
+
+ retval = bus_register(&gbphy_bus_type);
+ if (retval) {
+ pr_err("gbphy bus register failed (%d)\n", retval);
+ return retval;
+ }
+
+ retval = greybus_register(&gb_gbphy_driver);
+ if (retval) {
+ pr_err("error registering greybus driver\n");
+ goto error_gbphy;
+ }
+
+ return 0;
+
+error_gbphy:
+ bus_unregister(&gbphy_bus_type);
+ ida_destroy(&gbphy_id);
+ return retval;
+}
+module_init(gbphy_init);
+
+static void __exit gbphy_exit(void)
+{
+ greybus_deregister(&gb_gbphy_driver);
+ bus_unregister(&gbphy_bus_type);
+ ida_destroy(&gbphy_id);
+}
+module_exit(gbphy_exit);
+
+MODULE_LICENSE("GPL v2");
diff --git a/drivers/staging/greybus/gbphy.h b/drivers/staging/greybus/gbphy.h
new file mode 100644
index 000000000000..79dbf7e1be58
--- /dev/null
+++ b/drivers/staging/greybus/gbphy.h
@@ -0,0 +1,71 @@
+/*
+ * Greybus Bridged-Phy Bus driver
+ *
+ * Copyright 2016 Google Inc.
+ *
+ * Released under the GPLv2 only.
+ */
+
+#ifndef __GBPHY_H
+#define __GBPHY_H
+
+struct gbphy_device {
+ u32 id;
+ struct greybus_descriptor_cport *cport_desc;
+ struct gb_bundle *bundle;
+ struct list_head list;
+ struct device dev;
+};
+#define to_gbphy_dev(d) container_of(d, struct gbphy_device, dev)
+
+static inline void *gb_gbphy_get_data(struct gbphy_device *gdev)
+{
+ return dev_get_drvdata(&gdev->dev);
+}
+
+static inline void gb_gbphy_set_data(struct gbphy_device *gdev, void *data)
+{
+ dev_set_drvdata(&gdev->dev, data);
+}
+
+struct gbphy_device_id {
+ __u8 protocol_id;
+};
+
+#define GBPHY_PROTOCOL(p) \
+ .protocol_id = (p),
+
+struct gbphy_driver {
+ const char *name;
+ int (*probe)(struct gbphy_device *,
+ const struct gbphy_device_id *id);
+ void (*remove)(struct gbphy_device *);
+ const struct gbphy_device_id *id_table;
+
+ struct device_driver driver;
+};
+#define to_gbphy_driver(d) container_of(d, struct gbphy_driver, driver)
+
+int gb_gbphy_get_version(struct gb_connection *connection);
+int gb_gbphy_register_driver(struct gbphy_driver *driver,
+ struct module *owner, const char *mod_name);
+void gb_gbphy_deregister_driver(struct gbphy_driver *driver);
+
+#define gb_gbphy_register(driver) \
+ gb_gbphy_register_driver(driver, THIS_MODULE, KBUILD_MODNAME)
+#define gb_gbphy_deregister(driver) \
+ gb_gbphy_deregister_driver(driver)
+
+/**
+ * module_gbphy_driver() - Helper macro for registering a gbphy driver
+ * @__gbphy_driver: gbphy_driver structure
+ *
+ * Helper macro for gbphy drivers to set up proper module init / exit
+ * functions. Replaces module_init() and module_exit() and keeps people from
+ * printing pointless things to the kernel log when their driver is loaded.
+ */
+#define module_gbphy_driver(__gbphy_driver) \
+ module_driver(__gbphy_driver, gb_gbphy_register, gb_gbphy_deregister)
+
+#endif /* __GBPHY_H */
+
diff --git a/drivers/staging/greybus/gpbridge.c b/drivers/staging/greybus/gpbridge.c
deleted file mode 100644
index 88f7d26121e4..000000000000
--- a/drivers/staging/greybus/gpbridge.c
+++ /dev/null
@@ -1,330 +0,0 @@
-/*
- * Greybus GP Bridge driver
- *
- * Copyright 2014 Google Inc.
- * Copyright 2014 Linaro Ltd.
- *
- * Released under the GPLv2 only.
- */
-
-#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
-
-#include <linux/types.h>
-#include <linux/module.h>
-#include <linux/moduleparam.h>
-#include <linux/kernel.h>
-#include <linux/slab.h>
-#include <linux/device.h>
-
-#include "greybus.h"
-#include "gpbridge.h"
-
-struct gpbridge_host {
- struct gb_bundle *bundle;
- struct list_head devices;
-};
-
-static DEFINE_IDA(gpbridge_id);
-
-static ssize_t protocol_id_show(struct device *dev,
- struct device_attribute *attr, char *buf)
-{
- struct gpbridge_device *gpbdev = to_gpbridge_dev(dev);
-
- return sprintf(buf, "0x%02x\n", gpbdev->cport_desc->protocol_id);
-}
-static DEVICE_ATTR_RO(protocol_id);
-
-static struct attribute *gpbdev_attrs[] = {
- &dev_attr_protocol_id.attr,
- NULL,
-};
-
-ATTRIBUTE_GROUPS(gpbdev);
-
-static void gpbdev_release(struct device *dev)
-{
- struct gpbridge_device *gpbdev = to_gpbridge_dev(dev);
-
- ida_simple_remove(&gpbridge_id, gpbdev->id);
- kfree(gpbdev);
-}
-
-static struct device_type greybus_gpbdev_type = {
- .name = "gpbridge_device",
- .release = gpbdev_release,
-};
-
-static int gpbdev_uevent(struct device *dev, struct kobj_uevent_env *env)
-{
- struct gpbridge_device *gpbdev = to_gpbridge_dev(dev);
- struct greybus_descriptor_cport *cport_desc = gpbdev->cport_desc;
- struct gb_bundle *bundle = gpbdev->bundle;
- struct gb_interface *intf = bundle->intf;
- struct gb_module *module = intf->module;
- struct gb_host_device *hd = intf->hd;
-
- if (add_uevent_var(env, "BUS=%u", hd->bus_id))
- return -ENOMEM;
- if (add_uevent_var(env, "MODULE=%u", module->module_id))
- return -ENOMEM;
- if (add_uevent_var(env, "INTERFACE=%u", intf->interface_id))
- return -ENOMEM;
- if (add_uevent_var(env, "GREYBUS_ID=%08x/%08x",
- intf->vendor_id, intf->product_id))
- return -ENOMEM;
- if (add_uevent_var(env, "BUNDLE=%u", gpbdev->bundle->id))
- return -ENOMEM;
- if (add_uevent_var(env, "BUNDLE_CLASS=%02x", bundle->class))
- return -ENOMEM;
- if (add_uevent_var(env, "GPBDEV_ID=%u", gpbdev->id))
- return -ENOMEM;
- if (add_uevent_var(env, "PROTOCOL_ID=%02x", cport_desc->protocol_id))
- return -ENOMEM;
-
- return 0;
-}
-
-static const struct gpbridge_device_id *
-gpbdev_match_id(struct gpbridge_device *gpbdev, struct gpbridge_driver *gpbdrv)
-{
- const struct gpbridge_device_id *id = gpbdrv->id_table;
-
- if (!id)
- return NULL;
-
- for (; id->protocol_id; id++)
- if (id->protocol_id == gpbdev->cport_desc->protocol_id)
- return id;
-
- return NULL;
-}
-
-static int gpbdev_match(struct device *dev, struct device_driver *drv)
-{
- struct gpbridge_driver *gpbdrv = to_gpbridge_driver(drv);
- struct gpbridge_device *gpbdev = to_gpbridge_dev(dev);
- const struct gpbridge_device_id *id;
-
- id = gpbdev_match_id(gpbdev, gpbdrv);
- if (id)
- return 1;
-
- return 0;
-}
-
-static int gpbdev_probe(struct device *dev)
-{
- struct gpbridge_driver *gpbdrv = to_gpbridge_driver(dev->driver);
- struct gpbridge_device *gpbdev = to_gpbridge_dev(dev);
- const struct gpbridge_device_id *id;
-
- id = gpbdev_match_id(gpbdev, gpbdrv);
- if (!id)
- return -ENODEV;
-
- return gpbdrv->probe(gpbdev, id);
-}
-
-static int gpbdev_remove(struct device *dev)
-{
- struct gpbridge_driver *gpbdrv = to_gpbridge_driver(dev->driver);
- struct gpbridge_device *gpbdev = to_gpbridge_dev(dev);
-
- gpbdrv->remove(gpbdev);
- return 0;
-}
-
-static struct bus_type gpbridge_bus_type = {
- .name = "gpbridge",
- .match = gpbdev_match,
- .probe = gpbdev_probe,
- .remove = gpbdev_remove,
- .uevent = gpbdev_uevent,
-};
-
-int gb_gpbridge_register_driver(struct gpbridge_driver *driver,
- struct module *owner, const char *mod_name)
-{
- int retval;
-
- if (greybus_disabled())
- return -ENODEV;
-
- driver->driver.bus = &gpbridge_bus_type;
- driver->driver.name = driver->name;
- driver->driver.owner = owner;
- driver->driver.mod_name = mod_name;
-
- retval = driver_register(&driver->driver);
- if (retval)
- return retval;
-
- pr_info("registered new driver %s\n", driver->name);
- return 0;
-}
-EXPORT_SYMBOL_GPL(gb_gpbridge_register_driver);
-
-void gb_gpbridge_deregister_driver(struct gpbridge_driver *driver)
-{
- driver_unregister(&driver->driver);
-}
-EXPORT_SYMBOL_GPL(gb_gpbridge_deregister_driver);
-
-int gb_gpbridge_get_version(struct gb_connection *connection)
-{
- struct gb_protocol_version_request request;
- struct gb_protocol_version_response response;
- int retval;
-
- request.major = 1;
- request.minor = 0;
-
- retval = gb_operation_sync(connection, GB_REQUEST_TYPE_PROTOCOL_VERSION,
- &request, sizeof(request), &response,
- sizeof(response));
- if (retval)
- return retval;
-
- /* FIXME - do proper version negotiation here someday... */
-
- connection->module_major = response.major;
- connection->module_minor = response.minor;
-
- dev_dbg(&connection->hd->dev, "%s: v%u.%u\n", connection->name,
- response.major, response.minor);
-
- return 0;
-}
-EXPORT_SYMBOL_GPL(gb_gpbridge_get_version);
-
-static struct gpbridge_device *gb_gpbridge_create_dev(struct gb_bundle *bundle,
- struct greybus_descriptor_cport *cport_desc)
-{
- struct gpbridge_device *gpbdev;
- int retval;
- int id;
-
- id = ida_simple_get(&gpbridge_id, 1, 0, GFP_KERNEL);
- if (id < 0)
- return ERR_PTR(id);
-
- gpbdev = kzalloc(sizeof(*gpbdev), GFP_KERNEL);
- if (!gpbdev) {
- ida_simple_remove(&gpbridge_id, id);
- return ERR_PTR(-ENOMEM);
- }
-
- gpbdev->id = id;
- gpbdev->bundle = bundle;
- gpbdev->cport_desc = cport_desc;
- gpbdev->dev.parent = &bundle->dev;
- gpbdev->dev.bus = &gpbridge_bus_type;
- gpbdev->dev.type = &greybus_gpbdev_type;
- gpbdev->dev.groups = gpbdev_groups;
- gpbdev->dev.dma_mask = bundle->dev.dma_mask;
- dev_set_name(&gpbdev->dev, "gpb%d", id);
-
- retval = device_register(&gpbdev->dev);
- if (retval) {
- put_device(&gpbdev->dev);
- return ERR_PTR(retval);
- }
-
- return gpbdev;
-}
-
-static void gb_gpbridge_disconnect(struct gb_bundle *bundle)
-{
- struct gpbridge_host *gpb_host = greybus_get_drvdata(bundle);
- struct gpbridge_device *gpbdev, *temp;
-
- list_for_each_entry_safe(gpbdev, temp, &gpb_host->devices, list) {
- list_del(&gpbdev->list);
- device_unregister(&gpbdev->dev);
- }
-
- kfree(gpb_host);
-}
-
-static int gb_gpbridge_probe(struct gb_bundle *bundle,
- const struct greybus_bundle_id *id)
-{
- struct gpbridge_host *gpb_host;
- struct gpbridge_device *gpbdev;
- int i;
-
- if (bundle->num_cports == 0)
- return -ENODEV;
-
- gpb_host = kzalloc(sizeof(*gpb_host), GFP_KERNEL);
- if (!gpb_host)
- return -ENOMEM;
-
- gpb_host->bundle = bundle;
- INIT_LIST_HEAD(&gpb_host->devices);
- greybus_set_drvdata(bundle, gpb_host);
-
- /*
- * Create a bunch of children devices, one per cport, and bind the
- * bridged phy drivers to them.
- */
- for (i = 0; i < bundle->num_cports; ++i) {
- gpbdev = gb_gpbridge_create_dev(bundle, &bundle->cport_desc[i]);
- if (IS_ERR(gpbdev)) {
- gb_gpbridge_disconnect(bundle);
- return PTR_ERR(gpbdev);
- }
- list_add(&gpbdev->list, &gpb_host->devices);
- }
-
- return 0;
-}
-
-static const struct greybus_bundle_id gb_gpbridge_id_table[] = {
- { GREYBUS_DEVICE_CLASS(GREYBUS_CLASS_BRIDGED_PHY) },
- { },
-};
-MODULE_DEVICE_TABLE(greybus, gb_gpbridge_id_table);
-
-static struct greybus_driver gb_gpbridge_driver = {
- .name = "gpbridge",
- .probe = gb_gpbridge_probe,
- .disconnect = gb_gpbridge_disconnect,
- .id_table = gb_gpbridge_id_table,
-};
-
-static int __init gpbridge_init(void)
-{
- int retval;
-
- retval = bus_register(&gpbridge_bus_type);
- if (retval) {
- pr_err("gpbridge bus register failed (%d)\n", retval);
- return retval;
- }
-
- retval = greybus_register(&gb_gpbridge_driver);
- if (retval) {
- pr_err("error registering greybus driver\n");
- goto error_gpbridge;
- }
-
- return 0;
-
-error_gpbridge:
- bus_unregister(&gpbridge_bus_type);
- ida_destroy(&gpbridge_id);
- return retval;
-}
-module_init(gpbridge_init);
-
-static void __exit gpbridge_exit(void)
-{
- greybus_deregister(&gb_gpbridge_driver);
- bus_unregister(&gpbridge_bus_type);
- ida_destroy(&gpbridge_id);
-}
-module_exit(gpbridge_exit);
-
-MODULE_LICENSE("GPL v2");
diff --git a/drivers/staging/greybus/gpbridge.h b/drivers/staging/greybus/gpbridge.h
deleted file mode 100644
index 0cee2eb64237..000000000000
--- a/drivers/staging/greybus/gpbridge.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Greybus GPBridge phy driver
- *
- * Copyright 2016 Google Inc.
- *
- * Released under the GPLv2 only.
- */
-
-#ifndef __GPBRIDGE_H
-#define __GPBRIDGE_H
-
-struct gpbridge_device {
- u32 id;
- struct greybus_descriptor_cport *cport_desc;
- struct gb_bundle *bundle;
- struct list_head list;
- struct device dev;
-};
-#define to_gpbridge_dev(d) container_of(d, struct gpbridge_device, dev)
-
-static inline void *gb_gpbridge_get_data(struct gpbridge_device *gdev)
-{
- return dev_get_drvdata(&gdev->dev);
-}
-
-static inline void gb_gpbridge_set_data(struct gpbridge_device *gdev, void *data)
-{
- dev_set_drvdata(&gdev->dev, data);
-}
-
-struct gpbridge_device_id {
- __u8 protocol_id;
-};
-
-#define GPBRIDGE_PROTOCOL(p) \
- .protocol_id = (p),
-
-struct gpbridge_driver {
- const char *name;
- int (*probe)(struct gpbridge_device *,
- const struct gpbridge_device_id *id);
- void (*remove)(struct gpbridge_device *);
- const struct gpbridge_device_id *id_table;
-
- struct device_driver driver;
-};
-#define to_gpbridge_driver(d) container_of(d, struct gpbridge_driver, driver)
-
-int gb_gpbridge_get_version(struct gb_connection *connection);
-int gb_gpbridge_register_driver(struct gpbridge_driver *driver,
- struct module *owner, const char *mod_name);
-void gb_gpbridge_deregister_driver(struct gpbridge_driver *driver);
-
-#define gb_gpbridge_register(driver) \
- gb_gpbridge_register_driver(driver, THIS_MODULE, KBUILD_MODNAME)
-#define gb_gpbridge_deregister(driver) \
- gb_gpbridge_deregister_driver(driver)
-
-/**
- * module_gpbridge_driver() - Helper macro for registering a gpbridge driver
- * @__gpbridge_driver: gpbridge_driver structure
- *
- * Helper macro for gpbridge drivers to set up proper module init / exit
- * functions. Replaces module_init() and module_exit() and keeps people from
- * printing pointless things to the kernel log when their driver is loaded.
- */
-#define module_gpbridge_driver(__gpbridge_driver) \
- module_driver(__gpbridge_driver, gb_gpbridge_register, gb_gpbridge_deregister)
-
-#endif /* __GPBRIDGE_H */
-
diff --git a/drivers/staging/greybus/gpio.c b/drivers/staging/greybus/gpio.c
index adb213fd81b6..e1ad6802630a 100644
--- a/drivers/staging/greybus/gpio.c
+++ b/drivers/staging/greybus/gpio.c
@@ -16,7 +16,7 @@
#include <linux/mutex.h>
#include "greybus.h"
-#include "gpbridge.h"
+#include "gbphy.h"
struct gb_gpio_line {
/* The following has to be an array of line_max entries */
@@ -33,7 +33,7 @@ struct gb_gpio_line {
};
struct gb_gpio_controller {
- struct gpbridge_device *gpbdev;
+ struct gbphy_device *gbphy_dev;
struct gb_connection *connection;
u8 line_max; /* max line number */
struct gb_gpio_line *lines;
@@ -79,7 +79,7 @@ static int gb_gpio_activate_operation(struct gb_gpio_controller *ggc, u8 which)
static void gb_gpio_deactivate_operation(struct gb_gpio_controller *ggc,
u8 which)
{
- struct device *dev = &ggc->gpbdev->dev;
+ struct device *dev = &ggc->gbphy_dev->dev;
struct gb_gpio_deactivate_request request;
int ret;
@@ -97,7 +97,7 @@ static void gb_gpio_deactivate_operation(struct gb_gpio_controller *ggc,
static int gb_gpio_get_direction_operation(struct gb_gpio_controller *ggc,
u8 which)
{
- struct device *dev = &ggc->gpbdev->dev;
+ struct device *dev = &ggc->gbphy_dev->dev;
struct gb_gpio_get_direction_request request;
struct gb_gpio_get_direction_response response;
int ret;
@@ -151,7 +151,7 @@ static int gb_gpio_direction_out_operation(struct gb_gpio_controller *ggc,
static int gb_gpio_get_value_operation(struct gb_gpio_controller *ggc,
u8 which)
{
- struct device *dev = &ggc->gpbdev->dev;
+ struct device *dev = &ggc->gbphy_dev->dev;
struct gb_gpio_get_value_request request;
struct gb_gpio_get_value_response response;
int ret;
@@ -178,7 +178,7 @@ static int gb_gpio_get_value_operation(struct gb_gpio_controller *ggc,
static void gb_gpio_set_value_operation(struct gb_gpio_controller *ggc,
u8 which, bool value_high)
{
- struct device *dev = &ggc->gpbdev->dev;
+ struct device *dev = &ggc->gbphy_dev->dev;
struct gb_gpio_set_value_request request;
int ret;
@@ -217,7 +217,7 @@ static int gb_gpio_set_debounce_operation(struct gb_gpio_controller *ggc,
static void _gb_gpio_irq_mask(struct gb_gpio_controller *ggc, u8 hwirq)
{
- struct device *dev = &ggc->gpbdev->dev;
+ struct device *dev = &ggc->gbphy_dev->dev;
struct gb_gpio_irq_mask_request request;
int ret;
@@ -231,7 +231,7 @@ static void _gb_gpio_irq_mask(struct gb_gpio_controller *ggc, u8 hwirq)
static void _gb_gpio_irq_unmask(struct gb_gpio_controller *ggc, u8 hwirq)
{
- struct device *dev = &ggc->gpbdev->dev;
+ struct device *dev = &ggc->gbphy_dev->dev;
struct gb_gpio_irq_unmask_request request;
int ret;
@@ -246,7 +246,7 @@ static void _gb_gpio_irq_unmask(struct gb_gpio_controller *ggc, u8 hwirq)
static void _gb_gpio_irq_set_type(struct gb_gpio_controller *ggc,
u8 hwirq, u8 type)
{
- struct device *dev = &ggc->gpbdev->dev;
+ struct device *dev = &ggc->gbphy_dev->dev;
struct gb_gpio_irq_type_request request;
int ret;
@@ -285,7 +285,7 @@ static int gb_gpio_irq_set_type(struct irq_data *d, unsigned int type)
struct gpio_chip *chip = irq_data_to_gpio_chip(d);
struct gb_gpio_controller *ggc = gpio_chip_to_gb_gpio_controller(chip);
struct gb_gpio_line *line = &ggc->lines[d->hwirq];
- struct device *dev = &ggc->gpbdev->dev;
+ struct device *dev = &ggc->gbphy_dev->dev;
u8 irq_type;
switch (type) {
@@ -352,7 +352,7 @@ static int gb_gpio_request_handler(struct gb_operation *op)
{
struct gb_connection *connection = op->connection;
struct gb_gpio_controller *ggc = gb_connection_get_data(connection);
- struct device *dev = &ggc->gpbdev->dev;
+ struct device *dev = &ggc->gbphy_dev->dev;
struct gb_message *request;
struct gb_gpio_irq_event_request *event;
u8 type = op->type;
@@ -624,8 +624,8 @@ static int gb_gpio_to_irq(struct gpio_chip *chip, unsigned offset)
return irq_find_mapping(ggc->irqdomain, offset);
}
-static int gb_gpio_probe(struct gpbridge_device *gpbdev,
- const struct gpbridge_device_id *id)
+static int gb_gpio_probe(struct gbphy_device *gbphy_dev,
+ const struct gbphy_device_id *id)
{
struct gb_connection *connection;
struct gb_gpio_controller *ggc;
@@ -637,8 +637,8 @@ static int gb_gpio_probe(struct gpbridge_device *gpbdev,
if (!ggc)
return -ENOMEM;
- connection = gb_connection_create(gpbdev->bundle,
- le16_to_cpu(gpbdev->cport_desc->id),
+ connection = gb_connection_create(gbphy_dev->bundle,
+ le16_to_cpu(gbphy_dev->cport_desc->id),
gb_gpio_request_handler);
if (IS_ERR(connection)) {
ret = PTR_ERR(connection);
@@ -647,14 +647,14 @@ static int gb_gpio_probe(struct gpbridge_device *gpbdev,
ggc->connection = connection;
gb_connection_set_data(connection, ggc);
- ggc->gpbdev = gpbdev;
- gb_gpbridge_set_data(gpbdev, ggc);
+ ggc->gbphy_dev = gbphy_dev;
+ gb_gbphy_set_data(gbphy_dev, ggc);
ret = gb_connection_enable_tx(connection);
if (ret)
goto exit_connection_destroy;
- ret = gb_gpbridge_get_version(connection);
+ ret = gb_gbphy_get_version(connection);
if (ret)
goto exit_connection_disable;
@@ -676,9 +676,9 @@ static int gb_gpio_probe(struct gpbridge_device *gpbdev,
gpio->label = "greybus_gpio";
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5, 0)
- gpio->parent = &gpbdev->dev;
+ gpio->parent = &gbphy_dev->dev;
#else
- gpio->dev = &gpbdev->dev;
+ gpio->dev = &gbphy_dev->dev;
#endif
gpio->owner = THIS_MODULE;
@@ -729,9 +729,9 @@ exit_ggc_free:
return ret;
}
-static void gb_gpio_remove(struct gpbridge_device *gpbdev)
+static void gb_gpio_remove(struct gbphy_device *gbphy_dev)
{
- struct gb_gpio_controller *ggc = gb_gpbridge_get_data(gpbdev);
+ struct gb_gpio_controller *ggc = gb_gbphy_get_data(gbphy_dev);
struct gb_connection *connection = ggc->connection;
gb_connection_disable_rx(connection);
@@ -743,18 +743,18 @@ static void gb_gpio_remove(struct gpbridge_device *gpbdev)
kfree(ggc);
}
-static const struct gpbridge_device_id gb_gpio_id_table[] = {
- { GPBRIDGE_PROTOCOL(GREYBUS_PROTOCOL_GPIO) },
+static const struct gbphy_device_id gb_gpio_id_table[] = {
+ { GBPHY_PROTOCOL(GREYBUS_PROTOCOL_GPIO) },
{ },
};
-MODULE_DEVICE_TABLE(gpbridge, gb_gpio_id_table);
+MODULE_DEVICE_TABLE(gbphy, gb_gpio_id_table);
-static struct gpbridge_driver gpio_driver = {
+static struct gbphy_driver gpio_driver = {
.name = "gpio",
.probe = gb_gpio_probe,
.remove = gb_gpio_remove,
.id_table = gb_gpio_id_table,
};
-module_gpbridge_driver(gpio_driver);
+module_gbphy_driver(gpio_driver);
MODULE_LICENSE("GPL v2");
diff --git a/drivers/staging/greybus/i2c.c b/drivers/staging/greybus/i2c.c
index 69d6f07c0822..6c14e6776adf 100644
--- a/drivers/staging/greybus/i2c.c
+++ b/drivers/staging/greybus/i2c.c
@@ -13,11 +13,11 @@
#include <linux/i2c.h>