From patchwork Tue Oct 1 17:08:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13818617 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 2FEAFCEACEE for ; Tue, 1 Oct 2024 18:16:34 +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=kSLVaj6IwEJUfw17u4k55MQDQnXmLrBVWaGrFan3b14=; b=t/UWie3ifrtJGqbrpn0NI4Www+ FdY0jl33eZPHIWQWZB7fVAjzjXLTRqleWxvz7HBsUAaFyJjF1M465+ElGvSZM+OrobURecN85dmkc 4suy+/gQ3P0uMDy4o9AzFrRtUs1Cd8dkg/QVK2BdcJetjNJWhlLt4P9mMZVQa7ltOwJkPwnZxTHO2 jWw4az2Pd8CRNP96bPIB0NYlKpJsALOBwyqYb0ZRSrEUSKZ71CTIAqJhZM5L6wNtiRi70eu4SaaaQ lX5ytIdWoxFfL3h4TsDQWujOk/hXRItLDSpPW0zsfZF7l3C/PyzvJz++wl/Svvr+EVxJOMcMFA709 3edslJhQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1svhQH-00000003kUV-28lx; Tue, 01 Oct 2024 18:16:33 +0000 Received: from mail-db8eur05on20600.outbound.protection.outlook.com ([2a01:111:f403:2614::600] helo=EUR05-DB8-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1svgMt-00000003d3R-14GD for linux-i3c@lists.infradead.org; Tue, 01 Oct 2024 17:09:00 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ptlxuuzBWxGt+VILVWVhlhT6uzjhiNSdLScLzwJV9BKpZsAPqkgZcJQm/ywZ3N5psI0lYgdN5t8klNgaNs3I20tKvAOZeVuWVCJstri2R0TJdz8l9rvuvuxGVI0V3IpgPG3OOiphS4AqvPmePkVErWhfaGzi7+jrKMn6ZgOa/uCoL5GhqEmwZXpG/OO+6bW5YtPdwQrb1yj00Dtowb4PrEh1yLCkwkmi8cb/7K1D+E1GsD4hC9SX5oUe5NrDfAfroMQ8t0c5IcqxqJW65lp1+dtdEMI4d7WbAj0CSN8HIbXdZxfLD3Annf066naub9Xuf1tLlFBlK//DT6xn/MsWrQ== 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=UQfovDJ1ujrnEJUjiym92VRPxtkwgLrPMWqWNVDo7Hg=; b=aH5jnb1IjTqirryEox+IgOOkh+GbB0yzZPXI4k4FoC3Wj8JSn3bKmOboLCrwQ0WcchZEVXr0dAPoQ2rKqQZOFEevfjzcW4vOQvFLESgRYlDPTvDH9fcl5pnPpwS9/VUan2DxIcmplnnTMhRyL8jiHygYioN34pBykRXTH+vypvBI8+Y5bZdbg48Az+uAWQUqrpKlSKJDOdU5/3Z96m3963TJIPp+KS5pHFocZJb7UXrmu1LcuRKkgw/q7G/UqT/BfQOpc+wQsYupPaw5Du4X/mzmPZ7UaZmqJ7FqSAy9e1PdEtyr99Rc6lU+CSsXLHHuHp/lqx9n3EofR864daJeZw== 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=UQfovDJ1ujrnEJUjiym92VRPxtkwgLrPMWqWNVDo7Hg=; b=XNWZt/WC9ZZGaoozUF2XmhKdAlg9nTm3Gzw8t8+9zOmQTUEFuHSeaDwDQOGQdYVW39zsTvAZq9rPJWfMAf9BkqhQTvXMTXNmlU5GaCec51kQaQauEOrlT467pwnjcIV4RjvYeOlnyH2KfsXGSt3AFkWuI2V/gy9666RD1TP/7Fv3yko8rFTWFq0CdGJXB/ZMI0ZYhawsHm/g4VyiBSkuonfRd/RBQ478a33/IMKiUa0OevFd6z5CVqnGY1OgsQCod1W+7ZGrLENL76n1PmUfcXY9/Jh+zeofhpjS3m5SpVjczYwdewnSBqTiRCy8aLXvj6XxuQmh7i4sIpMl7ZffIQ== 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 PA4PR04MB9710.eurprd04.prod.outlook.com (2603:10a6:102:268::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.15; Tue, 1 Oct 2024 17:08:53 +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.8005.024; Tue, 1 Oct 2024 17:08:53 +0000 From: Frank Li Date: Tue, 01 Oct 2024 13:08:20 -0400 Subject: [PATCH 1/3] i3c: master: Replace hard code 2 with macro I3C_ADDR_SLOT_STATUS_BITS Message-Id: <20241001-i3c_dts_assign-v1-1-6ba83dc15eb8@nxp.com> References: <20241001-i3c_dts_assign-v1-0-6ba83dc15eb8@nxp.com> In-Reply-To: <20241001-i3c_dts_assign-v1-0-6ba83dc15eb8@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=1727802526; l=2002; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=DaFfN+74X5tC67JPy6GOxKmdvDVTxdkWjGpCgAk2ELc=; b=fAX8X1NwHDskH+QD8eHzVE0vVBShlP+PdkBhAhv4loUsBHQu7qbdbmhXAmSX1GTg8x6ap9ki1 tKQJHD9hd3iAeEsr4hXyLODMUYk2K9huSMsXNmne5OxK+5cfhjiCfcy X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: SJ0PR03CA0007.namprd03.prod.outlook.com (2603:10b6:a03:33a::12) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|PA4PR04MB9710:EE_ X-MS-Office365-Filtering-Correlation-Id: 8b7491f2-a605-4af1-a4e6-08dce23bb9d2 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|376014|7416014|52116014|366016|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?hQNNQXOTZKsydikBjya32PZXwCV+qgT?= =?utf-8?q?atgTzjRYGg9TrHglnU7GHpWUVOt7m3AFTwXVzTKPd3CtlKlYUTOaZfEmvv1gaigPK?= =?utf-8?q?0O5ilpZaDJioSXf+oKjhsnIRqMrxXnGWwfYthGNHfexIA+vuAK8JohWnaKZVXJ1lX?= =?utf-8?q?7IAN1uP5p83hSLNjHcnGdFh/HA+my9AYHNWIWeyMmwkNKnFfClD2Zkw37oHXJIMCh?= =?utf-8?q?nXjj5M+VlQNA6QFnQKYVBkDo84Qo2oamv7aYQZk+NgmUn+sul0PIE4juegypQmfeK?= =?utf-8?q?SHmMaZSKYKSAsGCGsYMDoJDK26mIZyU+WISLDgio9Vfldb2nHvS8ac7Y2o6d76uY8?= =?utf-8?q?gZmmi1/2iccwH0OWEFTfoHilfcn3wdfv39ltxhlnQicApqekIEcSUwDBXTm9muE9J?= =?utf-8?q?BQQTZccWutnvjQWFlRRivDvJiC0eByLiYb/GfSYylmKOGYFT7SNcSOMQNvvHZIwxd?= =?utf-8?q?EbUaQmnPki1KqHkVMK0EMIZGpDP38l4G/xOJkv9t0OSUlfI2g8LmZLPoQYAuMqsbT?= =?utf-8?q?2h6eF4vPllnuJeFk5kTeqnV8XcMBiydFxAVbun2skrkGQG2bfFHH9zLO0wvPFwD79?= =?utf-8?q?LXSDZ+v0t+KxwWsHaNZYtQkF7TCJImcirPyDFIXPfDJ8eQoUksUN/jSrwTQDRZAZu?= =?utf-8?q?hvR5Mumrzlb+ynvLMTA5NCFWYbtOgRjILoi6S49vxhksEbVu7X7LLqtYM+bdPwisI?= =?utf-8?q?8a3qXNwZUAZMurvbbk4GYuZndI5y8Zy1/pry3kTuceJLVpIGKsTJaTyMTYEUmthfL?= =?utf-8?q?uOU8lD8jZ95Gq9xCX11CFyfMczkjKlw2WCvTjiMi8Ck2uPjvo+tXjlpUfw48r9ms5?= =?utf-8?q?Bn1CvaoTU+MwSFzZu0+Gv6Kn7rzWUVznobyUyusTep1R71jAWRxmYyi0c10jOEX5K?= =?utf-8?q?ZeMDTIRNrEt2PoSi6j93KvZONBYo7fYCj1S9R0ppW+7Cv+YGG83fC0Pr9LMZIPnFo?= =?utf-8?q?Hs9seveEa55jMgzN7zvdmpEfKT8fvvGrbDfIb++SdSOsaoKYABwj4p9QiC7nLode5?= =?utf-8?q?g0o8k3A7VcqKKU3/qOiedlwgUndqCuXJWxwneBctQIlCLMwu7uLMizxrk0fY2PmbI?= =?utf-8?q?xfnCc0IoWj8tRxYVHi4P3p7WDOhdWaCExE8MLI3K95wsUC67jR2rgvDuwnIJ9PFjG?= =?utf-8?q?HDdCG5XmlBvXn7K8rC6gTQ0YRcjyhf4ghHeOur4K5z1YN6Ij2fQA6p5o+UNr96slg?= =?utf-8?q?1PmF4nDPMrzbtfdArYOikcW3q6e3bVe3ICmPn244SZGlEzskoPsKoRqpHZFJ8DGOp?= =?utf-8?q?TzXLciv6tOP0A6RWgesqinqqSTdsKAY3nJaH7qCjXmuRgGmgJvIRI/McluOESDg6e?= =?utf-8?q?uPJ5gU9C5/izG198D2TbcLGy4pJa0hyn1A=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)(376014)(7416014)(52116014)(366016)(1800799024)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?AwIij1OrL4zepSlTN7QQWMw8ovdZ?= =?utf-8?q?KBFOJDw94f0fEi4yU6ZOcOp3h82tu01wKb8hdB+3uPENMQsU4PqD0nOZLHaN8J+NE?= =?utf-8?q?2k/KjTqMSL6i+PRBYfYM0MZ7b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emm9/qhe6yx+bORKVHNFXXAlnXT7Y+TVwCpbGPa8CN/nxYL3?= =?utf-8?q?2dOKs+AIwVHNAbsxiqAJMaeDITqpHOnqMtlrL4YZoM73TjqyyIrYVrUN/MlCZ94J5?= =?utf-8?q?yC8hRHH9Rgs3W8gwGFRX3JFG4pD0m96Hmrh/WQ30a3ALwtuws7xm4arnSQk+WUbfB?= =?utf-8?q?yteZ9ArDmum7Kpp7D9mD/UexzaCmJduDvkwx/qiqvMp6uC+QhFnGSI2rnmwpiLvAZ?= =?utf-8?q?SrX9siP/iPAXJrNbJnMF08POWOBHT3MLOzsz0XW7DJoTr0a3qzKYAttEOYHMBHe92?= =?utf-8?q?sKq20iTjFoJ62n2ES2RdGjUgCYxs659Sa7U7B/lZqYWEm4kHV8YEmWWFyf2sPnScS?= =?utf-8?q?lb3TJK5gE3kq7HqoSoszFJg6KdtDS62GMANzpag58gM4eIxumwhmzAwRsHMQxJ1Zl?= =?utf-8?q?Y0GoEKsaK8p60W0loxmPjgr9ram7bmMMT9W/fU3iAl3NmQoKSu8Fjv/l4amJ0XfiC?= =?utf-8?q?Za+lRSBSue2eco2oIs+3xulIk47fXBlwAINyeFPxddB4H4CVdXhZW5oWEzD4mGJyX?= =?utf-8?q?248vTDiLcM7n?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8b7491f2-a605-4af1-a4e6-08dce23bb9d2 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Oct 2024 17:08:52.9280 (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: iqW3sXG2upmX0JquukqmCdaigM50q59DKBwlg5dK3iSlfOKT+f3vUz2uOabbB7t7u0s2Bhh3FN2G/E7D/AbacQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR04MB9710 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241001_100859_337584_A79B44ED X-CRM114-Status: GOOD ( 12.41 ) 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. Signed-off-by: Frank Li Reviewed-by: Miquel Raynal --- 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;