Skip to content

Commit 844fcbf

Browse files
jhovoldgregkh
authored andcommitted
greybus: svc: refactor interface re-enable
Add interface re-enable helper that is used during mode switch to disable and re-enable (enumerate) an interface. Signed-off-by: Johan Hovold <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent deba0c0 commit 844fcbf

File tree

1 file changed

+19
-7
lines changed
  • drivers/staging/greybus

1 file changed

+19
-7
lines changed

drivers/staging/greybus/svc.c

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -665,6 +665,24 @@ static int gb_svc_hello(struct gb_operation *op)
665665
return 0;
666666
}
667667

668+
static void gb_svc_intf_reenable(struct gb_svc *svc, struct gb_interface *intf)
669+
{
670+
int ret;
671+
672+
/* Mark as disconnected to prevent I/O during disable. */
673+
intf->disconnected = true;
674+
gb_interface_disable(intf);
675+
intf->disconnected = false;
676+
677+
ret = gb_interface_enable(intf);
678+
if (ret) {
679+
dev_err(&svc->dev, "failed to enable interface %u: %d\n",
680+
intf->interface_id, ret);
681+
682+
gb_interface_deactivate(intf);
683+
}
684+
}
685+
668686
static void gb_svc_process_intf_hotplug(struct gb_operation *operation)
669687
{
670688
struct gb_svc_intf_hotplug_request *request;
@@ -686,12 +704,7 @@ static void gb_svc_process_intf_hotplug(struct gb_operation *operation)
686704
dev_info(&svc->dev, "mode switch detected on interface %u\n",
687705
intf_id);
688706

689-
/* Mark as disconnected to prevent I/O during disable. */
690-
intf->disconnected = true;
691-
gb_interface_disable(intf);
692-
intf->disconnected = false;
693-
694-
goto enable_interface;
707+
return gb_svc_intf_reenable(svc, intf);
695708
}
696709

697710
intf = gb_interface_create(hd, intf_id);
@@ -713,7 +726,6 @@ static void gb_svc_process_intf_hotplug(struct gb_operation *operation)
713726
if (ret)
714727
goto err_interface_deactivate;
715728

716-
enable_interface:
717729
ret = gb_interface_enable(intf);
718730
if (ret) {
719731
dev_err(&svc->dev, "failed to enable interface %u: %d\n",

0 commit comments

Comments
 (0)