From: Johan Hovold Date: Wed, 9 Mar 2016 11:20:35 +0000 (+0100) Subject: greybus: svc: refactor interface-route destruction X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=39495a2bea4d523c4d36f28f3739caa8d3a404c4;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git 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: Johan Hovold Reviewed-by: Jeffrey Carlyle Reviewed-by: Viresh Kumar Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/greybus/svc.c b/drivers/staging/greybus/svc.c index 4ed108b124f8..efa418a1916c 100644 --- a/drivers/staging/greybus/svc.c +++ b/drivers/staging/greybus/svc.c @@ -518,21 +518,23 @@ err_ida_remove: 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; - u8 device_id = intf->device_id; + gb_svc_route_destroy(svc, svc->ap_intf_id, intf->interface_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; - gb_interface_remove(intf); + get_device(&intf->dev); - /* - * Destroy the two-way route between the AP and the interface. - */ - gb_svc_route_destroy(svc, svc->ap_intf_id, intf_id); + gb_interface_remove(intf); + gb_svc_interface_route_destroy(svc, intf); - ida_simple_remove(&svc->device_id_map, device_id); + put_device(&intf->dev); } 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; destroy_route: - gb_svc_route_destroy(svc, svc->ap_intf_id, intf_id); - ida_simple_remove(&svc->device_id_map, intf->device_id); + gb_svc_interface_route_destroy(svc, intf); destroy_interface: gb_interface_remove(intf); }