From nobody Thu Apr 2 23:55:27 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 AD6A634C9A6; Thu, 26 Mar 2026 08:06:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774512400; cv=none; b=gRlRlGA54pjTxM/oz5jjAn1uteg1pWvv71V+5OzezK0QCstGQQW44TyoQ0WFsqFWjOC5U+OjNZnYshJarXZuBpdJuY7TJL4cwNa8mq3NgVhYewqZCGCCsH7nuXinpBgqQVlUFv4/R2N+WkxwQHrmD/F132Sn6xFmfSvyGMAE/Og= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774512400; c=relaxed/simple; bh=ul9pqll2OSaIKRropAAhp3YOqELMgU3KZnuLR8PCb0A=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=KHTBvWzX/mJcR6D8NS2vizUR7T/hOtgfu80+fsOcNHOcvZ7OCmEI4fpSB1fLLpPTdwODaJAa05NtuPHuNGDj1rx3ihjImj+w856A4F+wQ5+vtISI/AXDltFj05Wm6aR6XS24QcgGmZp8eHZ9J8jRqiaME+GkLw58g/P3moxlKNk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Sxv8kEpD; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Sxv8kEpD" Received: by smtp.kernel.org (Postfix) with ESMTPS id 55DB2C116C6; Thu, 26 Mar 2026 08:06:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1774512400; bh=ul9pqll2OSaIKRropAAhp3YOqELMgU3KZnuLR8PCb0A=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=Sxv8kEpDuSmIyvYnOc1Ffy6fYZwnGNTt049PgLZ1MkC8L+/AG5bbKY8Q6w5CCDWuL 2eGOgGr1tqGMsMm7ZAyVnywqAApbKFfB6uhfRG5t4ZeNuW7b/q4x1D32ZCuESJlnfC RJzSr+5Gg9kcndlvx2n2O8AIiVZUDwIChsxvykTsNtbvaM7KHZAG9ZPdvuF2ZlGpzM yI+bLG45bVfAMj4zY9VIWRev87EfFykP1R47zUzN0OxtSn4lUtlnApMSvRhW6GeGwi /EoAPeQoxGq+YLmlFAKd3CQT0lLfa6mWQ8eeoQCoRdBEEDVJhvuZ0XfvUg1rMmPsZw gQrMmhEGKPuYQ== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 425CB106F2F1; Thu, 26 Mar 2026 08:06:40 +0000 (UTC) From: Manivannan Sadhasivam via B4 Relay Date: Thu, 26 Mar 2026 13:36:29 +0530 Subject: [PATCH v7 1/8] serdev: Convert to_serdev_*() helpers to macros and use container_of_const() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260326-pci-m2-e-v7-1-43324a7866e6@oss.qualcomm.com> References: <20260326-pci-m2-e-v7-0-43324a7866e6@oss.qualcomm.com> In-Reply-To: <20260326-pci-m2-e-v7-0-43324a7866e6@oss.qualcomm.com> To: Rob Herring , Greg Kroah-Hartman , Jiri Slaby , Nathan Chancellor , Nicolas Schier , Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Mark Pearson , "Derek J. Clark" , Manivannan Sadhasivam , Krzysztof Kozlowski , Conor Dooley , Marcel Holtmann , Luiz Augusto von Dentz , Bartosz Golaszewski , Andy Shevchenko , Bartosz Golaszewski Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-pci@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-bluetooth@vger.kernel.org, linux-pm@vger.kernel.org, Stephan Gerhold , Dmitry Baryshkov , linux-acpi@vger.kernel.org, Manivannan Sadhasivam , Hans de Goede , Bartosz Golaszewski X-Mailer: b4 0.15.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2281; i=manivannan.sadhasivam@oss.qualcomm.com; h=from:subject:message-id; bh=jiQzAn5Z8SWByOSZJxw8qqvki+Y9WdMaik55wmM6Ke4=; b=owEBbQGS/pANAwAKAVWfEeb+kc71AcsmYgBpxOkN7QMgu4LjM3x43OR9CENDooFBJw/r4GLN7 2zRqvnG/3CJATMEAAEKAB0WIQRnpUMqgUjL2KRYJ5dVnxHm/pHO9QUCacTpDQAKCRBVnxHm/pHO 9Q/8B/9L9PzZdlZtRSQt7yFVwM+Ywox50hU7tZyqqCob/AWQ0gC3MIuljKol4DqeEKrHPFVmiva eJS9cmcEvH4DdGrOwXzmMGzH3lDu5D6aiC9AwXX+9g+CBuTDTdu1Tx3OGwrI+PlwQ2qKsd3EVfT diULuU+zZPyB7sVftDwDzzCV4ENzXsY3Cb8j5DLMnzBcoiwwsi/hl6iJK314J9U9fiZf4ELQaUx 8nLSaKGvu9MZCOTNqusrEc6WtyDRIC63fTtTs6D46itl07MI/9EAv5kKXLevUau3YvJeVTid7u9 m051x36zfz0eKSGPF9/r2nx3MnYgKoTt62pFMRrUaIjMyrr2 X-Developer-Key: i=manivannan.sadhasivam@oss.qualcomm.com; a=openpgp; fpr=C668AEC3C3188E4C611465E7488550E901166008 X-Endpoint-Received: by B4 Relay for manivannan.sadhasivam@oss.qualcomm.com/default with auth_id=461 X-Original-From: Manivannan Sadhasivam Reply-To: manivannan.sadhasivam@oss.qualcomm.com From: Manivannan Sadhasivam If these helpers receive the 'const struct device' pointer, then the const qualifier will get dropped, leading to below warning: warning: passing argument 1 of =E2=80=98to_serdev_device_driver=E2=80=99 di= scards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers] This is not an issue as of now, but with the future commits adding serdev device based driver matching, this warning will get triggered. Hence, convert these helpers to macros so that the qualifier get preserved and also use container_of_const() as container_of() is deprecated. Tested-by: Hans de Goede # ThinkPad T14s = gen6 (arm64) Reviewed-by: Bartosz Golaszewski Signed-off-by: Manivannan Sadhasivam Reviewed-by: Rob Herring (Arm) --- include/linux/serdev.h | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/include/linux/serdev.h b/include/linux/serdev.h index 5654c58eb73c..0c7d3c27d1f8 100644 --- a/include/linux/serdev.h +++ b/include/linux/serdev.h @@ -49,10 +49,7 @@ struct serdev_device { struct mutex write_lock; }; =20 -static inline struct serdev_device *to_serdev_device(struct device *d) -{ - return container_of(d, struct serdev_device, dev); -} +#define to_serdev_device(d) container_of_const(d, struct serdev_device, de= v) =20 /** * struct serdev_device_driver - serdev slave device driver @@ -68,10 +65,7 @@ struct serdev_device_driver { void (*shutdown)(struct serdev_device *); }; =20 -static inline struct serdev_device_driver *to_serdev_device_driver(struct = device_driver *d) -{ - return container_of(d, struct serdev_device_driver, driver); -} +#define to_serdev_device_driver(d) container_of_const(d, struct serdev_dev= ice_driver, driver) =20 enum serdev_parity { SERDEV_PARITY_NONE, @@ -112,10 +106,7 @@ struct serdev_controller { const struct serdev_controller_ops *ops; }; =20 -static inline struct serdev_controller *to_serdev_controller(struct device= *d) -{ - return container_of(d, struct serdev_controller, dev); -} +#define to_serdev_controller(d) container_of_const(d, struct serdev_contro= ller, dev) =20 static inline void *serdev_device_get_drvdata(const struct serdev_device *= serdev) { --=20 2.51.0