Files
linux-nv-oot/scripts/coccinelle/platform_driver_remove.cocci
Jon Hunter 74c0a6d16d drivers: Drop inline from driver remove wrapper
The driver remove function is a function pointer and therefore, it does
not make sense to define the function as an 'inline'. Update the
coccinelle script and drivers to remove the inline statement.

Bug 4749580

Change-Id: Ia03691b75c4edffe609f27468b911a92a5ddbd68
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3233980
(cherry picked from commit 2c3a31c9b72785ee35ad079422b624f59a35f622)
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3276870
Reviewed-by: Brad Griffis <bgriffis@nvidia.com>
GVS: buildbot_gerritrpt <buildbot_gerritrpt@nvidia.com>
2025-01-06 06:09:10 -08:00

78 lines
1.6 KiB
Plaintext

// SPDX-License-Identifier: GPL-2.0-only
// SPDX-FileCopyrightText: Copyright (c) 2024-2025 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 void removefn_wrapper(struct platform_device *pdev)
+{
+ removefn(pdev);
+}
+#else
+static 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 void removefn_wrapper(struct platform_device *pdev)
+{
+ removefn(pdev);
+}
+#else
+static 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 "..."