From patchwork Wed Nov 3 17:38: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: 12601355 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 8D53DC433EF for ; Wed, 3 Nov 2021 17:38:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6C9C460724 for ; Wed, 3 Nov 2021 17:38:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230191AbhKCRkv (ORCPT ); Wed, 3 Nov 2021 13:40:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45802 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229943AbhKCRkt (ORCPT ); Wed, 3 Nov 2021 13:40:49 -0400 Received: from mail-ot1-x32f.google.com (mail-ot1-x32f.google.com [IPv6:2607:f8b0:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C824FC061203 for ; Wed, 3 Nov 2021 10:38:12 -0700 (PDT) Received: by mail-ot1-x32f.google.com with SMTP id n13-20020a9d710d000000b005558709b70fso4515997otj.10 for ; Wed, 03 Nov 2021 10:38:12 -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=KNIg2kQ3uZauu+dnwK3HwVUo4epk3uh+4Ru2o+wrxl0=; b=ILGjE1hgsxqN3af/0WC7REvDKgUS7+6LqX6lOkbSBAzASsdyW8wbRImU0SNUwB48Nc UW6KiJ1e0JCzGrLJAm7s6Lcl5AWZoMzgIP6wE38AC4mw+sV/R5PDAcvltRJ6jH/dF3xo wRC7HScW0cjAz9xgavhgDhIoNYFnQg4z3q+suYLGj8tfqJdROD1MSSkMM33ig/8XpPjw lTlJtkgar8mgjyJdvjTp1i6eRs/WbVekjEg2Qa6VYOpmHyxHvvoeCoGI7JmOKm0N35g7 CoDS1jynUT7ELatCQK+qEGU0rytOyhZIoxFKbYfvqNlgGEEdiKyr1CCm/mYaXKEHGVXa ZZGA== 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=KNIg2kQ3uZauu+dnwK3HwVUo4epk3uh+4Ru2o+wrxl0=; b=rpmmG9W077/4SyWfo3gvdGHfvoCEqglFF93pPp7u4SSr9/Wq3wPX3iGWnD4f82q83W FmRF/rmXQAJ/OUoeAZBkUcEv6LqhC++mmFwKG68HBK8rTL7Su7wA501c6ztUcrkj6hZH rg1gVGHqfxxZBgrkrfbI0VPVaxnjiPy52+HfPUf7HsPi5NQujZu7WoTDiVtxZMKEFXC/ 9XcFA5xxgINafgSSTdjxE0xUFG69wnkdcRo6tZRAGTcv6a8PJZDdFgrgdUWQytvn18bu v4izkvsQyY6t01qPpxzardGwtZBjIxS6/ZjBO3e+ytdIpbHZsbiI5UjbM6uE5n4QXJby 1gFQ== X-Gm-Message-State: AOAM531JvyH3NigBD7OD8BZl1/ChafiHrrnjxK7Tire4Wy7caGM5awuB HRTP4OB94pBR0c2W8hGDmHm94VS6oSL3G+Ns X-Google-Smtp-Source: ABdhPJwMefisJ6fYt8/aFM7zFKH09aYePVgs7ob6+8bNCxPG+kXZp8UpPBPULcCTaQBjsUg8VtkQsQ== X-Received: by 2002:a05:6830:1e42:: with SMTP id e2mr33459329otj.41.1635961092162; Wed, 03 Nov 2021 10:38:12 -0700 (PDT) Received: from fedora ([187.64.134.142]) by smtp.gmail.com with ESMTPSA id d7sm669920otl.19.2021.11.03.10.38.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Nov 2021 10:38:11 -0700 (PDT) Date: Wed, 3 Nov 2021 14:38:05 -0300 From: =?iso-8859-1?q?Ma=EDra?= Canal To: daniel.thompson@linaro.org, lee.jones@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 v5] 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 --- V1 -> V2: Initialize variable and simplify conditional loop V2 -> V3: Fix assignment of NULL variable V3 -> V4: Replace division for pwm_set_relative_duty_cycle V4 -> V5: Fix overwrite of state.period --- drivers/video/backlight/lp855x_bl.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/drivers/video/backlight/lp855x_bl.c b/drivers/video/backlight/lp855x_bl.c index e94932c69f54..e70a7b72dcf3 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_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; + } else { + pwm_get_state(lp->pwm, &state); } - pwm_config(lp->pwm, duty, period); - if (duty) - pwm_enable(lp->pwm); - else - pwm_disable(lp->pwm); + pwm_set_relative_duty_cycle(&state, br, max_br); + state.enabled = state.duty_cycle; + + pwm_apply_state(lp->pwm, &state); } static int lp855x_bl_update_status(struct backlight_device *bl)