From patchwork Tue Oct 8 15:18:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13826624 Received: from DUZPR83CU001.outbound.protection.outlook.com (mail-northeuropeazon11013046.outbound.protection.outlook.com [52.101.67.46]) (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 4EAF61E0089 for ; Tue, 8 Oct 2024 15:18:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.67.46 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728400734; cv=fail; b=mCpW7+6nQSBFfkWD8yyQgb4ZaZougU22Q/t004mRelxRwvp2+YPHKUu9NuYOe6Dveyu2zW0NPwnOiogDHEm9KDG7K+sxL5ALVyxf2Mpz666uDpbsaoGQYxGC19jkLk+pq2irxIivxDtrritJtmCwYUW50pDEI1nqz3tP+n9yS5I= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728400734; c=relaxed/simple; bh=mJQ2NVwjODXELkcDKNUIEYw/DZI0LGJGAQy+lGen7bE=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=o/Olp5iSvNmPInWsk8ZwbB7RBCWJ+F81qyymqFKsTeKd+KQ53ffWZEjzJnLSb/SxTtI87/3+HvUFzyy5HCqnvm99kheqv79PSv1/U2f3dHnglCaxfAa2QLcFJnBAHuxE2SuzrhpdoyGdMb9ZNC2aFrdwNUWohKo/XEmrRcgDpC4= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=aDHwHjT6; arc=fail smtp.client-ip=52.101.67.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="aDHwHjT6" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=L2V2LYdcjEA0jgBTzCYfg8KcJF2zvjpDwo2mVgvhaSmCZKlUMQ0etZ2QyeZnexMjkKgmPUboBIiRKg/w1jsMAjXRMSM2ksreHo83yhMI3wpedEPsOeqRzaux6E3YkacWhEeQPKljlPz86VnSOPaRS1T7lf7gosqnoKxNkuSGhd3nswLwR3wXUokHk4p1dWSnJwt39H6xrB3WPLmU5Jk7x5wIsDMoQ9wqMB2VWmmFNDQFk/TxchVQqJYERSgvubPthgDQPLanL/T6xKG7w8awbp+qQdo8Yp/Vj5vEONm+EOtvKTceLRsQZ2NcBJa+Gqz6qPFGXuE8ueYIF9vvA/qVnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=CtrMS8OXbe0qcYxmNRu2SlrZq9vhMYyZCg5B65vBMeY=; b=soocErKvx1hSo5ye/7oSqx8Y+s6/UooqD4cj5i35hKZSTz/a3KB9YZo62cQTGShfOjSyFcx+57tuh2TAjLUfHZyr8yuVeVCNoMPwirporRDydLcyxxl4qzJzwtDmDQ//WPnhRg7bRo+++TZAt9FZVXNydQU0udEySLUpbilqKU04GaagRN8yHqdmFMPOtkrmeOpMvcKNi6EQwhTAigFJvvZD1Y+PGVJvkfLBp9SOQAL/F5AvnSAQ/ZaANad6BoF4wZleZYrSM8k7hdMLXRwE2Eo0TjlJ4eRz+StH6M7qMxnvNWSVPFiJtdIoRvlyaOUTgyqBmGcfZCjXjTUClKI0MA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=CtrMS8OXbe0qcYxmNRu2SlrZq9vhMYyZCg5B65vBMeY=; b=aDHwHjT6R3oBw8A2rX3nt/STBxD1aODnZtXarkBNXrJnYeR7w1serANqLxLcPPqcngJgJXUI4lqXfgFEkiFM9GL/rt1tUOYWSsM7BiM0E2Y4VRGLpAn0OhpgF2WBXlUsFtXGI9ZiRD1+IQcMjhkcI3bp/ZOVgQ02DyYJYOuKXTsWjjeuh5jcucUePo9kf+L+CyjPI8auPAmqUucyjQjGwC3NgZBkfWtP87l4+Z150taaSsnPeY3EuOZHX0R9euH4TsCBqz5HTgVYqcMZQFx6oGh91u5JS9+tj1TGBvYzYoLdG6FZT/o9Qq58dUFNvkEHMgxbySHwgv1ZmZ8+5GIt7w== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from DB9PR04MB9626.eurprd04.prod.outlook.com (2603:10a6:10:309::18) by DB8PR04MB7194.eurprd04.prod.outlook.com (2603:10a6:10:127::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.23; Tue, 8 Oct 2024 15:18:47 +0000 Received: from DB9PR04MB9626.eurprd04.prod.outlook.com ([fe80::e81:b393:ebc5:bc3d]) by DB9PR04MB9626.eurprd04.prod.outlook.com ([fe80::e81:b393:ebc5:bc3d%3]) with mapi id 15.20.8026.019; Tue, 8 Oct 2024 15:18:47 +0000 From: Frank Li Date: Tue, 08 Oct 2024 11:18:24 -0400 Subject: [PATCH v7 1/3] i3c: master: Replace hard code 2 with macro I3C_ADDR_SLOT_STATUS_BITS Message-Id: <20241008-i3c_dts_assign-v7-1-96ec93d1f34c@nxp.com> References: <20241008-i3c_dts_assign-v7-0-96ec93d1f34c@nxp.com> In-Reply-To: <20241008-i3c_dts_assign-v7-0-96ec93d1f34c@nxp.com> To: Alexandre Belloni Cc: linux-i3c@lists.infradead.org, linux-kernel@vger.kernel.org, arnd@arndb.de, bbrezillon@kernel.org, boris.brezillon@collabora.com, conor.culhane@silvaco.com, gregkh@linuxfoundation.org, imx@lists.linux.dev, miquel.raynal@bootlin.com, pthombar@cadence.com, ravindra.yashvant.shinde@nxp.com, Frank Li X-Mailer: b4 0.13-dev-e586c X-Developer-Signature: v=1; a=ed25519-sha256; t=1728400720; l=2178; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=mJQ2NVwjODXELkcDKNUIEYw/DZI0LGJGAQy+lGen7bE=; b=UnbOBSsYXxfymZwvnMKhf6Sj/J6XWt0gN36MJyZunF41KlP0gmWvL/QhEQ82FL183JmvlROKG 00ALDPU/NVyAP0Zf4eLkR/JyXjkaQxwKyAF7afIoDtL2fERVCQmqUcR X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: BYAPR11CA0101.namprd11.prod.outlook.com (2603:10b6:a03:f4::42) To DB9PR04MB9626.eurprd04.prod.outlook.com (2603:10a6:10:309::18) Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB9PR04MB9626:EE_|DB8PR04MB7194:EE_ X-MS-Office365-Filtering-Correlation-Id: 6e3c7333-6db8-4aa6-61d0-08dce7ac8156 X-LD-Processed: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|52116014|376014|7416014|366016|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?bh1bNck+8qaZwKygIZMLDDpj/ffTlQ1?= =?utf-8?q?tnnVvz927Exs9Sds9uVBDPxCXp2d589Y0FrHJmF07fGbbdlnpl7HofHxqTTxyI4yh?= =?utf-8?q?8hskS8ZKQIVqLvIDqZ3lY3EqD2u0Jm2rZVx7rOEyu4Oj1Bnn+qIfy7JzWB7hNaP2B?= =?utf-8?q?IRRL6FA5WTpghSEbssVfdK84ono474zpPlJOWtUWj+yyOkY9Bk7exNlNyH1q8VUfW?= =?utf-8?q?Hh48gm1l4knU/9g4XHg3UHTQdJCFgHiTpy2UAKBjhMx+YIHBrCGr6ybNRMAtus6ho?= =?utf-8?q?MX9xctlfZuf5f0/Bx2bvOd1i2HVHL94J3o3u4LRYg7pl+cDfGzWV5IPvs57b96DUn?= =?utf-8?q?zy9MocLYuRJM5hJiQbZireIKu/DGKgvwwLlqh1inv6DaeXGz5rSkpHOnZo+O+/Wc1?= =?utf-8?q?w4DIvumkodSLrZIzLtVYVWlBHvtkh9rC+V2at2ZiPrSbQdjY+PRxS0GJBaGAac6Ks?= =?utf-8?q?C6nFiG42HK6Sk4btO6XGuuGluaSAknwxW4pYi2u3mxU8paWAaeP7GoFEO0AAvWnfN?= =?utf-8?q?G72qkSlnSGgSM46sJWIvyrbWVpq6XOuw7MtPlKDwGYJqTbeMNpfPfKioKlnK0yKBZ?= =?utf-8?q?ADe3FVUNNXkSLnB1pUdKgFk2xAKFffpNDpqdOw4I2dFdM0W/1a1ecleYQkt4AP82X?= =?utf-8?q?Tbi5h6pERkvMNdJ3ZinY3K85IGs/VOI7+dWCoEiqw+PoIfLdis/uRsoq8/V/iP9QK?= =?utf-8?q?5sDDSr0HCHW+CKFfSdtjL8HFRjckiidbZEgWiN+YiU5vewVgkz4rLNedmDVViPGDU?= =?utf-8?q?6lJD2WjCT/V3PTaOnJhiSF5IxAXWsBv0sLxz2H/x5N0WP7pif5Ahy/G6/SC1WJ8JI?= =?utf-8?q?v/nTbQgvUXYIW/UnxHpp64IC3oEIsIFsb5QYdy+uyyxAyL+xslSwCiCuTP40mt7/Q?= =?utf-8?q?uBI7yiyJ/MwtVFXLAje6cg4eapObQRv4UEy/2TfSu1YvWXkvaBIekL2QvIDB2j+rA?= =?utf-8?q?CN+NynBAjWpzJdv2croNLyry+y73T9PyePzFP8uD8c7zsPeFZAhhwc/xlT2s1JH76?= =?utf-8?q?D6zPfswA+llknmAKygKMeusn1+MLX/X86B6r6MkZl0f2JX8I4nqo1Lqlc96pVJZnR?= =?utf-8?q?MoGcwUGv+VEyQWAT+hyXFoC/7il9OatN+Xu3mYWoqQcdC+yMUbCTaEBi719rC7631?= =?utf-8?q?R6bH37zXnZ4dXmP/ApviWPxazs692RUQMNspnApvmfCR4ifK0Ph25YBxR+5l2DqCL?= =?utf-8?q?ONZ/g+tIEGa+UTBvVks4C4vv/jZyjpxg2QC013dvXP2cZEBRevYXpoPZL0wx8O13S?= =?utf-8?q?NFvZIfmub498npaWvZkt5FGuiB7mamIwV7Q=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB9PR04MB9626.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(52116014)(376014)(7416014)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?NV63vVP+fBiiqS4CpsX1ock6zEbS?= =?utf-8?q?lPNME85KdqDhJWiJ3q21hmXQA5h/eofufdX/w1cd0rNVbRf7U8o8I910Bh37Q3Uen?= =?utf-8?q?baX1iNaEg4AH7c9s4RRf+Pf9OYEM9kY849ID0Ci1qQYSYGyV67doTx4kT2boR6w/Y?= =?utf-8?q?vj7quP4KpcPMEuvQJ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VUAme/QzyEqmwkGzoTgsDmPXJa4?= =?utf-8?q?WR5Y8IJ7RIwr3/DcD7YGtPgz56Qj8SLJPV7B1Z6iJmVsjObcr3YQpkgK9Yq8CfgFZ?= =?utf-8?q?t/CEt0jEyN+oBEN4ayJyycWhfvggAnRCfILo/HsMwvMbzMOni70DJxgoMFpV2gV8z?= =?utf-8?q?wNt+EoXVwa2G+uagC/ybDgBFIJg6v5hatYJqmW1q5KOxqjGHrrcBn26ZhxcJ1Upah?= =?utf-8?q?LY1ONuPK8eCVi6bxQ0rpQBz4gGLoedCVLWn6bbF864VSKO72oRVf5MLVIqOWa+siE?= =?utf-8?q?Yxp+ncxtfPo3NzUWUQnNMu9ki7dfQNe8WOzPvXPESFeBxZ0kXNKe2KJGB95hO6LAl?= =?utf-8?q?66q2i2Z7EqmDp3TezjYvPvimtc6z1xWKhIY7rQ61+8FiuLrvgYKW+sfnz9B9yO51D?= =?utf-8?q?OY7bqkMfSkDt7iBF+MtUzBBZCLLFeywjlefNtRFnXKHjStGLNqydob74=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6e3c7333-6db8-4aa6-61d0-08dce7ac8156 X-MS-Exchange-CrossTenant-AuthSource: DB9PR04MB9626.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Oct 2024 15:18:47.1137 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 1Yj42lLtg32gIdIQBoCSe6mwHyiSIugfzpGMYfpN7YT3u338H8Io7SMOIX4AiIQigdtMLWmi9PfWTfcuWLz9KA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR04MB7194 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 --- Change from v6 to v7 - none Change from v5 to v6 - fix version, should start from v5 - add Miquel's review tag Change from v3 to v4 - rename to I3C_ADDR_SLOT_STATUS_BITS --- 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 6f3eb710a75d6..dcf8d23c5941a 100644 --- a/drivers/i3c/master.c +++ b/drivers/i3c/master.c @@ -348,7 +348,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; @@ -362,7 +362,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 2a1ed05d5782a..2100547b2d8d2 100644 --- a/include/linux/i3c/master.h +++ b/include/linux/i3c/master.h @@ -313,6 +313,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 @@ -354,7 +356,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;