Commit e54b106d authored by Sandeep Patil's avatar Sandeep Patil Committed by Greg Kroah-Hartman
Browse files

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: default avatarSandeep Patil <patil_sandeep@projectara.com>
Suggested-by: default avatarGreg Kroah-Hartman <gregkh@google.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@google.com>
parent e16715c1
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -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
+330 −0
Original line number Diff line number Diff line
/*
 * Greybus GP Bridge driver
 * Greybus Bridged-Phy Bus driver
 *
 * Copyright 2014 Google Inc.
 * Copyright 2014 Linaro Ltd.
@@ -17,49 +17,49 @@
#include <linux/device.h>

#include "greybus.h"
#include "gpbridge.h"
#include "gbphy.h"

struct gpbridge_host {
struct gbphy_host {
	struct gb_bundle *bundle;
	struct list_head devices;
};

static DEFINE_IDA(gpbridge_id);
static DEFINE_IDA(gbphy_id);

static ssize_t protocol_id_show(struct device *dev,
				 struct device_attribute *attr, char *buf)
{
	struct gpbridge_device *gpbdev = to_gpbridge_dev(dev);
	struct gbphy_device *gbphy_dev = to_gbphy_dev(dev);

	return sprintf(buf, "0x%02x\n", gpbdev->cport_desc->protocol_id);
	return sprintf(buf, "0x%02x\n", gbphy_dev->cport_desc->protocol_id);
}
static DEVICE_ATTR_RO(protocol_id);

static struct attribute *gpbdev_attrs[] = {
static struct attribute *gbphy_dev_attrs[] = {
	&dev_attr_protocol_id.attr,
	NULL,
};

ATTRIBUTE_GROUPS(gpbdev);
ATTRIBUTE_GROUPS(gbphy_dev);

static void gpbdev_release(struct device *dev)
static void gbphy_dev_release(struct device *dev)
{
	struct gpbridge_device *gpbdev = to_gpbridge_dev(dev);
	struct gbphy_device *gbphy_dev = to_gbphy_dev(dev);

	ida_simple_remove(&gpbridge_id, gpbdev->id);
	kfree(gpbdev);
	ida_simple_remove(&gbphy_id, gbphy_dev->id);
	kfree(gbphy_dev);
}

static struct device_type greybus_gpbdev_type = {
	.name	 =	"gpbridge_device",
	.release =	gpbdev_release,
static struct device_type greybus_gbphy_dev_type = {
	.name	 =	"gbphy_device",
	.release =	gbphy_dev_release,
};

static int gpbdev_uevent(struct device *dev, struct kobj_uevent_env *env)
static int gbphy_dev_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 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;
@@ -73,11 +73,11 @@ static int gpbdev_uevent(struct device *dev, struct kobj_uevent_env *env)
	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))
	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, "GPBDEV_ID=%u", gpbdev->id))
	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;
@@ -85,65 +85,65 @@ static int gpbdev_uevent(struct device *dev, struct kobj_uevent_env *env)
	return 0;
}

static const struct gpbridge_device_id *
gpbdev_match_id(struct gpbridge_device *gpbdev, struct gpbridge_driver *gpbdrv)
static const struct gbphy_device_id *
gbphy_dev_match_id(struct gbphy_device *gbphy_dev, struct gbphy_driver *gbphy_drv)
{
	const struct gpbridge_device_id *id = gpbdrv->id_table;
	const struct gbphy_device_id *id = gbphy_drv->id_table;

	if (!id)
		return NULL;

	for (; id->protocol_id; id++)
		if (id->protocol_id == gpbdev->cport_desc->protocol_id)
		if (id->protocol_id == gbphy_dev->cport_desc->protocol_id)
			return id;

	return NULL;
}

static int gpbdev_match(struct device *dev, struct device_driver *drv)
static int gbphy_dev_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;
	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 = gpbdev_match_id(gpbdev, gpbdrv);
	id = gbphy_dev_match_id(gbphy_dev, gbphy_drv);
	if (id)
		return 1;

	return 0;
}

static int gpbdev_probe(struct device *dev)
static int gbphy_dev_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;
	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 = gpbdev_match_id(gpbdev, gpbdrv);
	id = gbphy_dev_match_id(gbphy_dev, gbphy_drv);
	if (!id)
		return -ENODEV;

	return gpbdrv->probe(gpbdev, id);
	return gbphy_drv->probe(gbphy_dev, id);
}

static int gpbdev_remove(struct device *dev)
static int gbphy_dev_remove(struct device *dev)
{
	struct gpbridge_driver *gpbdrv = to_gpbridge_driver(dev->driver);
	struct gpbridge_device *gpbdev = to_gpbridge_dev(dev);
	struct gbphy_driver *gbphy_drv = to_gbphy_driver(dev->driver);
	struct gbphy_device *gbphy_dev = to_gbphy_dev(dev);

	gpbdrv->remove(gpbdev);
	gbphy_drv->remove(gbphy_dev);
	return 0;
}

static struct bus_type gpbridge_bus_type = {
	.name =		"gpbridge",
	.match =	gpbdev_match,
	.probe =	gpbdev_probe,
	.remove =	gpbdev_remove,
	.uevent =	gpbdev_uevent,
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_gpbridge_register_driver(struct gpbridge_driver *driver,
int gb_gbphy_register_driver(struct gbphy_driver *driver,
			     struct module *owner, const char *mod_name)
{
	int retval;
@@ -151,7 +151,7 @@ int gb_gpbridge_register_driver(struct gpbridge_driver *driver,
	if (greybus_disabled())
		return -ENODEV;

	driver->driver.bus = &gpbridge_bus_type;
	driver->driver.bus = &gbphy_bus_type;
	driver->driver.name = driver->name;
	driver->driver.owner = owner;
	driver->driver.mod_name = mod_name;
@@ -163,15 +163,15 @@ int gb_gpbridge_register_driver(struct gpbridge_driver *driver,
	pr_info("registered new driver %s\n", driver->name);
	return 0;
}
EXPORT_SYMBOL_GPL(gb_gpbridge_register_driver);
EXPORT_SYMBOL_GPL(gb_gbphy_register_driver);

void gb_gpbridge_deregister_driver(struct gpbridge_driver *driver)
void gb_gbphy_deregister_driver(struct gbphy_driver *driver)
{
	driver_unregister(&driver->driver);
}
EXPORT_SYMBOL_GPL(gb_gpbridge_deregister_driver);
EXPORT_SYMBOL_GPL(gb_gbphy_deregister_driver);

int gb_gpbridge_get_version(struct gb_connection *connection)
int gb_gbphy_get_version(struct gb_connection *connection)
{
	struct gb_protocol_version_request request;
	struct gb_protocol_version_response response;
@@ -196,135 +196,135 @@ int gb_gpbridge_get_version(struct gb_connection *connection)

	return 0;
}
EXPORT_SYMBOL_GPL(gb_gpbridge_get_version);
EXPORT_SYMBOL_GPL(gb_gbphy_get_version);

static struct gpbridge_device *gb_gpbridge_create_dev(struct gb_bundle *bundle,
static struct gbphy_device *gb_gbphy_create_dev(struct gb_bundle *bundle,
				struct greybus_descriptor_cport *cport_desc)
{
	struct gpbridge_device *gpbdev;
	struct gbphy_device *gbphy_dev;
	int retval;
	int id;

	id = ida_simple_get(&gpbridge_id, 1, 0, GFP_KERNEL);
	id = ida_simple_get(&gbphy_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);
	gbphy_dev = kzalloc(sizeof(*gbphy_dev), GFP_KERNEL);
	if (!gbphy_dev) {
		ida_simple_remove(&gbphy_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);
	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(&gpbdev->dev);
		put_device(&gbphy_dev->dev);
		return ERR_PTR(retval);
	}

	return gpbdev;
	return gbphy_dev;
}

static void gb_gpbridge_disconnect(struct gb_bundle *bundle)
static void gb_gbphy_disconnect(struct gb_bundle *bundle)
{
	struct gpbridge_host *gpb_host = greybus_get_drvdata(bundle);
	struct gpbridge_device *gpbdev, *temp;
	struct gbphy_host *gbphy_host = greybus_get_drvdata(bundle);
	struct gbphy_device *gbphy_dev, *temp;

	list_for_each_entry_safe(gpbdev, temp, &gpb_host->devices, list) {
		list_del(&gpbdev->list);
		device_unregister(&gpbdev->dev);
	list_for_each_entry_safe(gbphy_dev, temp, &gbphy_host->devices, list) {
		list_del(&gbphy_dev->list);
		device_unregister(&gbphy_dev->dev);
	}

	kfree(gpb_host);
	kfree(gbphy_host);
}

static int gb_gpbridge_probe(struct gb_bundle *bundle,
static int gb_gbphy_probe(struct gb_bundle *bundle,
			  const struct greybus_bundle_id *id)
{
	struct gpbridge_host *gpb_host;
	struct gpbridge_device *gpbdev;
	struct gbphy_host *gbphy_host;
	struct gbphy_device *gbphy_dev;
	int i;

	if (bundle->num_cports == 0)
		return -ENODEV;

	gpb_host = kzalloc(sizeof(*gpb_host), GFP_KERNEL);
	if (!gpb_host)
	gbphy_host = kzalloc(sizeof(*gbphy_host), GFP_KERNEL);
	if (!gbphy_host)
		return -ENOMEM;

	gpb_host->bundle = bundle;
	INIT_LIST_HEAD(&gpb_host->devices);
	greybus_set_drvdata(bundle, gpb_host);
	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) {
		gpbdev = gb_gpbridge_create_dev(bundle, &bundle->cport_desc[i]);
		if (IS_ERR(gpbdev)) {
			gb_gpbridge_disconnect(bundle);
			return PTR_ERR(gpbdev);
		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(&gpbdev->list, &gpb_host->devices);
		list_add(&gbphy_dev->list, &gbphy_host->devices);
	}

	return 0;
}

static const struct greybus_bundle_id gb_gpbridge_id_table[] = {
static const struct greybus_bundle_id gb_gbphy_id_table[] = {
	{ GREYBUS_DEVICE_CLASS(GREYBUS_CLASS_BRIDGED_PHY) },
	{ },
};
MODULE_DEVICE_TABLE(greybus, gb_gpbridge_id_table);
MODULE_DEVICE_TABLE(greybus, gb_gbphy_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 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 gpbridge_init(void)
static int __init gbphy_init(void)
{
	int retval;

	retval = bus_register(&gpbridge_bus_type);
	retval = bus_register(&gbphy_bus_type);
	if (retval) {
		pr_err("gpbridge bus register failed (%d)\n", retval);
		pr_err("gbphy bus register failed (%d)\n", retval);
		return retval;
	}

	retval = greybus_register(&gb_gpbridge_driver);
	retval = greybus_register(&gb_gbphy_driver);
	if (retval) {
		pr_err("error registering greybus driver\n");
		goto error_gpbridge;
		goto error_gbphy;
	}

	return 0;

error_gpbridge:
	bus_unregister(&gpbridge_bus_type);
	ida_destroy(&gpbridge_id);
error_gbphy:
	bus_unregister(&gbphy_bus_type);
	ida_destroy(&gbphy_id);
	return retval;
}
module_init(gpbridge_init);
module_init(gbphy_init);

static void __exit gpbridge_exit(void)
static void __exit gbphy_exit(void)
{
	greybus_deregister(&gb_gpbridge_driver);
	bus_unregister(&gpbridge_bus_type);
	ida_destroy(&gpbridge_id);
	greybus_deregister(&gb_gbphy_driver);
	bus_unregister(&gbphy_bus_type);
	ida_destroy(&gbphy_id);
}
module_exit(gpbridge_exit);
module_exit(gbphy_exit);

MODULE_LICENSE("GPL v2");
+71 −0
Original line number Diff line number Diff line
/*
 * Greybus GPBridge phy driver
 * Greybus Bridged-Phy Bus driver
 *
 * Copyright 2016 Google Inc.
 *
 * Released under the GPLv2 only.
 */

