From nobody Tue Apr 7 02:35:30 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 483CB359A8F; Tue, 17 Mar 2026 04:30:03 +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=1773721803; cv=none; b=NyVkT0gY0Mfw/hUOliolS4kuwpatdDd7sqA1GvUa4D8WvyfsJtAlHvb8PVp5MQM6Tbo7vOdaFv/eIaiZ9rfY9WtnauVoASIj/TS/cXbJEJQ0ez4IvLppyE8NfNTP1gQWtF03exOUGiVuVgv5fXxOlGzG5e8vUEJka3KitoarJSs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773721803; c=relaxed/simple; bh=ul9pqll2OSaIKRropAAhp3YOqELMgU3KZnuLR8PCb0A=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=F6Nq5ghWoeGmJniju/Y5VDEhmzVj32dlRWpP4o2zJMhRNRyhJcgUkenhzTv81XN3AvtH3ev2dnfLvuSFzcIquJIMFRuEjuKsf6nYZOfeEUxY42mMw1ZhbNgZI8pZb6VInAW3/f/+xhO28MLUqxHSJC7zDo0MWIRsdhsl2jpC4gE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=iZRxnQq6; 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="iZRxnQq6" Received: by smtp.kernel.org (Postfix) with ESMTPS id D3239C2BC86; Tue, 17 Mar 2026 04:30:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1773721802; bh=ul9pqll2OSaIKRropAAhp3YOqELMgU3KZnuLR8PCb0A=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=iZRxnQq6kHPy8LH3qDYtqHCcdrxj1UFqbIJBW8LnWHRRRwmUUvgLynpEEFRKUHNiy 0Cil9aMpE0OnV3b6mENgiOB1u5UpGN5HBYEQQO0Kh4GSnR5bXUJCWcDhmHEDho9BF9 5J1ER163kbqxvkQfgiQrmdqV9pCytWOUkJ3Safl+Qd+SwmbR4vv/D8Hl0iHoaqURe7 niKbGnw4PT6PkpEZ3UZ3P3l9tOGtkEKbGARq8193GhAXZvWSoDRPgRkIEynkYjWFNt UUavuHmo5BXanIfhtQasEAlnkyJLS07GenBlhMdlCF2scMlhElSmCM+2Kzucx8/cqf FEez92BKF1zMw== 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 B9009FB5EB2; Tue, 17 Mar 2026 04:30:02 +0000 (UTC) From: Manivannan Sadhasivam via B4 Relay Date: Tue, 17 Mar 2026 09:59:51 +0530 Subject: [PATCH v6 1/9] 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: <20260317-pci-m2-e-v6-1-9c898f108d3d@oss.qualcomm.com> References: <20260317-pci-m2-e-v6-0-9c898f108d3d@oss.qualcomm.com> In-Reply-To: <20260317-pci-m2-e-v6-0-9c898f108d3d@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.14.3 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+kc71AcsmYgBpuNjHwuJFA1dPQTJH6LbPjiT5vRdRFNwUVP8Fe TSJXC2EPGiJATMEAAEKAB0WIQRnpUMqgUjL2KRYJ5dVnxHm/pHO9QUCabjYxwAKCRBVnxHm/pHO 9XOWB/4mAGk+oVE4NGv7T0zySPzX/h//9aeuUfqfQP0GrKtcV3D51LxzRIdlx39eNkuB2JPDINk vTszFOoLbtTE6f++gfTA9FzIgv5vURENzPlhRotgxFyDtcdJAR3mIsFuX9Vgusz855SSEpajm7P 81WG8Bg/kk6GUdznjURFb+/Dzi9i4OSLWCdKgJoT/EvpTqAHI8/Y+gL9Q61NMgni26EkxTBERXk 4TIs/taMqGCW68Ef2D0Weueg3vhLb3yV0Ayv8xZf7VeYNQVwJ84EQ2QQ6Rgq3GuL9x1rmLT0LpJ eEasYWtHxyVBxyUZnNDKmZ2v9Blv30RgHZtdxK60csOQTaso 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 --- 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