Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp5635670rwl; Tue, 11 Apr 2023 08:04:17 -0700 (PDT) X-Google-Smtp-Source: AKy350bB+245q0FPMmv3ZT64FxA4tJNHCNVU1sgvtF0rvhBPi7DyM4op02BvKj0j6pubie/3QVsT X-Received: by 2002:aa7:d855:0:b0:504:88fb:8841 with SMTP id f21-20020aa7d855000000b0050488fb8841mr9865615eds.21.1681225457538; Tue, 11 Apr 2023 08:04:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681225457; cv=none; d=google.com; s=arc-20160816; b=F/5JjgUixtzCFruSwml43tMhRwOa8xUlN6ln6OstGyZ/3Is9YH48e4lrEKIAPtJlKP q6HRXba7/ha9+VfuEjdTlHNAXzFkaclu8ZYOXn5cDOIFkucOAsHUVmcpO3KdrRY1IWwz qrExoXxhL2KYImQEgUa0KSDJpY4CY2uVeZ1qCfQRnmidHGkDPwdxa1gdoKWaUmGkDGfN vVVI6bPKzVEVnIiGqkFSTY5H6kebY59O/BMCq49LvZtaPbVbmlE7odR+5fO+04abQOkH 4CIjapR8kB70ghRgFRqVXORnYHw2YIqDyNrzlnyqmjTXuelFqSvpgzl+QNVSBPoSuLQI 6YzA== 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:dkim-signature; bh=p+7EgUv9jkdXjRA3gr33Ow73zM+WORow955dG/OXSYw=; b=wk6nleqJ9ewTer1sGBIBSsFrsRtDYAlqcQpAMxexCBXBRz3q6Yr6da3KAKsKfzciwu iblfsj/AV6Jj1oq/4Lic6XNvoy/YNeG4XmR1ujHR8Xuwi2Q9N7zKkK4rQuAimESNnGMu hRVGxtl1VwuVQ7Xlm1fOHmkyizYwgEYEuEN2Mv4hclnZIFpeC0k9/eCINB28q0HXGPnV +v2QjQ3cnT+CZD6N35Ekri/jqEwLBfjYn2al94WcEJiRtwvNQQd9gwUuR7c8rVmDPkjf ldIw0FI1ohzDdooSBrszcdb8lcIcdSFalAi7qJhU6AEX6y1Es2Q3xz4gAMK+1cn8Qkbh FMNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NKdxbJj6; 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=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o13-20020aa7d3cd000000b00504bbaf98c5si2190080edr.395.2023.04.11.08.03.38; Tue, 11 Apr 2023 08:04:17 -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=@linaro.org header.s=google header.b=NKdxbJj6; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229834AbjDKO6x (ORCPT + 99 others); Tue, 11 Apr 2023 10:58:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50068 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229583AbjDKO6v (ORCPT ); Tue, 11 Apr 2023 10:58:51 -0400 Received: from mail-yw1-x112b.google.com (mail-yw1-x112b.google.com [IPv6:2607:f8b0:4864:20::112b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 665051BF4 for ; Tue, 11 Apr 2023 07:58:50 -0700 (PDT) Received: by mail-yw1-x112b.google.com with SMTP id 00721157ae682-54ee108142eso165028957b3.2 for ; Tue, 11 Apr 2023 07:58:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1681225129; x=1683817129; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=p+7EgUv9jkdXjRA3gr33Ow73zM+WORow955dG/OXSYw=; b=NKdxbJj6+++Qx1RBTul/EYsy4fNEind+c3hExeZZwsD7j+gmZKprlQYNhKojLhIus1 DREKHOD1m+OzPV4UxWZDrRPhO7uIfWrWnKZODRMnpzxPuxQKeVtsNmL+rHl6VRCIHkmD 5X0GzwBzv92GOdaNAiaHYjxK43i+iR0UBWj1yku5kRAFFa6ycmbkun1fuBAyz3ByyGSS 7Os+zcGa9FfpR62qubpr3mQqUzVNbKGJdvt3Y/AgnFNf6EqbwLvcVQXNzbPr2a5frThD etowCochjiGdgsB+6zENMWVTUGP7r3FTmy14bWSUYwZ5xxF5eJgjxJDMBxn/RZIIYJdq SEzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1681225129; x=1683817129; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=p+7EgUv9jkdXjRA3gr33Ow73zM+WORow955dG/OXSYw=; b=H92Zy76mK6lOyJDPyWM8pF3vmQFKT1XZ4106dAFYpTUPMeq+zLuUDzlMhP6YQJrtbn dPyQkPM9r4EkC7/ioX36OSwNRMkPtryncYxmuRFeib1Xqztp7ufAM5KMNGY3GxQb6q7F RoxvatH6JeOrjR2JgI74+tNP3PCCtrgQ/CtTJK9CwGlTJPNPUb1ArBrC5QCVbyAWSPTn yHqaHD+eLfYHi3zkFhQAo+8tVvrqHlKe6tiALCiGAYLhvW0gG26ogbnK2n1sQmKTuet6 MJ0BQzktovEEg39oXV10hOiSLETHifrDG+nt9/ORXXUSahQdJK+Dhq+HQimEFtFPoq+/ 4gGA== X-Gm-Message-State: AAQBX9cbE4LHi/+VBTFDoZ3Lks/K5R5MuYmqwJfph272reC7uxWj9uo7 NiX/yxq7PBjzWBDak41WgBGkGA== X-Received: by 2002:a81:6607:0:b0:545:62d7:6fac with SMTP id a7-20020a816607000000b0054562d76facmr7401983ywc.10.1681225129441; Tue, 11 Apr 2023 07:58:49 -0700 (PDT) Received: from fedora (69-109-179-158.lightspeed.dybhfl.sbcglobal.net. [69.109.179.158]) by smtp.gmail.com with ESMTPSA id ci10-20020a05690c0a8a00b0054f666f32b3sm493469ywb.40.2023.04.11.07.58.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Apr 2023 07:58:48 -0700 (PDT) Date: Tue, 11 Apr 2023 10:58:47 -0400 From: William Breathitt Gray To: Andy Shevchenko Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Johannes Berg , Jonathan Cameron , Andrew Morton , Al Viro , Nathan Chancellor , Nick Desaulniers Subject: Re: [PATCH v3 3/3] counter: 104-quad-8: Utilize helper functions to handle PR, FLAG and PSC Message-ID: References: <669c8f782f11fe27c4568e4fc3ba459c4f954874.1681134558.git.william.gray@linaro.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="gFuETjZ/k9bxpdFT" Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS 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 --gFuETjZ/k9bxpdFT Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Apr 11, 2023 at 05:43:49PM +0300, Andy Shevchenko wrote: > On Tue, Apr 11, 2023 at 10:05:25AM -0400, William Breathitt Gray wrote: > > On Tue, Apr 11, 2023 at 04:50:03PM +0300, Andy Shevchenko wrote: > > > On Mon, Apr 10, 2023 at 10:03:13AM -0400, William Breathitt Gray wrot= e: > > > > The Preset Register (PR), Flag Register (FLAG), and Filter Clock > > > > Prescaler (PSC) have common usage patterns. Wrap up such usage into > > > > dedicated functions to improve code clarity. >=20 > ... >=20 > > > > *val =3D 0; > > >=20 > > > Is not needed now as always being initialized by below call. > >=20 > > The regmap_noinc_read() call only reads the number of bytes requested. > > Since we request 3 bytes, the upper bytes of the u64 val remain > > uninitialized, so that is why we need to set *val =3D 0. This isn't > > immediately clear in the code, so I can add a comment to make it > > explicit. >=20 > Hmm... > Since we are using byte array for the value, can we actually use > memset() to show that explicitly? Perhaps in that way it will be more vis= ible? >=20 > > > > spin_lock_irqsave(&priv->lock, irqflags); > > > > =20 > > > > iowrite8(SELECT_RLD | RESET_BP | TRANSFER_CNTR_TO_OL, &chan->cont= rol); > > > > - > > > > - for (i =3D 0; i < 3; i++) > > > > - *val |=3D (unsigned long)ioread8(&chan->data) << (8 * i); > > > > + ioread8_rep(&chan->data, val, 3); >=20 > But hold on, wouldn't this have an endianess issue? The call fills in LE, > while here you use the CPU order. >=20 > > > > spin_unlock_irqrestore(&priv->lock, irqflags); >=20 > That said, I think you should have something like >=20 > u8 value[3]; >=20 > ioread8_rep(..., value, sizeof(value)); >=20 > *val =3D get_unaligned_le24(value); >=20 > --=20 > With Best Regards, > Andy Shevchenko Yes, I think you're right, that solves both problems at once so I'll use get_aligned_le24() to set *val. William Breathitt Gray --gFuETjZ/k9bxpdFT Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEARYKAB0WIQSNN83d4NIlKPjon7a1SFbKvhIjKwUCZDV1pwAKCRC1SFbKvhIj K2kMAQDrWJPvMhPcHbdWvH5AkY0ad7jOK/SX/wZ3onxHUaOz7gD/YS6aHONzpLYQ A2jVwk6XOn1NF2BILQcKRTPvWCls9gQ= =VkrK -----END PGP SIGNATURE----- --gFuETjZ/k9bxpdFT--