提交 76f13081 编写于 作者: S Saravana Kannan 提交者: Greg Kroah-Hartman

driver core: Create __fwnode_link_del() helper function

The same code is repeated in multiple locations. Create a helper
function for it.
Reviewed-by: NGeert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: NSaravana Kannan <saravanak@google.com>
Link: https://lore.kernel.org/r/20210915172808.620546-3-saravanak@google.comSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 68223eee
...@@ -101,6 +101,19 @@ int fwnode_link_add(struct fwnode_handle *con, struct fwnode_handle *sup) ...@@ -101,6 +101,19 @@ int fwnode_link_add(struct fwnode_handle *con, struct fwnode_handle *sup)
return ret; return ret;
} }
/**
* __fwnode_link_del - Delete a link between two fwnode_handles.
* @link: the fwnode_link to be deleted
*
* The fwnode_link_lock needs to be held when this function is called.
*/
static void __fwnode_link_del(struct fwnode_link *link)
{
list_del(&link->s_hook);
list_del(&link->c_hook);
kfree(link);
}
/** /**
* fwnode_links_purge_suppliers - Delete all supplier links of fwnode_handle. * fwnode_links_purge_suppliers - Delete all supplier links of fwnode_handle.
* @fwnode: fwnode whose supplier links need to be deleted * @fwnode: fwnode whose supplier links need to be deleted
...@@ -112,11 +125,8 @@ static void fwnode_links_purge_suppliers(struct fwnode_handle *fwnode) ...@@ -112,11 +125,8 @@ static void fwnode_links_purge_suppliers(struct fwnode_handle *fwnode)
struct fwnode_link *link, *tmp; struct fwnode_link *link, *tmp;
mutex_lock(&fwnode_link_lock); mutex_lock(&fwnode_link_lock);
list_for_each_entry_safe(link, tmp, &fwnode->suppliers, c_hook) { list_for_each_entry_safe(link, tmp, &fwnode->suppliers, c_hook)
list_del(&link->s_hook); __fwnode_link_del(link);
list_del(&link->c_hook);
kfree(link);
}
mutex_unlock(&fwnode_link_lock); mutex_unlock(&fwnode_link_lock);
} }
...@@ -131,11 +141,8 @@ static void fwnode_links_purge_consumers(struct fwnode_handle *fwnode) ...@@ -131,11 +141,8 @@ static void fwnode_links_purge_consumers(struct fwnode_handle *fwnode)
struct fwnode_link *link, *tmp; struct fwnode_link *link, *tmp;
mutex_lock(&fwnode_link_lock); mutex_lock(&fwnode_link_lock);
list_for_each_entry_safe(link, tmp, &fwnode->consumers, s_hook) { list_for_each_entry_safe(link, tmp, &fwnode->consumers, s_hook)
list_del(&link->s_hook); __fwnode_link_del(link);
list_del(&link->c_hook);
kfree(link);
}
mutex_unlock(&fwnode_link_lock); mutex_unlock(&fwnode_link_lock);
} }
...@@ -1887,9 +1894,7 @@ static void __fw_devlink_link_to_consumers(struct device *dev) ...@@ -1887,9 +1894,7 @@ static void __fw_devlink_link_to_consumers(struct device *dev)
if (!own_link || ret == -EAGAIN) if (!own_link || ret == -EAGAIN)
continue; continue;
list_del(&link->s_hook); __fwnode_link_del(link);
list_del(&link->c_hook);
kfree(link);
} }
} }
...@@ -1941,9 +1946,7 @@ static void __fw_devlink_link_to_suppliers(struct device *dev, ...@@ -1941,9 +1946,7 @@ static void __fw_devlink_link_to_suppliers(struct device *dev,
if (!own_link || ret == -EAGAIN) if (!own_link || ret == -EAGAIN)
continue; continue;
list_del(&link->s_hook); __fwnode_link_del(link);
list_del(&link->c_hook);
kfree(link);
/* If no device link was created, nothing more to do. */ /* If no device link was created, nothing more to do. */
if (ret) if (ret)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册