Commit bd821005 authored by Vladyslav Tarasiuk's avatar Vladyslav Tarasiuk Committed by David S. Miller

devlink: Create generic devlink health reporter search function

Add a generic __devlink_health_reporter_find_by_name() that can be used
with arbitrary devlink health reporter list.
Signed-off-by: default avatarVladyslav Tarasiuk <vladyslavt@mellanox.com>
Reviewed-by: default avatarMoshe Shemesh <moshe@mellanox.com>
Reviewed-by: default avatarJiri Pirko <jiri@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 3c5584bf
...@@ -5309,18 +5309,28 @@ devlink_health_reporter_priv(struct devlink_health_reporter *reporter) ...@@ -5309,18 +5309,28 @@ devlink_health_reporter_priv(struct devlink_health_reporter *reporter)
EXPORT_SYMBOL_GPL(devlink_health_reporter_priv); EXPORT_SYMBOL_GPL(devlink_health_reporter_priv);
static struct devlink_health_reporter * static struct devlink_health_reporter *
devlink_health_reporter_find_by_name(struct devlink *devlink, __devlink_health_reporter_find_by_name(struct list_head *reporter_list,
const char *reporter_name) struct mutex *list_lock,
const char *reporter_name)
{ {
struct devlink_health_reporter *reporter; struct devlink_health_reporter *reporter;
lockdep_assert_held(&devlink->reporters_lock); lockdep_assert_held(list_lock);
list_for_each_entry(reporter, &devlink->reporter_list, list) list_for_each_entry(reporter, reporter_list, list)
if (!strcmp(reporter->ops->name, reporter_name)) if (!strcmp(reporter->ops->name, reporter_name))
return reporter; return reporter;
return NULL; return NULL;
} }
static struct devlink_health_reporter *
devlink_health_reporter_find_by_name(struct devlink *devlink,
const char *reporter_name)
{
return __devlink_health_reporter_find_by_name(&devlink->reporter_list,
&devlink->reporters_lock,
reporter_name);
}
static struct devlink_health_reporter * static struct devlink_health_reporter *
__devlink_health_reporter_create(struct devlink *devlink, __devlink_health_reporter_create(struct devlink *devlink,
const struct devlink_health_reporter_ops *ops, const struct devlink_health_reporter_ops *ops,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment