From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-lf1-f49.google.com (mail-lf1-f49.google.com [209.85.167.49]) (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 9EE1A41E6AE for ; Tue, 11 Aug 2026 08:47:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786438026; cv=none; b=dptAgLm0myavASkVXcHREt75JVP/MHRypQ+VsQFga344KGuf1d2Wmg11lQELPKEL6OkNj82kf7hlH5PrgqzNNzot0kM4YmS1QZQvP7p+K+0EirTPhzJk5hNhnyNQsyZxzVv3IVaqKDk/5AuzCbU9qadujZMtjZGhdUUuyRwT2/0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786438026; c=relaxed/simple; bh=EVZVpJBRdZCy+qujCaf5OnM7atnyetFlOKsXkQ2K0ow=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=o21g8VQvu7nrHmxexqOdgx7Lu1YnSpwe3AMLlHEuFZubx7OSXwysBUtKmQoCwG4RotypcnWtL248lhf5SKWIC+Le0HHMf8i9WJX90QMrLwmvDZalWwfenaVVe1MfQ/khHSBYnqoXYSuEZr0JZVOhZAyFdF2PyoZbew1iH67rS6A= 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=gCj/wndN; arc=none smtp.client-ip=209.85.167.49 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gCj/wndN" Received: by mail-lf1-f49.google.com with SMTP id 2adb3069b0e04-5b013aa02b2so914584e87.0 for ; Tue, 11 Aug 2026 01:47:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786438022; x=1787042822; darn=vger.kernel.org; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to :content-type; bh=IiZI9DdC23B8FjIXst2Hzamy5igvzMmXHo3Scfcb8/c=; b=gCj/wndN3UPZ+4T1x0H8A+2z5DgFrY75y7zG2QEXZUEv+lp7vEMsMinJdrMddIsE2Q cckUhiafGlOf3zSqErATU+GXWooAelVH4ns7QiBKuAumdLOwo+X1ayk4V4xzbbHDwEes Yu/YrMeLHHvDtWu1PXqU0+b/u+ohdx8iussELEeseJW2NR0V5iStDxS9X6vPfrd3hek8 pHtE8sBlwRpmethgvoR1RJoAzJb5Ab2q2UYGfl6xwryf81hVC3wE4euIXfa790SKj4+M YABzHyPbIiNcofbD5W1bB3FFRa2u9b1yTk8vHZha/MSTuHxLmkp16NIC6zA9g9Fk2q7P DVBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786438022; x=1787042822; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=IiZI9DdC23B8FjIXst2Hzamy5igvzMmXHo3Scfcb8/c=; b=VQkeaGkRbGmeaou+pW3LfnFXm+cTg8KZazgZLrOxlZBDoboRmPDX/m8PruS3OfIRDd WBPjrl1b2kPeUPv9mN3tUW/gu5reF7MNTGkhluaqt1DH83CL8ErGNsttIhEYVRmgF8hD fwGOcZJWa9953ayGV1J40PycLN6srqTAB48zPrON5KgKx/3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e87.11.1786438021919; Tue, 11 Aug 2026 01:47:01 -0700 (PDT) Received: from ?IPV6:2a10:a5c0:800d:dd00:8fdf:935a:2c85:d703? ([2a10:a5c0:800d:dd00:8fdf:935a:2c85:d703]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-3a0fa6e0f9dsm1178621fa.41.2026.08.11.01.46.59 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 11 Aug 2026 01:47:00 -0700 (PDT) Message-ID: <440e5deb-8a2c-4379-bc58-e838b427e48e@gmail.com> Date: Tue, 11 Aug 2026 11:46:59 +0300 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 2/5] power: supply: bd71828: Fix current direction To: Andy Shevchenko Cc: Matti Vaittinen , Matti Vaittinen , Andreas Kemnade , Sebastian Reichel , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Kalle Niemi , =?UTF-8?Q?Topi_Sonkaj=C3=A4rvi?= , Mikko Mutanen , Markus Laine References: <22c6816204b3f2a8b50df8171e384937822d195b.1786356145.git.mazziesaccount@gmail.com> Content-Language: en-US, en-AU, en-GB, en-BW From: Matti Vaittinen In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Thanks for the review(s) Andy. On 10/08/2026 20:18, Andy Shevchenko wrote: > On Mon, Aug 10, 2026 at 01:09:07PM +0300, Matti Vaittinen wrote: > >> Both the current and the average current registers contain same >> 'direction' -bit to denote the direction of the current. The code >> reading these registers incorrectly caches the direction read from the >> first register, and uses it also for the second. >> >> Fix this by initializing the direction bit for both register reads. > > ... > >> static int bd71828_get_current_ds_adc(struct bd71828_power *pwr, int *curr, int > >> { >> __be16 tmp_curr; >> char *tmp = (char *)&tmp_curr; >> - int dir = 1; >> int regs[] = { pwr->regs->ibat, pwr->regs->ibat_avg }; >> int *vals[] = { curr, curr_avg }; >> int ret, i; > >> - for (dir = 1, i = 0; i < ARRAY_SIZE(regs); i++) { >> + for (i = 0; i < ARRAY_SIZE(regs); i++) { > > > While at it > > for (unsigned int i = 0; i < ARRAY_SIZE(regs); i++) { > >> + int dir = 1; > > > ...and drop it from the top declaration. Nope. I'm not a fan of introducing variables inside loop conditions. It's too easy for me to miss them. And, even if I liked the idea (and I don't), it is not a change related to the actual fix - and making it for this loop only would make the style inconsistent in this file. Yours, -- Matti -- Matti Vaittinen Linux kernel developer at ROHM Semiconductors Oulu Finland ~~ When things go utterly wrong vim users can always type :help! ~~