Skip to content

Commit

Permalink
cxl: Create an auxiliary device for fwctl_cxl
Browse files Browse the repository at this point in the history
This will link the fwctl subsystem to CXL devices.

Signed-off-by: Dave Jiang <[email protected]>
Signed-off-by: Jason Gunthorpe <[email protected]>
  • Loading branch information
jgunthorpe committed Aug 21, 2024
1 parent 0490d20 commit 960f17f
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions drivers/cxl/core/memdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

DECLARE_RWSEM(cxl_memdev_rwsem);

#define CXL_ADEV_NAME "fwctl-cxl"

/*
* An entire PCI topology full of devices should be enough for any
* config
Expand Down Expand Up @@ -1030,6 +1032,7 @@ static const struct file_operations cxl_memdev_fops = {
struct cxl_memdev *devm_cxl_add_memdev(struct device *host,
struct cxl_dev_state *cxlds)
{
struct auxiliary_device *adev;
struct cxl_memdev *cxlmd;
struct device *dev;
struct cdev *cdev;
Expand All @@ -1056,11 +1059,27 @@ struct cxl_memdev *devm_cxl_add_memdev(struct device *host,
if (rc)
goto err;

adev = &cxlds->cxl_mbox.adev;
adev->id = cxlmd->id;
adev->name = CXL_ADEV_NAME;
adev->dev.parent = dev;

rc = auxiliary_device_init(adev);
if (rc)
goto err;

rc = auxiliary_device_add(adev);
if (rc)
goto aux_err;

rc = devm_add_action_or_reset(host, cxl_memdev_unregister, cxlmd);
if (rc)
return ERR_PTR(rc);
return cxlmd;

aux_err:
auxiliary_device_uninit(adev);

err:
/*
* The cdev was briefly live, shutdown any ioctl operations that
Expand Down

0 comments on commit 960f17f

Please sign in to comment.