From patchwork Mon May 29 16:32:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 686803 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 9BC4FC77B7E for ; Mon, 29 May 2023 16:35:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229739AbjE2QfC (ORCPT ); Mon, 29 May 2023 12:35:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229625AbjE2Qev (ORCPT ); Mon, 29 May 2023 12:34:51 -0400 Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B055B2; Mon, 29 May 2023 09:34:50 -0700 (PDT) Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-3f6d3f83d0cso36417315e9.2; Mon, 29 May 2023 09:34:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1685378089; x=1687970089; 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=IlQrvGRD4ZHltBpv2SQtNiv0lfrM6U3jabiv2fdlEjA=; b=DtHAc0glKUPrO98buFtsgCTz1Ie8aLDtveoXlqHpy4/v/pzDmV6NkXceOfvN2VkKJO Mzlc6eKDDreLC9/+0Klduzktr30qbdTdYjpLA6b/rpcTluYntiEhyO0pX8otblRuioJK e39c9hD4rORHrGO4IhsWDGn4p1+bGbOzmtiBfxnuywI9eUiZkKO80S5gleEdSnt+qmED Xd/o8iF/f8TgMtkhdnG/s5eFksnFMGOPHBlG9y3SEdgP9Kfug33ktmKDKIGN+0zhowYZ E1g2czs++O2e+XgfIG6G1bFZ+QZpOvRgZ/9oEC0pdwJxPftpAIIaR6KRzJujsufgu0bX DyIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685378089; x=1687970089; 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=IlQrvGRD4ZHltBpv2SQtNiv0lfrM6U3jabiv2fdlEjA=; b=MWzqKmbOiWFBaA14h1wNDITl/ZiMp+082HMNCEU7rCnHbxjKvo8uvDdAU8ZkcOuFhF BBmTieuoLAuPibM8sWCqeO5jrpRxoNOstSrIS8ijYR+PwcZPXG2IU3XLtn2t+J9LARzj +ian8QOnHkannScAtSoPMOSdp9Dl6/Kxs27XEOY0kflqJUR0maz3k7Dm3OX6FVDnEKdM QTrz7FS+pAhhP0ad+mUXvRJcRu4G0vw2/7fUFMzKNSLzmC+T4Jp5uZxly9LGDVVfYvzF ZzGtCdnYY4tzu8FX5BZypp4eo5UJc3iCqPy8ZPBsvMfdneyi0VYc2mKlebj3wHl9DBZ4 IVvw== X-Gm-Message-State: AC+VfDwRawo7OFOA+mjjrs9SPHYaNvsSCoao2eiBR/jIrszuMRfWHqTT NvDNl5OinFpCoKCBWqGHeUc= X-Google-Smtp-Source: ACHHUZ641zKVt+dvxchLwmAXeTl3o99OfbAJcCRE4+hN+GQzUQzNx2B0Z3gWlYjxdlQlll5hmeYOkA== X-Received: by 2002:a05:600c:d5:b0:3f5:ce2:9c82 with SMTP id u21-20020a05600c00d500b003f50ce29c82mr10531066wmm.32.1685378088594; Mon, 29 May 2023 09:34:48 -0700 (PDT) Received: from localhost.localdomain (93-34-93-173.ip49.fastwebnet.it. [93.34.93.173]) by smtp.googlemail.com with ESMTPSA id h14-20020a5d6e0e000000b002ff2c39d072sm417513wrz.104.2023.05.29.09.34.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 May 2023 09:34:48 -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 v4 06/13] leds: trigger: netdev: add basic check for hw control support Date: Mon, 29 May 2023 18:32:36 +0200 Message-Id: <20230529163243.9555-7-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230529163243.9555-1-ansuelsmth@gmail.com> References: <20230529163243.9555-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; }