Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp5615009pxb; Sun, 7 Nov 2021 16:27:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJwHAeVrk7cN47qbTVUMxyL9NnqsbRFXnD2JmxHB9fEei2daT7eCoDagaXt1P0y2TV2FrSIf X-Received: by 2002:a50:cd5a:: with SMTP id d26mr95037830edj.132.1636331270136; Sun, 07 Nov 2021 16:27:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636331270; cv=none; d=google.com; s=arc-20160816; b=IuPoz352LcAFsbRQJQwRHOrpF+4q7cyWDmV3v51BGzPtJ0o3lX5OSD8w4/Uhv8ABKV GCGR+uevYRFkxPsN0cEC6SCTcEu8aIbhyq6X8KanOsY74CcGM5ZOhPJXU3ZOpYOuKH+w X1dyKvx9T3HoevaRn17SEQ8fEao+3DUgsBwXdN6sRnOI34HtJEpZhEXA83HQbNyITMJO /TQgOgW+fY7fqAH25O04LAzhzMK8Ch1wYeBXqKhrz3EURLeCBRRGwHkCgTLbOtbv+Oy5 59XSbojQvg7rMzmR2vYsZb7y3gNH0AzJ0jUKkXmCJsjLKvJ8bVQemzkeLsy4z5CDG2B2 uZ6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=VyeZHDdSwGISZyzqOK+B4uXVVUSgq43HQIoWxpUGxj4=; b=u+cdnFoLHvXwrLG6wx4eu8acvmQPHKwyp4pCHtVo/MFsoC8iVS3G6NlIwOjLTJNUBd jNIxjp9KBnsms/L16aKW5GsuqE1rCGt96ROUJRpARIQQTjHLnrpASMy5VAzg9jJOhNlP MdGH9gyfO7+Gi3aozDBL6zykgJF7KZCyKh0l5pyXVGEosPnHav/WnOOlb0+rXzFPdhfm UeunjRvesqFFuGvcARrH+uFYiY2xC7C7OC3wjqHoV8zHt7Sf6bG45SCfhkRRwmx8SyHD h306QXNJ6nEcssZ7f/ksBJaFL/pM7sImikaWO4z63fxv/Zey0QIjOsnP6FaK98jgfgt+ wauA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=TnpWk0pF; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dm3si20923749ejc.316.2021.11.07.16.27.27; Sun, 07 Nov 2021 16:27:50 -0800 (PST) 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; dkim=pass header.i=@gmail.com header.s=20210112 header.b=TnpWk0pF; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236097AbhKGSAu (ORCPT + 99 others); Sun, 7 Nov 2021 13:00:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236040AbhKGSAk (ORCPT ); Sun, 7 Nov 2021 13:00:40 -0500 Received: from mail-ed1-x529.google.com (mail-ed1-x529.google.com [IPv6:2a00:1450:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A7F4C061570; Sun, 7 Nov 2021 09:57:57 -0800 (PST) Received: by mail-ed1-x529.google.com with SMTP id o8so53301456edc.3; Sun, 07 Nov 2021 09:57:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=VyeZHDdSwGISZyzqOK+B4uXVVUSgq43HQIoWxpUGxj4=; b=TnpWk0pFTsLmNk8kJbZWTS7Gy1s6k52LvKPishdlowMQAxNKbwHvJWL1Y5fcDnreuG FRtkdNUyEOZqNCOcKWzZJ/iVzVldQt7G3pjpU74H0ohQhYrpnpH5siAV1RO5OCsnt4p6 s5HEPHne+Z58cPV+Jn43v972a0aObB1OKZ1Ddou6x5jGzWChIKNunRvfocXmA+k+knRg 4TRnF6oEaFGph/hKRYnw6ScgrlxZeSJEBsDU0W9sa/VVAnpd7BN31bYeO78+o1PqiE8W PrgfXp6oynpk1mjHzRRbUCMSLniVq9GKhqoj2vB2z+wA1fjfnOiANLPrwLfrZ4Q186xQ OXhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=VyeZHDdSwGISZyzqOK+B4uXVVUSgq43HQIoWxpUGxj4=; b=Y9pY0Xpnn1/SrSfdi5b5bPTNNTMZ3NSGgiwEjUXKiCL52XT92U5705/wdLYkZF+d6t M69vRj9zGqEwe17L+P0h/WQpN9xe8MG+GprMczKSCcZzkLlMT56tE/g4oLvQsmjsWJBR 7It79IhxhXCWBHNvoZWssoEyJ1fq8sXkzzCNCb9k+PRXLTXKGwWX/bwyrMP+IpONtz3f kr5Xj5nPq0az4jJwGN6oCPH/AHvjqd5CDnhbbSGsrHwXmyWaMAnEeb3Jvl342Tvs15tC y6e6HNJAGKQN+Fors6r5YWmrDkJMUXq30CItvSreah17Au42PklX8cEesFgYgi69RKuR 2SCg== X-Gm-Message-State: AOAM531mfx7FLJStsBA5kFI+OQV/hSA9IwlQGRJ8lghzx6STfhULecbl hny4HgJpN5iULjmEZkuLps8= X-Received: by 2002:a17:906:ecac:: with SMTP id qh12mr31479962ejb.377.1636307876105; Sun, 07 Nov 2021 09:57:56 -0800 (PST) Received: from Ansuel-xps.localdomain (93-42-71-246.ip85.fastwebnet.it. [93.42.71.246]) by smtp.googlemail.com with ESMTPSA id m11sm4251182edd.58.2021.11.07.09.57.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Nov 2021 09:57:55 -0800 (PST) From: Ansuel Smith To: Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Jakub Kicinski , Rob Herring , Jonathan Corbet , Pavel Machek , Ansuel Smith , John Crispin , netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-leds@vger.kernel.org Subject: [RFC PATCH 2/6] leds: permit to declare supported offload triggers Date: Sun, 7 Nov 2021 18:57:14 +0100 Message-Id: <20211107175718.9151-3-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211107175718.9151-1-ansuelsmth@gmail.com> References: <20211107175718.9151-1-ansuelsmth@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org With LEDs that can be offload driven, permit to declare supported triggers in the dts and add them to the cled struct to be used by the related offload trigger. This is particurally useful for phy that have support for HW blinking on tx/rx traffic or based on the speed link. Signed-off-by: Ansuel Smith --- Documentation/leds/leds-class.rst | 4 ++++ drivers/leds/led-class.c | 15 ++++++++++++++- include/linux/leds.h | 5 ++++- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/Documentation/leds/leds-class.rst b/Documentation/leds/leds-class.rst index 035a738afc4a..ab50b58d6a21 100644 --- a/Documentation/leds/leds-class.rst +++ b/Documentation/leds/leds-class.rst @@ -191,6 +191,10 @@ If the second argument (enable) to the trigger_offload() method is false, any active HW offloading must be deactivated. In this case errors are not permitted in the trigger_offload() method. +LEDs can declare the supported offload trigger using linux,supported-offload-triggers +binding in the dts. This is just an array of string that will be used by any +offload trigger to check the supported triggers and configure the LED offload mode +and bheaviour. Known Issues ============ diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c index f4bb02f6e042..56f75e70b81e 100644 --- a/drivers/leds/led-class.c +++ b/drivers/leds/led-class.c @@ -339,7 +339,7 @@ int led_classdev_register_ext(struct device *parent, char composed_name[LED_MAX_NAME_SIZE]; char final_name[LED_MAX_NAME_SIZE]; const char *proposed_name = composed_name; - int ret; + int count, ret; if (init_data) { if (init_data->devname_mandatory && !init_data->devicename) { @@ -358,6 +358,19 @@ int led_classdev_register_ext(struct device *parent, if (fwnode_property_present(init_data->fwnode, "retain-state-shutdown")) led_cdev->flags |= LED_RETAIN_AT_SHUTDOWN; + + if (fwnode_property_present(init_data->fwnode, + "linux,supported-offload-triggers")) { + count = fwnode_property_string_array_count( + init_data->fwnode, "linux,supported-offload-triggers"); + + led_cdev->supported_offload_triggers = + kcalloc(count, sizeof(char *), GFP_KERNEL); + fwnode_property_read_string_array( + init_data->fwnode, "linux,supported-offload-triggers", + led_cdev->supported_offload_triggers, count); + led_cdev->supported_offload_triggers_count = count; + } } } else { proposed_name = led_cdev->name; diff --git a/include/linux/leds.h b/include/linux/leds.h index 949ab461287f..ff1f903f8079 100644 --- a/include/linux/leds.h +++ b/include/linux/leds.h @@ -157,7 +157,10 @@ struct led_classdev { #ifdef CONFIG_LEDS_OFFLOAD_TRIGGERS int offloaded; - /* some LEDs cne be driven by HW */ + /* LEDs can have multiple offload triggers */ + int supported_offload_triggers_count; + const char **supported_offload_triggers; + /* some LEDs may be able to offload some SW triggers to HW */ int (*trigger_offload)(struct led_classdev *led_cdev, bool enable); #endif -- 2.32.0