Re: [PATCH 5/7] ocxl: Create a clear delineation between ocxl backend & frontend

From: Frederic Barrat
Date: Thu Mar 14 2019 - 12:27:16 EST





diff --git a/drivers/misc/ocxl/file.c b/drivers/misc/ocxl/file.c
index 865b3d176431..424bb0b40afb 100644
--- a/drivers/misc/ocxl/file.c
+++ b/drivers/misc/ocxl/file.c

-int ocxl_register_afu(struct ocxl_afu *afu)
+int ocxl_file_register_afu(struct ocxl_afu *afu)
{
int minor;
+ int rc;
+ struct ocxl_file_info *info;
+ struct ocxl_fn *fn = afu->fn;
+ struct pci_dev *pci_dev = to_pci_dev(fn->dev.parent);
+
+ info = kzalloc(sizeof(*info), GFP_KERNEL);
+ if (info == NULL)
+ return -ENOMEM;
- minor = allocate_afu_minor(afu);
- if (minor < 0)
+ info->afu = afu;
+
+ minor = allocate_minor(info);
+ if (minor < 0) {
+ kfree(info);
return minor;
- afu->dev.devt = MKDEV(MAJOR(ocxl_dev), minor);
- afu->dev.class = ocxl_class;
- return device_register(&afu->dev);
+ }
+
+ info->dev.parent = &fn->dev;
+ info->dev.devt = MKDEV(MAJOR(ocxl_dev), minor);
+ info->dev.class = ocxl_class;
+
+ ocxl_afu_set_private(afu, info, ocxl_file_release);


We no longer define a 'release' method for the AFU device. We need one, which should in turn free the info struct when the device ref count hits 0. That should explain the following error seen when unloading the driver:
"Device 'xyz' does not have a release() function, it is broken and must be fixed. See Documentation/kobject.txt"

Fred