Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp484335ybn; Wed, 25 Sep 2019 03:02:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqxfNMHGBfE0Zf68dKgHcRJzQOvzvaOf3gh3sJECdqOXMGT3X98JQyxU/IIpfke6iW7JpnzG X-Received: by 2002:a2e:50b:: with SMTP id 11mr5686229ljf.11.1569405774304; Wed, 25 Sep 2019 03:02:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569405774; cv=none; d=google.com; s=arc-20160816; b=I92VfGAI2Sclm9WfyL6cMweEvicZnjQOfQN3XyGZcMSc6kM0PQfryh0IscX734H/xg ci/aDQVJrwkp4Eg+WyZ9MoPG2AHbkIqAOSU8/IQmigvldfKDjllteYtaqeQ94jOzdXVS 0GhHIhhYgqjq7SnZSkDBaLp9jFzLOFB/gYvcpQElW2xTNs5FgA/1GBN8+sd2YtLi3B7s NJXEleEVgyqYiUoBvfcbVQ/aaP0Ye9p6AyVUjv7ILKPVEtdB+IQpTUnTfwjw1rWCF2U3 230eQNEf8H0NEuP5y/FnLr0FxvcnyRa/URlyvV9v4CHrWa5Hv4f4BKJkrlOWCyfAZkVw QE6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=Bo3LHciudT0e3Wr5RFxKeQr9Fv9edwVOpiANXYmskNo=; b=MsZly0ejKl9IGcE6VQkwyiyiUcoWx1DP7MabSjWzve14yaV7u/uahwG5cvkdIq/si2 tjuaPsTsHk6WIsuVpyXSTNq5YQcjEjOScFQlwLRPHBhUrfxK1m7Hfd2sv8qd/tKRKHVY epyDbHH44SFHUrIjpDipx9tt2ANp+5nsIqgR60nbPWBloo+XeqqYPuzXgoyDz5nv3uRy CAF9StM+LJRRptM9Fg3S7Ix3gT0hpQGhlpG5U6Eqj3IliWRdyUPv+CaVSQbHdCvjddCL QUyXaxvZKAW+vX2zpAHmlxYnu+xPsd6fFbEUcIHetX4dDjoL+zbWTQxAwTGIMYdDaa7L htAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b="Z/Q8cf9e"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z26si2285876ejw.359.2019.09.25.03.02.16; Wed, 25 Sep 2019 03:02:54 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b="Z/Q8cf9e"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730071AbfIWJO3 (ORCPT + 99 others); Mon, 23 Sep 2019 05:14:29 -0400 Received: from fllv0016.ext.ti.com ([198.47.19.142]:47198 "EHLO fllv0016.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726363AbfIWJO2 (ORCPT ); Mon, 23 Sep 2019 05:14:28 -0400 Received: from fllv0034.itg.ti.com ([10.64.40.246]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id x8N9EMvN130460; Mon, 23 Sep 2019 04:14:22 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1569230062; bh=Bo3LHciudT0e3Wr5RFxKeQr9Fv9edwVOpiANXYmskNo=; h=Subject:To:CC:References:From:Date:In-Reply-To; b=Z/Q8cf9eV1MFBKGu1OyC4oMQP6T0YS1B5ISVX+a3tX2tcvjO4Dyt9b83V89On6aKK wm/IwosRtWqOfhOq+X82+auTkVxgci7JsyhMAUzZuSfs9im2NLiYKRJqGSfQaXJyUT a8ulpXMXFtrVKRDZHBM06SmifUpS9k4o+cGqEoh0= Received: from DFLE102.ent.ti.com (dfle102.ent.ti.com [10.64.6.23]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x8N9EMnf082374 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 23 Sep 2019 04:14:22 -0500 Received: from DFLE108.ent.ti.com (10.64.6.29) by DFLE102.ent.ti.com (10.64.6.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Mon, 23 Sep 2019 04:14:22 -0500 Received: from fllv0039.itg.ti.com (10.64.41.19) by DFLE108.ent.ti.com (10.64.6.29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5 via Frontend Transport; Mon, 23 Sep 2019 04:14:16 -0500 Received: from [10.250.99.146] (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id x8N9EK8P046730; Mon, 23 Sep 2019 04:14:21 -0500 Subject: Re: [PATCH v4 1/3] led: make led_set_brightness_sync() use led_set_brightness_nosleep() To: Jacek Anaszewski , , CC: , , , References: <20190920122525.15712-1-jjhiblot@ti.com> <20190920122525.15712-2-jjhiblot@ti.com> From: Jean-Jacques Hiblot Message-ID: <2172e1c7-931e-d510-648b-80ef9c606ab6@ti.com> Date: Mon, 23 Sep 2019 11:14:20 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Jacek, On 20/09/2019 23:10, Jacek Anaszewski wrote: > Hi Jean, > > On 9/20/19 2:25 PM, Jean-Jacques Hiblot wrote: >> Making led_set_brightness_sync() use led_set_brightness_nosleep() has 2 >> advantages: >> - works for LED controllers that do not provide brightness_set_blocking() >> - When the blocking callback is used, it uses the workqueue to update the >> LED state, removing the need for mutual exclusion between >> led_set_brightness_sync() and set_brightness_delayed(). > And third: > > - it compromises the "sync" part of the function name :-) Making it sync is the role of the flush_work() function. It waits until the deferred work has been done. JJ > This function has been introduced specifically to be blocking > and have the immediate effect. Its sole client is > drivers/media/v4l2-core/v4l2-flash-led-class.c. > >> Signed-off-by: Jean-Jacques Hiblot >> --- >> drivers/leds/led-core.c | 12 +++++++----- >> 1 file changed, 7 insertions(+), 5 deletions(-) >> >> diff --git a/drivers/leds/led-core.c b/drivers/leds/led-core.c >> index f1f718dbe0f8..50e28a8f9357 100644 >> --- a/drivers/leds/led-core.c >> +++ b/drivers/leds/led-core.c >> @@ -294,15 +294,17 @@ EXPORT_SYMBOL_GPL(led_set_brightness_nosleep); >> int led_set_brightness_sync(struct led_classdev *led_cdev, >> enum led_brightness value) >> { >> + int ret; >> + >> if (led_cdev->blink_delay_on || led_cdev->blink_delay_off) >> return -EBUSY; >> >> - led_cdev->brightness = min(value, led_cdev->max_brightness); >> - >> - if (led_cdev->flags & LED_SUSPENDED) >> - return 0; >> + ret = led_set_brightness_nosleep(led_cdev, value); >> + if (!ret) >> + return ret; >> >> - return __led_set_brightness_blocking(led_cdev, led_cdev->brightness); >> + flush_work(&led_cdev->set_brightness_work); >> + return 0; >> } >> EXPORT_SYMBOL_GPL(led_set_brightness_sync); >> >>