[PATCH 13/20] headers: add class_create() single-argument backport for kernels < 6.4
Yi Cong <[email protected]> Wed, 24 Jun 2026 15:38:37 +0800
| Newsgroups | org.kernel.vger.backports |
|---|---|
| Message-ID | <[email protected]> |
From: Yi Cong <[email protected]> In v6.4 class_create() was simplified to take only the name argument, using THIS_MODULE implicitly. For older kernels, provide a wrapper that forwards to the two-argument __class_create() macro. Signed-off-by: Yi Cong <[email protected]> --- backport/backport-include/linux/device.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/backport/backport-include/linux/device.h b/backport/backport-include/linux/device.h index 06595285..069337b7 100644 --- a/backport/backport-include/linux/device.h +++ b/backport/backport-include/linux/device.h @@ -12,4 +12,18 @@ struct device_attribute dev_attr_##_name = __ATTR_RO_MODE(_name, 0400) #endif +#if LINUX_VERSION_IS_LESS(6,4,0) +/* + * class_create() in v6.4+ takes only the name argument and uses + * THIS_MODULE implicitly. For older kernels, provide a wrapper + * that forwards to the 2-argument macro version. + */ +#undef class_create +#define class_create(name) \ +({ \ + static struct lock_class_key __key; \ + __class_create(THIS_MODULE, (name), &__key); \ +}) +#endif + #endif /* __BACKPORT_DEVICE_H_ */ -- 2.43.0