From: Johan Hovold Date: Wed, 20 Jul 2016 14:40:22 +0000 (+0200) Subject: greybus: interface: clean up ES3 activation-retry hack X-Git-Tag: v4.9-rc1~119^2~378^2~21^2~137 X-Git-Url: http://git.cascardo.info/?p=cascardo%2Flinux.git;a=commitdiff_plain;h=3e93cb6abbc023aebf311618481263e000bf26fb greybus: interface: clean up ES3 activation-retry hack Clean up the ES3 activation retry-hack and isolate it in the interface code. This way the retry hack can be reused when we soon start allowing interfaces to be reactivated after having been powered down. Reviewed-by: Sandeep Patil Signed-off-by: Johan Hovold Reviewed-by: Alex Elder Reviewed-by: Viresh Kumar Reviewed-by: Patrick Titiano Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/greybus/interface.c b/drivers/staging/greybus/interface.c index 9fe6764a6ac2..8e1b6c017c81 100644 --- a/drivers/staging/greybus/interface.c +++ b/drivers/staging/greybus/interface.c @@ -844,8 +844,8 @@ static int gb_interface_activate_operation(struct gb_interface *intf) case GB_SVC_INTF_TYPE_UNIPRO: intf->type = GB_INTERFACE_TYPE_UNIPRO; dev_err(&intf->dev, "interface type UniPro not supported\n"); - /* FIXME: check if this is a Toshiba bridge before retrying? */ - return -EAGAIN; + /* FIXME: handle as an error for now */ + return -ENODEV; case GB_SVC_INTF_TYPE_GREYBUS: intf->type = GB_INTERFACE_TYPE_GREYBUS; break; @@ -865,12 +865,7 @@ static int gb_interface_hibernate_link(struct gb_interface *intf) return gb_svc_intf_set_power_mode_hibernate(svc, intf->interface_id); } -/* - * Activate an interface. - * - * Locking: Caller holds the interface mutex. - */ -int gb_interface_activate(struct gb_interface *intf) +static int _gb_interface_activate(struct gb_interface *intf) { int ret; @@ -919,6 +914,35 @@ err_vsys_disable: return ret; } +/* + * Activate an interface. + * + * Locking: Caller holds the interface mutex. + */ +int gb_interface_activate(struct gb_interface *intf) +{ + int retries = 3; + int ret; + + /* + * At present, we assume a UniPro-only module + * to be a Greybus module that failed to send its mailbox + * poke. There is some reason to believe that this is + * because of a bug in the ES3 bootrom. + * + * FIXME: Check if this is a Toshiba bridge before retrying? + */ + while (retries--) { + ret = _gb_interface_activate(intf); + if (ret == -ENODEV && intf->type == GB_SVC_INTF_TYPE_UNIPRO) + continue; + + break; + } + + return ret; +} + /* * Deactivate an interface. * diff --git a/drivers/staging/greybus/module.c b/drivers/staging/greybus/module.c index 3ae58768cc87..d506fa0b3272 100644 --- a/drivers/staging/greybus/module.c +++ b/drivers/staging/greybus/module.c @@ -143,15 +143,10 @@ static void gb_module_register_interface(struct gb_interface *intf) struct gb_module *module = intf->module; u8 intf_id = intf->interface_id; int ret; - int retries = 3; mutex_lock(&intf->mutex); - while (retries--) { - ret = gb_interface_activate(intf); - if (ret != -EAGAIN) - break; - } + ret = gb_interface_activate(intf); if (ret) { if (intf->type != GB_INTERFACE_TYPE_DUMMY) { dev_err(&module->dev, @@ -159,19 +154,6 @@ static void gb_module_register_interface(struct gb_interface *intf) intf_id, ret); } - /* - * -EAGAIN indicates that the Greybus operation - * interface_activate determined the remote interface to be - * UniPro-only. At present, we assume a UniPro-only module - * to be a Greybus module that failed to send its mailbox - * poke. There is some reason to believe that this is - * because of a bug in the ES3 bootrom. If we exhause our - * retries trying to activate such an interface, convert - * the error code back into a "no device" error. - */ - if (ret == -EAGAIN) - ret = -ENODEV; - gb_interface_add(intf); goto err_unlock; }