{
struct greybus_host_device *hd;
struct gb_endo *endo;
- u16 endo_id = 0x4755; // FIXME - get endo "ID" from the SVC
+ 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
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);
}
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,
};
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;
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);
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)
/* 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);