Skip to content

Commit 0c87131

Browse files
rafaeljwgregkh
authored andcommitted
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 <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]> Link: https://lore.kernel.org/r/4326215.LvFx2qVVIh@kreacher Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 80dd33c commit 0c87131

File tree

1 file changed

+13
-18
lines changed

1 file changed

+13
-18
lines changed

drivers/base/core.c

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,12 @@ static void device_link_synchronize_removal(void)
199199
{
200200
synchronize_srcu(&device_links_srcu);
201201
}
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+
}
202208
#else /* !CONFIG_SRCU */
203209
static DECLARE_RWSEM(device_links_lock);
204210

@@ -233,6 +239,12 @@ int device_links_read_lock_held(void)
233239
static inline void device_link_synchronize_removal(void)
234240
{
235241
}
242+
243+
static void device_link_remove_from_lists(struct device_link *link)
244+
{
245+
list_del(&link->s_node);
246+
list_del(&link->c_node);
247+
}
236248
#endif /* !CONFIG_SRCU */
237249

238250
static bool device_is_ancestor(struct device *dev, struct device *target)
@@ -855,7 +867,6 @@ struct device_link *device_link_add(struct device *consumer,
855867
}
856868
EXPORT_SYMBOL_GPL(device_link_add);
857869

858-
#ifdef CONFIG_SRCU
859870
static void __device_link_del(struct kref *kref)
860871
{
861872
struct device_link *link = container_of(kref, struct device_link, kref);
@@ -865,25 +876,9 @@ static void __device_link_del(struct kref *kref)
865876

866877
pm_runtime_drop_link(link);
867878

868-
list_del_rcu(&link->s_node);
869-
list_del_rcu(&link->c_node);
870-
device_unregister(&link->link_dev);
871-
}
872-
#else /* !CONFIG_SRCU */
873-
static void __device_link_del(struct kref *kref)
874-
{
875-
struct device_link *link = container_of(kref, struct device_link, kref);
876-
877-
dev_info(link->consumer, "Dropping the link to %s\n",
878-
dev_name(link->supplier));
879-
880-
pm_runtime_drop_link(link);
881-
882-
list_del(&link->s_node);
883-
list_del(&link->c_node);
879+
device_link_remove_from_lists(link);
884880
device_unregister(&link->link_dev);
885881
}
886-
#endif /* !CONFIG_SRCU */
887882

888883
static void device_link_put_kref(struct device_link *link)
889884
{

0 commit comments

Comments
 (0)