From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=192.198.163.11 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796058910; b=QJDcPheCBFOTDAZrhBHWeBS3NS6MEpQBLHpd+d6opfukHdBdBlb9FI1WqsaMiJrrtKnP LfsDXD/G65VVGgpPdIpenQpqgpZ1cBW77Nu8debJ89Bdy4EKmAdHw5uvgKaButg5pr0Yw Kei10BueE9h99iWuHOh/4wCqEz11BZYyWRifnjtIXUbVpyR0/Nslf/93tUF2IPlY7LmR7 Kkxuqz0xcmnYGTP1LFcHZeCkJYfp2+ZEMGRMq8mTzoKRr/iptlYAg12Iyp4DoPsT0b201 8DovkW0E5FP1TCpMTokT8Ttj/g9GzJITI2a8irRIrCqsZ/plSRY4yMVPwrwSzsXtfQw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796058910; h=DMARC-Filter:DKIM-Signature:X-CSE-ConnectionGUID:X-CSE-MsgGUID: X-IronPort-AV:X-IronPort-AV:Received:X-CSE-ConnectionGUID: X-CSE-MsgGUID:X-ExtLoop1:X-IronPort-AV:Received:Date:From:To:Cc: Subject:Message-ID:References:MIME-Version:Content-Type: Content-Disposition:In-Reply-To:Organization; bh=ZOvzSts1qZgB16zq95lR+iKnd4Fa1MCPdaRjILf+Dpw=; b=488Brhg5CoHucJCCcv0tL9tsAQ2VGcpo2/MoEY57GLCBcfJb3+sp3OMKCDhgMrquR4xa mjNSUhXiJj44prdzNHrrG1En3a/msNADFroEPI7hnnE/JXcvOL/X0RqeUBkFiDvixG/FT 1k7gJrS1moIkoYJ5u9dZnrAPS4JA5f0QBOvVR79W4bAZThvZYDkHwVGgCfB52+e7L5fvX rOGND1qLdZl0EuLJQ8q9F8S2tWujTFVz/Kz/WaSJhMHDodc2sZ8fmK2N6Eh168cUwQJcq TUFfRx+F2ig1fOvDyJHL6Tzhr/QWcBWgmTu8zcaq2piLmIVj22Cs8+pkdIjChddTz/Q== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=AvEAW958; arc=none smtp.remote-ip=192.198.163.11 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 26B58606A332; Mon, 30 Nov 2026 17:15:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 26B58606A332 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=AvEAW958 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796058911; x=1827594911; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=ZOvzSts1qZgB16zq95lR+iKnd4Fa1MCPdaRjILf+Dpw=; b=AvEAW958qbd+mBtbr3LylSNdm+kqBf+1c9zaz6Nj1/oJEKlGJyzoF9ym NmxwKYS+I5emP/cqdKsbM1UQzQXMfPsLbsh4HAfkBqFZSfTRPmvkG2ruQ 1fQQ2rMWpbM30Zc+BSmliM9X7q+V12b2nbu7vsefkbKbfylwDbP3/sKso zWgdfjQRgsFOib6o23M23ArnzV1fZrkOsSFcKkRYVklB2cuDMxtKifJga qgZs09kk3PHF2Cs/dYf/Bck05u1tLwIZ97930R4oxwdwbKAszl2u29KyL EqITIBD/35QbSOgB6dDxbxUscu8spLWmxV5RWFheLfQAG+wBqXKj2wbe6 g==; X-CSE-ConnectionGUID: zNWZfH6QQyKuFBbMsixdnw== X-CSE-MsgGUID: F+HjExgVReu+RtBjnto2yg== X-IronPort-AV: E=McAfee;i="6800,10657,11982"; a="4815278" X-IronPort-AV: E=Sophos;i="6.27,243,1787036400"; d="scan'208";a="4815278" Received: from orviesa007.jf.intel.com ([10.64.159.147]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Nov 2026 09:15:10 -0800 X-CSE-ConnectionGUID: P3GgFMUURRGdGCK6lbxOYA== X-CSE-MsgGUID: nd5IECGuTXOvW/cmiQu/wA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,243,1787036400"; d="scan'208";a="12976285" Received: from abityuts-desk1.ger.corp.intel.com (HELO localhost) ([10.245.244.117]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Nov 2026 09:15:07 -0800 Date: Mon, 30 Nov 2026 19:15:05 +0200 From: Andy Shevchenko To: Arnav Kapoor Cc: Jonathan Cameron , David Lechner , Nuno =?iso-8859-1?Q?S=E1?= , Andy Shevchenko , Gwendal Grignou , Stephen Boyd , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 4/6] iio: proximity: sx9360: fix hardware gain encoding Message-ID: References: <20261128115534.558478-1-kapoorarnav43@gmail.com> <20261128115534.558478-5-kapoorarnav43@gmail.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20261128115534.558478-5-kapoorarnav43@gmail.com> Organization: Intel Finland Oy - BIC 0357606-4 - c/o Alberga Business Park, 6 krs, Bertel Jungin Aukio 5, 02600 Espoo On Sat, Nov 28, 2026 at 05:24:52PM +0530, Arnav Kapoor wrote: > The sx9360 PROX_CTRL0 gain handling was copied from the original sx9324 > driver and has the same bug that commit 108e4d4de2b5 > ("iio:proximity:sx9324: Fix hardware gain read/write") fixed there: > > - The gain field holds ilog2() + 1, with 0 reserved, so a gain > of 1 is 0x1 and a gain of 8 is 0x4. read_gain() and write_gain() > use ilog2() instead, so every gain is off by one: writing 1 > programs the reserved code 0 and writing 8 programs a gain of 4. > - SX9360_REG_PROX_CTRL0_GAIN_1 is 0x80, which sets the reserved bit 7 > and leaves the gain field at the reserved code 0, instead of > 0x1 << 3. > > Semtech's own SX9360 driver (shipped in Samsung Galaxy kernels) decodes > the field the same way, codes 1..4 as x1..x8 and 0, 5..7 as reserved, > and programs 0x09 (gain x1, bit 7 clear) into both PROX_CTRL0 > registers. > > Use the same encoding as sx9324: add one when writing, subtract one > when reading, return -EINVAL for the reserved codes on read, and build > the default with FIELD_PREP_CONST(). SX9360_REG_PROX_CTRL0_GAIN_8 used > by the range check in write_gain() becomes 0x4 accordingly. > Fixes: 1cdb4c47f7f5 ("iio:proximity:sx9360: Add sx9360 support") > Link: https://github.com/TeamWin/android_kernel_samsung_d2q/blob/master/drivers/sensors/sx9360.c Do not put unreferred Link tags to the commit messages. Use the form of Link: $URL [1] and refer with [1] in the commit message above. -- With Best Regards, Andy Shevchenko