From patchwork Thu Oct 3 20:14:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13821540 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 5D2ABCF34C4 for ; Thu, 3 Oct 2024 20:14:52 +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=C+kwc15+UXM5V9q0TW3G612KpxVg97gNNdKgxInbcZ8=; b=iCw5/j+kLJPUaT0qJY2glAwxmB bfmaPqoxDUMxBb9xHQw8Z1doP6wo4s0D7DPez8MogIp6V/SCgQpgHjgF1rp8bXRhKjtTTQ5dd48fb jYHU0eiwRIqxPMgNcYVXnmG/RVumwpSChHdpXzBtoK71xN7Se/lwoWRD9mw9Vs3T63CmfHpGX5Hcm QiZgKL1OfXM3IaO1ZAYu5HxEQEpXiPPtOynPRgdpAd/229Ko8JydBJUPhTdvqcx/9B4rUnTAnHlkD 4I/fnlbrYaQvuxD7vM0U+65VQdmaSgaA1QKEZDV5t+9l6+roWF/yD6BiGoB4+VYbHXmPjev7X95bL tFvffcWA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1swSDs-0000000AHMo-0OcD; Thu, 03 Oct 2024 20:14:52 +0000 Received: from mail-northeuropeazlp170120003.outbound.protection.outlook.com ([2a01:111:f403:c200::3] helo=DU2PR03CU002.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1swSDo-0000000AHLf-3uul for linux-i3c@lists.infradead.org; Thu, 03 Oct 2024 20:14:50 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=TjyKE2ucAaBhMvkKuz6mxnLCf7JhROHITIZnvDiY/ezHTTqkH8Di4269II6zEsWs2/ckzI+GiKqV1G2YFKomdTiPBMrgil+fu5O5fZzV9YiKbzF/1e82kGKZZM/E6PM/D3FpVkX0K+LsAR9HhcpTTioBsYXrZFpWmNP9U93sbNAu91Xza/dJ1dyHrejI5IXTC5NpTyFkqiL1tcLO6bC9AaUTu8531HdRAVzxabFUkfvuYMyMFaVbZOiDFe5h4/9IxiYuCGtVZEZIbGui8iXY1bbOS3n5oW4Y9+gjf5JmIvZQT0xrZqfS7/jKuAXVpabO9xCBloouYBf/n+Vm7mspTQ== 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=D/u6Y9ZMfX/Q1R8ZZt0lGNOvoJ+yV3wXF+hGur9mRoI=; b=hycc2sexGHQIbq27etK4eqcjO/a/VF34NE+osJpu7TBkAcubTnh1hZ2ff9sJZ7MoSsVfGqhHi3pG/hiaOy/hSohQI8n6c/B+tBTbx0HZxh5/OnFKhU4cjblHGUBMfcTHEzhjl/t/0K1tKAM3W6o402un4R6YsRJwpgch8BeJ8eQBAZb1Qx1+ay7wyvpiLWDJW2R349xjheaWnqe5S3lkSY38gvPZdolXp/+/snZ8LRJw1HqQq3Fcp1N6HDDtPE9/TGBmjyXadV4TFyrH5h5RWkUxgZEPnIY8lMjG3J+qktVj76tdO/EZXRKckVgvdXfqlPqAi3+ABPv9mePUn37ZuA== 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=D/u6Y9ZMfX/Q1R8ZZt0lGNOvoJ+yV3wXF+hGur9mRoI=; b=X0FUVkdod8Kcvk3MgvIphLPjeAeTzIUi4PwGoQFmhkDujQVzcAHrLIUSZPX3ItiB6e4fAS/dM70Aayu5VNzYLD14QSTLt17pbEwsBZvY7dPY2wmSpiHUKK/7ccKUzAvKgcEexp3psI/WXKk7iKpIrCnh7JZnYhrjoFdyLBELLGbGot/QAO4X0zDePUGHT7PK7WCDlKZ2KLERbcg4e0Wjd1rlH1ZEXYzptT6iomT1UbVCQx4QKUzlLxCZIih0EAl3RdxyGFAR4jetqRSasz9EiKmSIiYvbntnXEkHgpHNVgk1I4DbsmRq6pn1sHDpgGUPyv60gvKRhuiNuLJj2IFwLQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) by AS4PR04MB9291.eurprd04.prod.outlook.com (2603:10a6:20b:4e6::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.16; Thu, 3 Oct 2024 20:14:45 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06%4]) with mapi id 15.20.8026.016; Thu, 3 Oct 2024 20:14:45 +0000 From: Frank Li Date: Thu, 03 Oct 2024 16:14:19 -0400 Subject: [PATCH v6 1/3] i3c: master: Replace hard code 2 with macro I3C_ADDR_SLOT_STATUS_BITS Message-Id: <20241003-i3c_dts_assign-v6-1-eae2569c92ca@nxp.com> References: <20241003-i3c_dts_assign-v6-0-eae2569c92ca@nxp.com> In-Reply-To: <20241003-i3c_dts_assign-v6-0-eae2569c92ca@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=1727986479; l=2146; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=1vXOLZgsQFMbuKD3plBcCWtNrrRzSd/JO0oImYMerAQ=; b=YI/N+PJitl8UKnhClq8Ufr2kkVTjpnW1S7QpbfEUQsQlC0/gAnDnquQVjzIxnif+qFlZiNOUO MJuNXkbBgXMCmeqUCRVs+dMFNdZGB2qelW3O0lZVVD4ySVoxFlToHTN X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: BY1P220CA0008.NAMP220.PROD.OUTLOOK.COM (2603:10b6:a03:59d::16) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|AS4PR04MB9291:EE_ X-MS-Office365-Filtering-Correlation-Id: 965ea561-7185-4716-dd25-08dce3e8063f 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|376014|52116014|7416014|366016|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?Jf7ZXr4GvRpF/6Mbu+zR18IpXz3EGZe?= =?utf-8?q?ZWwrm/cXW/OcztMHv+cCcPza3y2zR6FaLHVmb5fyAMAzbz+VqWWs6+bNAtMMjCFM/?= =?utf-8?q?y9cRLtPJHIwfdDTtOJwgY0VC7PeO/pf7lTQc+vUcpuO8hCGzeMVP5EhbkQZ3EIek8?= =?utf-8?q?N+liwfEY+FmJfWznX5qm//q3mWxBgDL5bb10/s1QTBadw+2Qv/9/IkVEc09pBTVH7?= =?utf-8?q?njlJQzfifNcu9NV+Ieu+U4ixDoHljIUwIuOPxKwDbg/EIKPdy5mlReAEeqt8p1LHR?= =?utf-8?q?5OCgrIyjI+zezBO+/M+lxgXU3I7YzMw/alwK8Qq8ld+RnmwCiJPOAZbC1lbfHC+Mt?= =?utf-8?q?BAFiPu4U1oMVl+Ec/NbxZCUvp05JBXO3CYoojGQ9IUrjxkjC62K+5202wMlKJ0n7P?= =?utf-8?q?2KG+s11XrcbWUNlosq8pzTkB7mad8hHuW740NB0x2HVx1vP8lFWwDMVL1zxRffQmH?= =?utf-8?q?KBnKxt4n0QrNAUYszTW26fWCRhRTKIXNFctzrAU3BZTuMILFiEZv2uAp/Di8K42Fs?= =?utf-8?q?GTtEMoZY9Y8D1mXqGRv8m8nzPQ8hvbfUUlZacV4lFIZ2egJy6wvOvzHA9IJxcoVyg?= =?utf-8?q?LX5e8BigRBhrhEmn5F0vKgpBuNpNgC1P1aKMXqfCO8CD2+Z7SFfrxUqpCcdkVgIb7?= =?utf-8?q?dRwZwuKDaS6GkNF8UwA4EJDk3KpDqAWHJPRzRSlSsL0Rh2793tor3ytQZajExvYZf?= =?utf-8?q?gvDw9epYCrVMlmywTjGFdQqtZxdroPjHr5UwWfwZulVWUlt+QI8OPNCrQndOWNUt0?= =?utf-8?q?u3/YfK7S6Yo1ttdE0r88p2q3lUkqa9nDJZfB1TLFqakJFbpWiqgcMnPHBnsC6dzkE?= =?utf-8?q?0O968rlQdQ7LviMGnV9Gx3+BJ9DEQNF22QoFTLuz1GioEenXqNgwjhQ0OZBhYrHF0?= =?utf-8?q?z9cvX2uWhzMKSGldgzZXI8xx1HxaQolor6xeqU9P0LHT1WigUFMWH5xMGa18o/FPP?= =?utf-8?q?uzmTXYysXa/rBePM8q4uoge7/HvXcfAV/Ypyn2YZGXKRGrQpil22wQNXnYsWbYnNj?= =?utf-8?q?1sHicYxOqD/6UaPyYhG11MxHxSgVT6sIa55//iAEVkofUaXCC1yvd6e3JNINcLE1i?= =?utf-8?q?nN71u5jJxsbC6Cq9us7AYQ/7W45w0tvpCt7PjMdpaeW7VjLx9gIroZO6EcVa4FtEU?= =?utf-8?q?sYX5BWpQIq8haPW5rrbqq+NgBdJjR7RtjmieDqBtZ4GeJq9UZvBW/V4JckZh6GVEn?= =?utf-8?q?HUwCtp9sYF8wKhS5CcgBWmv03LPOyN9qdOAuW+QBexmVs4hilZyfYVOT8fc2Vvbl4?= =?utf-8?q?/pHm7zznOeDokNi4A/QSjCX7+EVbiWwc92w=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB9642.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(376014)(52116014)(7416014)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?SaOmJ7GxOMLhPSJR/2lFVX1+eZlB?= =?utf-8?q?zLQL4EPvLdxozSww8vH+TG/GmAfJYLF4C9aiupnV8sMDXbnsJFcWVeK1A3nqh3GL4?= =?utf-8?q?6elA22egoRR25rCyBiw+5a92k3BrMDSduUOnsrqOOM8conQ1bsS7GNyv7ITA8xl4T?= =?ut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ahG507aZPL?= =?utf-8?q?/vI9tLCyaJOS7vxzWN48QNn90T+ce8EZyI635Lhw2ecnTMYzQydLC0I1HaxoonLYL?= =?utf-8?q?KNqrWMxrNlk1GG10CTWmkW/r1FG/DX7ykGehFosWLkYAPdIXj5T/A+Aoe/keVmsCu?= =?utf-8?q?lzRFhOuAFxHEOVlZnAuj65gob6yQjpnqu3MUhN/FoktPewUEOVoLvXojHH/AqawYR?= =?utf-8?q?gMXzrKcQbA9d3HXnT4CHMxpiOkvx9kBfaACm1C0Q/a2RgKcdy+jJuHjDjwMCn+xyH?= =?utf-8?q?KEVvSs8ZxK48wmdQ3+sQSBOeq4VhFbOj+vAPlWt9H5PAlO6MNT8aPPVRi6BfBqowq?= =?utf-8?q?kwCOG/77+tP65V8PLpuwwM3bepsNS9DD8edCjtMJLjfJchC/9gvmAxd1JisPanV1S?= =?utf-8?q?AFkRGPxTBkZpmtY/cRxmoCVLPPboSbVT7GyV+HxfuV4krhiG2PiPoJfhkupZzr+b2?= =?utf-8?q?JnF5tdjP8VDBoXguSpYu7sK5ghreB39yBRcpQn6ZmrZ+8vDoIe97MZqg=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 965ea561-7185-4716-dd25-08dce3e8063f X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Oct 2024 20:14:45.7309 (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: cNI/bvNpyY7bgdA9XRMEpw6wfGOCUHVGEP2O9wue/srrDssCgmRSgvo6A2qtZ/QSeKtpl1PI7n9MG7sSn8EW7Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS4PR04MB9291 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241003_131449_012959_C549E179 X-CRM114-Status: GOOD ( 12.51 ) 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 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;