Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp2552266pxy; Mon, 3 May 2021 02:47:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxgwLopGlB8OIOPm2CMydzMd1v3nZUyZJtTy7Par0w69xs/qFCecmhUxetMIDfxHS6ronmY X-Received: by 2002:a63:a62:: with SMTP id z34mr17149996pgk.189.1620035242541; Mon, 03 May 2021 02:47:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620035242; cv=none; d=google.com; s=arc-20160816; b=w918hjl/DKqc2l1Fyudm82O312hkG0wAJDNCIbsj7o+Eknd44iyuOQrJoC/I8s4iz8 PXUOiXJer/dmo/6aSAPn91eJx+TY+2htQylmbG+FfJUrLb4/anVHCm3GIh6ZHq/a4rhb Nxs1hObUmltJIRIyR7x8/9N/C+Idhl0I0dwFoeZu/P0xYOL76Tqd02xa2C6/l8p1+O8t DIWAVAGg/Z2Z1arvTmpA7ihI3FPiAf1oRYsz7wqAmpq1P8SGaw3JhUnmGlm8AwgB9gms pGM9pLT5ohFej9+dJFRmICJ3vFnUXdDzeV8VzKItCAPODXmMy6yfJg6n8Kuoa1+zlQ/l RBWQ== 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 :message-id:date:subject:cc:to:from; bh=fGqvrO4RkOBnPCSKDJV2k8CycVb8l526xHyLQmam2pE=; b=0ZCdjW0D3mDAlYlY6c57ec4wbXbFHuGKli7ASdYs/cnqAnXPtKq8T9mZN8+4wu2V3d luawmwnBoOorCMYRVw7bnjvjeQaEA1AGYB4VFvl0wx6fMmRerz/vg+HlR/oLxP1lUsWh PIpMgEIWSL8NPTTqTcSSkgTcHjXFVawAsyEHn0I/ifsiZuPp3w1DoCWaM1vvujLn35rz m6VOOO3fa29ps6ThC8VItCx+wPisgcvTHRat1R/xpUObWdOe8KeAOJzzRFat9GZylTET Saj0JY9PM876benEKOAiNnoiD/qIVHcopLBQsr9Lt7Vb2e+d8NIk5hDoaDeaV/Nb4lO0 JYBA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p2si23481309pjv.24.2021.05.03.02.47.07; Mon, 03 May 2021 02:47:22 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233065AbhECJ0k (ORCPT + 99 others); Mon, 3 May 2021 05:26:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38692 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231531AbhECJ0j (ORCPT ); Mon, 3 May 2021 05:26:39 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA098C06174A for ; Mon, 3 May 2021 02:25:46 -0700 (PDT) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ldUpj-0007qu-Mh; Mon, 03 May 2021 11:25:43 +0200 Received: from [2a0a:edc0:0:900:2e4d:54ff:fe67:bfa5] (helo=ginster) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.92) (envelope-from ) id 1ldUpi-0007dH-9i; Mon, 03 May 2021 11:25:42 +0200 Received: from jbe by ginster with local (Exim 4.92) (envelope-from ) id 1ldUpi-0003mY-8r; Mon, 03 May 2021 11:25:42 +0200 From: Juergen Borleis To: linux-leds@vger.kernel.org, Pavel Machek Cc: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , linux-kernel@vger.kernel.org, Greg Kroah-Hartman , kernel@pengutronix.de Subject: [PATCH] leds: trigger/tty: Use led_set_brightness() to support all use cases Date: Mon, 3 May 2021 11:25:42 +0200 Message-Id: <20210503092542.14497-1-jbe@pengutronix.de> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: jbe@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Using led_set_brightness_sync() only works for LEDs which are connected via some kind of external bus like I²C or SPI. But it doesn't work for the simple use case of directly connected LEDs via GPIOs. Because this function only honors the led_classdev::brightness_set_blocking callback. But the LED-GPIO driver registers the led_classdev::brightness_set member if the GPIO can be modified directly and thus, TTY triggers fail silently with -ENOTSUPP. With the previously used led_set_brightness() it works for both use cases. This function first checks for the simple case where the GPIO can be changed without additional overhead, and if it fails, does the modification via a workqueue. Signed-off-by: Juergen Borleis --- drivers/leds/trigger/ledtrig-tty.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/leds/trigger/ledtrig-tty.c b/drivers/leds/trigger/ledtrig-tty.c index f62db7e..af61281 100644 --- a/drivers/leds/trigger/ledtrig-tty.c +++ b/drivers/leds/trigger/ledtrig-tty.c @@ -122,12 +122,12 @@ static void ledtrig_tty_work(struct work_struct *work) if (icount.rx != trigger_data->rx || icount.tx != trigger_data->tx) { - led_set_brightness_sync(trigger_data->led_cdev, LED_ON); + led_set_brightness(trigger_data->led_cdev, LED_ON); trigger_data->rx = icount.rx; trigger_data->tx = icount.tx; } else { - led_set_brightness_sync(trigger_data->led_cdev, LED_OFF); + led_set_brightness(trigger_data->led_cdev, LED_OFF); } out: -- 2.20.1