Lines Matching refs:nvdimm_map

53 struct nvdimm_map {  struct
66 static struct nvdimm_map *find_nvdimm_map(struct device *dev, in find_nvdimm_map() argument
70 struct nvdimm_map *nvdimm_map; in find_nvdimm_map() local
72 list_for_each_entry(nvdimm_map, &nvdimm_bus->mapping_list, list) in find_nvdimm_map()
73 if (nvdimm_map->offset == offset) in find_nvdimm_map()
74 return nvdimm_map; in find_nvdimm_map()
78 static struct nvdimm_map *alloc_nvdimm_map(struct device *dev, in alloc_nvdimm_map()
82 struct nvdimm_map *nvdimm_map; in alloc_nvdimm_map() local
84 nvdimm_map = kzalloc(sizeof(*nvdimm_map), GFP_KERNEL); in alloc_nvdimm_map()
85 if (!nvdimm_map) in alloc_nvdimm_map()
88 INIT_LIST_HEAD(&nvdimm_map->list); in alloc_nvdimm_map()
89 nvdimm_map->nvdimm_bus = nvdimm_bus; in alloc_nvdimm_map()
90 nvdimm_map->offset = offset; in alloc_nvdimm_map()
91 nvdimm_map->flags = flags; in alloc_nvdimm_map()
92 nvdimm_map->size = size; in alloc_nvdimm_map()
93 kref_init(&nvdimm_map->kref); in alloc_nvdimm_map()
102 nvdimm_map->mem = memremap(offset, size, flags); in alloc_nvdimm_map()
104 nvdimm_map->iomem = ioremap(offset, size); in alloc_nvdimm_map()
106 if (!nvdimm_map->mem) in alloc_nvdimm_map()
111 list_add(&nvdimm_map->list, &nvdimm_bus->mapping_list); in alloc_nvdimm_map()
113 return nvdimm_map; in alloc_nvdimm_map()
118 kfree(nvdimm_map); in alloc_nvdimm_map()
125 struct nvdimm_map *nvdimm_map; in nvdimm_map_release() local
127 nvdimm_map = container_of(kref, struct nvdimm_map, kref); in nvdimm_map_release()
128 nvdimm_bus = nvdimm_map->nvdimm_bus; in nvdimm_map_release()
130 dev_dbg(&nvdimm_bus->dev, "%pa\n", &nvdimm_map->offset); in nvdimm_map_release()
131 list_del(&nvdimm_map->list); in nvdimm_map_release()
132 if (nvdimm_map->flags) in nvdimm_map_release()
133 memunmap(nvdimm_map->mem); in nvdimm_map_release()
135 iounmap(nvdimm_map->iomem); in nvdimm_map_release()
136 release_mem_region(nvdimm_map->offset, nvdimm_map->size); in nvdimm_map_release()
137 kfree(nvdimm_map); in nvdimm_map_release()
142 struct nvdimm_map *nvdimm_map = data; in nvdimm_map_put() local
143 struct nvdimm_bus *nvdimm_bus = nvdimm_map->nvdimm_bus; in nvdimm_map_put()
146 kref_put(&nvdimm_map->kref, nvdimm_map_release); in nvdimm_map_put()
160 struct nvdimm_map *nvdimm_map; in devm_nvdimm_memremap() local
163 nvdimm_map = find_nvdimm_map(dev, offset); in devm_nvdimm_memremap()
164 if (!nvdimm_map) in devm_nvdimm_memremap()
165 nvdimm_map = alloc_nvdimm_map(dev, offset, size, flags); in devm_nvdimm_memremap()
167 kref_get(&nvdimm_map->kref); in devm_nvdimm_memremap()
170 if (!nvdimm_map) in devm_nvdimm_memremap()
173 if (devm_add_action_or_reset(dev, nvdimm_map_put, nvdimm_map)) in devm_nvdimm_memremap()
176 return nvdimm_map->mem; in devm_nvdimm_memremap()