#ifndef __GPBRIDGE_H
#define __GPBRIDGE_H
#ifndef __GBPHY_H
#define __GBPHY_H

struct gpbridge_device {
struct gbphy_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)
#define to_gbphy_dev(d) container_of(d, struct gbphy_device, dev)

static inline void *gb_gpbridge_get_data(struct gpbridge_device *gdev)
static inline void *gb_gbphy_get_data(struct gbphy_device *gdev)
{
	return dev_get_drvdata(&gdev->dev);
}

static inline void gb_gpbridge_set_data(struct gpbridge_device *gdev, void *data)
static inline void gb_gbphy_set_data(struct gbphy_device *gdev, void *data)
{
	dev_set_drvdata(&gdev->dev, data);
}

struct gpbridge_device_id {
struct gbphy_device_id {
	__u8 protocol_id;
};

#define GPBRIDGE_PROTOCOL(p)		\
#define GBPHY_PROTOCOL(p)		\
	.protocol_id	= (p),

struct gpbridge_driver {
struct gbphy_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;
	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_gpbridge_driver(d) container_of(d, struct gpbridge_driver, driver)
#define to_gbphy_driver(d) container_of(d, struct gbphy_driver, driver)

int gb_gpbridge_get_version(struct gb_connection *connection);
int gb_gpbridge_register_driver(struct gpbridge_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_gpbridge_deregister_driver(struct gpbridge_driver *driver);
void gb_gbphy_deregister_driver(struct gbphy_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)
#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_gpbridge_driver() - Helper macro for registering a gpbridge driver
 * @__gpbridge_driver: gpbridge_driver structure
 * module_gbphy_driver() - Helper macro for registering a gbphy driver
 * @__gbphy_driver: gbphy_driver structure
 *
 * Helper macro for gpbridge drivers to set up proper module init / exit
 * 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_gpbridge_driver(__gpbridge_driver)	\
	module_driver(__gpbridge_driver, gb_gpbridge_register, gb_gpbridge_deregister)
#define module_gbphy_driver(__gbphy_driver)	\
	module_driver(__gbphy_driver, gb_gbphy_register, gb_gbphy_deregister)

#endif /* __GPBRIDGE_H */
#endif /* __GBPHY_H */
+27 −27
Original line number Diff line number Diff line
@@ -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 @@ static int gb_gpio_probe(struct gpbridge_device *gpbdev,
	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");
+19 −19
Original line number Diff line number Diff line
@@ -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 @@ static int gb_i2c_probe(struct gpbridge_device *gpbdev,
	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");
Loading