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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 72C05C6FA99 for ; Fri, 10 Mar 2023 21:54:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232048AbjCJVyP (ORCPT ); Fri, 10 Mar 2023 16:54:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58220 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231996AbjCJVxr (ORCPT ); Fri, 10 Mar 2023 16:53:47 -0500 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ADD0314FE07 for ; Fri, 10 Mar 2023 13:50:19 -0800 (PST) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1paka5-00043Y-LX; Fri, 10 Mar 2023 22:47:17 +0100 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1paka1-003GHn-RB; Fri, 10 Mar 2023 22:47:13 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1paka1-003tZx-3f; Fri, 10 Mar 2023 22:47:13 +0100 Date: Fri, 10 Mar 2023 22:46:58 +0100 From: Uwe =?utf-8?Q?Kleine-K=C3=B6nig?= To: fnkl.kernel@gmail.com Cc: Thierry Reding , Rob Herring , Krzysztof Kozlowski , - , Hector Martin , Sven Peter , Alyssa Rosenzweig , linux-pwm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v8 2/5] pwm: Add Apple PWM controller Message-ID: <20230310214658.424vui3frynit437@pengutronix.de> References: <20230214-fpwm-v8-0-65518a0d4944@gmail.com> <20230214-fpwm-v8-2-65518a0d4944@gmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="wbrnvcvhbc5cviao" Content-Disposition: inline In-Reply-To: <20230214-fpwm-v8-2-65518a0d4944@gmail.com> X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ukl@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --wbrnvcvhbc5cviao Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hello Sascha, On Fri, Mar 10, 2023 at 07:44:08PM +0100, Sasha Finkelstein via B4 Relay wr= ote: > +static int apple_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, > + const struct pwm_state *state) > +{ > + struct apple_pwm *fpwm; > + > + if (state->polarity =3D=3D PWM_POLARITY_INVERSED) > + return -EINVAL; > + > + fpwm =3D to_apple_pwm(chip); > + if (state->enabled) { > + u64 on_cycles, off_cycles; > + > + on_cycles =3D mul_u64_u64_div_u64(fpwm->clkrate, > + state->duty_cycle, NSEC_PER_SEC); > + if (on_cycles > 0xFFFFFFFF) > + on_cycles =3D 0xFFFFFFFF; > + > + off_cycles =3D mul_u64_u64_div_u64(fpwm->clkrate, > + state->period, NSEC_PER_SEC) - on_cycles; > + if (off_cycles > 0xFFFFFFFF) > + return -ERANGE; This is still wrong and needs clamping, too. Best regards Uwe --=20 Pengutronix e.K. | Uwe Kleine-K=F6nig | Industrial Linux Solutions | https://www.pengutronix.de/ | --wbrnvcvhbc5cviao Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEfnIqFpAYrP8+dKQLwfwUeK3K7AkFAmQLpU8ACgkQwfwUeK3K 7Al6iAf/brzDkPdu7qhixSZXlHEcf+6cCEGjYdch6SwKLkspprLcOrBvHsvEa8ay TYG02baQpF4eNbZdPBbBv2b4VOqDOJ92H8Bx7IvfhCQy+fdZkSCiSeXHPteY91Hc A56UkrBNesv68qEdfX6e4vtVYZbexHFqgaeTZMPfr8dsqt0ms0RyyMMuT/DhrpPs sBTZd7V0IybwXTCEomXUMbxOA1mzWfU05rEz4bPUOS14N9TL8i1Mom8VsZrMD5UH bO6F9Y13HCXq8xUgLKZnoxqEEm1E2r6ZunUTSb/RenSaxGE2xx9NlHlTNeyKJR2V FYA1FefcQgl8RIZvCowtSH9Y+Lkcvg== =MgXN -----END PGP SIGNATURE----- --wbrnvcvhbc5cviao--