Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp451965rwr; Thu, 20 Apr 2023 01:33:45 -0700 (PDT) X-Google-Smtp-Source: AKy350bjZZMQgg436gGZlNzK/m/mEeJCuIj7Ns+5MIqMNSlTVNPHNyOzruy+0FeJaAvL0PtlS4Pu X-Received: by 2002:a17:903:2987:b0:1a6:bb7b:7a40 with SMTP id lm7-20020a170903298700b001a6bb7b7a40mr777742plb.64.1681979625205; Thu, 20 Apr 2023 01:33:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681979625; cv=none; d=google.com; s=arc-20160816; b=wezV2pdpCQrYkDif5+E4K3lh6LXAoiEtgt2HEu+pFU8u/DQpNg9yReSr9ZbXNich0Z rfacOOFkYZ6M/Pk7xex4zZk8JmxUeOvMy3zQc3hwxVIFrYYInwG9BlQ6LCj2ypxaMPSA JZ806brDNpXRk4h542L7x/EPD+sMYm82e6tpPjxHkuUVVairqLpIh/UDRXyRZ5mrhlzt 4jBhpc/tTMf2myGCZbe+kp2i+oeeTWKgU+RZ5U7bY3We1dIgkwtemVMF99Io++O95uvC ALrSdaVnqYSEZMzCpd8AcKsR0O9BxkSvSYNzznO4rsTPtO09RPR4znzU+A+KVK6tOgfG uNpw== 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=b+FjfRmR22cJrJma/6ivIa3YCYJTPdzpncndd49SxqQ=; b=YDE3KpAWbIdB0QdMa6v05zqkM1DNArQp2HGBrAtlk2fQUZiXhq/EdJppBTarcf9mHw 202DOz2Ac6gFUDAAlOfSVygTaiP8y0qfYUsgLjVfVveZkUjb+0Rc2VbzJUa5//iBgk8U YOEFLQZJaQKT0/Tci/rHS7k4XBWQP/ScRsKQx/CPO6SqDc9ZcEyW3oujvTJgyL5nQraB 1dkBDVMAjIqv3ROqvsC5/HY90yc/GrhTjfCZ4d0kTyk6zUUMvuUzllTWpKdNzuXdY0Il 52ye4ppyOP4N1Qd6tTR70im+LlhILT/MFe4Nu1j8C8gFW7MrQeKJx1wKm2/NSIHA2F01 xTeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="RSaIJl/4"; 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 k7-20020a170902ce0700b001a6eb86e0bcsi1422812plg.294.2023.04.20.01.33.34; Thu, 20 Apr 2023 01:33:45 -0700 (PDT) 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="RSaIJl/4"; 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 S234414AbjDTIWf (ORCPT + 99 others); Thu, 20 Apr 2023 04:22:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52834 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233947AbjDTIWd (ORCPT ); Thu, 20 Apr 2023 04:22:33 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0BEB626B3; Thu, 20 Apr 2023 01:22:30 -0700 (PDT) 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 dfw.source.kernel.org (Postfix) with ESMTPS id 90051645E6; Thu, 20 Apr 2023 08:22:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0590DC433D2; Thu, 20 Apr 2023 08:22:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1681978947; bh=S6H5PDpbon+c+zJoAhcp+xf9q+yBVa0TMRe9t5rUVuw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=RSaIJl/4PHmkhfJoMtSl5CpTBcy/cZJuGad086SLCzEOg8G/jdfICrHPmzS+W6yfB wWdQWhlkG317bH19nQaG1MCodBqczMZeCgJoeWbnGh6QU0TSdXuSUO2HhzpSxFpNLj ULkkYU7cNemnI3HIg2OtoYgIwa/vpwu9/xH41LU0N29VAolyIJ3B3qTOkP8YQb7dy9 EojsJUlOE2ND6wBXv8hFHbffAiEnhhH16wpQT4vQPYU9j9dONS0vnXjJDPPLNx9dlg PMKxNcrQMrUFHbPPq4oSN7Bi+lEBy/meI9REsEB539/TlKC+01BnYq6A/vnSHqHp00 cq3q+SsMDCpDg== Date: Thu, 20 Apr 2023 09:22:22 +0100 From: Lee Jones To: Eddie James Cc: linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org, pavel@ucw.cz Subject: Re: [RESEND] leds: Ensure hardware blinking turns off when requested Message-ID: <20230420082222.GC9904@google.com> References: <20230405165028.73579-1-eajames@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20230405165028.73579-1-eajames@linux.ibm.com> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 Wed, 05 Apr 2023, Eddie James wrote: > If an LED is blinking through the hardware and the trigger is deactivated, > the driver will set the brightness to 0 to disable blinking. However, if > the LED driver doesn't support non-blocking operations, the request for > setting brightness to 0 will get queued. Then if a user requests a new > non-zero brightness before the request for 0 brightness is executed, the > LED blinking will not get disabled since the brightness will simply be > updated. > Fix this by flushing the workqueue before updating the requested > brightness. You make a convincing argument for this. > Fixes: 4d71a4a12b13 ("leds: Add support for setting brightness in a synchronous way") > Signed-off-by: Eddie James > --- > drivers/leds/led-class.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c > index 9255bc11f99d..78a270300d30 100644 > --- a/drivers/leds/led-class.c > +++ b/drivers/leds/led-class.c > @@ -57,6 +57,8 @@ static ssize_t brightness_store(struct device *dev, > > if (state == LED_OFF) > led_trigger_remove(led_cdev); > + /* flush out any request to disable blinking */ > + flush_work(&led_cdev->set_brightness_work); > led_set_brightness(led_cdev, state); > flush_work(&led_cdev->set_brightness_work); Just to be clear, you want to flush the work before AND after setting the brightness? In the commit message, could you make it clear why simply moving this flush won't work. -- Lee Jones [李琼斯]