Loading...
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#include <linux/range.h>
7
8struct dev_dax;
9struct resource;
10struct dax_device;
11struct dax_region;
12void dax_region_put(struct dax_region *dax_region);
13
14#define IORESOURCE_DAX_STATIC (1UL << 0)
15struct dax_region *alloc_dax_region(struct device *parent, int region_id,
16 struct range *range, int target_node, unsigned int align,
17 unsigned long flags);
18
19struct dev_dax_data {
20 struct dax_region *dax_region;
21 struct dev_pagemap *pgmap;
22 resource_size_t size;
23 int id;
24};
25
26struct dev_dax *devm_create_dev_dax(struct dev_dax_data *data);
27
28struct dax_device_driver {
29 struct device_driver drv;
30 struct list_head ids;
31 int match_always;
32 int (*probe)(struct dev_dax *dev);
33 void (*remove)(struct dev_dax *dev);
34};
35
36int __dax_driver_register(struct dax_device_driver *dax_drv,
37 struct module *module, const char *mod_name);
38#define dax_driver_register(driver) \
39 __dax_driver_register(driver, THIS_MODULE, KBUILD_MODNAME)
40void dax_driver_unregister(struct dax_device_driver *dax_drv);
41void kill_dev_dax(struct dev_dax *dev_dax);
42bool static_dev_dax(struct dev_dax *dev_dax);
43
44/*
45 * While run_dax() is potentially a generic operation that could be
46 * defined in include/linux/dax.h we don't want to grow any users
47 * outside of drivers/dax/
48 */
49void run_dax(struct dax_device *dax_dev);
50
51#define MODULE_ALIAS_DAX_DEVICE(type) \
52 MODULE_ALIAS("dax:t" __stringify(type) "*")
53#define DAX_DEVICE_MODALIAS_FMT "dax:t%d"
54
55#endif /* __DAX_BUS_H__ */
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#include <linux/range.h>
7
8struct dev_dax;
9struct resource;
10struct dax_device;
11struct dax_region;
12void dax_region_put(struct dax_region *dax_region);
13
14#define IORESOURCE_DAX_STATIC (1UL << 0)
15struct dax_region *alloc_dax_region(struct device *parent, int region_id,
16 struct range *range, int target_node, unsigned int align,
17 unsigned long flags);
18
19enum dev_dax_subsys {
20 DEV_DAX_BUS = 0, /* zeroed dev_dax_data picks this by default */
21 DEV_DAX_CLASS,
22};
23
24struct dev_dax_data {
25 struct dax_region *dax_region;
26 struct dev_pagemap *pgmap;
27 enum dev_dax_subsys subsys;
28 resource_size_t size;
29 int id;
30};
31
32struct dev_dax *devm_create_dev_dax(struct dev_dax_data *data);
33
34/* to be deleted when DEV_DAX_CLASS is removed */
35struct dev_dax *__dax_pmem_probe(struct device *dev, enum dev_dax_subsys subsys);
36
37struct dax_device_driver {
38 struct device_driver drv;
39 struct list_head ids;
40 int match_always;
41 int (*probe)(struct dev_dax *dev);
42 void (*remove)(struct dev_dax *dev);
43};
44
45int __dax_driver_register(struct dax_device_driver *dax_drv,
46 struct module *module, const char *mod_name);
47#define dax_driver_register(driver) \
48 __dax_driver_register(driver, THIS_MODULE, KBUILD_MODNAME)
49void dax_driver_unregister(struct dax_device_driver *dax_drv);
50void kill_dev_dax(struct dev_dax *dev_dax);
51
52#if IS_ENABLED(CONFIG_DEV_DAX_PMEM_COMPAT)
53int dev_dax_probe(struct dev_dax *dev_dax);
54#endif
55
56/*
57 * While run_dax() is potentially a generic operation that could be
58 * defined in include/linux/dax.h we don't want to grow any users
59 * outside of drivers/dax/
60 */
61void run_dax(struct dax_device *dax_dev);
62
63#define MODULE_ALIAS_DAX_DEVICE(type) \
64 MODULE_ALIAS("dax:t" __stringify(type) "*")
65#define DAX_DEVICE_MODALIAS_FMT "dax:t%d"
66
67#endif /* __DAX_BUS_H__ */