Commit 2adaefb1 authored by Johan Hovold's avatar Johan Hovold Committed by Greg Kroah-Hartman
Browse files

greybus: hd: make host device a device



Make the host device a proper device in the kernel device model.

Host devices will be our new greybus-bus root devices.

Signed-off-by: default avatarJohan Hovold <johan@hovoldconsulting.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@google.com>
parent a97015c9
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -55,7 +55,7 @@ void greybus_data_rcvd(struct gb_host_device *hd, u16 cport_id,

	connection = gb_connection_hd_find(hd, cport_id);
	if (!connection) {
		dev_err(hd->parent,
		dev_err(&hd->dev,
			"nonexistent connection (%zu bytes dropped)\n", length);
		return;
	}
@@ -196,7 +196,7 @@ static int gb_connection_hd_cport_enable(struct gb_connection *connection)

	ret = hd->driver->cport_enable(hd, connection->hd_cport_id);
	if (ret) {
		dev_err(hd->parent,
		dev_err(&hd->dev,
			"failed to enable host cport: %d\n", ret);
		return ret;
	}
@@ -502,7 +502,7 @@ int gb_connection_bind_protocol(struct gb_connection *connection)
				   connection->major,
				   connection->minor);
	if (!protocol) {
		dev_warn(connection->hd->parent,
		dev_warn(&connection->hd->dev,
				"protocol 0x%02hhx version %hhu.%hhu not found\n",
				connection->protocol_id,
				connection->major, connection->minor);
+13 −1
Original line number Diff line number Diff line
@@ -77,6 +77,7 @@ static int greybus_module_match(struct device *dev, struct device_driver *drv)

static int greybus_uevent(struct device *dev, struct kobj_uevent_env *env)
{
	struct gb_host_device *hd = NULL;
	struct gb_module *module = NULL;
	struct gb_interface *intf = NULL;
	struct gb_bundle *bundle = NULL;
@@ -89,7 +90,9 @@ static int greybus_uevent(struct device *dev, struct kobj_uevent_env *env)
		return 0;
	}

	if (is_gb_module(dev)) {
	if (is_gb_host_device(dev)) {
		hd = to_gb_host_device(dev);
	} else if (is_gb_module(dev)) {
		module = to_gb_module(dev);
	} else if (is_gb_interface(dev)) {
		intf = to_gb_interface(dev);
@@ -196,6 +199,12 @@ static int __init gb_init(void)
		goto error_bus;
	}

	retval = gb_hd_init();
	if (retval) {
		pr_err("gb_hd_init failed (%d)\n", retval);
		goto error_hd;
	}

	retval = gb_operation_init();
	if (retval) {
		pr_err("gb_operation_init failed (%d)\n", retval);
@@ -237,6 +246,8 @@ error_control:
error_endo:
	gb_operation_exit();
error_operation:
	gb_hd_exit();
error_hd:
	bus_unregister(&greybus_bus_type);
error_bus:
	gb_debugfs_cleanup();
@@ -252,6 +263,7 @@ static void __exit gb_exit(void)
	gb_control_protocol_exit();
	gb_endo_exit();
	gb_operation_exit();
	gb_hd_exit();
	bus_unregister(&greybus_bus_type);
	gb_debugfs_cleanup();
	tracepoint_synchronize_unregister();
+9 −9
Original line number Diff line number Diff line
@@ -219,7 +219,7 @@ static bool validate_front_ribs(struct gb_host_device *hd,
		layout->front_ribs = 0x5;
		break;
	default:
		dev_err(hd->parent,
		dev_err(&hd->dev,
			"%s: Invalid endo front mask 0x%02x, id 0x%04x\n",
			__func__, front_mask, endo_id);
		return false;
@@ -266,21 +266,21 @@ static bool validate_back_ribs(struct gb_host_device *hd,
	right_ribs = endo_back_right_ribs(endo_id, max_ribs);

	if (!single_cross_rib(left_ribs, right_ribs)) {
		dev_err(hd->parent,
		dev_err(&hd->dev,
			"%s: More than one spanning rib (left 0x%02x right 0x%02x), id 0x%04x\n",
			__func__, left_ribs, right_ribs, endo_id);
		return false;
	}

	if (modules_oversized(max_ribs, left_ribs)) {
			dev_err(hd->parent,
			dev_err(&hd->dev,
				"%s: Oversized module (left) 0x%02x, id 0x%04x\n",
				__func__, left_ribs, endo_id);
			return false;
	}

	if (modules_oversized(max_ribs, right_ribs)) {
			dev_err(hd->parent,
			dev_err(&hd->dev,
				"%s: Oversized module (Right) 0x%02x, id 0x%04x\n",
				__func__, right_ribs, endo_id);
			return false;
@@ -306,7 +306,7 @@ static bool validate_back_ribs(struct gb_host_device *hd,
	 * are of different widths.
	 */
	if (max_ribs != ENDO_BACK_RIBS_MEDIUM && left_ribs < right_ribs) {
		dev_err(hd->parent, "%s: Non-canonical endo id 0x%04x\n", __func__,
		dev_err(&hd->dev, "%s: Non-canonical endo id 0x%04x\n", __func__,
			endo_id);
		return false;
	}
@@ -334,7 +334,7 @@ static int gb_endo_validate_id(struct gb_host_device *hd,
		/* Mini Endo type */
		layout->max_ribs = ENDO_BACK_RIBS_MINI;
	} else {
		dev_err(hd->parent, "%s: Invalid endo type, id 0x%04x\n",
		dev_err(&hd->dev, "%s: Invalid endo type, id 0x%04x\n",
			__func__, endo_id);
		return -EINVAL;
	}
@@ -447,11 +447,11 @@ static int gb_endo_register(struct gb_host_device *hd,

	endo->dev_id = dev_id;

	endo->dev.parent = hd->parent;
	endo->dev.parent = &hd->dev;
	endo->dev.bus = &greybus_bus_type;
	endo->dev.type = &greybus_endo_type;
	endo->dev.groups = endo_groups;
	endo->dev.dma_mask = hd->parent->dma_mask;
	endo->dev.dma_mask = hd->dev.dma_mask;
	device_initialize(&endo->dev);
	dev_set_name(&endo->dev, "endo%hu", endo->dev_id);

@@ -463,7 +463,7 @@ static int gb_endo_register(struct gb_host_device *hd,

	retval = device_add(&endo->dev);
	if (retval) {
		dev_err(hd->parent, "failed to add endo device of id 0x%04x\n",
		dev_err(&hd->dev, "failed to add endo device of id 0x%04x\n",
			endo->id);
		put_device(&endo->dev);
	}
+6 −0
Original line number Diff line number Diff line
@@ -104,11 +104,17 @@ struct dentry *gb_debugfs_get(void);

extern struct bus_type greybus_bus_type;

extern struct device_type greybus_hd_type;
extern struct device_type greybus_endo_type;
extern struct device_type greybus_module_type;
extern struct device_type greybus_interface_type;
extern struct device_type greybus_bundle_type;

static inline int is_gb_host_device(const struct device *dev)
{
	return dev->type == &greybus_hd_type;
}

static inline int is_gb_endo(const struct device *dev)
{
	return dev->type == &greybus_endo_type;
+2 −2
Original line number Diff line number Diff line
@@ -114,13 +114,13 @@ DECLARE_EVENT_CLASS(gb_host_device,
	TP_ARGS(hd, intf_cport_id, payload_size),

	TP_STRUCT__entry(
		__string(name, dev_name(hd->parent))
		__string(name, dev_name(&hd->dev))
		__field(u16, intf_cport_id)
		__field(size_t, payload_size)
	),

	TP_fast_assign(
		__assign_str(name, dev_name(hd->parent))
		__assign_str(name, dev_name(&hd->dev))
		__entry->intf_cport_id = intf_cport_id;
		__entry->payload_size = payload_size;
	),
Loading