Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1553224ybt; Thu, 2 Jul 2020 08:10:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzTTlN3JlcvGmQD3u18kEe35N+TmfLLcecQtM30EvPU6DhlFrZWFXJ1Ej1uc5J2YEgIZafD X-Received: by 2002:a17:907:2149:: with SMTP id rk9mr27411720ejb.553.1593702621532; Thu, 02 Jul 2020 08:10:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593702621; cv=none; d=google.com; s=arc-20160816; b=MQHTfLe3iMovBNgPFHNbd9wTHVNxD5e6igNexfQBMIxd/WP+ZqAxE1PQZTOYdgJD/C M+lSNZQ1uZ6UAFkLPEjWAhWbvGWMohLuoFXVVjt20x/R3gJyZcLzUlLhT9bFZMs9TnCu O6jOkFmEHfeX2eE10d8dLuliJnbi4JUav2/RzzztGbGgzx9vbMPWgqAWjDTEtrDLzx2R EFDPd7oOH9tIdBOTmvjnzi19kOBurAy4c4xfj8SAv4vbMKGAR7sTylgKOgPNNvdz4nSP kzIViDfxuP9BCqpUdVIX0SQ2hFoGdWr+6vysTkag9ieBtz2n3/Hs/xJeeX6l3wsBr/vO CF2g== 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=z08JNN/HtZscD3Henh0D4s63FSea1oi6gHkygp77zOE=; b=hvtdRKHEWKIykPVyuSqVYmLeBKhBMNvDTl0geh/JGdObifVZ+yzXWEQtfCK16j5pDm 42sJEW/1NgBL0B06KxfVQm9QYtVaZCOl1wa0c/q2Re6fKKI2smQG1OqNxogkvbXFnCib FCRasv9iFoHuQJdhKfINdkwK/fv9aQ605XJUTDur++oSfb5OGHbRANo5QK080hFEEOlB 5UnbX5EoVxevEU3vdWyzy1zkmdROPRx8vxkZWe+0ZmKRuc2kYw7iMUa3YsMQilK48pd0 kuQeMLvG2zI9UGdTq40CiFpwJ5nkgO78bpEHVThiUm9CEZUVE0+pakigW/yEuFgqMoye vPDA== 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 e19si1020014edr.218.2020.07.02.08.09.57; Thu, 02 Jul 2020 08:10:21 -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 S1730106AbgGBPJS (ORCPT + 99 others); Thu, 2 Jul 2020 11:09:18 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:39726 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729369AbgGBPJL (ORCPT ); Thu, 2 Jul 2020 11:09:11 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from moshe@mellanox.com) with SMTP; 2 Jul 2020 18:09:09 +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 062F99J8020263; Thu, 2 Jul 2020 18:09:09 +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 062F99kB015409; Thu, 2 Jul 2020 18:09:09 +0300 Received: (from moshe@localhost) by dev-l-vrt-136.mtl.labs.mlnx (8.14.7/8.14.7/Submit) id 062F98vs015408; Thu, 2 Jul 2020 18:09:08 +0300 From: Moshe Shemesh To: "David S. Miller" Cc: Jiri Pirko , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Vladyslav Tarasiuk Subject: [PATCH net-next 3/7] devlink: Create generic devlink health reporter search function Date: Thu, 2 Jul 2020 18:08:09 +0300 Message-Id: <1593702493-15323-4-git-send-email-moshe@mellanox.com> X-Mailer: git-send-email 1.8.4.3 In-Reply-To: <1593702493-15323-1-git-send-email-moshe@mellanox.com> References: <1593702493-15323-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 dcf8006..98e6911 100644 --- a/net/core/devlink.c +++ b/net/core/devlink.c @@ -5283,19 +5283,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