Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3015959pxb; Mon, 1 Nov 2021 06:24:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJybyHNM1ks46MqZIialmoB13n3aR+5koh2FrZ8WrqR6PvRpV4Bad6sUcgQaSQ5vcGhrjkC3 X-Received: by 2002:a17:907:9609:: with SMTP id gb9mr37210127ejc.504.1635773066546; Mon, 01 Nov 2021 06:24:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635773066; cv=none; d=google.com; s=arc-20160816; b=djKfDjzlcphfFmgiEd6/dLi51bTtMg5f6to/NjasIA9o8onx9Ei/13xkNS5Vuhyifn ShxBwQEwgUDsZt4f+528/pgiOfebpd/GXv03+AQ5AJjmcaZFq/9g3dTGIAZJZFCsoZvI Chzr3dq4k6+1CtKuUPym6PjgvWQK0/1kq0T6ISFhqgUBhPZ0hGXr7lLWlmfCXOPC6vYX xoTQmP9dJakK0Eut5jUS/ayJznlsR25kWmfjRZJvKA8cNdcDFBabtu9kWTTnkLDA0J9s iQDZJwuoTW4E5FTOg2UoOwwGjveNd+OogcBPkA6Tpo/cnAxLDQrBM7KveZWy1pEMSO6h PhXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-disposition :mime-version:message-id:subject:cc:to:from:date:dkim-signature; bh=TtX9VhCBKuhF3Ol7gnPYFLRhj5nFsqp3SrQe6dqQFXM=; b=mIG14Lahf5qlACipIejZJsKHW9bnw9DdDCDmnYS2T/3xFVVkoWw5R9VNO7HKFB3csy vxb/+tVHGBaLoTLTgwMkQI/URYpzWbo3jWL6wLRCADWpM7BGzXp20G3VlVEaoiVBETwE /FIdszXHTJCD0dfO/q+6rm0af7QkxgNt118fiwFUCqOS1p8/gQhAV8DkJA6nBWBJQXqj zeUSk2KhbYz4gcljSI3j/ddY27IavO0EOYFf4Qpb+zIIMymWSbfYU089edgRKT1D7JS6 WHhj3p3bLCJEa9y5Mnm0sbQcI6Ef01IvAOdCyNEyRkHSSIGtpH+5F1mlWOzJhRIcwgn+ ddeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@usp.br header.s=usp-google header.b=ZnSQtUuz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=usp.br Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hd40si24572567ejc.493.2021.11.01.06.24.01; Mon, 01 Nov 2021 06:24:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@usp.br header.s=usp-google header.b=ZnSQtUuz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=usp.br Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232146AbhKANWF (ORCPT + 99 others); Mon, 1 Nov 2021 09:22:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40776 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232437AbhKANWC (ORCPT ); Mon, 1 Nov 2021 09:22:02 -0400 Received: from mail-qk1-x72f.google.com (mail-qk1-x72f.google.com [IPv6:2607:f8b0:4864:20::72f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B00EC061766 for ; Mon, 1 Nov 2021 06:19:29 -0700 (PDT) Received: by mail-qk1-x72f.google.com with SMTP id bq14so4954665qkb.1 for ; Mon, 01 Nov 2021 06:19:29 -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=TtX9VhCBKuhF3Ol7gnPYFLRhj5nFsqp3SrQe6dqQFXM=; b=ZnSQtUuzlxpPJR1GQQpbQSUoHtb09P8H7VrR18O2ahTTXRWmIDnxQOQgnULadzL610 JTN6lYue33HVu7p8L3y+810xNbHrJ19Tbeg/nOHqdYm3ftynFUO/NzeHUfMkEmSBM0as ixAQxM3YbNoJXyv6pSbwPGcTlgAAOJXCqc13eV7HVkg/mau8AHrgfsWxgHABcrz2rwRh UeEIEFLjysCIxUATqgwwbyaCpZHBJytSLFFgeo2NtXcSey60XzPh+fJHD56twsIX7o+/ PaI3j9470t9hHKW9dYvhUboq8DOEMMJw2ouHi3SnG6XPpzRVJ/ugKM+EZj1UusPbJosC Qq0g== 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=TtX9VhCBKuhF3Ol7gnPYFLRhj5nFsqp3SrQe6dqQFXM=; b=IqK9OfWxohAj1Klt9EmY8eL5lSU4j8o9VyWqIrkfIG9hHDSASr8rYA2DHRcCwFjau5 dbiDSkcy8rvKHThTbYcB7ImhN1KtRRhw9Cpj33x7acIS/3lZFZZ/MxZuWmfS0Uq1C44l 59bO16dZ09bEY8A43rizlFI8Ym+9h2Cq4QHm4QSBsgSIQ2cTsH17PvZitS/meLeCTVOg hwOyB7K4BdBnI1b/08aHYNthfGnkv9Q0i1jM5qmkaNxsbYOnCMR185sodNlIAAxEilmS E0l2gz0kRBxFl9aobfurUI7fn9sf0IRrcONWnreO4IDNOMi1GXzB3M3e35UpS8XTmtdx h16w== X-Gm-Message-State: AOAM532ldp+bJNDqUc0h7h+mUK7hiMJxjuukZElR685xRBCgydUuAYUC cgiiKn/AeggRMbsrS7qfYiUe6A== X-Received: by 2002:a05:620a:1999:: with SMTP id bm25mr23030512qkb.40.1635772767335; Mon, 01 Nov 2021 06:19:27 -0700 (PDT) Received: from fedora ([187.64.134.142]) by smtp.gmail.com with ESMTPSA id h17sm4185790qtx.64.2021.11.01.06.19.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Nov 2021 06:19:27 -0700 (PDT) Date: Mon, 1 Nov 2021 10:19:21 -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 v4] backlight: lp855x: Switch to atomic PWM API Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 simply conditional loop V2 -> V3: Fix assignment of NULL variable V3 -> V4: Replace division for pwm_set_relative_duty_cycle --- drivers/video/backlight/lp855x_bl.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/drivers/video/backlight/lp855x_bl.c b/drivers/video/backlight/lp855x_bl.c index e94932c69f54..bbf24564082a 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,15 @@ 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); + 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) -- 2.31.1