Commit 344943d2 authored by Alex Elder's avatar Alex Elder Committed by Greg Kroah-Hartman
Browse files

greybus: endo: record AP interface id



The AP resides in a particular position on an Endo, which is
identified by an interface ID.  (For now we'll assume the AP uses
just one interface.)  Record the this AP interface ID when creating
an Endo.  Add a sysfs attribute to display it as well.

Signed-off-by: default avatarAlex Elder <elder@linaro.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@google.com>
parent e45524f8
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -179,6 +179,7 @@ struct greybus_host_device *greybus_create_hd(struct greybus_host_driver *driver
	struct greybus_host_device *hd;
	struct gb_endo *endo;
	u16 endo_id = 0x4755;	// FIXME - get endo "ID" from the SVC
	u8 ap_intf_id = 0x01;	// FIXME - get AP interface ID from the SVC

	/*
	 * Validate that the driver implements all of the callbacks
@@ -212,7 +213,7 @@ struct greybus_host_device *greybus_create_hd(struct greybus_host_driver *driver
	ida_init(&hd->cport_id_map);
	hd->buffer_size_max = buffer_size_max;

	endo = gb_endo_create(hd, endo_id);
	endo = gb_endo_create(hd, endo_id, ap_intf_id);
	if (IS_ERR(endo)) {
		greybus_remove_hd(hd);
		return ERR_CAST(endo);
+17 −2
Original line number Diff line number Diff line
@@ -82,8 +82,18 @@ static ssize_t endo_id_show(struct device *dev,
}
static DEVICE_ATTR_RO(endo_id);

static ssize_t ap_intf_id_show(struct device *dev,
			struct device_attribute *attr, char *buf)
{
	struct gb_endo *endo = to_gb_endo(dev);

	return sprintf(buf, "0x%02x", endo->ap_intf_id);
}
static DEVICE_ATTR_RO(ap_intf_id);

static struct attribute *endo_attrs[] = {
	&dev_attr_endo_id.attr,
	&dev_attr_ap_intf_id.attr,
	NULL,
};

@@ -452,7 +462,8 @@ static int gb_endo_register(struct greybus_host_device *hd,
	return retval;
}

struct gb_endo *gb_endo_create(struct greybus_host_device *hd, u16 endo_id)
struct gb_endo *gb_endo_create(struct greybus_host_device *hd, u16 endo_id,
				u8 ap_intf_id)
{
	struct gb_endo *endo;
	int retval;
@@ -466,8 +477,12 @@ struct gb_endo *gb_endo_create(struct greybus_host_device *hd, u16 endo_id)
		retval = -EINVAL;
		goto free_endo;
	}

	if (ap_intf_id > max_endo_interface_id(&endo->layout)) {
		retval = -EINVAL;
		goto free_endo;
	}
	endo->id = endo_id;
	endo->ap_intf_id = ap_intf_id;

	/* Register Endo device */
	retval = gb_endo_register(hd, endo);
+3 −1
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ struct gb_endo {
	struct endo_layout layout;
	struct gb_svc_info svc_info;
	u16 id;
	u8 ap_intf_id;
};
#define to_gb_endo(d) container_of(d, struct gb_endo, dev)

@@ -47,7 +48,8 @@ struct gb_endo {
/* Greybus "private" definitions */
struct greybus_host_device;

struct gb_endo *gb_endo_create(struct greybus_host_device *hd, u16 endo_id);
struct gb_endo *gb_endo_create(struct greybus_host_device *hd,
				u16 endo_id, u8 ap_intf_id);
void gb_endo_remove(struct gb_endo *endo);

u8 endo_get_module_id(struct gb_endo *endo, u8 interface_id);