Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp663840iog; Mon, 13 Jun 2022 10:08:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwvVLDESxJSyH1j7UJckSOxshu2DfjJUDG1mYWbzCpO2qwU/YItshOZ0kEr6mhO8DSaQEpM X-Received: by 2002:a63:6c44:0:b0:3fa:ec6b:33e7 with SMTP id h65-20020a636c44000000b003faec6b33e7mr484972pgc.435.1655140099497; Mon, 13 Jun 2022 10:08:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655140099; cv=none; d=google.com; s=arc-20160816; b=qkBVuBT6/DVI6Tx+h2AgNVwGKKSTt9Wh/Dz8jznwmeYHM/wTMy/vrMTy+81q3PL4T7 bjy1M2DyRYbLoUq5B82JXdCk6bcDlpdnbBR3M718jSktlhOaY4KNZuA88Hk9JsV4CTsh Wx34Qjh2yxAXCC3RAXQtroRB8UIwJOrLMg5x82Glky7sXLEXu7nQMZJCki2W3PiJkl8n D16cyAJYgStVPkNwR+O1Rpqs++6ho4EP10c/B9W0dEYf4fBvkx1mH0UyRbXVC34ozWoB lACnGWli3+1hMVVHNwowMOyErvnfYEHF5uR7dSb/ke8tN8o6gnLor9rBzsaXkC+7izjS NTHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=PrfEHjLEBTABGeE5/eaKnKhgMSLDfd6bjnmA1Jj1As0=; b=FfRYZEi8fVmm6oBd3O53j0n0etGQfIMMR7xqdZZ2ZEd8BmfyV6TUtR42gYP2qyxTen T0gEkcRbN1Z5Ne0+dsKxk29QjTHVfXBVgSx6R5ugTfBzL6sp6dMm20saECg/1uwT/60T eG1P1X4CNAGjh6omy+FUxGPdZ/NBXltJm3j5Df1mzdPrHqhL02AKolehlbd2VcACsGll 7qSOubiOeW/w36kwaX3QDZ0kaD55IwI1dLJpIkkf6xRG+1jEXNtBkEQ0bHXZLRBzS/p0 fg+WXPtOUoM1oU2+jtjX3lYIpc/ajSsT/QxG/KyYRB+TS3PxNy3Njmqzkv7LvxIKS1/b zDew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1LvSD2U7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d9-20020a170902c18900b00163fd24ca86si9713330pld.282.2022.06.13.10.08.04; Mon, 13 Jun 2022 10:08:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1LvSD2U7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377506AbiFMNc4 (ORCPT + 99 others); Mon, 13 Jun 2022 09:32:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377870AbiFMNaW (ORCPT ); Mon, 13 Jun 2022 09:30:22 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4DEA66E8FF; Mon, 13 Jun 2022 04:25:15 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E26A36114A; Mon, 13 Jun 2022 11:25:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EF36DC34114; Mon, 13 Jun 2022 11:25:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655119512; bh=EO27XRrZvZM3OEMGUga+8QfaUgSMH/01Y5OujwF83w4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1LvSD2U71Rw5/tj/JgcNtr+3cmz3ROuRoeteHSQRpHzQyZIjl2QNgg8xRQfZRVLiA J88ELMCOtJXck7X8Os1O2dGNXGh1zoHyNSNLXh1195OZ1jp3cLLwMNjAUpTlHoTGft ulWcI/81Xw5JttKbNw3B/5jhjIWqVGnF/UQxSHTQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Thierry Reding , Sasha Levin Subject: [PATCH 5.18 022/339] pwm: lp3943: Fix duty calculation in case period was clamped Date: Mon, 13 Jun 2022 12:07:27 +0200 Message-Id: <20220613094927.181585995@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220613094926.497929857@linuxfoundation.org> References: <20220613094926.497929857@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Uwe Kleine-König [ Upstream commit 5e3b07ca5cc78cd4a987e78446849e41288d87cb ] The hardware only supports periods <= 1.6 ms and if a bigger period is requested it is clamped to 1.6 ms. In this case duty_cycle might be bigger than 1.6 ms and then the duty cycle register is written with a value bigger than LP3943_MAX_DUTY. So clamp duty_cycle accordingly. Fixes: af66b3c0934e ("pwm: Add LP3943 PWM driver") Signed-off-by: Uwe Kleine-König Signed-off-by: Thierry Reding Signed-off-by: Sasha Levin --- drivers/pwm/pwm-lp3943.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/pwm/pwm-lp3943.c b/drivers/pwm/pwm-lp3943.c index ea17d446a627..2bd04ecb508c 100644 --- a/drivers/pwm/pwm-lp3943.c +++ b/drivers/pwm/pwm-lp3943.c @@ -125,6 +125,7 @@ static int lp3943_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm, if (err) return err; + duty_ns = min(duty_ns, period_ns); val = (u8)(duty_ns * LP3943_MAX_DUTY / period_ns); return lp3943_write_byte(lp3943, reg_duty, val); -- 2.35.1