Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

platform/surface: aggregator: Make client device removal more generic

Currently, there are similar functions defined in the Aggregator
Registry and the controller core.

Make client device removal more generic and export it. We can then use
this function later on to remove client devices from device hubs as well
as the controller and avoid re-defining similar things.

Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com>
Link: https://lore.kernel.org/r/20211028002243.1586083-2-luzmaximilian@gmail.com
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>

authored by

Maximilian Luz and committed by
Hans de Goede
38543b72 0f0ac158

+19 -20
+8 -16
drivers/platform/surface/aggregator/bus.c
··· 374 374 } 375 375 376 376 /** 377 - * ssam_controller_remove_clients() - Remove SSAM client devices registered as 378 - * direct children under the given controller. 379 - * @ctrl: The controller to remove all direct clients for. 377 + * ssam_remove_clients() - Remove SSAM client devices registered as direct 378 + * children under the given parent device. 379 + * @dev: The (parent) device to remove all direct clients for. 380 380 * 381 - * Remove all SSAM client devices registered as direct children under the 382 - * given controller. Note that this only accounts for direct children of the 383 - * controller device. This does not take care of any client devices where the 384 - * parent device has been manually set before calling ssam_device_add. Refer 385 - * to ssam_device_add()/ssam_device_remove() for more details on those cases. 386 - * 387 - * To avoid new devices being added in parallel to this call, the main 388 - * controller lock (not statelock) must be held during this (and if 389 - * necessary, any subsequent deinitialization) call. 381 + * Remove all SSAM client devices registered as direct children under the given 382 + * device. Note that this only accounts for direct children of the device. 383 + * Refer to ssam_device_add()/ssam_device_remove() for more details. 390 384 */ 391 - void ssam_controller_remove_clients(struct ssam_controller *ctrl) 385 + void ssam_remove_clients(struct device *dev) 392 386 { 393 - struct device *dev; 394 - 395 - dev = ssam_controller_device(ctrl); 396 387 device_for_each_child_reverse(dev, NULL, ssam_remove_device); 397 388 } 389 + EXPORT_SYMBOL_GPL(ssam_remove_clients); 398 390 399 391 /** 400 392 * ssam_bus_register() - Register and set-up the SSAM client device bus.
-3
drivers/platform/surface/aggregator/bus.h
··· 12 12 13 13 #ifdef CONFIG_SURFACE_AGGREGATOR_BUS 14 14 15 - void ssam_controller_remove_clients(struct ssam_controller *ctrl); 16 - 17 15 int ssam_bus_register(void); 18 16 void ssam_bus_unregister(void); 19 17 20 18 #else /* CONFIG_SURFACE_AGGREGATOR_BUS */ 21 19 22 - static inline void ssam_controller_remove_clients(struct ssam_controller *ctrl) {} 23 20 static inline int ssam_bus_register(void) { return 0; } 24 21 static inline void ssam_bus_unregister(void) {} 25 22
+2 -1
drivers/platform/surface/aggregator/core.c
··· 22 22 #include <linux/sysfs.h> 23 23 24 24 #include <linux/surface_aggregator/controller.h> 25 + #include <linux/surface_aggregator/device.h> 25 26 26 27 #include "bus.h" 27 28 #include "controller.h" ··· 736 735 ssam_controller_lock(ctrl); 737 736 738 737 /* Remove all client devices. */ 739 - ssam_controller_remove_clients(ctrl); 738 + ssam_remove_clients(&serdev->dev); 740 739 741 740 /* Act as if suspending to silence events. */ 742 741 status = ssam_ctrl_notif_display_off(ctrl);
+9
include/linux/surface_aggregator/device.h
··· 319 319 ssam_device_driver_unregister) 320 320 321 321 322 + /* -- Helpers for controller and hub devices. ------------------------------- */ 323 + 324 + #ifdef CONFIG_SURFACE_AGGREGATOR_BUS 325 + void ssam_remove_clients(struct device *dev); 326 + #else /* CONFIG_SURFACE_AGGREGATOR_BUS */ 327 + static inline void ssam_remove_clients(struct device *dev) {} 328 + #endif /* CONFIG_SURFACE_AGGREGATOR_BUS */ 329 + 330 + 322 331 /* -- Helpers for client-device requests. ----------------------------------- */ 323 332 324 333 /**