diff options
author | Peter Colberg <peter.colberg@intel.com> | 2024-11-19 20:10:26 -0500 |
---|---|---|
committer | Xu Yilun <yilun.xu@linux.intel.com> | 2024-12-18 22:28:48 +0800 |
commit | 39ea74e33edc034831ed19902bfc17354c8fc8db (patch) | |
tree | 37ad5853ce91e48b80d336afe3f6294312637c3c /drivers/fpga/dfl.c | |
parent | 0783f41b00502d29fd70c31e727671d4a94e92f6 (diff) |
fpga: dfl: factor out feature device data from platform device data
Add a structure dfl_feature_dev_data to hold the DFL enumeration
info previously held in dfl_feature_platform_data. Allocate the new
structure using device-managed memory whose lifetime is bound to the
lifetime of the physical DFL, e.g., PCIe FPGA device. In a subsequent
commit, this will allow the feature platform device to be completely
destroyed and recreated on port release and assign, respectively, while
retaining the feature data in the new dfl_feature_dev_data structure.
Signed-off-by: Peter Colberg <peter.colberg@intel.com>
Reviewed-by: Matthew Gerlach <matthew.gerlach@linux.intel.com>
Reviewed-by: Basheer Ahmed Muddebihal <basheer.ahmed.muddebihal@linux.intel.com>
Acked-by: Xu Yilun <yilun.xu@intel.com>
Link: https://lore.kernel.org/r/20241120011035.230574-11-peter.colberg@intel.com
Signed-off-by: Xu Yilun <yilun.xu@linux.intel.com>
Diffstat (limited to 'drivers/fpga/dfl.c')
-rw-r--r-- | drivers/fpga/dfl.c | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/drivers/fpga/dfl.c b/drivers/fpga/dfl.c index 081b55d22973..1d1f2330beef 100644 --- a/drivers/fpga/dfl.c +++ b/drivers/fpga/dfl.c @@ -752,13 +752,7 @@ binfo_create_feature_dev_data(struct build_feature_devs_info *binfo) if (WARN_ON_ONCE(type >= DFL_ID_MAX)) return ERR_PTR(-EINVAL); - /* - * we do not need to care for the memory which is associated with - * the platform device. After calling platform_device_unregister(), - * it will be automatically freed by device's release() callback, - * platform_device_release(). - */ - fdata = kzalloc(struct_size(fdata, features, binfo->feature_num), GFP_KERNEL); + fdata = devm_kzalloc(binfo->dev, struct_size(fdata, features, binfo->feature_num), GFP_KERNEL); if (!fdata) return ERR_PTR(-ENOMEM); @@ -779,8 +773,6 @@ binfo_create_feature_dev_data(struct build_feature_devs_info *binfo) */ WARN_ON(fdata->disable_count); - fdev->dev.platform_data = fdata; - /* each sub feature has one MMIO resource */ fdev->num_resources = binfo->feature_num; fdev->resource = kcalloc(binfo->feature_num, sizeof(*fdev->resource), @@ -882,12 +874,18 @@ build_info_create_dev(struct build_feature_devs_info *binfo) */ static int feature_dev_register(struct dfl_feature_dev_data *fdata) { + struct dfl_feature_platform_data pdata = {}; struct platform_device *fdev = fdata->dev; int ret; fdev->dev.parent = &fdata->dfl_cdev->region->dev; fdev->dev.devt = dfl_get_devt(dfl_devs[fdata->type].devt_type, fdev->id); + pdata.fdata = fdata; + ret = platform_device_add_data(fdev, &pdata, sizeof(pdata)); + if (ret) + return ret; + ret = platform_device_add(fdev); if (ret) return ret; |