diff --git a/drivers/staging/greybus/core.c b/drivers/staging/greybus/core.c index 223c396c9992..290bee58511f 100644 --- a/drivers/staging/greybus/core.c +++ b/drivers/staging/greybus/core.c @@ -177,9 +177,6 @@ struct greybus_host_device *greybus_create_hd(struct greybus_host_driver *driver size_t buffer_size_max) { 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 @@ -213,17 +210,24 @@ 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, ap_intf_id); - if (IS_ERR(endo)) { - greybus_remove_hd(hd); - return ERR_CAST(endo); - } - hd->endo = endo; - return hd; } EXPORT_SYMBOL_GPL(greybus_create_hd); +int greybus_endo_setup(struct greybus_host_device *hd, u16 endo_id, + u8 ap_intf_id) +{ + struct gb_endo *endo; + + endo = gb_endo_create(hd, endo_id, ap_intf_id); + if (IS_ERR(endo)) + return PTR_ERR(endo); + hd->endo = endo; + + return 0; +} +EXPORT_SYMBOL_GPL(greybus_endo_setup); + void greybus_remove_hd(struct greybus_host_device *hd) { /* diff --git a/drivers/staging/greybus/es1.c b/drivers/staging/greybus/es1.c index 1ed10f4b8e49..f6539549d27f 100644 --- a/drivers/staging/greybus/es1.c +++ b/drivers/staging/greybus/es1.c @@ -551,6 +551,8 @@ static int ap_probe(struct usb_interface *interface, bool bulk_out_found = false; int retval = -ENOMEM; int i; + u16 endo_id = 0x4755; // FIXME - get endo "ID" from the SVC + u8 ap_intf_id = 0x01; // FIXME - get endo "ID" from the SVC u8 svc_interval = 0; udev = usb_get_dev(interface_to_usbdev(interface)); @@ -659,6 +661,17 @@ static int ap_probe(struct usb_interface *interface, gb_debugfs_get(), es1, &apb1_log_enable_fops); + /* + * XXX Soon this will be initiated later, with a combination + * XXX of a Control protocol probe operation and a + * XXX subsequent Control protocol connected operation for + * XXX the SVC connection. At that point we know we're + * XXX properly connected to an Endo. + */ + retval = greybus_endo_setup(hd, endo_id, ap_intf_id); + if (retval) + goto error; + return 0; error: ap_disconnect(interface); diff --git a/drivers/staging/greybus/es2.c b/drivers/staging/greybus/es2.c index 4733adcb8a22..4f676cf3c583 100644 --- a/drivers/staging/greybus/es2.c +++ b/drivers/staging/greybus/es2.c @@ -551,6 +551,8 @@ static int ap_probe(struct usb_interface *interface, bool bulk_out_found = false; int retval = -ENOMEM; int i; + u16 endo_id = 0x4755; // FIXME - get endo "ID" from the SVC + u8 ap_intf_id = 0x01; // FIXME - get endo "ID" from the SVC u8 svc_interval = 0; udev = usb_get_dev(interface_to_usbdev(interface)); @@ -659,6 +661,17 @@ static int ap_probe(struct usb_interface *interface, gb_debugfs_get(), es1, &apb1_log_enable_fops); + /* + * XXX Soon this will be initiated later, with a combination + * XXX of a Control protocol probe operation and a + * XXX subsequent Control protocol connected operation for + * XXX the SVC connection. At that point we know we're + * XXX properly connected to an Endo. + */ + retval = greybus_endo_setup(hd, endo_id, ap_intf_id); + if (retval) + goto error; + return 0; error: ap_disconnect(interface); diff --git a/drivers/staging/greybus/greybus.h b/drivers/staging/greybus/greybus.h index 4920458d65d0..30a93eafe064 100644 --- a/drivers/staging/greybus/greybus.h +++ b/drivers/staging/greybus/greybus.h @@ -108,6 +108,8 @@ struct greybus_host_device { struct greybus_host_device *greybus_create_hd(struct greybus_host_driver *hd, struct device *parent, size_t buffer_size_max); +int greybus_endo_setup(struct greybus_host_device *hd, u16 endo_id, + u8 ap_intf_id); void greybus_remove_hd(struct greybus_host_device *hd); struct greybus_driver {