Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp885917pxb; Wed, 27 Oct 2021 14:28:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyfsK26u/juoOrQsSiVc+oXkNkW1iOeaaW+9yEPBnWYQfyrUlfm8OwXEXvDeLiO6yjbmm+m X-Received: by 2002:a62:184e:0:b0:47c:19c7:fb2 with SMTP id 75-20020a62184e000000b0047c19c70fb2mr139736pfy.83.1635370104560; Wed, 27 Oct 2021 14:28:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635370104; cv=none; d=google.com; s=arc-20160816; b=rgVFTJMjspaXlwTV2JNSxHjQi41g8dchzF8TkJyZe300+m6OC1hkQz+FpDd7eC+pX3 cWxn1IyzuDPMY2AZn3dp1CWOWDuuQCqTSA9t3ooNULYJj0uSpJZr9i4rHxa6JSa0BI3q KC7tUXd4U2eYJ/907u6E/KjbKmUsoOiDaKXUVBXfKneJ6ege+JoWyqS2cCKwB10X7YoO HLcuDA/5gua7Ok99u1L2WRBPjhNy4GuNYbc341Nacosop90fig82UGMs4UrSonamNFos xtsR1jRqVDLP65YpKNCNer6WmAu2Vfk3YTKrvSfXsIaZBwBLew+4+X+71C5IioecCyHs Z5UA== 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=2kqOpDFNZWPONI45Sby6qnOsMGbi3VIWS2JFQhhdImo=; b=kSVZN+QIRR6hFVaoBRl4dUh2EyrcBArALEK56MbJz8kvvDtfDbMm9saZgp0758Xmvj IahlvhlkPlH1JgeBmv+siRiBJvl+qFvMVOb/enkiw/8ZDuwPoBxVO0w5G6x5sHp+kCqi /u3UkdarXpKjB5DIYOp37f4EQCuLBXiky3dOsS75CkkMfljPTGuzt6SBVUvM10Z+GF2I VFZDEIPf7uORqZ6vscV4NwWcutb2QN0iJ6fe6Hu4SdE3OP5EN2KRqeLbYdoQ31ucQt+c lOQn934WrSsIjsVNAibEWKKeMDWyGU68/kIM2oZSR9P4CDucFydOSANmqXzaYl9Q+HQ0 L72w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@usp.br header.s=usp-google header.b=GixmIbMG; 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 f17si1533268pfc.166.2021.10.27.14.28.12; Wed, 27 Oct 2021 14:28:24 -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=GixmIbMG; 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 S242759AbhJ0PhE (ORCPT + 97 others); Wed, 27 Oct 2021 11:37:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59418 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238418AbhJ0PhD (ORCPT ); Wed, 27 Oct 2021 11:37:03 -0400 Received: from mail-oi1-x236.google.com (mail-oi1-x236.google.com [IPv6:2607:f8b0:4864:20::236]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 68677C061570 for ; Wed, 27 Oct 2021 08:34:38 -0700 (PDT) Received: by mail-oi1-x236.google.com with SMTP id y128so3932656oie.8 for ; Wed, 27 Oct 2021 08:34:38 -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=2kqOpDFNZWPONI45Sby6qnOsMGbi3VIWS2JFQhhdImo=; b=GixmIbMGs686zqmSCHXywp2xoX2owfUVe6pBf4ojmha6g6G720NHuL8RcuXoLi/A8k E+d5CRy0MRcasKm2Z1LjHWkASDn+oID3sWQ2O9Si08N68bsmuK3kkNrnPtwCd8r7gMFy 3EjEmieCs2+FvkzfJ/tHHGdjCXZUDLqSNqfo/bWXDx0z9jRM8R0R89WR0eBxg+y3ntdc MJwtPpB8VdXOxAofBYTmplPxr2Lf3ihJDBTeRbb9QVpalkzUubklokKpHlBbVhV2ME39 chZhGb0tLL5u4dsxUmWUWfq0V4THBjzfiW+wNdUs/r8lyhv1TvACRkfmncKSqMOa/NTd fp2Q== 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=2kqOpDFNZWPONI45Sby6qnOsMGbi3VIWS2JFQhhdImo=; b=JY79s9zifcfLeeMWBrEbiCkWn02P7/pBR1Skqt3Rt0dJsoZWvg6q3YbOY2HCbdKCEo qONh9j8JCdxiHnV9VU0slg4oWYP0OaQepqWn6Hu3jVwv1B+yRl10JiASLs35MrZppsc/ x9P9sJxTdcBaNRTbm2r5yeqTDyW/m/sKbPh8i/v+tB5g8hwikakzujmthQl/0xAY2Gaq gcRcgFkeJ5EEP96fucUobZ54xSyz1sl5v4IykQTZF3hGkhzJQAxAuEE7AMY1y1DrulwF GJChzL7YEDQjn+mgJRXvsDgw1Id2OY5ZOzVI225thB/eQDXDblKCRR1pZfSeILUvBMyg dPlA== X-Gm-Message-State: AOAM533iVvbBcflSZ4Sr15gD9RqF+yb8owLWkneHamg1hwkDA1v0sm3N P3lXlozBbmyfhyE9zHZHie8mHQ== X-Received: by 2002:a05:6808:1287:: with SMTP id a7mr4104275oiw.45.1635348877700; Wed, 27 Oct 2021 08:34:37 -0700 (PDT) Received: from fedora ([187.64.134.142]) by smtp.gmail.com with ESMTPSA id j7sm106300oon.13.2021.10.27.08.34.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Oct 2021 08:34:36 -0700 (PDT) Date: Wed, 27 Oct 2021 12:34:30 -0300 From: =?iso-8859-1?Q?Ma=EDra?= Canal To: sean@mess.org, u.kleine-koenig@pengutronix.de, lkp@intel.com, mchehab@kernel.org, thierry.reding@gmail.com, lee.jones@linaro.org Cc: llvm@lists.linux.dev, kbuild-all@lists.01.org, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pwm@vger.kernel.org Subject: [PATCH v4] media: rc: pwm-ir-tx: 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 Reported-by: kernel test robot --- V1 -> V2: Assign variables directly and simplify conditional statement V2 -> V3: Fix declaration of undeclared variables V3 -> V4: Fix DIV_ROUND_CLOSEST error with u64 variables --- drivers/media/rc/pwm-ir-tx.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/media/rc/pwm-ir-tx.c b/drivers/media/rc/pwm-ir-tx.c index 4bc28d2c9cc9..105a9c24f1e3 100644 --- a/drivers/media/rc/pwm-ir-tx.c +++ b/drivers/media/rc/pwm-ir-tx.c @@ -53,22 +53,21 @@ static int pwm_ir_tx(struct rc_dev *dev, unsigned int *txbuf, { struct pwm_ir *pwm_ir = dev->priv; struct pwm_device *pwm = pwm_ir->pwm; - int i, duty, period; + struct pwm_state state; + int i; ktime_t edge; long delta; - period = DIV_ROUND_CLOSEST(NSEC_PER_SEC, pwm_ir->carrier); - duty = DIV_ROUND_CLOSEST(pwm_ir->duty_cycle * period, 100); + pwm_init_state(pwm, &state); - pwm_config(pwm, duty, period); + state.period = DIV_ROUND_CLOSEST(NSEC_PER_SEC, pwm_ir->carrier); + pwm_set_relative_duty_cycle(&state, pwm_ir->duty_cycle, 100); edge = ktime_get(); for (i = 0; i < count; i++) { - if (i % 2) // space - pwm_disable(pwm); - else - pwm_enable(pwm); + state.enabled = !(i % 2); + pwm_apply_state(pwm, &state); edge = ktime_add_us(edge, txbuf[i]); delta = ktime_us_delta(edge, ktime_get()); @@ -76,7 +75,8 @@ static int pwm_ir_tx(struct rc_dev *dev, unsigned int *txbuf, usleep_range(delta, delta + 10); } - pwm_disable(pwm); + state.enabled = false; + pwm_apply_state(pwm, &state); return count; } -- 2.31.1