Commit 39495a2b authored by Johan Hovold's avatar Johan Hovold Committed by Greg Kroah-Hartman

greybus: svc: refactor interface-route destruction

Add interface-route-destroy helper to tear down the route and release
the interface device id.

Note that we currently need to grab a reference to the interface to
prevent it from being deallocated before tearing down the route.
Signed-off-by: default avatarJohan Hovold <johan@hovoldconsulting.com>
Reviewed-by: default avatarJeffrey Carlyle <jcarlyle@google.com>
Reviewed-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@google.com>
parent bb2533a9
...@@ -518,21 +518,23 @@ static int gb_svc_interface_route_create(struct gb_svc *svc, ...@@ -518,21 +518,23 @@ static int gb_svc_interface_route_create(struct gb_svc *svc,
return ret; return ret;
} }
static void gb_svc_intf_remove(struct gb_svc *svc, struct gb_interface *intf) static void gb_svc_interface_route_destroy(struct gb_svc *svc,
struct gb_interface *intf)
{ {
u8 intf_id = intf->interface_id; gb_svc_route_destroy(svc, svc->ap_intf_id, intf->interface_id);
u8 device_id = intf->device_id; ida_simple_remove(&svc->device_id_map, intf->device_id);
}
static void gb_svc_intf_remove(struct gb_svc *svc, struct gb_interface *intf)
{
intf->disconnected = true; intf->disconnected = true;
gb_interface_remove(intf); get_device(&intf->dev);
/* gb_interface_remove(intf);
* Destroy the two-way route between the AP and the interface. gb_svc_interface_route_destroy(svc, intf);
*/
gb_svc_route_destroy(svc, svc->ap_intf_id, intf_id);
ida_simple_remove(&svc->device_id_map, device_id); put_device(&intf->dev);
} }
static void gb_svc_process_intf_hotplug(struct gb_operation *operation) static void gb_svc_process_intf_hotplug(struct gb_operation *operation)
...@@ -630,8 +632,7 @@ static void gb_svc_process_intf_hotplug(struct gb_operation *operation) ...@@ -630,8 +632,7 @@ static void gb_svc_process_intf_hotplug(struct gb_operation *operation)
return; return;
destroy_route: destroy_route:
gb_svc_route_destroy(svc, svc->ap_intf_id, intf_id); gb_svc_interface_route_destroy(svc, intf);
ida_simple_remove(&svc->device_id_map, intf->device_id);
destroy_interface: destroy_interface:
gb_interface_remove(intf); gb_interface_remove(intf);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment