#ifndef __DAX_H__
#define __DAX_H__
struct dax_device;
-struct dax_device *alloc_dax(void *private, const char *host);
+struct dax_operations;
+struct dax_device *alloc_dax(void *private, const char *host,
+ const struct dax_operations *ops);
void put_dax(struct dax_device *dax_dev);
bool dax_alive(struct dax_device *dax_dev);
void kill_dax(struct dax_device *dax_dev);
goto err_id;
}
- dax_dev = alloc_dax(dev_dax, NULL);
+ /*
+ * No 'host' or dax_operations since there is no access to this
+ * device outside of mmap of the resulting character device.
+ */
+ dax_dev = alloc_dax(dev_dax, NULL, NULL);
if (!dax_dev)
goto err_dax;
#include <linux/cdev.h>
#include <linux/hash.h>
#include <linux/slab.h>
+#include <linux/dax.h>
#include <linux/fs.h>
static int nr_dax = CONFIG_NR_DEV_DAX;
const char *host;
void *private;
bool alive;
+ const struct dax_operations *ops;
};
bool dax_alive(struct dax_device *dax_dev)
spin_unlock(&dax_host_lock);
}
-struct dax_device *alloc_dax(void *private, const char *__host)
+struct dax_device *alloc_dax(void *private, const char *__host,
+ const struct dax_operations *ops)
{
struct dax_device *dax_dev;
const char *host;
goto err_dev;
dax_add_host(dax_dev, host);
+ dax_dev->ops = ops;
dax_dev->private = private;
return dax_dev;
#include <asm/pgtable.h>
struct iomap_ops;
+struct dax_device;
+struct dax_operations {
+ /*
+ * direct_access: translate a device-relative
+ * logical-page-offset into an absolute physical pfn. Return the
+ * number of pages available for DAX at that pfn.
+ */
+ long (*direct_access)(struct dax_device *, pgoff_t, long,
+ void **, pfn_t *);
+};
int dax_read_lock(void);
void dax_read_unlock(int id);