Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1991610ybt; Thu, 2 Jul 2020 20:32:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw1Hv/9+O1UZXk6HzIr/Dm01hh567emG6ANShZ3jTxaXTGjhkl+hHnNNzRDsbGA9w3zeigS X-Received: by 2002:a17:906:5006:: with SMTP id s6mr29539313ejj.294.1593747171229; Thu, 02 Jul 2020 20:32:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593747171; cv=none; d=google.com; s=arc-20160816; b=HXxax0grKeGqOEY5j89LovegMhCOklLqOpPrJ2QWD6ZpXccZJcsU/yufdVOa+UUdNx GHkkI6/g9qyFaNzAAqwCLsoz6CzfQS0D1uPlcya2nW1TPOY56h0F9q1VZaYg5BxISTr+ 9KhMGVM95zp6PicCyDt84uedcpKOAtUdfAv84Doh+9K6yVYCcDPu/x1TIjHcBwF2vDf2 GYc4/jvFm2jAJvAXCg25C39q0jw4kQ7WMqDPJNXGEcmPwl9/XU5ijmyjwPflUo/6rcdC sWOTKtY7T3bbeKohfxXSh8vPuoEpyaLT+4V430fw1DeEPR83Wb4evscPg4DXYF3J7BNq hVOg== 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=jowv4UpnrmBImWPI8thuCDZpGwq/3dkcg1aL3Ex6ABWOC+hBq2NrJ3ndqOMP1AXl3V QaTMHpFXS+2zYiFA1SHh3v8KK1iU48Zd1IzGqXsZFYjfWGdvPH1aUOJYaGJ4FHVsknI2 9cAz5o2sgNJLloQH7kGcj1rxpFSPpKCuyhRqUOq20JPrgtUrUrcLXamMd+LC0wvVVzoO T1FE4SS5/QyUtOMhPhNNNgd4J+2eWKX+G+uDj6ktbF+WVcLA/WlBrSUI/BR+KhO3KZRi k1SMSeVjbKy20/RnWd8yirjeLAUzRiy2m923+G+jZq/6qmxIPmsLbTp+J6EDTBVWhpfV rraw== 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 i8si6952578edv.172.2020.07.02.20.32.28; Thu, 02 Jul 2020 20:32:51 -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 S1726368AbgGCD2z (ORCPT + 99 others); Thu, 2 Jul 2020 23:28:55 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:33612 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726144AbgGCD2V (ORCPT ); Thu, 2 Jul 2020 23:28:21 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from moshe@mellanox.com) with SMTP; 3 Jul 2020 06:28:15 +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 0633SF61006789; Fri, 3 Jul 2020 06:28:15 +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 0633SFCt006661; Fri, 3 Jul 2020 06:28:15 +0300 Received: (from moshe@localhost) by dev-l-vrt-136.mtl.labs.mlnx (8.14.7/8.14.7/Submit) id 0633SFb9006660; Fri, 3 Jul 2020 06:28:15 +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 v2 3/7] devlink: Create generic devlink health reporter search function Date: Fri, 3 Jul 2020 06:27:34 +0300 Message-Id: <1593746858-6548-4-git-send-email-moshe@mellanox.com> X-Mailer: git-send-email 1.8.4.3 In-Reply-To: <1593746858-6548-1-git-send-email-moshe@mellanox.com> References: <1593746858-6548-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