Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3319081imu; Wed, 7 Nov 2018 08:29:51 -0800 (PST) X-Google-Smtp-Source: AJdET5cYoGzlsDDYTgCmCfUiIrdmfMYx//SjwBm8DCzz88KS3DKXQJLq86EReoy4jUu3zYQFnkvd X-Received: by 2002:a62:31c2:: with SMTP id x185-v6mr875412pfx.39.1541608191912; Wed, 07 Nov 2018 08:29:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541608191; cv=none; d=google.com; s=arc-20160816; b=c8F2ljwyArdEQYuD3Io29Q04uN9nk8+bwrDBLRWp7AK1+eIRZcN88zVXRqRshtaiQT fXoIz/tQaMty1UZFpErWNCeCrdUP6BNVEZXZ7TcqXzXyb5wJYGODtmTg6WnQE9nYOjGp A9vNXMz/yqOhInPKBz9O7MV5i6AzCduco4B5VLipuvSRv5Zr/3H9SYPz64hzEaIpJ8wQ r7P25JlZ07+36+V7Q1rDkuUD28qEycDVmLjqCX9wJNULYVoz/Wlu77P2ipq5LTTntZim RaZzJPqDreIDqwxM9nmQkefeAF80FoMX13jdVsq1/t5s3oWEMPfYVyE6AA0Y52/+lYjW CcQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=5IQ7IREIGjlsyjir25BQfFTa3RtkG+nSv7mnMM6maKQ=; b=SC0DyZiVvPMF86PGNGNLvHx/ShIHMWnz0EQiUDUUTsIzsdJcWcCsQ+VUcuaSIZ5gja G6KY84+HenIRTTb6d0oKX0N+eiHMaRuhXdXKaFdWXPx1nxbYu8vy4lHR16x3UikWn1ME X09Xff6wkf6XKngseIv9/dnSlZrsLYLKYXjWjKZ2aTjwpbB9wIuP52V/rdDhvldCj+YM UpR+17lw7hT68MXtbpYciXh0EjWvd6L6GxEDZjA+LqMYWTwpmQr7HRDcALSabSTb6laa hlqUw0mlqatGuDBDJ2Gir75+xWmh0Dk8sb9toQ/bKWYtjo4kfZkNvj6PSzB/eLl9sj5e T/Gg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m3-v6si946869pgr.32.2018.11.07.08.29.36; Wed, 07 Nov 2018 08:29:51 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727989AbeKHCAR (ORCPT + 99 others); Wed, 7 Nov 2018 21:00:17 -0500 Received: from metis.ext.pengutronix.de ([85.220.165.71]:52353 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727546AbeKHCAQ (ORCPT ); Wed, 7 Nov 2018 21:00:16 -0500 Received: from ptx.hi.pengutronix.de ([2001:67c:670:100:1d::c0]) by metis.ext.pengutronix.de with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1gKQhZ-0005py-Ln; Wed, 07 Nov 2018 17:29:09 +0100 Received: from ukl by ptx.hi.pengutronix.de with local (Exim 4.89) (envelope-from ) id 1gKQhZ-0007KT-3M; Wed, 07 Nov 2018 17:29:09 +0100 Date: Wed, 7 Nov 2018 17:29:09 +0100 From: Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= To: =?iso-8859-1?Q?Cl=E9ment_P=E9ron?= Cc: Thierry Reding , Florian Fainelli , Ray Jui , Scott Branden , bcm-kernel-feedback-list@broadcom.com, linux-pwm@vger.kernel.org, linux-kernel@vger.kernel.org, Suji Velupillai Subject: Re: [PATCH 2/2] pwm: bcm-kona: apply pwm settings on enable Message-ID: <20181107162908.tejzekhc35pbknut@pengutronix.de> References: <20181107093613.26734-1-peron.clem@gmail.com> <20181107093613.26734-2-peron.clem@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20181107093613.26734-2-peron.clem@gmail.com> User-Agent: NeoMutt/20170113 (1.7.2) X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::c0 X-SA-Exim-Mail-From: ukl@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 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, On Wed, Nov 07, 2018 at 10:36:13AM +0100, Cl?ment P?ron wrote: > From: Suji Velupillai > > When pwm_bl framework calls enable, a call to pwm_is_enabled(pwm) still > return false, this prevents the backlight being turn on at boot time. > > Signed-off-by: Suji Velupillai > Signed-off-by: Cl?ment P?ron > --- > drivers/pwm/pwm-bcm-kona.c | 16 +++++++++++----- > 1 file changed, 11 insertions(+), 5 deletions(-) > > diff --git a/drivers/pwm/pwm-bcm-kona.c b/drivers/pwm/pwm-bcm-kona.c > index 09a95aeb3a70..d991d53c4b38 100644 > --- a/drivers/pwm/pwm-bcm-kona.c > +++ b/drivers/pwm/pwm-bcm-kona.c > @@ -108,8 +108,8 @@ static void kona_pwmc_apply_settings(struct kona_pwmc *kp, unsigned int chan) > ndelay(400); > } > > -static int kona_pwmc_config(struct pwm_chip *chip, struct pwm_device *pwm, > - int duty_ns, int period_ns) > +static int __pwmc_config(struct pwm_chip *chip, struct pwm_device *pwm, > + int duty_ns, int period_ns, bool pwmc_enabled) > { > struct kona_pwmc *kp = to_kona_pwmc(chip); > u64 val, div, rate; > @@ -155,7 +155,7 @@ static int kona_pwmc_config(struct pwm_chip *chip, struct pwm_device *pwm, > * always calculated above to ensure the new values are > * validated immediately instead of on enable. > */ > - if (pwm_is_enabled(pwm)) { > + if (pwm_is_enabled(pwm) || pwmc_enabled) { Having pwm-API-calls in hw-drivers is ugly. Apart from not giving the intended return code this function should IMHO be reserved to pwm consumers. The underlaying problem is that pwm-bl does: pwm_config(pwm, duty_cycle, period); pwm_enable(pwm); and expects that the duty_cycle and period is used then. Doesn't everything works just fine if the if-block is always executed? The better fix here would be to convert the driver to the atomic API (i.e. implement .apply instead of .config, .set_polarity, .enable and .disable). Alternatively in .enable ensure that the hardware is programmed with the parameters from pwm->state. (But converting to the atomic API is the better approach.) Best regards Uwe -- Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |