Files
linux-nv-oot/scripts/coccinelle/platform_driver_remove.cocci
Jon Hunter c463c63993 scripts: Add scripts for platform_driver remove
In Linux v6.11, the 'platform_driver' structure 'remove' callback was
updated to return void instead of 'int'. This change impacts all OOT
platform drivers and so instead of editing each manually, add a
coccinelle script to handle updating all platform drivers. This script
is ran by executing the following command ...

 $ spatch --in-place \
   --sp-file /path/to/scripts/coccinelle/platform_driver_remove.cocci
   <driver-source-directory>

Finally, add a test to the conftest script that is used to detect if the
platform driver 'remove' callback returns 'void'.

Bug 4749580

Change-Id: I53d25cc36cc3be97a6eeeb4ccbdf9b7dfda338a9
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3176834
(cherry picked from commit 24826db83f)
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3202689
Reviewed-by: Brad Griffis <bgriffis@nvidia.com>
GVS: buildbot_gerritrpt <buildbot_gerritrpt@nvidia.com>
2024-09-11 04:39:39 -07:00

78 lines
1.6 KiB
Plaintext

// SPDX-License-Identifier: GPL-2.0-only
// SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// Options: --no-includes --include-headers --smpl-spacing
@match1@
identifier p, removefn;
@@
struct platform_driver p = {
.remove = removefn,
};
@match2@
identifier p, removefn;
@@
struct platform_driver p = {
.remove = __exit_p(removefn),
};
@match3@
@@
#include <nvidia/conftest.h>
@fix1 depends on match1@
identifier match1.p;
identifier match1.removefn;
fresh identifier removefn_wrapper = removefn ## "_wrapper";
@@
+#if defined(NV_PLATFORM_DRIVER_STRUCT_REMOVE_RETURNS_VOID) /* Linux v6.11 */
+static inline void removefn_wrapper(struct platform_device *pdev)
+{
+ removefn(pdev);
+}
+#else
+static inline int removefn_wrapper(struct platform_device *pdev)
+{
+ return removefn(pdev);
+}
+#endif
+
struct platform_driver p = {
- .remove = removefn,
+ .remove = removefn_wrapper,
};
@fix2 depends on match2@
identifier match2.p;
identifier match2.removefn;
fresh identifier removefn_wrapper = removefn ## "_wrapper";
@@
+#if defined(NV_PLATFORM_DRIVER_STRUCT_REMOVE_RETURNS_VOID) /* Linux v6.11 */
+static inline void removefn_wrapper(struct platform_device *pdev)
+{
+ removefn(pdev);
+}
+#else
+static inline int removefn_wrapper(struct platform_device *pdev)
+{
+ return removefn(pdev);
+}
+#endif
+
struct platform_driver p = {
- .remove = __exit_p(removefn),
+ .remove = __exit_p(removefn_wrapper),
};
@fix3 depends on (match1 || match2) && !match3@
@@
+#include <nvidia/conftest.h>
+
#include <...>
@fix4 depends on (match1 || match2) && (!match3 && !fix3)@
@@
+#include <nvidia/conftest.h>
+
#include "..."