Skip to content

Commit f7e2910

Browse files
mwilczyweiny2
authored andcommitted
ACPI: NFIT: Use cleanup.h helpers instead of devm_*()
The new cleanup.h facilities that arrived in v6.5-rc1 can replace the the usage of devm semantics in acpi_nfit_init_interleave_set(). That routine appears to only be using devm to avoid goto statements. The new __free() annotation at variable declaration time can achieve the same effect more efficiently. There is no end user visible side effects of this patch, I was motivated to send this cleanup to practice using the new helpers. Suggested-by: Dave Jiang <[email protected]> Suggested-by: Andy Shevchenko <[email protected]> Reviewed-by: Dave Jiang <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Reviewed-by: Dan Williams <[email protected]> Signed-off-by: Michal Wilczynski <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Ira Weiny <[email protected]>
1 parent 610a9b8 commit f7e2910

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

drivers/acpi/nfit/core.c

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2257,26 +2257,23 @@ static int acpi_nfit_init_interleave_set(struct acpi_nfit_desc *acpi_desc,
22572257
struct nd_region_desc *ndr_desc,
22582258
struct acpi_nfit_system_address *spa)
22592259
{
2260+
u16 nr = ndr_desc->num_mappings;
2261+
struct nfit_set_info2 *info2 __free(kfree) =
2262+
kcalloc(nr, sizeof(*info2), GFP_KERNEL);
2263+
struct nfit_set_info *info __free(kfree) =
2264+
kcalloc(nr, sizeof(*info), GFP_KERNEL);
22602265
struct device *dev = acpi_desc->dev;
22612266
struct nd_interleave_set *nd_set;
2262-
u16 nr = ndr_desc->num_mappings;
2263-
struct nfit_set_info2 *info2;
2264-
struct nfit_set_info *info;
22652267
int i;
22662268

2269+
if (!info || !info2)
2270+
return -ENOMEM;
2271+
22672272
nd_set = devm_kzalloc(dev, sizeof(*nd_set), GFP_KERNEL);
22682273
if (!nd_set)
22692274
return -ENOMEM;
22702275
import_guid(&nd_set->type_guid, spa->range_guid);
22712276

2272-
info = devm_kcalloc(dev, nr, sizeof(*info), GFP_KERNEL);
2273-
if (!info)
2274-
return -ENOMEM;
2275-
2276-
info2 = devm_kcalloc(dev, nr, sizeof(*info2), GFP_KERNEL);
2277-
if (!info2)
2278-
return -ENOMEM;
2279-
22802277
for (i = 0; i < nr; i++) {
22812278
struct nd_mapping_desc *mapping = &ndr_desc->mapping[i];
22822279
struct nvdimm *nvdimm = mapping->nvdimm;
@@ -2337,8 +2334,6 @@ static int acpi_nfit_init_interleave_set(struct acpi_nfit_desc *acpi_desc,
23372334
}
23382335

23392336
ndr_desc->nd_set = nd_set;
2340-
devm_kfree(dev, info);
2341-
devm_kfree(dev, info2);
23422337

23432338
return 0;
23442339
}

0 commit comments

Comments
 (0)