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: 13844353 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C6B05D15DB6 for ; Mon, 21 Oct 2024 15:52:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Cc:To:In-Reply-To: References:Message-Id:Subject:Date:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=B8n5vE2o0UaZaeHSDNDzhuiG45EsVcBRsjVI+iD6+zc=; b=YWCuNgU59aYkrHz77TmLahvaFE 7XlmFyav6C8mA8VLt2YpdwtOPLMlJUKpqU+bYRQsnNqRumiptBwgCscTT0PjQb2Seuv+pYg4SX3M8 qhHwDuOSSIvvd2UbqESYGHTJ67Ngm5p+1qSWWNlkMpIJJ4FQ04aTqIC7H83KG2xJ1aOoFn6zraeME 8UtTHhD1Uc4nqNPsKu8mGIg8XHp6TN0VOy+RJNcY3j+f8N0CW9R5ALkquVKdtidzbTKp0lf5Y7Bd7 NGpmNS+Y1mYjx5TR/RVLLC9aZiSK4lVBG3m3d1CCAQnH3IochakEQJ5/datPb3qbKRxW78XlNhpXe Dif91XcA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t2uhk-00000007rtE-1lcN; Mon, 21 Oct 2024 15:52:24 +0000 Received: from mail-vi1eur05on2043.outbound.protection.outlook.com ([40.107.21.43] helo=EUR05-VI1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t2ub6-00000007qMr-0kLN for linux-i3c@lists.infradead.org; Mon, 21 Oct 2024 15:45:33 +0000 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) 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?V8uTgV2gpxx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BGZ7fEkEU0FmizOwULm1IJQrfeE+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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241021_084532_290772_EF2B8B0F X-CRM114-Status: GOOD ( 12.32 ) X-BeenThere: linux-i3c@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-i3c" Errors-To: linux-i3c-bounces+linux-i3c=archiver.kernel.org@lists.infradead.org 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;