xref: /linux/drivers/dax/bus.h (revision ec826909981c0b3262681ed7021b959593426d46)
1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright(c) 2016 - 2018 Intel Corporation. All rights reserved. */
3 #ifndef __DAX_BUS_H__
4 #define __DAX_BUS_H__
5 #include <linux/device.h>
6 
7 struct dev_dax;
8 struct resource;
9 struct dax_device;
10 struct dax_region;
11 void dax_region_put(struct dax_region *dax_region);
12 struct dax_region *alloc_dax_region(struct device *parent, int region_id,
13 		struct resource *res, int target_node, unsigned int align);
14 
15 enum dev_dax_subsys {
16 	DEV_DAX_BUS,
17 	DEV_DAX_CLASS,
18 };
19 
20 struct dev_dax *__devm_create_dev_dax(struct dax_region *dax_region, int id,
21 		struct dev_pagemap *pgmap, enum dev_dax_subsys subsys);
22 
23 static inline struct dev_dax *devm_create_dev_dax(struct dax_region *dax_region,
24 		int id, struct dev_pagemap *pgmap)
25 {
26 	return __devm_create_dev_dax(dax_region, id, pgmap, DEV_DAX_BUS);
27 }
28 
29 /* to be deleted when DEV_DAX_CLASS is removed */
30 struct dev_dax *__dax_pmem_probe(struct device *dev, enum dev_dax_subsys subsys);
31 
32 struct dax_device_driver {
33 	struct device_driver drv;
34 	struct list_head ids;
35 	int match_always;
36 };
37 
38 int __dax_driver_register(struct dax_device_driver *dax_drv,
39 		struct module *module, const char *mod_name);
40 #define dax_driver_register(driver) \
41 	__dax_driver_register(driver, THIS_MODULE, KBUILD_MODNAME)
42 void dax_driver_unregister(struct dax_device_driver *dax_drv);
43 void kill_dev_dax(struct dev_dax *dev_dax);
44 
45 #if IS_ENABLED(CONFIG_DEV_DAX_PMEM_COMPAT)
46 int dev_dax_probe(struct device *dev);
47 #endif
48 
49 /*
50  * While run_dax() is potentially a generic operation that could be
51  * defined in include/linux/dax.h we don't want to grow any users
52  * outside of drivers/dax/
53  */
54 void run_dax(struct dax_device *dax_dev);
55 
56 #define MODULE_ALIAS_DAX_DEVICE(type) \
57 	MODULE_ALIAS("dax:t" __stringify(type) "*")
58 #define DAX_DEVICE_MODALIAS_FMT "dax:t%d"
59 
60 #endif /* __DAX_BUS_H__ */
61