Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp10477931rwp; Thu, 20 Jul 2023 23:01:46 -0700 (PDT) X-Google-Smtp-Source: APBJJlEaR+p9mNZ0QqtTPtk8NAvZJvMxnpjhn6Kuc6r17k5jqgnlR9D/p2XpilgqDTn+mha4WOw8 X-Received: by 2002:a17:906:189:b0:991:f207:411e with SMTP id 9-20020a170906018900b00991f207411emr818737ejb.69.1689919305682; Thu, 20 Jul 2023 23:01:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689919305; cv=none; d=google.com; s=arc-20160816; b=oswJJK1e/5CC2wC5NUqtCGCS8njpiF38bk9na6ujUamkAFMqhsBgqYp6nyWsp4bckx YTuCUFh81Ar0tZ6Cp53NsNy87wGwF4S4PLwCZOK3A9An5t1Nvy/1tjtNbFOCPzdNnnUz 6qJauYEk6ZLL7cD+LfrkK/80QErhwZRJ7WS8a9DtOwWQ+/kDrpU45MgC3nbWB5Oxd8Uh sShumzVY7Kr7xyLcynsv7Mlco/M470Uy2jj7SHjN5Otrz22+1dS7xU/mp2wXJfyxrkaE 84+Bws/9lfT3aingium81rW0NXNl8e0t9cL0eGq0lrestT8P1Bu6nzG1md4Kd5xlICDj N/LQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=KBMEBNclFN+fVEGCBFSwLfypg9N0tWRPvW5UcwOGajs=; fh=cQmvpc0U5iOMzXJ7a0hLlC7c+zeTT817r7/M+HP9yt0=; b=FyNHDLoEhxcg8dbJdddn/QhN9QTUeMBd73ufL1iV58DlZzg/I5UhmHsngCMKvQlasO dM1pXp2Zd1qQyKlxDs2RxbIODbU4fJZ7CQHmQuyFz8Rw/L+upVC9t5QYZsQxon6v3yt9 3Gfo6dGJnmxto9Q8mboOulWKa/VACdbuKf22Oa2s3fpMkYZ6GvYOn2JT07tnf46sZwBR UOz+RyakdJFhWvZkQZkS3ffP2IRNQqMdBqYJN9bI/jZLQY5LLJ1H2I2R0Hi54Pvg96WS TVsQH8gwFff6p9sP8Qrq3hI8hdKDhvi+2EiUzaOaxHurihuKCsM45hFjBe4cxrHxGEkG GYng== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e23-20020a170906249700b0099315b29a1bsi1655671ejb.1036.2023.07.20.23.01.20; Thu, 20 Jul 2023 23:01:45 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230005AbjGUFv2 (ORCPT + 99 others); Fri, 21 Jul 2023 01:51:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36410 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229566AbjGUFu6 (ORCPT ); Fri, 21 Jul 2023 01:50:58 -0400 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 A02BA30D4 for ; Thu, 20 Jul 2023 22:50:06 -0700 (PDT) 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 1qMj1Z-0000q2-5G; Fri, 21 Jul 2023 07:49:57 +0200 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 1qMj1Y-000zrK-4u; Fri, 21 Jul 2023 07:49:56 +0200 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1qMj1X-006Xi5-De; Fri, 21 Jul 2023 07:49:55 +0200 Date: Fri, 21 Jul 2023 07:49:55 +0200 From: Uwe =?utf-8?Q?Kleine-K=C3=B6nig?= To: Thierry Reding Cc: Guiting Shen , claudiu.beznea@microchip.com, nicolas.ferre@microchip.com, alexandre.belloni@bootlin.com, linux-arm-kernel@lists.infradead.org, linux-pwm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v6] pwm: atmel: Enable clk when pwm already enabled in bootloader Message-ID: <20230721054955.4rzcgawqjeunlnm4@pengutronix.de> References: <20230716020652.18557-1-aarongt.shen@gmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="ossejx6vs65qbsem" Content-Disposition: inline In-Reply-To: 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 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=unavailable 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 --ossejx6vs65qbsem Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Jul 20, 2023 at 05:12:30PM +0200, Thierry Reding wrote: > On Sun, Jul 16, 2023 at 10:06:52AM +0800, Guiting Shen wrote: > > +static int atmel_pwm_enable_clk_if_on(struct atmel_pwm_chip *atmel_pwm= , bool on) > > +{ > > + unsigned int i, cnt =3D 0; > > + int ret =3D 0; > > + u32 sr; > > + > > + sr =3D atmel_pwm_readl(atmel_pwm, PWM_SR) & PWM_SR_ALL_CH_MASK; > > + if (!sr) > > + return 0; > > + > > + cnt =3D bitmap_weight((unsigned long *)&sr, atmel_pwm->chip.npwm); >=20 > Tiny nit here: not sure if that cast is safe to do. You've got a 32-bit > variable, but if you cast &sr to unsigned long * on a 64-bit machine it > would cause hweight64() to get called and that would then read 64 bits > from a 32-bit variable. This probably works most of the time because we > don't read any of the upper bits, but it is strictly an illegal access > and could be unaligned as well. While relevance of BE systems ceases slowly, such a machine would evaluate the wrong bits. =20 > Should we just turn sr into an unsigned long to be safe here? yes please. Best regards Uwe --=20 Pengutronix e.K. | Uwe Kleine-K=F6nig | Industrial Linux Solutions | https://www.pengutronix.de/ | --ossejx6vs65qbsem Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEP4GsaTp6HlmJrf7Tj4D7WH0S/k4FAmS6HIMACgkQj4D7WH0S /k6Hogf+KbFJk1P7JeO7yfCVB9HeoT4GjLWtIGQjHaDYde5xPAg8nxba5De/Y+NP lYh2+005hnYNkIoV9+fG8s/4eE5yAceqRbcj2e+EgUhFERASFZ5q5d7bCq7mxDIg eq+wpjipWb2+zRoVXZqtAjga/GlKUtYBaorsG5MfO8ggC4ij31PUxR6XPOIzKT6U 6B34omkgtZpJcY9f4vCAADJ/oUvcte2IYtf8qHmtIgSAbfwFoTV0E/2wWRh/evOl zzSRhoGRpXpiELleCq00X03DDeSfrR9r/FfjpzFczK5F9F703iMjshpGrVwg/vlJ zKHRQpngH2iJHVoV3WBe5ixA8nMA+A== =7YlN -----END PGP SIGNATURE----- --ossejx6vs65qbsem--