From patchwork Sat May 27 11:28:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 686590 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CBA96C7EE3A for ; Sat, 27 May 2023 11:29:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232465AbjE0L3c (ORCPT ); Sat, 27 May 2023 07:29:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56420 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232400AbjE0L30 (ORCPT ); Sat, 27 May 2023 07:29:26 -0400 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4540C124; Sat, 27 May 2023 04:29:23 -0700 (PDT) Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-3f6e4554453so11240475e9.3; Sat, 27 May 2023 04:29:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1685186962; x=1687778962; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=9HiOL7lEFVgjMaEJrcmVlJpY1uQMDGELzriKpZXWbcM=; b=aOrW7o/W6hFBEZhqXwl4wHAvgp9au7WiULHRilZP3Q2xTYOZXVCsfnJtUSMDULCdhZ wS0bl+5AwKCS3Ij4UhZHZr2r5bWkFsq5j6WHJtOyJ3p4QKEHdqFXaxmPo+O6tycDvf9G 7V/6pSpzPBgJOc8Z3zpvAWm5iQ40CrorrnwA/LvI8bFsBKx/u0jPL9xv2pIAGWizjXX2 VQppOBgLTzwH3ScwWOvvFFR24VPQtLYAls76cUloxJCYlUGdQ7hl9gAs/wzQH031LwtO I4mYQ8e9buVjU1DD0lUzaGHZtz6ZZtn0HuxTZCdOvp28KkuhORcD2HkfuTvWFWf6iYZK HaXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685186962; x=1687778962; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9HiOL7lEFVgjMaEJrcmVlJpY1uQMDGELzriKpZXWbcM=; b=Y8PFSfYPH22KeOaNfqHFTDMnCNrV5owbBHk8RhBLZ/GDikeOwiHtayDiwscglKnwmv vjuIOTvd30yajHPAALxk37wclTLO5p3zg2nvIxqYm0H74P6/FZy6ErM08/PuiPijXhS1 yO54lf3UUKB+TIu+hXKMzoCCTvmS8AhT2oNtfHhZDVyJLi4LzDqunFw0X0UIFA8NdtyO aZ9jbx6ajEKGh8b3ge11XzsuPiz9fYYmLJj84a77TmPERiJM7UBANrfSVhvZT31ps55C KIndHhZBH+FjrQ72T8c6/vCKdO5rf1zvskM5Uo5nz1NIJMuZqIscwyrPfID4YLAQb7CE ihsA== X-Gm-Message-State: AC+VfDwASpHCl/vSsllf1McAVX/Riufh9Zr6ImeZadY8RDZcIJtUuIGt Z9Q60udpQkdXe4S81sC9W2w= X-Google-Smtp-Source: ACHHUZ43haHLT1VQPLx8RjLuJVgl+/TPgdU/L/CT5L2PRDJ5Aj8MhWYqBbx1RqbtoGUVysE4syfKxg== X-Received: by 2002:a05:600c:d2:b0:3f6:536:a4b2 with SMTP id u18-20020a05600c00d200b003f60536a4b2mr3400538wmm.27.1685186961649; Sat, 27 May 2023 04:29:21 -0700 (PDT) Received: from localhost.localdomain (93-34-93-173.ip49.fastwebnet.it. [93.34.93.173]) by smtp.googlemail.com with ESMTPSA id q13-20020a7bce8d000000b003f43f82001asm11711000wmj.31.2023.05.27.04.29.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 May 2023 04:29:21 -0700 (PDT) From: Christian Marangi To: Pavel Machek , Lee Jones , Jonathan Corbet , Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Christian Marangi , linux-leds@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [net-next PATCH v3 06/13] leds: trigger: netdev: add basic check for hw control support Date: Sat, 27 May 2023 13:28:47 +0200 Message-Id: <20230527112854.2366-7-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230527112854.2366-1-ansuelsmth@gmail.com> References: <20230527112854.2366-1-ansuelsmth@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-leds@vger.kernel.org Add basic check for hw control support. Check if the required API are defined and check if the defined trigger supported in hw control for the LED driver match netdev. Signed-off-by: Christian Marangi Reviewed-by: Andrew Lunn --- drivers/leds/trigger/ledtrig-netdev.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/leds/trigger/ledtrig-netdev.c b/drivers/leds/trigger/ledtrig-netdev.c index e1f3cedd5d57..2101cbbda707 100644 --- a/drivers/leds/trigger/ledtrig-netdev.c +++ b/drivers/leds/trigger/ledtrig-netdev.c @@ -92,8 +92,22 @@ static void set_baseline_state(struct led_netdev_data *trigger_data) } } +static bool supports_hw_control(struct led_classdev *led_cdev) +{ + if (!led_cdev->hw_control_get || !led_cdev->hw_control_set || + !led_cdev->hw_control_is_supported) + return false; + + return !strcmp(led_cdev->hw_control_trigger, led_cdev->trigger->name); +} + static bool can_hw_control(struct led_netdev_data *trigger_data) { + struct led_classdev *led_cdev = trigger_data->led_cdev; + + if (!supports_hw_control(led_cdev)) + return false; + return false; }