From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-lj1-f175.google.com (mail-lj1-f175.google.com [209.85.208.175]) (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 8666840F73B for ; Wed, 12 Aug 2026 09:40:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.175 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786527656; cv=none; b=U/96QVWwnLFgkMnf1qTpI5GfIW1+wqqQlvbwh9IionmZBaei/QMwDceZHBVZY52J4/zeOOpHDRA5GnsiwYpUO01DQ6JgsEP0Hx+IbU78/dcTUzzaKMyINfAj8CXsWd7tov6Cggct0hk6LLpDtc/U8XyNgjNXX2eGTpakzfjyRmw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786527656; c=relaxed/simple; bh=vEnWUoUaz+j1jutZ0x7mn3UZx68qpKOkRpdbj6GiR4Q=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=DXqpez7qv/FMbs0WodLWrONmt12HZaFpTQ1Ko92A20fkcHGoTv/d3sdVTr6P4GsOPEZx/kuXymyvoNXwP3RNn/o4AIJZVOWBKwo7yMG39Daun/3aI7/NZRdwBXfDNJYsWFtGracnEcNvxsSgyzVzgS33lVUhSUr0RfJAe2frN7c= 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=bFi6eUae; arc=none smtp.client-ip=209.85.208.175 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="bFi6eUae" Received: by mail-lj1-f175.google.com with SMTP id 38308e7fff4ca-39c74722e27so10445111fa.0 for ; Wed, 12 Aug 2026 02:40:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786527649; x=1787132449; 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=+dz/gXZ21acjG3092zZMnoEfpN4U+nzeRDfy7pXv4tc=; b=bFi6eUaegxpFKCUdkGx55uamKhQFU5NhFgKu6SOXKPmz5dMu9QrHXQTj7gMOu8l6GA rKMEtyVxKcRSl2uUJwPCzSiYJjNh7WfRufyY4aF2H2HLHB29zUh6rFCGZYF1dWZZLqbz 1hgHu8J/MeDAazc9FAGXkzm4ioBc9/wDCUw0zyzfGmY+LEHk5wOjgtHfX1cmNglcTVM1 1+754oJrU9BUEUNnxzXrUiMBPm1byGG31+a/kqy9dLSsplFz7GKRcVlj0hOi8Ps7JvP7 InaWJv/SlY1ocMKZfN1LfjF1vT8/xUTJmesTl0tW6D3hsUnLnAFjyth5kO1h/MnoEv4g mWgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786527649; x=1787132449; 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=+dz/gXZ21acjG3092zZMnoEfpN4U+nzeRDfy7pXv4tc=; b=p/RJRJ066Q0d1lAky7EtJUX9wpjhHQmhXdvc47Xgk4NMQZNjx/lX02e33SXRRUSKB1 4fvnFNGitideUVs3aTz7L3pIqWdh2oD8UomABIhphzg0seaM0uVmAq2W44pu2S3dRswz 8+AEMDsTjZoT90GUsC5t50rzujtsZcyeamdMkP3r8FFXOU0bH+lhBDf0GY49rYNMCx0b NDLoFE718FBeBMT2ZjMqam/a4gWFYw03qTYKiYoRJlpstBmeWWV80nOBWo5j99UF1pTi BnIHXm8yYUYQp/RxUqYLAwavHasNsWnr61ZPqVCB5qNAcv5gP4hHBZMckC96mOiEk4W9 VuIw== X-Forwarded-Encrypted: i=1; AHgh+RqqgEhWI+kUUbkhhcClbi56L9XRrkf6f8ATpqyhnLtkyD0Itz4Rhb6T6LIco4OpziKdbJUOYBlWZvjlMI0=@vger.kernel.org X-Gm-Message-State: AOJu0YwuKCK/JmME8bmsMhMwzAykxHmxKHaRyviuy0hLeHtblocHpYwO n/JIawU0qr0UyO47euNVxkC2FRphuKV/7NMfKd1YbdbFhYqr1xHg5Unm X-Gm-Gg: AR+sD13e6jigv7uq/iyNYuLt99TFO9p6ANcoyvkQFU9W85P/OaIlH8QgOSjaQQCNJdn 6MfdmHmm4u/qE8sngvmk6lUvVvHMmkBNO3lXbReTtUkib/HV6eokEQIY3bSsR+hsibFHz4Z5lh5 /oQEUtyAkkqLW808yjRTEe3iy+8oMbVke3wz4vWtA1zsOoTDLtCENZSi3eIZLGG0mZ/8HhZ8bBr YKgRUBt0j1SAHi+KajIfMHLbB4nlDhA2lh55tM2cBDdinyB67jkSBodlkiiHRhdDwHoMewSwr6p T16C2Cys7LMWs6adxWwW12iE1PG1Y3kwUCuujSHSMrSE8D7abUB/rEj9R2Z19b8Nu5rIOSYvWsE h5EP7aSjdBlJwNV3QcM7o42uzg/h2xzZZSPnHKfLigMm7HIVMOpDH8iE6Nm5Jy/c6U9KZTzXz1R 1ENb1Z0RtabI3kIn2Mk11+2nyKcwwgL8ZIUMjnoFfsrgqWTcFpoPhvz41Qq/r2a7I+U3XD X-Received: by 2002:a2e:a9a2:0:b0:39b:11f9:6132 with SMTP id 38308e7fff4ca-3a102a5d000mr8943151fa.1.1786527648997; Wed, 12 Aug 2026 02:40:48 -0700 (PDT) Received: from [10.38.18.54] ([213.255.186.37]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-3a107d20f1esm3277211fa.16.2026.08.12.02.40.47 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 12 Aug 2026 02:40:48 -0700 (PDT) Message-ID: <1b08ee53-5adf-4de1-afdc-4419797142d8@gmail.com> Date: Wed, 12 Aug 2026 12:40:47 +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: Andreas Kemnade , Andy Shevchenko Cc: Matti Vaittinen , Matti Vaittinen , 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> <20260812101050.575c9bfb@kemnade.info> <20260812102536.63579b89@kemnade.info> Content-Language: en-US, en-AU, en-GB, en-BW From: Matti Vaittinen In-Reply-To: <20260812102536.63579b89@kemnade.info> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 12/08/2026 11:25, Andreas Kemnade wrote: > On Wed, 12 Aug 2026 11:17:36 +0300 > Andy Shevchenko wrote: > >> On Wed, Aug 12, 2026 at 10:10:50AM +0200, Andreas Kemnade wrote: >>> On Mon, 10 Aug 2026 13:09:07 +0300 >>> Matti Vaittinen wrote: >> >> ... >> >>> That code is complicated. What about a generic 16bit non_2complemented sign >>> to 2-complemented sign function/macro. Such would have prevented the error >>> in the first places. So &vals[i] = signbit_to_2complement(be16_to_cpu(tmp_curr), 15) * pwr->curr_factor >> >> Do you mean existing sign_extend32() from bitops.h? >> > > I don't think it does what is needed. Here we have > > 0000 0000 0000 0001 -> 1 > Usually we have > > 1111 1111 1111 1111 -> -1 > > but here > > 1000 0000 0000 0001 -> -1 > > If I do understand things correctly. I not find something useful > in bitops.h. > Thanks for the review and testing Andreas! We share the same (mis?)understanding. ;) I am not sure this is so widely used it'd warrant a generic macro. I am afraid that if someone encountered similar design, he would not expect a generic macro to exist. My gut feeling is that this is too marginal to be widely useful. I am not against it though, if someone wants to implement it. What comes to complexity - I agree. The code is messy, but mostly because of "clever hacks" done so values are in arrays indexed by loop. I, however, would like to see a minimal backportable fix, and potentially, larger clean-up which can then go in as a feature, without any rush. Yours, -- Matti -- Matti Vaittinen Linux kernel developer at ROHM Semiconductors Oulu Finland ~~ When things go utterly wrong vim users can always type :help! ~~