drivers: Add conftest test for class_create

In Linux v6.4, the module pointer argument is removed from the
class_create() function. Add a test to the conftest script that checks
if this argument for the class_create() function has been removed and
use the definition created by conftest to select which version of the
function is used.

Bug 4183168
Bug 4221847

Change-Id: I440e4b318001886cd0319bb3499ba33178475e8c
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2989020
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
Jon Hunter
2023-10-02 10:56:59 +01:00
committed by mobile promotions
parent 86dafc35bb
commit ce678a37b1
21 changed files with 100 additions and 33 deletions

View File

@@ -3,6 +3,8 @@
#define pr_fmt(fmt) "nvscic2c-pcie: endpoint: " fmt
#include <nvidia/conftest.h>
#include <linux/atomic.h>
#include <linux/cdev.h>
#include <linux/dma-fence.h>
@@ -1057,7 +1059,11 @@ endpoints_setup(struct driver_ctx_t *drv_ctx, void **endpoints_h)
if (ret < 0)
goto err;
#if defined(NV_CLASS_CREATE_HAS_NO_OWNER_ARG) /* Linux v6.4 */
eps_ctx->class = class_create(eps_ctx->drv_name);
#else
eps_ctx->class = class_create(THIS_MODULE, eps_ctx->drv_name);
#endif
if (IS_ERR_OR_NULL(eps_ctx->class)) {
ret = PTR_ERR(eps_ctx->class);
goto err;

View File

@@ -6,6 +6,8 @@
* secure buffer sharing use case across processes.
*/
#include <nvidia/conftest.h>
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/string.h>
@@ -20,7 +22,6 @@
#include <linux/cred.h>
#include <linux/of.h>
#include <linux/fs.h>
#include <linux/version.h>
#ifdef CONFIG_TEGRA_VIRTUALIZATION
#include <soc/tegra/virt/syscalls.h>
@@ -696,7 +697,7 @@ static int nvsciipc_probe(struct platform_device *pdev)
ctx->dev = &(pdev->dev);
platform_set_drvdata(pdev, ctx);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 4, 0)
#if defined(NV_CLASS_CREATE_HAS_NO_OWNER_ARG) /* Linux v6.4 */
ctx->nvsciipc_class = class_create(MODULE_NAME);
#else
ctx->nvsciipc_class = class_create(THIS_MODULE, MODULE_NAME);