From patchwork Sat Oct 30 13:35:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ma=C3=ADra_Canal?= X-Patchwork-Id: 12594307 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 57A5AC433F5 for ; Sat, 30 Oct 2021 13:35:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3C5E260F93 for ; Sat, 30 Oct 2021 13:35:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230057AbhJ3Nho (ORCPT ); Sat, 30 Oct 2021 09:37:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39410 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230043AbhJ3Nhm (ORCPT ); Sat, 30 Oct 2021 09:37:42 -0400 Received: from mail-oo1-xc2c.google.com (mail-oo1-xc2c.google.com [IPv6:2607:f8b0:4864:20::c2c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BBB6CC061570 for ; Sat, 30 Oct 2021 06:35:11 -0700 (PDT) Received: by mail-oo1-xc2c.google.com with SMTP id 64-20020a4a0d43000000b002b866fa13eeso4429570oob.2 for ; Sat, 30 Oct 2021 06:35:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=usp.br; s=usp-google; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :content-transfer-encoding; bh=Nev+29M1Y1dwB8aNLPolRw0Uq6JykoAuwC6Ewa8Lyr0=; b=tNFwRZaatxKVz+oal5PP8bXPiWaWArv8l8l//iYUmI1e07rxYIh+AOmCklpCDd359F Nyo97MskPgcjPSiR5JYaJjW8B2GRH4Glr2gnWteoASulUpMxyxSV4wViJyG8v4zJ+R/Q ulq5j2//v4gpeiRRB3zAUAL/NtgOx+FzNJ7WEuiUVlLdz8IP0X9oW0WKUptbyonTRsXU Ey9+p6E7Ju5AoIcPWXtmAZGbFpr4eGGWyT6A98fLVz+ub//9rggqvBLMgjij9sBEQ/Hg vhU/u3h53AKVOQJxkjVS9E0TOjNl7sXB8TysTB1sUCb6KOPsaYwvS4MYYquJv1oiMqkC 3upA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:content-transfer-encoding; bh=Nev+29M1Y1dwB8aNLPolRw0Uq6JykoAuwC6Ewa8Lyr0=; b=IpMsw+G28jjucqB3oeAgWtjHXQ9kUBuAM141Kro44cZQLgsBLrjdilfwMJyXrtOcs1 f6WfLO42G76kGM5x3kM9yNmW/nqyYHr5GH2bzvI6CJm4EkU31sFPe0Mq2A8rs3uL35hC Uo21mRkZCq6PlAagM2DFLfVTNvPehVdVETQ7ufSGCfjpPV3xPnJX1NQnZh7WnISZbfOs nzvG/bINzaOPgv4Fzzqdi2Ec5o8UaF5XDyD5ln/v/n0BV+5euiGe8BheHG9q62nxGxYc WFxGIw8qe2OD1Dxhf3rY4DbiyK/GgiAO1ZdXLYoCUFyqkw5/iLNTc7CAPxOpcb/NXR0F 8UtQ== X-Gm-Message-State: AOAM532BFM8X5nWkPN76w8YlgQRGEhsLmYByKQOIOsE380uIKCm+Qd9S KsOW8suEOD9A3j44MznuJgqq3A== X-Google-Smtp-Source: ABdhPJwjjpBHKPmKcM3z74OuzMIlzc4ezhVJZqYnZiGJnG1xoug8fjPSJXFIFEjPjxIBspnt8rzQqQ== X-Received: by 2002:a4a:d51a:: with SMTP id m26mr11795989oos.84.1635600910990; Sat, 30 Oct 2021 06:35:10 -0700 (PDT) Received: from fedora ([187.64.134.142]) by smtp.gmail.com with ESMTPSA id u15sm2792185oon.35.2021.10.30.06.35.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 30 Oct 2021 06:35:10 -0700 (PDT) Date: Sat, 30 Oct 2021 10:35:05 -0300 From: =?iso-8859-1?q?Ma=EDra?= Canal To: lee.jones@linaro.org, daniel.thompson@linaro.org, jingoohan1@gmail.com, thierry.reding@gmail.com, u.kleine-koenig@pengutronix.de Cc: dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pwm@vger.kernel.org Subject: [PATCH v3] backlight: lp855x: Switch to atomic PWM API Message-ID: MIME-Version: 1.0 Content-Disposition: inline Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Remove legacy PWM interface (pwm_config, pwm_enable, pwm_disable) and replace it for the atomic PWM API. Signed-off-by: MaĆ­ra Canal Reported-by: kernel test robot Reported-by: kernel test robot --- V1 -> V2: Initialize variable and simply conditional loop V2 -> V3: Fix assignment of NULL variable --- drivers/video/backlight/lp855x_bl.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/drivers/video/backlight/lp855x_bl.c b/drivers/video/backlight/lp855x_bl.c index e94932c69f54..627a31d05691 100644 --- a/drivers/video/backlight/lp855x_bl.c +++ b/drivers/video/backlight/lp855x_bl.c @@ -233,9 +233,8 @@ static int lp855x_configure(struct lp855x *lp) static void lp855x_pwm_ctrl(struct lp855x *lp, int br, int max_br) { - unsigned int period = lp->pdata->period_ns; - unsigned int duty = br * period / max_br; - struct pwm_device *pwm; + struct pwm_device *pwm = NULL; + struct pwm_state state; /* request pwm device with the consumer name */ if (!lp->pwm) { @@ -245,18 +244,16 @@ static void lp855x_pwm_ctrl(struct lp855x *lp, int br, int max_br) lp->pwm = pwm; - /* - * FIXME: pwm_apply_args() should be removed when switching to - * the atomic PWM API. - */ - pwm_apply_args(pwm); + pwm_init_state(lp->pwm, &state); + state.period = lp->pdata->period_ns; } - pwm_config(lp->pwm, duty, period); - if (duty) - pwm_enable(lp->pwm); - else - pwm_disable(lp->pwm); + pwm_get_state(lp->pwm, &state); + + state.duty_cycle = br * state.period / max_br; + state.enabled = state.duty_cycle; + + pwm_apply_state(lp->pwm, &state); } static int lp855x_bl_update_status(struct backlight_device *bl)