diff options
| author | Peter Colberg <[email protected]> | 2024-11-20 01:10:28 +0000 |
|---|---|---|
| committer | Xu Yilun <[email protected]> | 2024-12-18 14:28:48 +0000 |
| commit | 7b15c41110382ccc208a046932c762bcca16b5b1 (patch) | |
| tree | 45024c654c2d580c8f5461c7855e5a064ab989b7 /drivers/fpga/dfl.c | |
| parent | fpga: dfl: convert features from flexible array member to separate array (diff) | |
| download | kernel-7b15c41110382ccc208a046932c762bcca16b5b1.tar.gz kernel-7b15c41110382ccc208a046932c762bcca16b5b1.zip | |
fpga: dfl: store MMIO resources in feature device data
Instead of directly copying the MMIO resource of each feature to the
feature device resources, add a new member to the feature device data
to store the resources and copy them to the feature device using
platform_device_add_resources(). This prepares a subsequent commit
which completely destroys and recreates the feature device when
releasing and reassigning the corresponding port, respectively.
Signed-off-by: Peter Colberg <[email protected]>
Reviewed-by: Matthew Gerlach <[email protected]>
Reviewed-by: Basheer Ahmed Muddebihal <[email protected]>
Acked-by: Xu Yilun <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Xu Yilun <[email protected]>
Diffstat (limited to 'drivers/fpga/dfl.c')
| -rw-r--r-- | drivers/fpga/dfl.c | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/drivers/fpga/dfl.c b/drivers/fpga/dfl.c index 3015dfc1d552..143c5b479789 100644 --- a/drivers/fpga/dfl.c +++ b/drivers/fpga/dfl.c @@ -761,6 +761,11 @@ binfo_create_feature_dev_data(struct build_feature_devs_info *binfo) if (!fdata->features) return ERR_PTR(-ENOMEM); + fdata->resources = devm_kcalloc(binfo->dev, binfo->feature_num, + sizeof(*fdata->resources), GFP_KERNEL); + if (!fdata->resources) + return ERR_PTR(-ENOMEM); + fdata->dev = fdev; fdata->type = type; fdata->num = binfo->feature_num; @@ -778,13 +783,6 @@ binfo_create_feature_dev_data(struct build_feature_devs_info *binfo) */ WARN_ON(fdata->disable_count); - /* each sub feature has one MMIO resource */ - fdev->num_resources = binfo->feature_num; - fdev->resource = kcalloc(binfo->feature_num, sizeof(*fdev->resource), - GFP_KERNEL); - if (!fdev->resource) - return ERR_PTR(-ENOMEM); - /* fill features and resource information for feature dev */ list_for_each_entry_safe(finfo, p, &binfo->sub_features, node) { struct dfl_feature *feature = &fdata->features[index++]; @@ -822,7 +820,7 @@ binfo_create_feature_dev_data(struct build_feature_devs_info *binfo) return ERR_CAST(feature->ioaddr); } else { feature->resource_index = res_idx; - fdev->resource[res_idx++] = finfo->mmio_res; + fdata->resources[res_idx++] = finfo->mmio_res; } if (finfo->nr_irqs) { @@ -843,6 +841,8 @@ binfo_create_feature_dev_data(struct build_feature_devs_info *binfo) kfree(finfo); } + fdata->resource_num = res_idx; + return fdata; } @@ -886,6 +886,11 @@ static int feature_dev_register(struct dfl_feature_dev_data *fdata) fdev->dev.parent = &fdata->dfl_cdev->region->dev; fdev->dev.devt = dfl_get_devt(dfl_devs[fdata->type].devt_type, fdev->id); + ret = platform_device_add_resources(fdev, fdata->resources, + fdata->resource_num); + if (ret) + return ret; + pdata.fdata = fdata; ret = platform_device_add_data(fdev, &pdata, sizeof(pdata)); if (ret) |
