From patchwork Mon Aug 19 16:01:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13768541 Received: from DU2PR03CU002.outbound.protection.outlook.com (mail-northeuropeazon11012037.outbound.protection.outlook.com [52.101.66.37]) (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 E3E1A166F2A for ; Mon, 19 Aug 2024 16:02:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.66.37 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724083339; cv=fail; b=BdOr1fqo7csl7Wi5eDPCKbQ13dHjRI1riXYm0LRcmt3ynfQgCY94K6AlWobzPTfskPaF5r1gokNH1birKTQLx9GEKHaIUAZr6+brnVQxAZORrAu0Ei9pqYGjLtdWs6UjuQl8jlCcXb9MnzjGV+Yfck2HzPu9m/+jWbVYaAFhaKU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724083339; c=relaxed/simple; bh=/8gjfrLEbeqdvh2UWIsUOXSQLlEPInExNiw2wP5o2A0=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=FhuVuuEuG56iwTnRHYO7b8oEQiiOdl4B3iPzLxaYkYqIo2QnBWgsLIWXGZ8VI37Wc3Z3zlXhMhY5z6PVjj0MqbZKsXan8LzP7y5FS6bRrIn4paUNFpJx93v3QU6AsTes2rnEjikuoLDjPWJY/CB3DPiaa5730nRP2XkcfmgwjoY= 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=Xsb5brOP; arc=fail smtp.client-ip=52.101.66.37 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="Xsb5brOP" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=NFoZl59sUWP2TZ6Jw+NZ80oZgghDvfFYcoqZ8CzNOJATzHXxroWyCuZP3YrnidnBUfTuZ5SIx4lkd/XfQMmpnjCw2d2KBRLJ9cVI9zWK9WqIYhhNHSIg7uV3um7H9VMX+0EdfZjad0sBZek4SfvLVrQ799lx5scomay7doK1cII9UohgMHiLtddzXPYMLPkNrdlNJQ+RJZa9mzLRrk71VkEiDvHwJdvxwz3UwAA/O2WlJ8MImmHB9C/YEZluH16QxlI8PzJTufWLB1jVJRaZJKTRPeKcb8D4cnlwEezz3weKAE/HslMaW56t2Mq4OgbM3kcPlUTez65ETDUS17tXeQ== 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=/H5YFp3nwDhvmKVPeBWxGQWI1IbbbTbtrRrxup0oAxQ=; b=NOMi56D9MWEoNAJGfQ0tO/l5ejQS+oxQK9wCFOsXRofSYf0geWuVTP55FbMGn/Hat0HSZzy/n6aBC77LcJs8TynquairyRCagGSlTrZfh9jjbrPyO+dIKcuMcxS4Jr5H4KIP5NHrk0Z4qdKdXui7tCl3QVWMJ8+Gru1Fx2RHwkkzGb1hffEYLrUQyXH9r5/4RYw0umJPbt5MzvYnqrQVsBRHqwm6U6JMWTO7XPOqQa93ICmMEAdTpdRLcEyLpIa7QM67fl7ozth+xOH6F6rfRD1j2/o5alutvgvJeMFCuV76iJr9BEGddSS4MQR1YcWNl7iR46j2o1jDXFdD4IPy8A== 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=/H5YFp3nwDhvmKVPeBWxGQWI1IbbbTbtrRrxup0oAxQ=; b=Xsb5brOPh9GDcXNYBNuEltP1zxFSbDuZQdL8+iooSJZlQYKAycvLRYmI9PXLhisBXFbybABG8IZBnPtCMg1KbCeU09FjAZQf38R0Cqa3NL3N4W521BqlvjWi8TecFMM2uu/PA/g5ehlXV/hobiNus4SoKj6IqoD1bv80xa3EeqpoN7Z6q71E+WZzOQD3eaTQwmUKGUki58XQ2tmEVFtxKNFCZMtT8mq7anC4e0QXXqxC7CiMs5R0JyCMHFSP3h/++z7bg6gby14L9O7JohmXV8SdTF97AisXGAGPg79TQi7nG/F/Z3RpZNp5QNF9kqYs/ry0TeKq6tl/SM2XtwzqdA== 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 DU0PR04MB9659.eurprd04.prod.outlook.com (2603:10a6:10:320::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7875.21; Mon, 19 Aug 2024 16:02:13 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06%3]) with mapi id 15.20.7875.019; Mon, 19 Aug 2024 16:02:13 +0000 From: Frank Li Date: Mon, 19 Aug 2024 12:01:56 -0400 Subject: [PATCH v3 02/11] i3c: master: Replace hard code 2 with macro I3C_ADDR_SLOT_BITS Message-Id: <20240819-i3c_fix-v3-2-7d69f7b0a05e@nxp.com> References: <20240819-i3c_fix-v3-0-7d69f7b0a05e@nxp.com> In-Reply-To: <20240819-i3c_fix-v3-0-7d69f7b0a05e@nxp.com> To: Alexandre Belloni , Boris Brezillon , Parshuram Thombare , Greg Kroah-Hartman , Boris Brezillon , Arnd Bergmann , Miquel Raynal , Conor Culhane Cc: linux-i3c@lists.infradead.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev, Frank Li X-Mailer: b4 0.13-dev-e586c X-Developer-Signature: v=1; a=ed25519-sha256; t=1724083326; l=1901; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=/8gjfrLEbeqdvh2UWIsUOXSQLlEPInExNiw2wP5o2A0=; b=rR5dTmllJap2jATJpl9j2kxuFRoEdc/puEV6YC1vOtpHfaNtxtlfP2Yk+Lwbr/BrUE7GgD/ZH 1+Cq972U160DozBKnW5azrxjvHHUFAyAHKxTWTOmlQP4SUHdb9d9TRN X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: SA9PR03CA0005.namprd03.prod.outlook.com (2603:10b6:806:20::10) 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: PAXPR04MB9642:EE_|DU0PR04MB9659:EE_ X-MS-Office365-Filtering-Correlation-Id: b679f02f-9201-4ba2-c229-08dcc0684a0a 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|366016|1800799024|376014|7416014|52116014|38350700014; X-Microsoft-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kgj7B41a0JkMWIWQolqh/kQ/XeC6yqx8Dn+8IIuaZl7N3PGC7?= =?utf-8?q?aH3yf9fHsdnfAJSR7BQLgN78npCTuy2P7ntblHhh7AOnW/H/CP9W2zOc470jfoK4r?= =?utf-8?q?x4OwZyhJ2f4OYWJxH3O6FlhmNwd0xH796L9/JwUThdYXX7B6hfewHjWW6KNlxFnzh?= =?utf-8?q?gJL40C+XOvz4TP4hnyK4VosMmKaryCoHRyKcwc1hA0qg0+UXoy9MtcL6P1AH8K8rB?= =?utf-8?q?jk3AktNqjDQvUW4FUfOxmDR6VoJgnlHqsOklTRXrTQJ+oba/sCvagsGH+BjpV2n5K?= =?utf-8?q?jlqtJLe/E6AAM42LRfmk9VnUtzjofdDpdOFYp6q7ayWI6lRCadYaCKpwvbiOhZ2kK?= =?utf-8?q?ZFzVdcAHnZwKo/r+Jx/CRFzKJM8/a91Jan1LFZ9M/CCoDovKVz3cKPOUjpM2I/6ty?= =?utf-8?q?/ZdZtScXz106KFMQcEajEfwH1/OCeaaqc37P8DIuLQTegZVBq+gTpmSGpng9ef3g1?= =?utf-8?q?1RKNsc6ErhLM4FkRYK8H+yJBpC2wfDPf+g=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)(366016)(1800799024)(376014)(7416014)(52116014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?7GjGhFoSviPl2UHE15PDFVcDb7+f?= =?utf-8?q?MtT3vJfPI0rC/YeXgn2ZbANQMHbnS998BT0FKB6FPUTyJ4heUHnHBqmI5/7tEqBG5?= =?utf-8?q?/4ZIVoObbxjRGhoQ+zHDRKpLKFa1ENLsW8qkQUpChelszu8JeoH+fnu7QQWtBaJH0?= =?utf-8?q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?= =?utf-8?q?W44O9uxME5k5DSyIcgWJYzxqA+gBZKAmpfcJ7JRW9XOi6wVV00tmeQCMWDR1C1ZoK?= =?utf-8?q?KXXJG3A/8so4SpAmF8NX1GMvcrUKf3onTypTNHs1mgc5AvjpxuWCmJRCbMZYw9s9b?= =?utf-8?q?R+39WkmxXxZur+4YZbDDuLxbbeObuK0jqhdGIeo1qjONei4SIDEbyyLsO4+gzS7D+?= =?utf-8?q?GhLnIPbkkyGn2sZ2PPWaNNYYC/+bRkhdyvQGwcV9lgJ5kOJllgk7wUutvA3bW7/EV?= =?utf-8?q?DfZjwZgNwJhKPNzTwFtDN1LLQlHYHDucUZG04aKETK1EjT/VrYLvSKBjIsNdc8Ben?= =?utf-8?q?2gIpz/FGdXxJh9GJ84kfP5mM9Y4EKw7textRzAbGSMnfWrmZZT+9jh2kvdXtO3eEk?= =?utf-8?q?ET7jftKdZdJrRP9G9v3fyCbP8AM8HAG1lJlznsayJvwkKG3zIdEEXtawvPevBl23E?= =?utf-8?q?L1uAgTGQ88fuViV1zbLagFmDlbEm0n9cOJXNzxnkZQXGDiKx+cq6ubDPHri0Cjaiz?= =?utf-8?q?/5JBb5bQp42D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: b679f02f-9201-4ba2-c229-08dcc0684a0a X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Aug 2024 16:02:13.2004 (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: n/lD746UogE0sqVNQRhizFANGDLYPwdtd+9UmXUeG3hcN6Hd0BTM02MTiFCth7hwgf6o/6UwIZd0vEGfybSDkw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR04MB9659 Replace the hardcoded value 2, which indicates 2 bits for I3C address status, with the predefined macro I3C_ADDR_SLOT_BITS. Improve maintainability and extensibility of the code. Signed-off-by: Frank Li --- 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 852b32178b722..85c737554c940 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_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_BITS; unsigned long *ptr; if (addr > I2C_MAX_ADDR) diff --git a/include/linux/i3c/master.h b/include/linux/i3c/master.h index 074f632868d98..4601b6957f799 100644 --- a/include/linux/i3c/master.h +++ b/include/linux/i3c/master.h @@ -299,6 +299,8 @@ enum i3c_addr_slot_status { I3C_ADDR_SLOT_STATUS_MASK = 3, }; +#define I3C_ADDR_SLOT_BITS 2 + /** * struct i3c_bus - I3C bus object * @cur_master: I3C master currently driving the bus. Since I3C is multi-master @@ -340,7 +342,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_BITS) / BITS_PER_LONG]; enum i3c_bus_mode mode; struct { unsigned long i3c;