aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/fpga/dfl.c
diff options
context:
space:
mode:
authorPeter Colberg <[email protected]>2024-11-20 01:10:27 +0000
committerXu Yilun <[email protected]>2024-12-18 14:28:48 +0000
commitb3245f700ae2e9f0ecbcf36b8908f6460db91202 (patch)
tree35c087a581b3dbe3f86a5488a2ee38b9da29112f /drivers/fpga/dfl.c
parentfpga: dfl: factor out feature device data from platform device data (diff)
downloadkernel-b3245f700ae2e9f0ecbcf36b8908f6460db91202.tar.gz
kernel-b3245f700ae2e9f0ecbcf36b8908f6460db91202.zip
fpga: dfl: convert features from flexible array member to separate array
Use a separate array allocation for features and substitute a pointer for the flexible array member in the feature device data. A subsequent commit will add another array for resources. The current commit converts the flexible array member to a separate allocation for consistency. 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.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/drivers/fpga/dfl.c b/drivers/fpga/dfl.c
index 1d1f2330beef..3015dfc1d552 100644
--- a/drivers/fpga/dfl.c
+++ b/drivers/fpga/dfl.c
@@ -752,10 +752,15 @@ binfo_create_feature_dev_data(struct build_feature_devs_info *binfo)
if (WARN_ON_ONCE(type >= DFL_ID_MAX))
return ERR_PTR(-EINVAL);
- fdata = devm_kzalloc(binfo->dev, struct_size(fdata, features, binfo->feature_num), GFP_KERNEL);
+ fdata = devm_kzalloc(binfo->dev, sizeof(*fdata), GFP_KERNEL);
if (!fdata)
return ERR_PTR(-ENOMEM);
+ fdata->features = devm_kcalloc(binfo->dev, binfo->feature_num,
+ sizeof(*fdata->features), GFP_KERNEL);
+ if (!fdata->features)
+ return ERR_PTR(-ENOMEM);
+
fdata->dev = fdev;
fdata->type = type;
fdata->num = binfo->feature_num;