For callers that need to get the dev_dax struct from a dax_device in
order to call DAX APIs, add a dax_get_dev_dax() helper.

Signed-off-by: Dave Jiang <[email protected]>
---
 drivers/dax/bus.c   | 6 ++++++
 include/linux/dax.h | 7 +++++++
 2 files changed, 13 insertions(+)

diff --git a/drivers/dax/bus.c b/drivers/dax/bus.c
index 759163722e4c..a99db3739e45 100644
--- a/drivers/dax/bus.c
+++ b/drivers/dax/bus.c
@@ -1515,6 +1515,12 @@ static int dev_dax_zero_page_range(struct dax_device 
*dax_dev,
        return 0;
 }
 
+struct dax_device *dax_get_dev_dax(struct dev_dax *dev_dax)
+{
+       return dev_dax->dax_dev;
+}
+EXPORT_SYMBOL_GPL(dax_get_dev_dax);
+
 static long dev_dax_direct_access(struct dax_device *dax_dev, pgoff_t pgoff,
                                  long nr_pages, enum dax_access_mode mode,
                                  void **kaddr, unsigned long *pfn)
diff --git a/include/linux/dax.h b/include/linux/dax.h
index a5e1a3ca1a0d..da1413c8a21f 100644
--- a/include/linux/dax.h
+++ b/include/linux/dax.h
@@ -62,6 +62,9 @@ void set_dax_nomc(struct dax_device *dax_dev);
 void set_dax_synchronous(struct dax_device *dax_dev);
 size_t dax_recovery_write(struct dax_device *dax_dev, pgoff_t pgoff,
                void *addr, size_t bytes, struct iov_iter *i);
+struct dev_dax;
+struct dax_device *dax_get_dev_dax(struct dev_dax *dev_dax);
+
 /*
  * Check if given mapping is supported by the file / underlying device.
  */
@@ -122,6 +125,10 @@ static inline size_t dax_recovery_write(struct dax_device 
*dax_dev,
 {
        return 0;
 }
+static inline struct dax_device *dax_get_dev_dax(struct dev_dax *dev_dax)
+{
+       return NULL;
+}
 #endif
 
 struct writeback_control;
-- 
2.53.0


Reply via email to