From patchwork Mon Oct 21 15:45:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13844348 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2083.outbound.protection.outlook.com [40.107.22.83]) (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 AA83D1C4633 for ; Mon, 21 Oct 2024 15:45:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.22.83 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729525533; cv=fail; b=qzsQLMqb3JK5nl4KzGdFhzZCsGNlluGc8jSlGHMyCq3xNp0UXkesMOoqpCy1zLLvww5hJK92B/Y87Y9eVp9WlYkSD/UMwMAPK9jqqYJZ8fqnK301myNV890ucmVP7xGI4y1SmX+2MOpra23QxhD4pgFhzdLYz4C/RtgDuX+nDd4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729525533; c=relaxed/simple; bh=RF+K6k5hNWi6XLW985uClu+rYjI9LQWRNm31Nm82054=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=rK6fHBZC5iQe+Nc67Y5u4wS74ntCISjs8yqc1bHjW7LUazoLRYtCTzcGVl4YHSUV5w/v3OKpXJ12zlKK7b5XRXCuhORRTmbM3/K6FvSM6pdlFFpgomkkGkoRKwSghD02spjYqk5waVa/eEbgevFt3PgOSMkM2rUgxFBirRB2638= 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=OROyzr2D; arc=fail smtp.client-ip=40.107.22.83 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="OROyzr2D" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=NMvHCILlRHLfrCswfDoV5fVIYGAX3vzTrCsmCnf/4F+MQe1x/ZXIRmr1r1Z0j1ruqDwtGlpQa6KdlebHmTIF5NxUpUnLACRDq1rys8YALMafYWdeMs0VcIdY7EMv7wDfFMByUbPtK6y+qBjqT+FANrWCufik0TduwcAlZA2O56ID3WmpF+6m2GM/HCIB8toBPUrbgYC/nZm6alPSOeJBhYG+xMQcEyrlsBiG1j+/74GA1hCpAZmRsRN/wieq2bD2/DO7sdawyZWG4QUImWXqLCp4y7cQrUr+Lh0gBsYSSVCTwSXgGuAjO9qg/PknZ/jw8ZCu3pvIe8pcBpxtG8fzag== 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=7eZFESgy2A7HhzoaZNK6yCDosWtkgT9dE8V/zsOlrEI=; b=N+OaA9WZ6mTTErHb5pV6JO2hmpjNLOHBRqIXDkHWwOP4HqWZo89cpuCJy/Hq6Zws8bGRU7WlZwGVu0avEYKh+RGJKaN/A848YQnMdfBXNNsdfzevSHRfMZ5OzB7HQgvZbO3rqCi1eqFh+16DEqScbsMgMe7RS1JEfu0ewNwc9gSYKi55c4edo+I1HeD7LI/V93gIebCDQYysV/VFq2lYGVUhFC9FcxuQuEHEXkIR6cYVHnZFCBqstRELiqZ7KBDBOIuFzTHa0u2r9J8+XBdopcR1nXaciX1Mg+QSivwMJnXtz52twkQmv9WzKOFpgTO8xkKTQTMe2D0W6vbCGgtFVg== 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=7eZFESgy2A7HhzoaZNK6yCDosWtkgT9dE8V/zsOlrEI=; b=OROyzr2Dc5uOjVlcIg8dvyBMxM67HEU+lJ7E0DJ0x93xiyWCPsfBKbb0ixuivUSfpij9R9th7qAcGzNyjVZPuo2ttgtoWCCoNnQWhgl/XseoPwwwYBtcSZc88J0CpeIHF3awuwC1Y+8KGSGlk/9stVoitKu21UWcjgD2jcjglPrBMi3fjk4Az39MSK+AcBtigle6evFn3zUaidvkz2j9GLiQvQ4Y1jkpzT9/uDBOJCy3BjU5RnQEfBur4lIQ+1ybK4U9pqJ9Qo3rZidMnozWVBcaHI1+NLRupeMxIZS5lps14yte49TPUcjwpkelA3hYhS47kyjXFB63r3b0ttc+Sg== 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 PAXPR04MB9058.eurprd04.prod.outlook.com (2603:10a6:102:231::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.18; Mon, 21 Oct 2024 15:45:26 +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.8069.018; Mon, 21 Oct 2024 15:45:26 +0000 From: Frank Li Date: Mon, 21 Oct 2024 11:45:06 -0400 Subject: [PATCH v8 1/3] i3c: master: Replace hard code 2 with macro I3C_ADDR_SLOT_STATUS_BITS Message-Id: <20241021-i3c_dts_assign-v8-1-4098b8bde01e@nxp.com> References: <20241021-i3c_dts_assign-v8-0-4098b8bde01e@nxp.com> In-Reply-To: <20241021-i3c_dts_assign-v8-0-4098b8bde01e@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=1729525518; l=2178; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=RF+K6k5hNWi6XLW985uClu+rYjI9LQWRNm31Nm82054=; b=CSxhsJyAOUE6ysMbYthQdcJruajKe3LuFbt9atMnCijWsJwGhdWDPW4SMM0DHjqyFeUZbl1u3 8vfBTnve4OKAnNCYpzAsJykbEx5joma9gYfqOWnTRw/AHkIvPm2F2db X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: BYAPR08CA0006.namprd08.prod.outlook.com (2603:10b6:a03:100::19) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) 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_|PAXPR04MB9058:EE_ X-MS-Office365-Filtering-Correlation-Id: 3a644a80-8d54-45fb-3a85-08dcf1e761c8 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|52116014|366016|7416014|376014|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?o5zHgnMywiWCiiTuMbWG9ksQEt4lUw/?= =?utf-8?q?ng77M3J/yTSudRztEDZPc5GBzMXjwIOMz8/LwOUvBkbgrYYiKiJNHIyHL83Iq4FhY?= =?utf-8?q?vubEjyyFNywmeeV1HMHnzJrfs9UVhejZ2OqhL6B/mFPW8OSTZP8tw23Tb5WNUr8q1?= =?utf-8?q?yoc7KeUaTg7v07V5bmY4Rx16L6TevSKReXB2+at/Hofj8KY8TrojuGavb6efauiJS?= =?utf-8?q?WL43+7XjgMMbkMhSmzwwhGt+zlW3FLfTw9WgeOuafN4VT3CUT0K0y6XLRIRstGu3O?= =?utf-8?q?zPaUXQge5AihtyiZigYtW+p9SVKJPDjSQGfBYkigzHkYVKdIW4bHFsqIW2FVMDe+W?= =?utf-8?q?MKs/dVqfQ4DSapO2xdqhJozVM6vAxlbHJT+4AoHYYTavi2Oi2bfYNgkfDHkesZMDY?= =?utf-8?q?SiTCA9jNVuzyUFypTLGEHF9bx+MDJwuKWG6raaInA/7pKea19pvLTBJXc2r94kIMZ?= =?utf-8?q?gG4HX/dvWE8Aup7BFa3+C2YSedH000nxJoaxgO5kVPkL/MyGxRvTMm8Ux/yKWgeXO?= =?utf-8?q?JEnHnRgHo2lU4Y/hjxJJguW8kxuQ2h0sYhhCGSa5Nru0lT/056iZWsfJI7nH3ZHUI?= =?utf-8?q?tCFRrUTzUuuuZmf7HYUJBLWDiMr2j1ZpNdyM7ukUyl5sL/WNKgGl6oCKwfbbdU9LU?= =?utf-8?q?VnT89ME+XXK7NI4vw3tAgCZbRPrLohtc7kJHoLnCRwZ+kQbAC4c+/tPndvcOuYfUI?= =?utf-8?q?4McUjBRmE0bAsjiOcd1CN/1mEFB4Lv49ThDcg1boUbXaau/jmvikVvCSl6Awaq/aX?= =?utf-8?q?jrUbaZYZDaYIz3Ps+ueFkkqFd7WbUpBMoFllU2qaFDCcMbGNjUwHUsRG0nM4rk5LY?= =?utf-8?q?H8xN9OKYnEffyTtBxLLwPW8GRL6+qkMmLSgJp9UhRTO+FN+SbdEdiV5QCXZsWPlZ4?= =?utf-8?q?wn4uezZp3U3+Ep8w1rGOkLaKiEqwtKODgwJjCo6ZjTt1emCScl4bsXE/rRLjuG2rH?= =?utf-8?q?EUJsuAaP7wb0AddrMh+KKsfe/Aspk77501kOX04OhnLvyFjiiE48hSWgymc5aIwRK?= =?utf-8?q?KWqyqw0v/vJh395TzLz/hGWx1Blh8hIzszkZkVwrj7TeF1hXhPYU3D/QVW6g+lfCa?= =?utf-8?q?e20SrKNZuFocPdxG7rdkL9Y4E0u9tdm61FNFxNgXp3EjIMKF1XU+sEUAWAaBlXoWT?= =?utf-8?q?5vYcmveJ+cMKaykA/wf6by7QLAm0nLC2uKR6YM04OsmCPm9gYTaztc1Ji4n/GW6u8?= =?utf-8?q?VbAerq7jLsOen8EAFbnUfET5D99gI3cuGuspB12bttZoAzaSgf4FMco/lkjQYQBBU?= =?utf-8?q?a3z07bQUueHdGGNTjweRjTQKyYGXd5hsqGOHdRhD91XW5NPyCj8/QeiA=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)(52116014)(366016)(7416014)(376014)(1800799024)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?FBzlAFTHGVLdtFQys7i60s4K1B9t?= =?utf-8?q?Wk0ohciSHkEGwwlPiuf/BOaq6sE0khu+LOuAr76i5loD89CQ6H6gviQFt6sm+mqo7?= =?utf-8?q?AezPUeIrjjEviryrmBzDZ2dm32vjaEffvYVzVInU0sbQkZ9Mk+1jOVuRhsknNEfpA?= =?utf-8?q?V8uTgV2gpxxhy8cnme3ciy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0FmizOwULm1IJQrfeE+kgVlu98kmKv7OsQN6nbh?= =?utf-8?q?Rr0mWRtkrm0TZ5AcFr/NEgUncL5E6QHigaYOrm3bj+FVkUNxL39DKhelrpKKQuJFc?= =?utf-8?q?BynylYkiMFVsL8KpKOpUTC9fMx/o1kAGUCrGObKZCIeKTdVVPgtm/BsWk+GS4cu0r?= =?utf-8?q?H+Z/gHT8pZh+OZ5bFU8Xx797JMrg0dr82cchQE1vkFEyuftoF6QS2q9M7IfEOiwlO?= =?utf-8?q?kSikVkkegmm8vAXZsHzHMsohYTj5ewOO62gQbEqNudmFwr9IK73sb+5CkyMfQj2vq?= =?utf-8?q?Eh5YXccLZAevykMTIq/8lLfZABvQhlSKpz+K7O5V0mFUmfjqSe2Zfml9CLbagIhca?= =?utf-8?q?mXemyFcum6hYkwWVTr4/7QKvw7JmUaMfgO9k0yhUsfwg1LnfRZhniCYpT+43IKxz0?= =?utf-8?q?XTZiAfnDFdka5kzF8okGONeccEfchO9b9VUdftIldis8YntJjXeHDOzR+qDxQfTkE?= =?utf-8?q?teHuzcCsvEKE?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3a644a80-8d54-45fb-3a85-08dcf1e761c8 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2024 15:45:26.2442 (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: ChLOMTjXIkXrKNYuYVUuQ/6YYVRq8Z92E6rr/ZaTPeg28yF+f/CLYla+beBOHtBxfv+gCvyyCF43gx7nQDShpA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB9058 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 v8 - 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;