Received: by 2002:a05:7208:2202:b0:86:316c:7444 with SMTP id s2csp2386749rbb; Tue, 4 Jun 2024 04:05:55 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWn4pJT+fzhXmmrZenE3bClwVLNTSmH7j77ezfL+MXszWJ7vaNK7XbjsIE2eUI8zKb16eeus/jUzzJ9OjckuIpljRDLQ/9iFBTcjWT67w== X-Google-Smtp-Source: AGHT+IEQuUW/lOueEyP4R15RVyi1YlCVffmpyb9EF/AszNAN8HzNiu+lP8V76El7PGzGqnuYzH7H X-Received: by 2002:a50:c30b:0:b0:57a:2763:c29b with SMTP id 4fb4d7f45d1cf-57a3647ffecmr8292202a12.41.1717499154873; Tue, 04 Jun 2024 04:05:54 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717499154; cv=pass; d=google.com; s=arc-20160816; b=uYuEPGKgIcj1Fx4h6pB3jECjRYmssDbcMiADtISibZ+uFr/f97w7TjPN69OFPjetgR X1Cp2QvwGveVQHraMtev/qqvM7bkRD/zUGBzDbeXnXNhxewJ+FDOiQk1Cwi17fqQmfUk qK48GR3kn9SXRsV6vAU5BDEuF1n+2U+YGVuAhAfyQiHXKrLQ/oHbknrf8GTfuPjN9w0X cyWQ2fpQApU0x9s5CCJZPfPfgl4j0t/YfWsLXiHP2oHRyhCGDKo0WIOWdYOGAavzZz5J aNMpr0yoh+8eOZHeRpyHuUiEV9/OpsHHTh8vfuKEX1/zAhkTpEX/boinqXGFVh4lCgRt kPGg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=pjJNON3xbO+Yh03gyOu9rx6tlrOQ/KcMrKYC4qdTMT4=; fh=4Hf1i1eR+8vIGqREJ3qCjXS9uSKEboE+2Rsdcf6QZg8=; b=0ZqvE502aW5BgDl3gz68Ki6II2BnFYZBZJ//TQd4co440sFNztf46mhcSrT6KVp7sk 05TacvK3kHyxB50hk+LEhvKOMt3Q0IlIzmdftwS1UoNVZfz4XqAoA9Kdid7RKL8PpcUO 76JCPuUHq2A8FD3pwPwYjEdem0c0m3PZUm1+E3JIIDt5HVfa1R8P0PcB+AbCqeAOM1Sj D49cu7SiyBhVgexc+bTXb/g4FQ8Y81S+WkMV9Wmo6lLPtsE+94ck1WGpG+r2GcY0O7OG L/GngV8ero7nf6G3yazOn1AE2+t+sMgkLiboOhJhV5Aqb4dY2qmwFgiz1GIokOJ/RIsx LFBw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=jnbMkOk7; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-200487-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-200487-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-57a7054afcasi1169201a12.412.2024.06.04.04.05.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 04:05:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-200487-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=jnbMkOk7; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-200487-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-200487-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 5BEBA1F21BD1 for ; Tue, 4 Jun 2024 11:05:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A64A5145347; Tue, 4 Jun 2024 11:05:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="jnbMkOk7" Received: from mail-lf1-f44.google.com (mail-lf1-f44.google.com [209.85.167.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 28F4F4A07; Tue, 4 Jun 2024 11:05:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.44 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717499143; cv=none; b=buLRckyZj2TZeurHYHOCcBr0h6FY9ceR78FW2esKZwVGpTFFUk5ZR+f6ZS2Sr72N9ullqJeGKvozl19sGMXXAsb8rRzHOhGuBYHVgXEiD6mZWR3KiSGHwxBeXHkTveuxfPb71YVwOtrAn9U8Z79HF6l4zGkcoumIHJt0uIq8N3w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717499143; c=relaxed/simple; bh=TY7XvU4SbXdxEdswCoVLHuqEj9CxfdQLBwmuALZPUxA=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=HzIY+oXAB9DZTo26MrRFq1r1jGItqGxHQTkTPtRC0DDUr2uNi8apbwYCZZLAefNkxaIQzMLFFgRvtTat3eA8u0Apo+gYmwxnoxgHMA8mgcorOyKbeydBsPZilSLzVHAKKBiJJe38lnaYcSoRo+V5FOXT+B2ccwXSiDXA0765QfY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=jnbMkOk7; arc=none smtp.client-ip=209.85.167.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-lf1-f44.google.com with SMTP id 2adb3069b0e04-52b98fb5c32so3052228e87.1; Tue, 04 Jun 2024 04:05:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717499140; x=1718103940; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=pjJNON3xbO+Yh03gyOu9rx6tlrOQ/KcMrKYC4qdTMT4=; b=jnbMkOk7tUVVy8fW44JZSGZea3OUJCuffIqYc1j/lGfLowPTnPJsmTvgzHd/kh5emR fgUu0JFObDkAZ6PapU2t48Ac07rna4vRODWpvCx8yxX+bEIfGEHdEYusTlaWDVkkKnfD rklotBjrth/1VS1Sib0AkjAbZtswr7zBxEvENCRUoYPYc1Wl4TTmgm9Ix2ne2UFCKU69 1++jE/3SYSHXBVZQjr0jv3D4R4BO1+3XqPhiryBL2N1hd+YC21NKLBofOYQHgOmKCZkv tGHXkMoDwv+VAq/NxH/KVzn/a0JewAQpKUVdsJy9cwc22SPx7B61/SCE7jU/rCm7qEos qisA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717499140; x=1718103940; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pjJNON3xbO+Yh03gyOu9rx6tlrOQ/KcMrKYC4qdTMT4=; b=IAa1wb6uOg5MpfMekEv8zNVfwCuX+o+Kso+GfvpvLWDvz9v1fheomwA+xEiHp+ua4B Bda3H3lk8liKv6gl838wAV58aH8qXoRYjoHNDvpuQ8vRdIlCnocyvTbZTgVQAcxu5GI2 TPazZ/nx/+HMLY11dakKFMqgex3LZWXt8VfabK2Zn9l53mElGcfOIBsVVTudb2cVaiYr remiIvYHU6jpb835iXbWiJdA/aiwXsTe1feZktTcb3J+6Tvnf4nZseQBbk1zY68RGtDy HsZR0Z0/VKvd5ZiZY2/803PtzsivJpayEvJoBL89yHiI5vyZ4AF2mGobgPZILqB2Bc9u z0Xw== X-Forwarded-Encrypted: i=1; AJvYcCXWvXedEk/eskLraoXJRRMC6sLfE2VgfRLSOIV2QlXtg9W86PGa8/ZO/AMRUA+yXWNYq8fkQzWeQgUist6T7mQhIQPJ7lhP60MpHNYSagEs8PI+Y5sXsTY8qJ08AmhYApLXCUiMDG7jxga0Cvi3EcGcov7Ckb2z4UzwwNSBRDd0qT1s3w== X-Gm-Message-State: AOJu0YwY2xLTmNuvFrz2VO01t956I+KTD/3dNwCgCmzxEy9tPMJ0irch OIRHKY83JoUvUGxU5CP0HnwJmvlIuXCkaRrzzRuS2xstxZgAr2n00en0oW8zaByUXP+wpIK6lOz s/1VlHEWfPc5Z869oB1+opl6s+L8= X-Received: by 2002:ac2:5de5:0:b0:52b:9955:43b3 with SMTP id 2adb3069b0e04-52b99554482mr4801820e87.60.1717499140011; Tue, 04 Jun 2024 04:05:40 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240530093410.112716-1-angelogioacchino.delregno@collabora.com> <20240530093410.112716-3-angelogioacchino.delregno@collabora.com> <84f1c58c-0a5d-4131-a16b-b76bf28862ee@collabora.com> In-Reply-To: <84f1c58c-0a5d-4131-a16b-b76bf28862ee@collabora.com> From: Andy Shevchenko Date: Tue, 4 Jun 2024 14:05:03 +0300 Message-ID: Subject: Re: [PATCH v1 2/4] iio: adc: Add support for MediaTek MT6357/8/9 Auxiliary ADC To: AngeloGioacchino Del Regno Cc: jic23@kernel.org, lars@metafoo.de, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, matthias.bgg@gmail.com, lee@kernel.org, andy@kernel.org, nuno.sa@analog.com, bigunclemax@gmail.com, dlechner@baylibre.com, marius.cristea@microchip.com, marcelo.schmitt@analog.com, fr0st61te@gmail.com, mitrutzceclan@gmail.com, mike.looijmans@topic.nl, marcus.folkesson@gmail.com, linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, kernel@collabora.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Jun 4, 2024 at 1:38=E2=80=AFPM AngeloGioacchino Del Regno wrote: > Il 30/05/24 15:34, Andy Shevchenko ha scritto: > > On Thu, May 30, 2024 at 12:34=E2=80=AFPM AngeloGioacchino Del Regno > > wrote: ... > >> +#define PMIC_RG_RESET_VAL (BIT(0) | BIT(3)) > > > > In this form it requires a comment explaining each mentioned bit. > > I don't have an explanation for this, I know it's two different bits from= some > reveng, but the downstream driver declares that simply as 0x9. > > Should I just "mask" this as 0x9 instead? In this case for all of the questionable forms, please add a oneline comment suggesting that "these are different bits without known purpose of each." or something like that. ... > >> +#define MT6358_IMP0_CLEAR (BIT(14) | BIT(7)) > > > > As per above. > > > > Same, I don't have any explanation for that. > > If you prefer, I can define this as 0x4080, but honestly I prefer keeping > it as-is since I am sure it's not a magic number but really two bits to f= lip > in a register. As per above. ... > >> + u8 r_numerator; > >> + u8 r_denominator; > > > > Can you add struct u8_fract to the math.h and use it? I will Ack/R the > > respective patch. > > Yeah, I did that exactly because u8_fract wasn't there and I didn't want > to waste more bits, but since you just asked for it... well, I'm happier = :-) Note, it's enough to have my Rb tag and route that change via IIO tree. We have done similar way for other changes in math.h (or aline) in the past. ... > >> + /* Assert ADC reset */ > >> + regmap_set_bits(regmap, pdata->regs[PMIC_HK_TOP_RST_CON0], PMI= C_RG_RESET_VAL); > > > > No required delay in between? > > No, as strange as it may look, there is no delay required in between: thi= s is > because the register R/W is behind the PMIC Wrapper as much as all of the= other > MediaTek PMIC (sub)devices, so, missing delays was intentional here, yes. Maybe a comment? ... > >> + mutex_lock(&adc_dev->lock); > > > > Why not use cleanup.h? > > I want to unlock the mutex immediately right after executing read_imp() o= r > mt6359_auxadc_read_adc(), and I don't want the reset to be done while a m= utex > is being held, as that makes no sense for this driver. That's why we have scoped_guard(). Exactly for such cases. > Besides, I find the macros in cleanup.h to be cryptic - in my opinion, th= ey > require better documentation as, for example, I don't understand when the > guard(mutex)(my_mutex) is supposed to acquire the lock and when it's supp= osed > to release it. They are cryptic due to limitations in C language. But for the end user it doesn't matter. The behaviour is well understandable and makes code cleaner and less prone for errors such as missing unlocks. So, please use cleanup.h. --=20 With Best Regards, Andy Shevchenko