From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dl1-f43.google.com (mail-dl1-f43.google.com [74.125.82.43]) (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 2B068382F10 for ; Sat, 2 May 2026 18:18:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.43 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777745887; cv=none; b=ahN+HrwQMB59blRbvAqC+I9dSt9M+iX/ewThqYX0W23CA+7dyMu62aV6p+MTrTEoeZwoEPgi4uh6+XxWgBKutq/2UqrWJT/tLBNzHkS1/zjx3eGFo/QRD6GLA9CXPVI084uYw/Twn0/TP/In0pv5YZmIjGPmpsjXLF9Nsf/BSS4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777745887; c=relaxed/simple; bh=jts4+FJYN6UyWxaro5eVJAAHa7cKOp7aG2a8YzJF8wg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=XZCHg5djY6NpXvU87+YinVnlDxAduNx4udvw1Kc+1QAtQeXdndqFivp3YVFrBsZeXwAvC2y5qeoJwxtsRL38UddgNwsU2fHzGfvu3weg5cNrS14LApsIA1cAo9YXMfRDQ2J0PR0N6QmLKsPUmrmFf7NzZHQNo17jPV2dZq03iso= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=roeck-us.net; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=qQejEsH7; arc=none smtp.client-ip=74.125.82.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=roeck-us.net 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="qQejEsH7" Received: by mail-dl1-f43.google.com with SMTP id a92af1059eb24-12c726ef332so4466555c88.1 for ; Sat, 02 May 2026 11:18:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777745885; x=1778350685; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:sender:from:to:cc:subject:date:message-id :reply-to; bh=1rTKLeEzmcOTeOi8iU/w4Bp+3pGJXAWFdcis8mzt4mc=; b=qQejEsH7Esa17Od1nvfjpImi8puShPk8STt8n/Gfupn3SS+cRL1kfaKiCLSRBwcVWd UV9s+AdmivHfnqmFvOMw9KjBrTunB94G9X4cTAqVsI1TREs9r2aKyZJSnXZzMnaK1x/C VHbOf0bJse8XIRbW1MIxM2YbK3dlARwCZFBmJc4DLaYddinATjDlXfZm+/BhncdbVRv6 DJNb3cClZstephKWznOfr+dYZqxAUVefuB5a6wXOgHMMoHns/ANNBe/ZDo9PAxK/VsQ/ NhAPVu7C0kzezY6ijFSDVMTTdggLBJ8ozajt8t1EQdNsdmu9/oe0RMc9m7ldU1kkli/R AG3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777745885; x=1778350685; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:sender:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=1rTKLeEzmcOTeOi8iU/w4Bp+3pGJXAWFdcis8mzt4mc=; b=UynB/6xV9QZ4o8Xo/y9g968qFJZqKK0XfssEbiq41bXXPxPcMNKZXcOMhQyCapccvQ LWfB8kqrGsy0/wyXLD26Po2LoVGVMgE53r+Ke7NiTRJ/y4ku4YtpbCBwVEtZcSJe9mdK cNWWsg8HzpTgzq3VE8vg2zH6oqWtVJDj3uLoWQSS3h690TNoVFFzNzRKrcnGu18d09Nz w4uXtCfUD+E47Fd9QzMZFNXBHZhLxrsqpb9wCfYn4BELhGvsLSf6FTgpJ7hBDn4Kwcle p17YoJaZ2jTzxD7GfeCIiVV2cILunoAXlkMSS7Jhr86cDSbzfOIug30U7cXmVcBM28rp gqpw== X-Forwarded-Encrypted: i=1; AFNElJ/p2z83sEMBHk2qKt/ZX5wMzv/W1tgXZncXQumSNqVhpogAWmIa/XZZhwYY+Q3aKcE2kq5mm8nQtfGfpus=@vger.kernel.org X-Gm-Message-State: AOJu0Yz9WuUERiefEPcMTHk8gblkMRYW025Xk5c/2ICbtjgvlGr8T4as +RQRD9/On6DlNaM7+0L7+v83ld2pc57kBilrAKCssAC9sj6CqSwbaIbs X-Gm-Gg: AeBDietcNc+Vs6O3SmAf88e4xBy4K9m4EV+pUmSVz2eUMaLeTmjQ6xjVxmiqgl5fTFp TP7RM/husNXQNRZ3xD0hZB81Ik+KcYDecBRRJ5BJU5S13zI7AL/Ik2bPQ0FIiSOxeSFXjbA68qk ZU8t0fW0xG+EWiXoLIqESde/ZOmlbNLgg5PW8ouWa2IfC4dbBEEK1FWYYgGNzzPSgi+y6GsIf9+ K5bLhyfn+HT7usCXHZ3SiNMWUkzIPRF0aUrZvvI/3dWBsDZdW9p6wCfB7TId014qtm1VvJJTwcA zToGM//XCxHENnG2XrecRlbiMgGFJF686INkAYwFe3Eu8ByIlInWH76MbguiLeFquhTp2+Sm+rl xAhpMu7+aF+3uRV76hmG3ERG2vzx7lnAEr5eSkYAhir/GR+yX65kSwQYs7bszgyR5W2i8KQ9arc fcp4PURPibtKk0imOibFjuPGSkjclos2SnOqlpTh/JbuaSJDAerRnmOv+K9Q== X-Received: by 2002:a05:7300:ec0a:b0:2df:c5bb:3720 with SMTP id 5a478bee46e88-2efb8998ae0mr1737914eec.15.1777745885309; Sat, 02 May 2026 11:18:05 -0700 (PDT) Received: from server.roeck-us.net ([2600:1700:e321:62f0:da43:aeff:fecc:bfd5]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-2ee3889d611sm11866491eec.1.2026.05.02.11.18.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 May 2026 11:18:04 -0700 (PDT) Sender: Guenter Roeck Date: Sat, 2 May 2026 11:18:03 -0700 From: Guenter Roeck To: Tabrez Ahmed Cc: linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org, david.laight.linux@gmail.com, me@brighamcampbell.com, shuah@kernel.org, Sashiko Subject: Re: [PATCH v6 1/3] hwmon: (ads7871) Fix endianness bug in 16-bit register reads Message-ID: <9eb1bafa-c3a1-4f3f-b210-9257bf347c91@roeck-us.net> References: <20260502020844.110038-1-tabreztalks@gmail.com> <20260502020844.110038-2-tabreztalks@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260502020844.110038-2-tabreztalks@gmail.com> On Sat, May 02, 2026 at 07:38:42AM +0530, Tabrez Ahmed wrote: > The ads7871_read_reg16() function relies on spi_w8r16() to read the > 16-bit sensor output. The ADS7871 device transmits the Least Significant > Byte (LSB) first. > > On Little-Endian architectures, spi_w8r16() correctly reconstructs the > 16-bit value. However, on Big-Endian architectures, the byte swapping > causes the first received byte (LSB) to be placed in the most significant > byte of the u16, resulting in corrupted voltage readings. > > To fix this, cast the integer result of spi_w8r16() to a restricted > __le16 type and convert it to the host CPU's native byte order using > le16_to_cpu(). Negative error codes returned by the SPI core are caught > and returned prior to the conversion to avoid mangling the error status. > > Reported-by: Sashiko > Closes: https://sashiko.dev/#/patchset/20260418034601.90226-1-tabreztalks@gmail.com > Suggested-by: David Laight > Signed-off-by: Tabrez Ahmed Sorry for the confusion - this is the one I applied. Thanks, Guenter