From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 76BEC21578B; Thu, 12 Dec 2024 15:35:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734017758; cv=none; b=k87JKJ3ttb7PNuhm7OxgeTvbH/WJL2d5oo3EH+vxSfCZTPpt8cdkhYq22Zne+mTZQSPlmP63UQKU5BuT+cazQ9RSZYXhVZP1j0tAxqem71d9sGdk6qe+CZZ7cDS05VR/ohcvVinPghU5VAI6HU++GDhhcLLZK0fsMLUtahFnvZs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734017758; c=relaxed/simple; bh=KPxi4ZGvUKyq5/Y40SDBDgECRgfzBUpk7uxYaB13noA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fTce1Lqg+FyZem4hD74efgPo+1+Ax0oQ/VZ0f6g8YG466LXhHbC55QnRVkk0083b8RugW2UbpzHihX5At6AtD3RiFUgR/j8pI2YreNlWsPoIHgdXERukxoVqb9BVtyXxMwrw6KDjWnL3SrjzaOnnB0WClQjS11le9iXxjqyuLo4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=xVNjlQyx; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="xVNjlQyx" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DA236C4CECE; Thu, 12 Dec 2024 15:35:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1734017758; bh=KPxi4ZGvUKyq5/Y40SDBDgECRgfzBUpk7uxYaB13noA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xVNjlQyxEyziLl+9Ja8R6Cv6f3aSl/OJbBhWtah1OdSbr4+6neIX2nmq6qVX/Gx4s qhpnehUEjOHGqtfYdRdw6dlcHrUWR65xmUklQoUzp+bqcFWFxNdsVi2tCxquVep3qd iI+mDuCWJVSy6eAOq5eYmmGOl/+hJ+G0oEHchf2c= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Miquel Raynal , Frank Li , Alexandre Belloni , Sasha Levin Subject: [PATCH 6.6 104/356] i3c: master: Replace hard code 2 with macro I3C_ADDR_SLOT_STATUS_BITS Date: Thu, 12 Dec 2024 15:57:03 +0100 Message-ID: <20241212144248.749006275@linuxfoundation.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241212144244.601729511@linuxfoundation.org> References: <20241212144244.601729511@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org 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: Frank Li [ Upstream commit 16aed0a6520ba01b7d22c32e193fc1ec674f92d4 ] Replace the hardcoded value 2, which indicates 2 bits for I3C address status, with the predefined macro I3C_ADDR_SLOT_STATUS_BITS. Improve maintainability and extensibility of the code. Reviewed-by: Miquel Raynal Signed-off-by: Frank Li Link: https://lore.kernel.org/r/20241021-i3c_dts_assign-v8-1-4098b8bde01e@nxp.com Signed-off-by: Alexandre Belloni Stable-dep-of: 851bd21cdb55 ("i3c: master: Fix dynamic address leak when 'assigned-address' is present") Signed-off-by: Sasha Levin --- drivers/i3c/master.c | 4 ++-- include/linux/i3c/master.h | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c index 78171a754a3f8..2b6bc03652139 100644 --- a/drivers/i3c/master.c +++ b/drivers/i3c/master.c @@ -345,7 +345,7 @@ static enum i3c_addr_slot_status i3c_bus_get_addr_slot_status(struct i3c_bus *bus, u16 addr) { unsigned long status; - int bitpos = addr * 2; + int bitpos = addr * I3C_ADDR_SLOT_STATUS_BITS; if (addr > I2C_MAX_ADDR) return I3C_ADDR_SLOT_RSVD; @@ -359,7 +359,7 @@ i3c_bus_get_addr_slot_status(struct i3c_bus *bus, u16 addr) static void i3c_bus_set_addr_slot_status(struct i3c_bus *bus, u16 addr, enum i3c_addr_slot_status status) { - int bitpos = addr * 2; + int bitpos = addr * I3C_ADDR_SLOT_STATUS_BITS; unsigned long *ptr; if (addr > I2C_MAX_ADDR) diff --git a/include/linux/i3c/master.h b/include/linux/i3c/master.h index f0aa4c549aa7f..ed6b153481021 100644 --- a/include/linux/i3c/master.h +++ b/include/linux/i3c/master.h @@ -305,6 +305,8 @@ enum i3c_addr_slot_status { I3C_ADDR_SLOT_STATUS_MASK = 3, }; +#define I3C_ADDR_SLOT_STATUS_BITS 2 + /** * struct i3c_bus - I3C bus object * @cur_master: I3C master currently driving the bus. Since I3C is multi-master @@ -346,7 +348,7 @@ enum i3c_addr_slot_status { struct i3c_bus { struct i3c_dev_desc *cur_master; int id; - unsigned long addrslots[((I2C_MAX_ADDR + 1) * 2) / BITS_PER_LONG]; + unsigned long addrslots[((I2C_MAX_ADDR + 1) * I3C_ADDR_SLOT_STATUS_BITS) / BITS_PER_LONG]; enum i3c_bus_mode mode; struct { unsigned long i3c; -- 2.43.0