Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934557AbdGTKhX (ORCPT ); Thu, 20 Jul 2017 06:37:23 -0400 Received: from mail-wr0-f175.google.com ([209.85.128.175]:34283 "EHLO mail-wr0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934414AbdGTKhU (ORCPT ); Thu, 20 Jul 2017 06:37:20 -0400 Subject: Re: [PATCH v3 3/5] pwm-backlight: add support for PWM delays proprieties. To: Pavel Machek Cc: Enric Balletbo i Serra , Thierry Reding , Lee Jones , Jingoo Han , Bartlomiej Zolnierkiewicz , Rob Herring , Richard Purdie , Jacek Anaszewski , Heiko Stuebner , linux-pwm@vger.kernel.org, linux-fbdev@vger.kernel.org, linux-kernel@vger.kernel.org, groeck@chromium.org, linux-rockchip@lists.infradead.org References: <20170717212811.25374-1-enric.balletbo@collabora.com> <20170717212811.25374-3-enric.balletbo@collabora.com> <20170720080656.GC13103@amd> From: Daniel Thompson Message-ID: <38adad8d-754b-d1dd-167a-913afd8075d6@linaro.org> Date: Thu, 20 Jul 2017 11:37:17 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <20170720080656.GC13103@amd> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1227 Lines: 42 On 20/07/17 09:06, Pavel Machek wrote: > Hi! > >>> --- a/drivers/video/backlight/pwm_bl.c >>> +++ b/drivers/video/backlight/pwm_bl.c >>> @@ -10,6 +10,7 @@ >>> * published by the Free Software Foundation. >>> */ >>> +#include >>> #include >>> #include >>> #include >>> @@ -35,6 +36,7 @@ struct pwm_bl_data { >>> struct gpio_desc *enable_gpio; >>> unsigned int scale; >>> bool legacy; >>> + unsigned int pwm_delay[2]; >> >> Two named members would be better here (eliminating the "magic" 0 >> and 1). > > My thought, too. > >>> @@ -56,6 +58,9 @@ static void pwm_backlight_power_on(struct pwm_bl_data *pb, int brightness) >>> pwm_enable(pb->pwm); >>> + if (pb->pwm_delay[0]) >>> + usleep_range(pb->pwm_delay[0], pb->pwm_delay[0] * 2); > > Plus I'd just do the delay unconditionally :-). ... does this still apply if this code is switched to msleep()? msleep() has no wait avoidance[1] and if lots of drivers are reckless about sleeping for 10ms it soon starts to show up in the boot time (especially optimized ones). Daniel. [1] As it happens I can't see that many early bail out paths in usleep_range() either.