Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp2636724rwb; Fri, 20 Jan 2023 05:38:48 -0800 (PST) X-Google-Smtp-Source: AMrXdXtC2NZn7XodfL0ZDDA0D2H3Gr0g0wRy45hYZMG1gMEzUxDReITyIIyoeTqLeNGuWo/lnhP2 X-Received: by 2002:a05:6a00:430a:b0:574:35fd:379e with SMTP id cb10-20020a056a00430a00b0057435fd379emr14908809pfb.2.1674221928409; Fri, 20 Jan 2023 05:38:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674221928; cv=none; d=google.com; s=arc-20160816; b=bJwks4YJlRHBOTnmGK31t0JjXj90zy3H9rITHwgPJrP3woz6db4zsMVVjiIiCefneI Z8faN3LWq1pWcTptVOs4mP7/1Q5+UWD9l4JsQ/BuRBDeJw0vly3JX38IuOW6ErZG1vSk tQ393pDbNQSDha2qcNqIUixKK1yvCw5syloNRHII2JxUuQ3+dycqe0Y0OxIv5GaDeH5V YGGU0+OuKghIm7g3S3rxSxMzDADxbAj8cvczmmRW8Q/lh+b4weElbOnzkCh/7wGsINsF U+vPIX3Qhg0J/LnVO6ytNNjE0SHeVOzf9PGQ8ma54Rqe9uEhNQ8vUdNDSN2J8AlyQZ3a ToxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=BMjqCjirShjVtuaz8rQa75RoliOGr7Ji6qkIjZUY65M=; b=BWROhsXs+XWGOWp89xuZ8s3hL6pk6jRgJ/QsivTysg30bVoQHNOEsF01qTWeXh0aNP TA6N+qKLi1vqfsE9D6vgO0jHBngBYN7UeoG+FwHiTM+RcYSXjGPMBoWpeKhAFrNPg1IH v4Bl+8pFdBURl/2eDLqKeXeWau9tV7GyoJIbGNZesF7QOmCX8ez9QHUUz60ABpLoIyp9 hIHvY+obj/JdP+C01gOMLZRu8zCxCB4P3j5bWXmg/qgjrhXhriABp3/FWfnBokgILgD1 tmyRIFWcHh2U/vfArXQ0GVIxMk6q/sfY90IJc3h5ZtqdxonV+JFgghe/dGz1O5p0APWe nBjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=LfV3hfiq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u70-20020a627949000000b00588c119c016si34993399pfc.135.2023.01.20.05.38.42; Fri, 20 Jan 2023 05:38:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=LfV3hfiq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229784AbjATN2B (ORCPT + 51 others); Fri, 20 Jan 2023 08:28:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43606 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229609AbjATN17 (ORCPT ); Fri, 20 Jan 2023 08:27:59 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 96FC63D08F; Fri, 20 Jan 2023 05:27:58 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 52A38B82827; Fri, 20 Jan 2023 13:27:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CE326C433D2; Fri, 20 Jan 2023 13:27:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674221275; bh=Tq1E8pyeCQPwUYf1ZR4/fdWEN6omesfFHTkmVrGa92c=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=LfV3hfiqxwvoDK//mZGT9qFEcQnUW1SloBQDbmtwkZs6OBuu/xSZq9DKEHbQ+7mak vHzPQpkjwyGs59ZDZjvFTHxUELgHm/Kw7T4+ugTTbYGuWE5gu2FRaJCfFKD1iOVB3R JU6JgoLB22eE/7IbbQNwrp1N703HmZLoBmVyGsyLE/6LQ+1gDZGqrPtZoi8fn425AE 89WvN7RXFq2cLKbJHoPNC1paqwU8iHBMMFhteObNfw3gdbJRHqd50S/Un1U+8U86UJ jY9ee9LP2rzNA8zRcv7CnrLS2U8UsAadT+PL40uL22TXdLt+9fLBlpVQeq8XUtNCq0 7PUKvEmHlX0DQ== Date: Fri, 20 Jan 2023 13:27:50 +0000 From: Lee Jones To: Jacek Anaszewski Cc: Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= , Qingtao Cao , Qingtao Cao , Pavel Machek , linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/1] leds: ledtrig-tty.c: call led_set_brightness() when the blocking callback is not available Message-ID: References: <20221209001039.7287-1-qingtao.cao@digi.com> <20221209124058.dwez7wohs7dfeiik@pengutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 07 Jan 2023, Jacek Anaszewski wrote: > Hi all, > > On 1/4/23 17:20, Lee Jones wrote: > > On Fri, 09 Dec 2022, Uwe Kleine-König wrote: > > > > > On Fri, Dec 09, 2022 at 10:10:38AM +1000, Qingtao Cao wrote: > > > > The Marvell GPIO controller's driver will setup its struct gpio_chip's can_sleep > > > > false, making create_gpio_led() setting up the brightness_set function pointer > > > > instead of the brightness_set_blocking function pointer. In this case the > > > > nonblocking version led_set_brightness() should be fallen back on by ledtrig_tty_work() > > > > > > > > Signed-off-by: Qingtao Cao > > > > --- > > > > drivers/leds/trigger/ledtrig-tty.c | 10 ++++++++-- > > > > 1 file changed, 8 insertions(+), 2 deletions(-) > > > > > > > > diff --git a/drivers/leds/trigger/ledtrig-tty.c b/drivers/leds/trigger/ledtrig-tty.c > > > > index f62db7e520b5..e43d285b5d06 100644 > > > > --- a/drivers/leds/trigger/ledtrig-tty.c > > > > +++ b/drivers/leds/trigger/ledtrig-tty.c > > > > @@ -122,12 +122,18 @@ 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); > > > > + if (trigger_data->led_cdev->brightness_set_blocking) > > > > + led_set_brightness_sync(trigger_data->led_cdev, LED_ON); > > > > + else if (trigger_data->led_cdev->brightness_set) > > > > + led_set_brightness(trigger_data->led_cdev, LED_ON); > > > > > > I had similar issues in the past where a function call worked for > > > sleeping LEDs but not atomic ones (or the other way around? Don't > > > remember the details.) > > > > > > I wonder if there isn't a function that does the right thing no matter > > > what type the LED is. The other triggers should have the same issue, and > > > doing the above check in all of them just looks wrong. > > > > Anyone fancy taking a deeper dive into this? > > > > I'd usually have a go myself, but I'm presently swamped. > > > > Pavel already has an idea? > > > > There is led_set_brightness_nosleep() and it should be used here > from the beginning. Generally it should be used always in triggers. Thanks for helping to keep an eye on things Jacek. Much appreciated. -- Lee Jones [李琼斯]