Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp500040ybt; Fri, 10 Jul 2020 05:30:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzB76ffTMs91TAt1tHy+7Ons4yTXC9BIIWEF71X2avfZhmEqKxN4B/kV1BEWuLaAVj4NNBx X-Received: by 2002:a05:6402:1a4b:: with SMTP id bf11mr61073231edb.191.1594384236468; Fri, 10 Jul 2020 05:30:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594384236; cv=none; d=google.com; s=arc-20160816; b=fEc2v3HJSTTfJqhj7w5Sn2qO3/L1WNGjmGc81su+qsX1Ta4Rfk8Rz9uzavh8ATw94l LnSVt4gK0pdCz3LAMuuYnokdSf6ThxiB/ZOzQdiIXdrT9bX/5BACs6xrWUlb+p0pQxW7 CEP+Eb2acAs3QVNIAUCp+I1AVoog4HquHwb12u6KnVLrvi98Bh18PRTeT+Qc59IF/9u+ RFUzKv5jVckn18HQjqx7wj5s8jChKa2Fu2qpKk2zNkjjaVh7WO4CfS/AxrSMD+D88Lec I7/g5oLuLzdStXQpQn+/k5VE3J90xXycI+rXx17Yvbnr2L/B9A60/SBTPiepgx5GTNQ5 n4WQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=pgLC3H1hhD4vZBxa0WeaUk7KTFxA4MIeay/PLzYkNag=; b=fwmpl1tS835CRmJFU2QlG3oH/cG+q433+HefxKbTe+/fR2ic6OhTBKbBnv1tiCquAK ABzE2qUUyE+9M0tAcUliz3UBApIP7SCM/J9wjE22EaLgkqQJRREn+pHrLlcNO7PK1szZ t6tPDHUxvsYI9KQyGBaatiY+S9VofbRtGrGVDYjKjth8+iQ+cH9OKjaaMNaAOwNejlql 6ew0cprUaT6chXbdzmmwJUlVJ4Pxp8sZo37hQL5bB5uQTyUjpFv/N60TrbstzyS7ZWa4 MG73SCMItBQaXmZ8PsbZzWeE6bwcEDEma5iQkkv3oHk71ozjZytDm1G/QmJPnJwLLmYz iBsw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mellanox.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id mb24si3729956ejb.233.2020.07.10.05.30.13; Fri, 10 Jul 2020 05:30:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mellanox.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728112AbgGJM0k (ORCPT + 99 others); Fri, 10 Jul 2020 08:26:40 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:51782 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727866AbgGJMZz (ORCPT ); Fri, 10 Jul 2020 08:25:55 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from moshe@mellanox.com) with SMTP; 10 Jul 2020 15:25:48 +0300 Received: from dev-l-vrt-136.mtl.labs.mlnx (dev-l-vrt-136.mtl.labs.mlnx [10.234.136.1]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 06ACPmaQ012393; Fri, 10 Jul 2020 15:25:48 +0300 Received: from dev-l-vrt-136.mtl.labs.mlnx (localhost [127.0.0.1]) by dev-l-vrt-136.mtl.labs.mlnx (8.14.7/8.14.7) with ESMTP id 06ACPmIZ003374; Fri, 10 Jul 2020 15:25:48 +0300 Received: (from moshe@localhost) by dev-l-vrt-136.mtl.labs.mlnx (8.14.7/8.14.7/Submit) id 06ACPmpK003373; Fri, 10 Jul 2020 15:25:48 +0300 From: Moshe Shemesh To: "David S. Miller" , Jakub Kicinski Cc: Jiri Pirko , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Vladyslav Tarasiuk Subject: [PATCH net-next v3 3/7] devlink: Create generic devlink health reporter search function Date: Fri, 10 Jul 2020 15:25:09 +0300 Message-Id: <1594383913-3295-4-git-send-email-moshe@mellanox.com> X-Mailer: git-send-email 1.8.4.3 In-Reply-To: <1594383913-3295-1-git-send-email-moshe@mellanox.com> References: <1594383913-3295-1-git-send-email-moshe@mellanox.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Vladyslav Tarasiuk Add a generic __devlink_health_reporter_find_by_name() that can be used with arbitrary devlink health reporter list. Signed-off-by: Vladyslav Tarasiuk Reviewed-by: Moshe Shemesh Reviewed-by: Jiri Pirko --- net/core/devlink.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/net/core/devlink.c b/net/core/devlink.c index b85f211..4e995de 100644 --- a/net/core/devlink.c +++ b/net/core/devlink.c @@ -5309,19 +5309,29 @@ struct devlink_health_reporter { EXPORT_SYMBOL_GPL(devlink_health_reporter_priv); static struct devlink_health_reporter * -devlink_health_reporter_find_by_name(struct devlink *devlink, - const char *reporter_name) +__devlink_health_reporter_find_by_name(struct list_head *reporter_list, + struct mutex *list_lock, + const char *reporter_name) { struct devlink_health_reporter *reporter; - lockdep_assert_held(&devlink->reporters_lock); - list_for_each_entry(reporter, &devlink->reporter_list, list) + lockdep_assert_held(list_lock); + list_for_each_entry(reporter, reporter_list, list) if (!strcmp(reporter->ops->name, reporter_name)) return reporter; 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 * __devlink_health_reporter_create(struct devlink *devlink, const struct devlink_health_reporter_ops *ops, u64 graceful_period, void *priv) -- 1.8.3.1