Skip to content

Commit 243f29f

Browse files
committed
libnvdimm: add an api to cast a 'struct nd_region' to its 'struct device'
For debug, it is useful for bus providers to be able to retrieve the 'struct device' associated with an nd_region instance that it registered. We already have to_nd_region() to perform the reverse cast operation, in fact its duplicate declaration can be removed from the private drivers/nvdimm/nd.h header. Reviewed-by: Dave Jiang <dave.jiang@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
1 parent 7872713 commit 243f29f

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

drivers/nvdimm/nd.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,6 @@ static inline struct device *nd_dax_create(struct nd_region *nd_region)
341341
}
342342
#endif
343343

344-
struct nd_region *to_nd_region(struct device *dev);
345344
int nd_region_to_nstype(struct nd_region *nd_region);
346345
int nd_region_register_namespaces(struct nd_region *nd_region, int *err);
347346
u64 nd_region_interleave_set_cookie(struct nd_region *nd_region,

drivers/nvdimm/region_devs.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,14 @@ struct nd_region *to_nd_region(struct device *dev)
182182
}
183183
EXPORT_SYMBOL_GPL(to_nd_region);
184184

185+
struct device *nd_region_dev(struct nd_region *nd_region)
186+
{
187+
if (!nd_region)
188+
return NULL;
189+
return &nd_region->dev;
190+
}
191+
EXPORT_SYMBOL_GPL(nd_region_dev);
192+
185193
struct nd_blk_region *to_nd_blk_region(struct device *dev)
186194
{
187195
struct nd_region *nd_region = to_nd_region(dev);

include/linux/libnvdimm.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ void nvdimm_bus_unregister(struct nvdimm_bus *nvdimm_bus);
164164
struct nvdimm_bus *to_nvdimm_bus(struct device *dev);
165165
struct nvdimm *to_nvdimm(struct device *dev);
166166
struct nd_region *to_nd_region(struct device *dev);
167+
struct device *nd_region_dev(struct nd_region *nd_region);
167168
struct nd_blk_region *to_nd_blk_region(struct device *dev);
168169
struct nvdimm_bus_descriptor *to_nd_desc(struct nvdimm_bus *nvdimm_bus);
169170
struct device *to_nvdimm_bus_dev(struct nvdimm_bus *nvdimm_bus);

0 commit comments

Comments
 (0)