Skip to content

Commit 2532f41

Browse files
djbwstellarhopper
authored andcommitted
dax: Cleanup extra dax_region references
Now that free_dev_dax_id() internally manages the references it needs the extra references taken by the dax_region drivers are not needed. Reported-by: Ira Weiny <ira.weiny@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com> Link: https://lore.kernel.org/r/168577285161.1672036.8111253437794419696.stgit@dwillia2-xfh.jf.intel.com Reviewed-by: Dave Jiang <dave.jiang@intel.com> Reviewed-by: Fan Ni <fan.ni@samsung.com> Reviewed-by: Ira Weiny <ira.weiny@intel.com> Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
1 parent 70aab28 commit 2532f41

5 files changed

Lines changed: 4 additions & 24 deletions

File tree

drivers/dax/bus.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -454,11 +454,10 @@ static void dax_region_free(struct kref *kref)
454454
kfree(dax_region);
455455
}
456456

457-
void dax_region_put(struct dax_region *dax_region)
457+
static void dax_region_put(struct dax_region *dax_region)
458458
{
459459
kref_put(&dax_region->kref, dax_region_free);
460460
}
461-
EXPORT_SYMBOL_GPL(dax_region_put);
462461

463462
/* a return value >= 0 indicates this invocation invalidated the id */
464463
static int __free_dev_dax_id(struct dev_dax *dev_dax)
@@ -641,7 +640,6 @@ struct dax_region *alloc_dax_region(struct device *parent, int region_id,
641640
return NULL;
642641
}
643642

644-
kref_get(&dax_region->kref);
645643
if (devm_add_action_or_reset(parent, dax_region_unregister, dax_region))
646644
return NULL;
647645
return dax_region;

drivers/dax/bus.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ struct dev_dax;
99
struct resource;
1010
struct dax_device;
1111
struct dax_region;
12-
void dax_region_put(struct dax_region *dax_region);
1312

1413
/* dax bus specific ioresource flags */
1514
#define IORESOURCE_DAX_STATIC BIT(0)

drivers/dax/cxl.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ static int cxl_dax_region_probe(struct device *dev)
1313
struct cxl_region *cxlr = cxlr_dax->cxlr;
1414
struct dax_region *dax_region;
1515
struct dev_dax_data data;
16-
struct dev_dax *dev_dax;
1716

1817
if (nid == NUMA_NO_NODE)
1918
nid = memory_add_physaddr_to_nid(cxlr_dax->hpa_range.start);
@@ -28,13 +27,8 @@ static int cxl_dax_region_probe(struct device *dev)
2827
.id = -1,
2928
.size = range_len(&cxlr_dax->hpa_range),
3029
};
31-
dev_dax = devm_create_dev_dax(&data);
32-
if (IS_ERR(dev_dax))
33-
return PTR_ERR(dev_dax);
3430

35-
/* child dev_dax instances now own the lifetime of the dax_region */
36-
dax_region_put(dax_region);
37-
return 0;
31+
return PTR_ERR_OR_ZERO(devm_create_dev_dax(&data));
3832
}
3933

4034
static struct cxl_driver cxl_dax_region_driver = {

drivers/dax/hmem/hmem.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ static int dax_hmem_probe(struct platform_device *pdev)
1616
struct dax_region *dax_region;
1717
struct memregion_info *mri;
1818
struct dev_dax_data data;
19-
struct dev_dax *dev_dax;
2019

2120
/*
2221
* @region_idle == true indicates that an administrative agent
@@ -38,13 +37,8 @@ static int dax_hmem_probe(struct platform_device *pdev)
3837
.id = -1,
3938
.size = region_idle ? 0 : range_len(&mri->range),
4039
};
41-
dev_dax = devm_create_dev_dax(&data);
42-
if (IS_ERR(dev_dax))
43-
return PTR_ERR(dev_dax);
4440

45-
/* child dev_dax instances now own the lifetime of the dax_region */
46-
dax_region_put(dax_region);
47-
return 0;
41+
return PTR_ERR_OR_ZERO(devm_create_dev_dax(&data));
4842
}
4943

5044
static struct platform_driver dax_hmem_driver = {

drivers/dax/pmem.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ static struct dev_dax *__dax_pmem_probe(struct device *dev)
1313
int rc, id, region_id;
1414
resource_size_t offset;
1515
struct nd_pfn_sb *pfn_sb;
16-
struct dev_dax *dev_dax;
1716
struct dev_dax_data data;
1817
struct nd_namespace_io *nsio;
1918
struct dax_region *dax_region;
@@ -65,12 +64,8 @@ static struct dev_dax *__dax_pmem_probe(struct device *dev)
6564
.pgmap = &pgmap,
6665
.size = range_len(&range),
6766
};
68-
dev_dax = devm_create_dev_dax(&data);
6967

70-
/* child dev_dax instances now own the lifetime of the dax_region */
71-
dax_region_put(dax_region);
72-
73-
return dev_dax;
68+
return devm_create_dev_dax(&data);
7469
}
7570

7671
static int dax_pmem_probe(struct device *dev)

0 commit comments

Comments
 (0)