From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EDC5D47A0C0; Tue, 16 Jun 2026 16:51:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781628721; cv=none; b=vBTgmCn75lBNxMK4xOanwtXGdPAKhKPiM7fs9jK95mlWSY3eLOg7gefrmDqrDatS1y9npgsZ4OZveiqpxe4qcGyBBbIj6inqX5GIJHmdkNcIQ0yWo3Jd5cZTnTiPv8UJln6hojdhhtuYV8O750REdrlrxW4fdJJNjHiG28/PQ9Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781628721; c=relaxed/simple; bh=P8qPkl2lIxZw9mw+5HTMYrJWS7KUvXcJs34G3DPwQhU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZE7+y0SgXS5rELDrP7afl+EeBst5mxXRl0rNPcz+ccrsAjniMwNbWN7KLQENwZPIV6xTeXDCRBHclA02hL/KBmjYkrLPV3lQnBa2owJvBXMI9LJlVP9HjQdfAEXpDVlyfPLMZrBJ0uoJfiIKlMnxkRGGbrkLV1xS4kPp+6Tz6Og= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=i+DD5PX9; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="i+DD5PX9" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F36AD1F000E9; Tue, 16 Jun 2026 16:51:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1781628719; bh=5/UU1n5n0/l8KZuzMTRO3vyA6kk027D2TpcUmOdCKfk=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=i+DD5PX9nqqXiiyQ/hNtV/cRfrONBw2NuaOa5m99JKRr2GwqdImCyCfrRxolNNkcS aEuHGdye7NBozfvuTb2DW+9vKAtmJy8ZAvCFklhq8j8fkgTFaIJK8KCBfxeNXC85uJ Xo2uHiOWd1VW2HWQLZDEs/vmnl7Vvlgvv+nSr5mY= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Aldo Conte , Jonathan Cameron Subject: [PATCH 6.6 117/452] iio: light: cm3323: fix reg_conf not being initialized correctly Date: Tue, 16 Jun 2026 20:25:44 +0530 Message-ID: <20260616145123.851859229@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260616145117.796205997@linuxfoundation.org> References: <20260616145117.796205997@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Aldo Conte commit 1f4f0bcc5255dec5c4c3a1551bf49d8c33b69b20 upstream. The code stores the return value of i2c_smbus_write_word_data() in data->reg_conf; however, this value represents the result of the write operation and not the value actually written to the configuration register. This meant that the contents of data->reg_conf did not truly reflect the contents of the hardware register. Instead, save the value of the register before the write and use this value in the I2C write. The bug was found by code inspection: i2c_smbus_write_word_data() returns 0 on success, not the value written to the register. Tested using i2c-stub on a Raspberry Pi 3B running a custom 6.19.10 kernel. Before loading the driver, the configuration register 0x00 CM3323_CMD_CONF was populated with 0x0030 using `i2cset -y 11 0x10 0x00 0x0030 w`, encoding an integration time of 320ms in bits[6:4]. Due to incorrect initialization of data->reg_conf in cm3323_init(), the print of integration_time returns 0.040000 instead of the expected 0.320000. This happens because the read of the integration_time depends on cm3323_get_it_bits() that is based on the value of data->reg_conf, which is erroneously set to 0. With this fix applied, data->reg_conf correctly saves 0x0030 after init and the successive integration_time reports 0.320000 as expected. Fixes: 8b0544263761 ("iio: light: Add support for Capella CM3323 color sensor") Cc: stable@vger.kernel.org Signed-off-by: Aldo Conte Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/iio/light/cm3323.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) --- a/drivers/iio/light/cm3323.c +++ b/drivers/iio/light/cm3323.c @@ -89,15 +89,14 @@ static int cm3323_init(struct iio_dev *i /* enable sensor and set auto force mode */ ret &= ~(CM3323_CONF_SD_BIT | CM3323_CONF_AF_BIT); + data->reg_conf = ret; - ret = i2c_smbus_write_word_data(data->client, CM3323_CMD_CONF, ret); + ret = i2c_smbus_write_word_data(data->client, CM3323_CMD_CONF, data->reg_conf); if (ret < 0) { dev_err(&data->client->dev, "Error writing reg_conf\n"); return ret; } - data->reg_conf = ret; - return 0; }