1
0
Fork 0

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>
hifive-unleashed-5.1
Sandeep Patil 2016-05-19 08:52:39 -07:00 committed by Greg Kroah-Hartman
parent e16715c135
commit e54b106dd1
14 changed files with 555 additions and 555 deletions

View File

@ -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

View File

@ -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");

View File

@ -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 */

View File

@ -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");

View File

@ -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 */

View File

@ -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");

View File

@ -13,11 +13,11 @@
#include <linux/i2c.h>
#include "greybus.h"
#include "gpbridge.h"
#include "gbphy.h"
struct gb_i2c_device {
struct gb_connection *connection;
struct gpbridge_device *gpbdev;
struct gbphy_device *gbphy_dev;
u32 functionality;
@ -85,7 +85,7 @@ gb_i2c_operation_create(struct gb_connection *connection,
u32 i;
if (msg_count > (u32)U16_MAX) {
dev_err(&gb_i2c_dev->gpbdev->dev, "msg_count (%u) too big\n",
dev_err(&gb_i2c_dev->gbphy_dev->dev, "msg_count (%u) too big\n",
msg_count);
return NULL;
}
@ -168,7 +168,7 @@ static int gb_i2c_transfer_operation(struct gb_i2c_device *gb_i2c_dev,
struct i2c_msg *msgs, u32 msg_count)
{
struct gb_connection *connection = gb_i2c_dev->connection;
struct device *dev = &gb_i2c_dev->gpbdev->dev;
struct device *dev = &gb_i2c_dev->gbphy_dev->dev;
struct gb_operation *operation;
int ret;
@ -242,8 +242,8 @@ static int gb_i2c_device_setup(struct gb_i2c_device *gb_i2c_dev)
return gb_i2c_functionality_operation(gb_i2c_dev);
}
static int gb_i2c_probe(struct gpbridge_device *gpbdev,
const struct gpbridge_device_id *id)
static int gb_i2c_probe(struct gbphy_device *gbphy_dev,
const struct gbphy_device_id *id)
{
struct gb_connection *connection;
struct gb_i2c_device *gb_i2c_dev;
@ -254,8 +254,8 @@ static int gb_i2c_probe(struct gpbridge_device *gpbdev,
if (!gb_i2c_dev)
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),
NULL);
if (IS_ERR(connection)) {
ret = PTR_ERR(connection);
@ -264,14 +264,14 @@ static int gb_i2c_probe(struct gpbridge_device *gpbdev,
gb_i2c_dev->connection = connection;
gb_connection_set_data(connection, gb_i2c_dev);
gb_i2c_dev->gpbdev = gpbdev;
gb_gpbridge_set_data(gpbdev, gb_i2c_dev);
gb_i2c_dev->gbphy_dev = gbphy_dev;
gb_gbphy_set_data(gbphy_dev, gb_i2c_dev);
ret = gb_connection_enable(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;
@ -286,7 +286,7 @@ static int gb_i2c_probe(struct gpbridge_device *gpbdev,
adapter->algo = &gb_i2c_algorithm;
/* adapter->algo_data = what? */
adapter->dev.parent = &gpbdev->dev;
adapter->dev.parent = &gbphy_dev->dev;
snprintf(adapter->name, sizeof(adapter->name), "Greybus i2c adapter");
i2c_set_adapdata(adapter, gb_i2c_dev);
@ -306,9 +306,9 @@ exit_i2cdev_free:
return ret;
}
static void gb_i2c_remove(struct gpbridge_device *gpbdev)
static void gb_i2c_remove(struct gbphy_device *gbphy_dev)
{
struct gb_i2c_device *gb_i2c_dev = gb_gpbridge_get_data(gpbdev);
struct gb_i2c_device *gb_i2c_dev = gb_gbphy_get_data(gbphy_dev);
struct gb_connection *connection = gb_i2c_dev->connection;
i2c_del_adapter(&gb_i2c_dev->adapter);
@ -317,18 +317,18 @@ static void gb_i2c_remove(struct gpbridge_device *gpbdev)
kfree(gb_i2c_dev);
}
static const struct gpbridge_device_id gb_i2c_id_table[] = {
{ GPBRIDGE_PROTOCOL(GREYBUS_PROTOCOL_I2C) },
static const struct gbphy_device_id gb_i2c_id_table[] = {
{ GBPHY_PROTOCOL(GREYBUS_PROTOCOL_I2C) },
{ },
};
MODULE_DEVICE_TABLE(gpbridge, gb_i2c_id_table);
MODULE_DEVICE_TABLE(gbphy, gb_i2c_id_table);
static struct gpbridge_driver i2c_driver = {
static struct gbphy_driver i2c_driver = {
.name = "i2c",
.probe = gb_i2c_probe,
.remove = gb_i2c_remove,
.id_table = gb_i2c_id_table,
};
module_gpbridge_driver(i2c_driver);
module_gbphy_driver(i2c_driver);
MODULE_LICENSE("GPL v2");

View File

@ -32,7 +32,7 @@
#define TOSHIBA_DMID 0x0126
#define TOSHIBA_ES2_BRIDGE_DPID 0x1000
#define TOSHIBA_ES3_APBRIDGE_DPID 0x1001
#define TOSHIBA_ES3_GPBRIDGE_DPID 0x1002
#define TOSHIBA_ES3_GBPHY_DPID 0x1002
static int gb_interface_dme_attr_get(struct gb_interface *intf,

View File

@ -86,7 +86,7 @@ struct gb_loopback {
struct gb_loopback_stats throughput;
struct gb_loopback_stats requests_per_second;
struct gb_loopback_stats apbridge_unipro_latency;
struct gb_loopback_stats gpbridge_firmware_latency;
struct gb_loopback_stats gbphy_firmware_latency;
int type;
int async;
@ -106,7 +106,7 @@ struct gb_loopback {
u32 lbid;
u64 elapsed_nsecs;
u32 apbridge_latency_ts;
u32 gpbridge_latency_ts;
u32 gbphy_latency_ts;
u32 send_count;
};
@ -290,7 +290,7 @@ gb_loopback_stats_attrs(throughput);
/* Latency across the UniPro link from APBridge's perspective */
gb_loopback_stats_attrs(apbridge_unipro_latency);
/* Firmware induced overhead in the GPBridge */
gb_loopback_stats_attrs(gpbridge_firmware_latency);
gb_loopback_stats_attrs(gbphy_firmware_latency);
/* Number of errors encountered during loop */
gb_loopback_ro_attr(error);
@ -340,9 +340,9 @@ static struct attribute *loopback_attrs[] = {
&dev_attr_apbridge_unipro_latency_min.attr,
&dev_attr_apbridge_unipro_latency_max.attr,
&dev_attr_apbridge_unipro_latency_avg.attr,
&dev_attr_gpbridge_firmware_latency_min.attr,
&dev_attr_gpbridge_firmware_latency_max.attr,
&dev_attr_gpbridge_firmware_latency_avg.attr,
&dev_attr_gbphy_firmware_latency_min.attr,
&dev_attr_gbphy_firmware_latency_max.attr,
&dev_attr_gbphy_firmware_latency_avg.attr,
&dev_attr_type.attr,
&dev_attr_size.attr,
&dev_attr_us_wait.attr,
@ -670,7 +670,7 @@ static int gb_loopback_sync_transfer(struct gb_loopback *gb, u32 len)
int retval;
gb->apbridge_latency_ts = 0;
gb->gpbridge_latency_ts = 0;
gb->gbphy_latency_ts = 0;
request = kmalloc(len + sizeof(*request), GFP_KERNEL);
if (!request)
@ -696,7 +696,7 @@ static int gb_loopback_sync_transfer(struct gb_loopback *gb, u32 len)
retval = -EREMOTEIO;
}
gb->apbridge_latency_ts = (u32)__le32_to_cpu(response->reserved0);
gb->gpbridge_latency_ts = (u32)__le32_to_cpu(response->reserved1);
gb->gbphy_latency_ts = (u32)__le32_to_cpu(response->reserved1);
gb_error:
kfree(request);
@ -752,7 +752,7 @@ static int gb_loopback_async_transfer_complete(
} else {
gb->apbridge_latency_ts =
(u32)__le32_to_cpu(response->reserved0);
gb->gpbridge_latency_ts =
gb->gbphy_latency_ts =
(u32)__le32_to_cpu(response->reserved1);
}
@ -850,12 +850,12 @@ static void gb_loopback_reset_stats(struct gb_loopback *gb)
sizeof(struct gb_loopback_stats));
memcpy(&gb->apbridge_unipro_latency, &reset,
sizeof(struct gb_loopback_stats));
memcpy(&gb->gpbridge_firmware_latency, &reset,
memcpy(&gb->gbphy_firmware_latency, &reset,
sizeof(struct gb_loopback_stats));
/* Should be initialized at least once per transaction set */
gb->apbridge_latency_ts = 0;
gb->gpbridge_latency_ts = 0;
gb->gbphy_latency_ts = 0;
memset(&gb->ts, 0, sizeof(struct timeval));
}
@ -931,8 +931,8 @@ static void gb_loopback_calculate_latency_stats(struct gb_loopback *gb)
/* Log the firmware supplied latency values */
gb_loopback_update_stats(&gb->apbridge_unipro_latency,
gb->apbridge_latency_ts);
gb_loopback_update_stats(&gb->gpbridge_firmware_latency,
gb->gpbridge_latency_ts);
gb_loopback_update_stats(&gb->gbphy_firmware_latency,
gb->gbphy_latency_ts);
}
static void gb_loopback_calculate_stats(struct gb_loopback *gb, bool error)

View File

@ -13,7 +13,7 @@
#include <linux/pwm.h>
#include "greybus.h"
#include "gpbridge.h"
#include "gbphy.h"
struct gb_pwm_chip {
struct gb_connection *connection;
@ -178,8 +178,8 @@ static const struct pwm_ops gb_pwm_ops = {
.owner = THIS_MODULE,
};
static int gb_pwm_probe(struct gpbridge_device *gpbdev,
const struct gpbridge_device_id *id)
static int gb_pwm_probe(struct gbphy_device *gbphy_dev,
const struct gbphy_device_id *id)
{
struct gb_connection *connection;
struct gb_pwm_chip *pwmc;
@ -190,8 +190,8 @@ static int gb_pwm_probe(struct gpbridge_device *gpbdev,
if (!pwmc)
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),
NULL);
if (IS_ERR(connection)) {
ret = PTR_ERR(connection);
@ -200,13 +200,13 @@ static int gb_pwm_probe(struct gpbridge_device *gpbdev,
pwmc->connection = connection;
gb_connection_set_data(connection, pwmc);
gb_gpbridge_set_data(gpbdev, pwmc);
gb_gbphy_set_data(gbphy_dev, pwmc);
ret = gb_connection_enable(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;
@ -217,7 +217,7 @@ static int gb_pwm_probe(struct gpbridge_device *gpbdev,
pwm = &pwmc->chip;
pwm->dev = &gpbdev->dev;
pwm->dev = &gbphy_dev->dev;
pwm->ops = &gb_pwm_ops;
pwm->base = -1; /* Allocate base dynamically */
pwm->npwm = pwmc->pwm_max + 1;
@ -225,7 +225,7 @@ static int gb_pwm_probe(struct gpbridge_device *gpbdev,
ret = pwmchip_add(pwm);
if (ret) {
dev_err(&gpbdev->dev,
dev_err(&gbphy_dev->dev,
"failed to register PWM: %d\n", ret);
goto exit_connection_disable;
}
@ -241,9 +241,9 @@ exit_pwmc_free:
return ret;
}
static void gb_pwm_remove(struct gpbridge_device *gpbdev)
static void gb_pwm_remove(struct gbphy_device *gbphy_dev)
{
struct gb_pwm_chip *pwmc = gb_gpbridge_get_data(gpbdev);
struct gb_pwm_chip *pwmc = gb_gbphy_get_data(gbphy_dev);
struct gb_connection *connection = pwmc->connection;
pwmchip_remove(&pwmc->chip);
@ -252,18 +252,18 @@ static void gb_pwm_remove(struct gpbridge_device *gpbdev)
kfree(pwmc);
}
static const struct gpbridge_device_id gb_pwm_id_table[] = {
{ GPBRIDGE_PROTOCOL(GREYBUS_PROTOCOL_PWM) },
static const struct gbphy_device_id gb_pwm_id_table[] = {
{ GBPHY_PROTOCOL(GREYBUS_PROTOCOL_PWM) },
{ },
};
MODULE_DEVICE_TABLE(gpbridge, gb_pwm_id_table);
MODULE_DEVICE_TABLE(gbphy, gb_pwm_id_table);
static struct gpbridge_driver pwm_driver = {
static struct gbphy_driver pwm_driver = {
.name = "pwm",
.probe = gb_pwm_probe,
.remove = gb_pwm_remove,
.id_table = gb_pwm_id_table,
};
module_gpbridge_driver(pwm_driver);
module_gbphy_driver(pwm_driver);
MODULE_LICENSE("GPL v2");

View File

@ -15,11 +15,11 @@
#include <linux/workqueue.h>
#include "greybus.h"
#include "gpbridge.h"
#include "gbphy.h"
struct gb_sdio_host {
struct gb_connection *connection;
struct gpbridge_device *gpbdev;
struct gbphy_device *gbphy_dev;
struct mmc_host *mmc;
struct mmc_request *mrq;
struct mutex lock; /* lock for this host */
@ -708,8 +708,8 @@ static const struct mmc_host_ops gb_sdio_ops = {
.get_cd = gb_mmc_get_cd,
};
static int gb_sdio_probe(struct gpbridge_device *gpbdev,
const struct gpbridge_device_id *id)
static int gb_sdio_probe(struct gbphy_device *gbphy_dev,
const struct gbphy_device_id *id)
{
struct gb_connection *connection;
struct mmc_host *mmc;
@ -717,12 +717,12 @@ static int gb_sdio_probe(struct gpbridge_device *gpbdev,
size_t max_buffer;
int ret = 0;
mmc = mmc_alloc_host(sizeof(*host), &gpbdev->dev);
mmc = mmc_alloc_host(sizeof(*host), &gbphy_dev->dev);
if (!mmc)
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_sdio_request_handler);
if (IS_ERR(connection)) {
ret = PTR_ERR(connection);
@ -735,14 +735,14 @@ static int gb_sdio_probe(struct gpbridge_device *gpbdev,
host->connection = connection;
gb_connection_set_data(connection, host);
host->gpbdev = gpbdev;
gb_gpbridge_set_data(gpbdev, host);
host->gbphy_dev = gbphy_dev;
gb_gbphy_set_data(gbphy_dev, host);
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;
@ -767,7 +767,7 @@ static int gb_sdio_probe(struct gpbridge_device *gpbdev,
mutex_init(&host->lock);
spin_lock_init(&host->xfer);
host->mrq_workqueue = alloc_workqueue("mmc-%s", 0, 1,
dev_name(&gpbdev->dev));
dev_name(&gbphy_dev->dev));
if (!host->mrq_workqueue) {
ret = -ENOMEM;
goto exit_buf_free;
@ -801,9 +801,9 @@ exit_mmc_free:
return ret;
}
static void gb_sdio_remove(struct gpbridge_device *gpbdev)
static void gb_sdio_remove(struct gbphy_device *gbphy_dev)
{
struct gb_sdio_host *host = gb_gpbridge_get_data(gpbdev);
struct gb_sdio_host *host = gb_gbphy_get_data(gbphy_dev);
struct gb_connection *connection = host->connection;
struct mmc_host *mmc;
@ -823,18 +823,18 @@ static void gb_sdio_remove(struct gpbridge_device *gpbdev)
mmc_free_host(mmc);
}
static const struct gpbridge_device_id gb_sdio_id_table[] = {
{ GPBRIDGE_PROTOCOL(GREYBUS_PROTOCOL_SDIO) },
static const struct gbphy_device_id gb_sdio_id_table[] = {
{ GBPHY_PROTOCOL(GREYBUS_PROTOCOL_SDIO) },
{ },
};
MODULE_DEVICE_TABLE(gpbridge, gb_sdio_id_table);
MODULE_DEVICE_TABLE(gbphy, gb_sdio_id_table);
static struct gpbridge_driver sdio_driver = {
static struct gbphy_driver sdio_driver = {
.name = "sdio",
.probe = gb_sdio_probe,
.remove = gb_sdio_remove,
.id_table = gb_sdio_id_table,
};
module_gpbridge_driver(sdio_driver);
module_gbphy_driver(sdio_driver);
MODULE_LICENSE("GPL v2");

View File

@ -10,17 +10,17 @@
#include <linux/module.h>
#include "greybus.h"
#include "gpbridge.h"
#include "gbphy.h"
#include "spilib.h"
static int gb_spi_probe(struct gpbridge_device *gpbdev,
const struct gpbridge_device_id *id)
static int gb_spi_probe(struct gbphy_device *gbphy_dev,
const struct gbphy_device_id *id)
{
struct gb_connection *connection;
int ret;
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),
NULL);
if (IS_ERR(connection))
return PTR_ERR(connection);
@ -29,15 +29,15 @@ static int gb_spi_probe(struct gpbridge_device *gpbdev,
if (ret)
goto exit_connection_destroy;
ret = gb_gpbridge_get_version(connection);
ret = gb_gbphy_get_version(connection);
if (ret)
goto exit_connection_disable;
ret = gb_spilib_master_init(connection, &gpbdev->dev);
ret = gb_spilib_master_init(connection, &gbphy_dev->dev);
if (ret)
goto exit_connection_disable;
gb_gpbridge_set_data(gpbdev, connection);
gb_gbphy_set_data(gbphy_dev, connection);
return 0;
@ -49,27 +49,27 @@ exit_connection_destroy:
return ret;
}
static void gb_spi_remove(struct gpbridge_device *gpbdev)
static void gb_spi_remove(struct gbphy_device *gbphy_dev)
{
struct gb_connection *connection = gb_gpbridge_get_data(gpbdev);
struct gb_connection *connection = gb_gbphy_get_data(gbphy_dev);
gb_spilib_master_exit(connection);
gb_connection_disable(connection);
gb_connection_destroy(connection);
}
static const struct gpbridge_device_id gb_spi_id_table[] = {
{ GPBRIDGE_PROTOCOL(GREYBUS_PROTOCOL_SPI) },
static const struct gbphy_device_id gb_spi_id_table[] = {
{ GBPHY_PROTOCOL(GREYBUS_PROTOCOL_SPI) },
{ },
};
MODULE_DEVICE_TABLE(gpbridge, gb_spi_id_table);
MODULE_DEVICE_TABLE(gbphy, gb_spi_id_table);
static struct gpbridge_driver spi_driver = {
static struct gbphy_driver spi_driver = {
.name = "spi",
.probe = gb_spi_probe,
.remove = gb_spi_remove,
.id_table = gb_spi_id_table,
};
module_gpbridge_driver(spi_driver);
module_gbphy_driver(spi_driver);
MODULE_LICENSE("GPL v2");

View File

@ -29,7 +29,7 @@
#include <linux/kdev_t.h>
#include "greybus.h"
#include "gpbridge.h"
#include "gbphy.h"
#define GB_NUM_MINORS 16 /* 16 is is more than enough */
#define GB_NAME "ttyGB"
@ -42,7 +42,7 @@ struct gb_tty_line_coding {
};
struct gb_tty {
struct gpbridge_device *gpbdev;
struct gbphy_device *gbphy_dev;
struct tty_port port;
void *buffer;
size_t buffer_payload_max;
@ -78,7 +78,7 @@ static int gb_uart_receive_data_handler(struct gb_operation *op)
unsigned long tty_flags = TTY_NORMAL;
if (request->payload_size < sizeof(*receive_data)) {
dev_err(&gb_tty->gpbdev->dev,
dev_err(&gb_tty->gbphy_dev->dev,
"short receive-data request received (%zu < %zu)\n",
request->payload_size, sizeof(*receive_data));
return -EINVAL;
@ -88,7 +88,7 @@ static int gb_uart_receive_data_handler(struct gb_operation *op)
recv_data_size = le16_to_cpu(receive_data->size);
if (recv_data_size != request->payload_size - sizeof(*receive_data)) {
dev_err(&gb_tty->gpbdev->dev,
dev_err(&gb_tty->gbphy_dev->dev,
"malformed receive-data request received (%u != %zu)\n",
recv_data_size,
request->payload_size - sizeof(*receive_data));
@ -113,7 +113,7 @@ static int gb_uart_receive_data_handler(struct gb_operation *op)
count = tty_insert_flip_string_fixed_flag(port, receive_data->data,
tty_flags, recv_data_size);
if (count != recv_data_size) {
dev_err(&gb_tty->gpbdev->dev,
dev_err(&gb_tty->gbphy_dev->dev,
"UART: RX 0x%08x bytes only wrote 0x%08x\n",
recv_data_size, count);
}
@ -130,7 +130,7 @@ static int gb_uart_serial_state_handler(struct gb_operation *op)
struct gb_uart_serial_state_request *serial_state;
if (request->payload_size < sizeof(*serial_state)) {
dev_err(&gb_tty->gpbdev->dev,
dev_err(&gb_tty->gbphy_dev->dev,
"short serial-state event received (%zu < %zu)\n",
request->payload_size, sizeof(*serial_state));
return -EINVAL;
@ -157,7 +157,7 @@ static int gb_uart_request_handler(struct gb_operation *op)
ret = gb_uart_serial_state_handler(op);
break;
default:
dev_err(&gb_tty->gpbdev->dev,
dev_err(&gb_tty->gbphy_dev->dev,
"unsupported unsolicited request: 0x%02x\n", type);
ret = -EINVAL;
}
@ -211,7 +211,7 @@ static int send_break(struct gb_tty *gb_tty, u8 state)
struct gb_uart_set_break_request request;
if ((state != 0) && (state != 1)) {
dev_err(&gb_tty->gpbdev->dev,
dev_err(&gb_tty->gbphy_dev->dev,
"invalid break state of %d\n", state);
return -EINVAL;
}
@ -619,8 +619,8 @@ static const struct tty_operations gb_ops = {
static struct tty_port_operations null_ops = { };
static int gb_uart_probe(struct gpbridge_device *gpbdev,
const struct gpbridge_device_id *id)
static int gb_uart_probe(struct gbphy_device *gbphy_dev,
const struct gbphy_device_id *id)
{
struct gb_connection *connection;
size_t max_payload;
@ -633,8 +633,8 @@ static int gb_uart_probe(struct gpbridge_device *gpbdev,
if (!gb_tty)
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_uart_request_handler);
if (IS_ERR(connection)) {
retval = PTR_ERR(connection);
@ -678,15 +678,15 @@ static int gb_uart_probe(struct gpbridge_device *gpbdev,
gb_tty->port.ops = &null_ops;
gb_tty->connection = connection;
gb_tty->gpbdev = gpbdev;
gb_tty->gbphy_dev = gbphy_dev;
gb_connection_set_data(connection, gb_tty);
gb_gpbridge_set_data(gpbdev, gb_tty);
gb_gbphy_set_data(gbphy_dev, gb_tty);
retval = gb_connection_enable_tx(connection);
if (retval)
goto exit_release_minor;
retval = gb_gpbridge_get_version(connection);
retval = gb_gbphy_get_version(connection);
if (retval)
goto exit_connection_disable;
@ -704,7 +704,7 @@ static int gb_uart_probe(struct gpbridge_device *gpbdev,
goto exit_connection_disable;
tty_dev = tty_port_register_device(&gb_tty->port, gb_tty_driver, minor,
&gpbdev->dev);
&gbphy_dev->dev);
if (IS_ERR(tty_dev)) {
retval = PTR_ERR(tty_dev);
goto exit_connection_disable;
@ -727,9 +727,9 @@ exit_tty_free:
return retval;
}
static void gb_uart_remove(struct gpbridge_device *gpbdev)
static void gb_uart_remove(struct gbphy_device *gbphy_dev)
{
struct gb_tty *gb_tty = gb_gpbridge_get_data(gpbdev);
struct gb_tty *gb_tty = gb_gbphy_get_data(gbphy_dev);
struct gb_connection *connection = gb_tty->connection;
struct tty_struct *tty;
@ -800,13 +800,13 @@ static void gb_tty_exit(void)
idr_destroy(&tty_minors);
}
static const struct gpbridge_device_id gb_uart_id_table[] = {
{ GPBRIDGE_PROTOCOL(GREYBUS_PROTOCOL_UART) },
static const struct gbphy_device_id gb_uart_id_table[] = {
{ GBPHY_PROTOCOL(GREYBUS_PROTOCOL_UART) },
{ },
};
MODULE_DEVICE_TABLE(gpbridge, gb_uart_id_table);
MODULE_DEVICE_TABLE(gbphy, gb_uart_id_table);
static struct gpbridge_driver uart_driver = {
static struct gbphy_driver uart_driver = {
.name = "uart",
.probe = gb_uart_probe,
.remove = gb_uart_remove,
@ -821,7 +821,7 @@ static int gb_uart_driver_init(void)
if (ret)
return ret;
ret = gb_gpbridge_register(&uart_driver);
ret = gb_gbphy_register(&uart_driver);
if (ret) {
gb_tty_exit();
return ret;
@ -833,7 +833,7 @@ module_init(gb_uart_driver_init);
static void gb_uart_driver_exit(void)
{
gb_gpbridge_deregister(&uart_driver);
gb_gbphy_deregister(&uart_driver);
gb_tty_exit();
}

View File

@ -14,7 +14,7 @@
#include <linux/usb/hcd.h>
#include "greybus.h"
#include "gpbridge.h"
#include "gbphy.h"
/* Version of the Greybus USB protocol we support */
#define GB_USB_VERSION_MAJOR 0x00
@ -38,7 +38,7 @@ struct gb_usb_hub_control_response {
struct gb_usb_device {
struct gb_connection *connection;
struct gpbridge_device *gpbdev;
struct gbphy_device *gbphy_dev;
};
static inline struct gb_usb_device *to_gb_usb_device(struct usb_hcd *hcd)
@ -59,7 +59,7 @@ static void hcd_stop(struct usb_hcd *hcd)
ret = gb_operation_sync(dev->connection, GB_USB_TYPE_HCD_STOP,
NULL, 0, NULL, 0);
if (ret)
dev_err(&dev->gpbdev->dev, "HCD stop failed '%d'\n", ret);
dev_err(&dev->gbphy_dev->dev, "HCD stop failed '%d'\n", ret);
}
static int hcd_start(struct usb_hcd *hcd)
@ -71,7 +71,7 @@ static int hcd_start(struct usb_hcd *hcd)
ret = gb_operation_sync(dev->connection, GB_USB_TYPE_HCD_START,
NULL, 0, NULL, 0);
if (ret) {
dev_err(&dev->gpbdev->dev, "HCD start failed '%d'\n", ret);
dev_err(&dev->gbphy_dev->dev, "HCD start failed '%d'\n", ret);
return ret;
}
@ -161,11 +161,11 @@ static struct hc_driver usb_gb_hc_driver = {
.hub_control = hub_control,
};
static int gb_usb_probe(struct gpbridge_device *gpbdev,
const struct gpbridge_device_id *id)
static int gb_usb_probe(struct gbphy_device *gbphy_dev,
const struct gbphy_device_id *id)
{
struct gb_connection *connection;
struct device *dev = &gpbdev->dev;
struct device *dev = &gbphy_dev->dev;
struct gb_usb_device *gb_usb_dev;
struct usb_hcd *hcd;
int retval;
@ -174,8 +174,8 @@ static int gb_usb_probe(struct gpbridge_device *gpbdev,
if (!hcd)
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),
NULL);
if (IS_ERR(connection)) {
retval = PTR_ERR(connection);
@ -185,8 +185,8 @@ static int gb_usb_probe(struct gpbridge_device *gpbdev,
gb_usb_dev = to_gb_usb_device(hcd);
gb_usb_dev->connection = connection;
gb_connection_set_data(connection, gb_usb_dev);
gb_usb_dev->gpbdev = gpbdev;
gb_gpbridge_set_data(gpbdev, gb_usb_dev);
gb_usb_dev->gbphy_dev = gbphy_dev;
gb_gbphy_set_data(gbphy_dev, gb_usb_dev);
hcd->has_tt = 1;
@ -194,7 +194,7 @@ static int gb_usb_probe(struct gpbridge_device *gpbdev,
if (retval)
goto exit_connection_destroy;
retval = gb_gpbridge_get_version(connection);
retval = gb_gbphy_get_version(connection);
if (retval)
goto exit_connection_disable;
@ -226,9 +226,9 @@ exit_usb_put:
return retval;
}
static void gb_usb_remove(struct gpbridge_device *gpbdev)
static void gb_usb_remove(struct gbphy_device *gbphy_dev)
{
struct gb_usb_device *gb_usb_dev = gb_gpbridge_get_data(gpbdev);
struct gb_usb_device *gb_usb_dev = gb_gbphy_get_data(gbphy_dev);
struct gb_connection *connection = gb_usb_dev->connection;
struct usb_hcd *hcd = gb_usb_device_to_hcd(gb_usb_dev);
@ -238,18 +238,18 @@ static void gb_usb_remove(struct gpbridge_device *gpbdev)
usb_put_hcd(hcd);
}
static const struct gpbridge_device_id gb_usb_id_table[] = {
{ GPBRIDGE_PROTOCOL(GREYBUS_PROTOCOL_USB) },
static const struct gbphy_device_id gb_usb_id_table[] = {
{ GBPHY_PROTOCOL(GREYBUS_PROTOCOL_USB) },
{ },
};
MODULE_DEVICE_TABLE(gpbridge, gb_usb_id_table);
MODULE_DEVICE_TABLE(gbphy, gb_usb_id_table);
static struct gpbridge_driver usb_driver = {
static struct gbphy_driver usb_driver = {
.name = "usb",
.probe = gb_usb_probe,
.remove = gb_usb_remove,
.id_table = gb_usb_id_table,
};
module_gpbridge_driver(usb_driver);
module_gbphy_driver(usb_driver);
MODULE_LICENSE("GPL v2");