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

@@ -18,7 +18,6 @@
#include <linux/poll.h>
#include <linux/slab.h>
#include <linux/sync_file.h>
#include <linux/version.h>
#include "include/uapi/linux/host1x-fence.h"
@@ -436,10 +435,10 @@ static int host1x_uapi_init(struct host1x_uapi *uapi)
if (err)
return err;
#if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 4, 0))
uapi->class = class_create(THIS_MODULE, "host1x-fence");
#else
#if defined(NV_CLASS_CREATE_HAS_NO_OWNER_ARG) /* Linux v6.4 */
uapi->class = class_create("host1x-fence");
#else
uapi->class = class_create(THIS_MODULE, "host1x-fence");
#endif
if (IS_ERR(uapi->class)) {
err = PTR_ERR(uapi->class);

View File

@@ -3,6 +3,8 @@
* Copyright (c) 2022-2023, NVIDIA Corporation. All rights reserved.
*/
#include <nvidia/conftest.h>
#include <linux/clk.h>
#include <linux/debugfs.h>
#include <linux/dma-fence.h>
@@ -112,10 +114,10 @@ static struct device *nvhost_client_device_create(struct platform_device *pdev,
struct device *dev;
int err;
#if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 4, 0))
pdata->nvhost_class = class_create(THIS_MODULE, pdev->dev.of_node->name);
#else
#if defined(NV_CLASS_CREATE_HAS_NO_OWNER_ARG) /* Linux v6.4 */
pdata->nvhost_class = class_create(pdev->dev.of_node->name);
#else
pdata->nvhost_class = class_create(THIS_MODULE, pdev->dev.of_node->name);
#endif
if (IS_ERR(pdata->nvhost_class)) {
dev_err(&pdev->dev, "failed to create class\n");