From patchwork Tue Aug 13 15:15:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13762220 Received: from DUZPR83CU001.outbound.protection.outlook.com (mail-northeuropeazon11013008.outbound.protection.outlook.com [52.101.67.8]) (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 0FB9C1A0703 for ; Tue, 13 Aug 2024 15:15:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.67.8 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723562132; cv=fail; b=O5nUWLbahZlppiusuS3bk/DIoIGJQrAQTd2AdUE3fth8GjuxQghVv5B46jpyyD4XEy1pUBBopPxf51AIPdSYFCQHUbAswE7DyPkiEb5KRHvysONsbQhzWaGaE3YydTMQsbhBMMd9acdbxYs3BAZgccHNM0mpdZvkbn3BN9aEw2w= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723562132; c=relaxed/simple; bh=/8gjfrLEbeqdvh2UWIsUOXSQLlEPInExNiw2wP5o2A0=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=Rplddnz/PNX6EYgS42NTCBsOafuLthPlrBqxdHqPSlEP00ibo81kBHtZNHj+q5mgRi1fOTA7IVonQWAxoC7z/sYd39N4KbTu1ZzmLslmyKb3k2ljTEkNYW4yTKiiIOQMqu9cdTkW8mw1xmvIdPygvHPFdM6QwEwYBfLp6YHnyB8= 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=iWprLadK; arc=fail smtp.client-ip=52.101.67.8 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="iWprLadK" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=jS1jTjR6UlTF2GBx/6XDFvWUuDVIZmcDG9/V9ZZM7danR+hULrivJ5iWr19DlUnupZvJY2AqAXAxcPfqKzIkQJzb4kOHVlWF7SN9dkLfj8si1FxSXpAs37xgi0+0hT6kf2iXW4QJoUPFuSGdvrmdjgdPb5E8Dp+B1cazPJtXAOoEA0617/EiuSmNz5fKZgiImdMUEiBY00VCP6wWK/Eu8jcCwMrjAcQd6wjlZzViwcroaj4tN6jCVv4S2tH5QTb7Pudj5zJIFS0tdAyL+VDrjCb6yuCmdjzCjbVUXwp5q2cUuGutqf+Jg24Wn546TD/IEnxY7gPMQEjfDv2XFmHOVw== 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=w15lF//nMWZoaV/9/vEfzJmsKXsSAgv6Y87JOhFLC2Wyg58axFwnvWq7PoPWSXnDvdQYAvRQL7fpLLjG4ya09X2Gj7Do33Emqf3NiqBZAPuTKCC7RWK1JDvu6aq6GNiOBIVEmkOdlU6o1yLv/m5jFybNR5dKunbSumi5d828ddZQpML5M74+8B3BU2ZM8NkPorYQkA1fhysq9UUezGMAZZO6CNh5gsb0dXrrm3ejGIneNZG5cwPvIOhoHzhgsyGE34XxjHLrs45dT4P/w58RyVadFbETC+yAN4NTvPeqkflhlpholLj9CkStWjujcONHpJeKiKizYomWfVUzAOc04Q== 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=iWprLadKXRs6i29YiCF4/JRDxul5jUi7LSSlcX6NQnbObgk2+eTGWxOJGnzYD31p93QDhuMIW2pD80XnY9a0FgcK76A3H7HqxwnuCqQMKkdaVSjFB8gOP+KsrZE4kbUj7Yy73IrPIPi5f/OsviuVLQojHCdOGZPCkizipDTRxIbQWInB7r3jzmGodxlLQg13VLrLPGVL3aHCZsUUD++BRmJtUgXOTYtOgJfL9FL46XNFexmWfE6KMyku22HgosHDiawopBtmyery3ppy9Sa3dAFB1fiXeTDT9mdTmzq8Rd6kFHoF60hrYeXPcfN4WD72iOW39Z9wTveQBNHRy5tNMQ== 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 AS8PR04MB8404.eurprd04.prod.outlook.com (2603:10a6:20b:3f8::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7849.22; Tue, 13 Aug 2024 15:15:26 +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.7849.019; Tue, 13 Aug 2024 15:15:26 +0000 From: Frank Li Date: Tue, 13 Aug 2024 11:15:00 -0400 Subject: [PATCH v2 02/11] i3c: master: Replace hard code 2 with macro I3C_ADDR_SLOT_BITS Message-Id: <20240813-i3c_fix-v2-2-68fe4a050188@nxp.com> References: <20240813-i3c_fix-v2-0-68fe4a050188@nxp.com> In-Reply-To: <20240813-i3c_fix-v2-0-68fe4a050188@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=1723562115; l=1901; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=/8gjfrLEbeqdvh2UWIsUOXSQLlEPInExNiw2wP5o2A0=; b=aAI64uSk6gehOExiLMjcxc+d4R6RvosZUcMgzFIqERXuQK4d7uTDbYP+5jo+gh5C8vj9v1Rr8 7sRCuTPYDXdCyE6jvkHohlLWDLjYiZtkSVYOZcfsA4WjeNQZBxy+nie X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: SJ0PR05CA0125.namprd05.prod.outlook.com (2603:10b6:a03:33d::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_|AS8PR04MB8404:EE_ X-MS-Office365-Filtering-Correlation-Id: c8589006-8752-4995-0a0e-08dcbbaac267 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|7416014|376014|52116014|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?Uuu/d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QH6815/ZoO1HrFw59UUDom4qf04zX0qH+mQ?= =?utf-8?q?Wg9hGmpd+7IUuY+OpwBTjbhbosHb6Pp9O1MSR+1MAQoK00cEmFUe8Cbg2Oaz/SJw4?= =?utf-8?q?q0OKw4cmUNyO+xT3zyWkRkKTRsy1WqNf+OhjVS/OxeCGn/Okes+wl/wg3s6JHSDeA?= =?utf-8?q?FnPrP3eini/13gxB1blauBgBqqqSpTIc3htE0snmpjZS0lk1l4y+VWthJh+Uh0D4f?= =?utf-8?q?g7olUf3aXBSE3HY8qfeRXftNgnz7VMobgJzsd8Kir15DdNL+JQCHUKImLoifZh9g0?= =?utf-8?q?p4nvZf0tnfq5yBHjXNUt37zbaz0s+0b+iMhlmB8eXXltPYIn160ZZuJlCzNWaKA+o?= =?utf-8?q?APaKfSwC5bBNeFYXYWgrlZaW5AEL6aj5P9Jf8MmeewL+AkO4zB/m2tYoCs7PNrEYa?= =?utf-8?q?7eoIFQ57FViYWKC3f7Iy8PRIVd9BbCVzauTQ2tMgyY5kFqoRuecQHKOAqx8jmtXg/?= =?utf-8?q?x+7ur1HVqbOAN2TSndZ2y7Mf4fJNSgu5+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)(7416014)(376014)(52116014)(1800799024)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?+R3TVwQer6WUGNnIKAg9hJjfOsaK?= =?utf-8?q?M9K1X4aKZwZ4n0oRyrEyaWM+I0kYJ4V1doiN6BogbutGIIgZ4u2llz83sdhAVTNqx?= =?utf-8?q?DOGA/AIhnVv8Ek6mnMRzNDE+DLaP2iYODYRdrHUL9WyyNMlhEYMLLtX9FfMaq2YvE?= =?utf-8?q?apcTBWyOO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R+WiOL8sTGiG7ciot2AePzTvCcTiL548PdQXRJc9W5kgYRZLV?= =?utf-8?q?KJcqOl78jf9VouLaoWZamAUHhND36b6D4xsyWsh9vKfkkdMsBsIJg9Bx0Ktea39DE?= =?utf-8?q?6ORROl8nmLubH0w3i9usAg8v5JKkRtXTJYfxEY5lF+ph1by2nj4NrGNM7cEjiuCpL?= =?utf-8?q?i0NMyE7BfyMmAt+1EhkLpzo6XHHx0zYkJR8mrX5I2fat6Fk4RN1wImcz+PZTOdeD6?= =?utf-8?q?PtnPlCoJcf9mogV5aRMogN0KspaJWbCveiadMkkz5zd0w66bD4uvkdGk0ti4PNTz7?= =?utf-8?q?5BPYQytefZOsrm0NiPi2HNHs/N6O6OTC/Yrjed+yA9kGcz57hChbsTdHXoQeAq/Jt?= =?utf-8?q?SANbOxlZTykbdvILgPwQQ/j+CIfD+w+pw1yzU6EBAxytUbDRqJnk9vlYC6mT8ndqX?= =?utf-8?q?LAwZ/x/xIiyzHFZMqaqYFZEGPw+idJ9R93tXuWBCqSZn+UF6oQitlksU=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: c8589006-8752-4995-0a0e-08dcbbaac267 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Aug 2024 15:15:26.1093 (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: mtLy2DjpBPWAz4RdHbY2/R1mua+Oy0x+ZRaln3VR//TGGGPUQjzT/nRcEXP+H1sM8HjX076uTxH0Mgvs8HY+JQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB8404 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;