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

drivers: base: Reduce device link removal code duplication

Reduce device link removal code duplication between the cases when
SRCU is enabled and when it is disabled by moving the only differing
piece of it (which is the removal of the link from the consumer and
supplier lists) into a separate wrapper function (defined differently
for each of the cases in question).

No intentional functional impact.

Reviewed-by: Saravana Kannan <saravanak@google.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Link: https://lore.kernel.org/r/4326215.LvFx2qVVIh@kreacher
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Rafael J. Wysocki and committed by
Greg Kroah-Hartman
0c871315 80dd33cf

+13 -18
+13 -18
drivers/base/core.c
··· 199 199 { 200 200 synchronize_srcu(&device_links_srcu); 201 201 } 202 + 203 + static void device_link_remove_from_lists(struct device_link *link) 204 + { 205 + list_del_rcu(&link->s_node); 206 + list_del_rcu(&link->c_node); 207 + } 202 208 #else /* !CONFIG_SRCU */ 203 209 static DECLARE_RWSEM(device_links_lock); 204 210 ··· 238 232 239 233 static inline void device_link_synchronize_removal(void) 240 234 { 235 + } 236 + 237 + static void device_link_remove_from_lists(struct device_link *link) 238 + { 239 + list_del(&link->s_node); 240 + list_del(&link->c_node); 241 241 } 242 242 #endif /* !CONFIG_SRCU */ 243 243 ··· 867 855 } 868 856 EXPORT_SYMBOL_GPL(device_link_add); 869 857 870 - #ifdef CONFIG_SRCU 871 858 static void __device_link_del(struct kref *kref) 872 859 { 873 860 struct device_link *link = container_of(kref, struct device_link, kref); ··· 876 865 877 866 pm_runtime_drop_link(link); 878 867 879 - list_del_rcu(&link->s_node); 880 - list_del_rcu(&link->c_node); 868 + device_link_remove_from_lists(link); 881 869 device_unregister(&link->link_dev); 882 870 } 883 - #else /* !CONFIG_SRCU */ 884 - static void __device_link_del(struct kref *kref) 885 - { 886 - struct device_link *link = container_of(kref, struct device_link, kref); 887 - 888 - dev_info(link->consumer, "Dropping the link to %s\n", 889 - dev_name(link->supplier)); 890 - 891 - pm_runtime_drop_link(link); 892 - 893 - list_del(&link->s_node); 894 - list_del(&link->c_node); 895 - device_unregister(&link->link_dev); 896 - } 897 - #endif /* !CONFIG_SRCU */ 898 871 899 872 static void device_link_put_kref(struct device_link *link) 900 873 {