Lines Matching refs:nd_btt

18 	struct nd_btt *nd_btt = to_nd_btt(dev);  in nd_btt_release()  local
21 nd_detach_ndns(&nd_btt->dev, &nd_btt->ndns); in nd_btt_release()
22 ida_simple_remove(&nd_region->btt_ida, nd_btt->id); in nd_btt_release()
23 kfree(nd_btt->uuid); in nd_btt_release()
24 kfree(nd_btt); in nd_btt_release()
27 struct nd_btt *to_nd_btt(struct device *dev) in to_nd_btt()
29 struct nd_btt *nd_btt = container_of(dev, struct nd_btt, dev); in to_nd_btt() local
32 return nd_btt; in to_nd_btt()
42 struct nd_btt *nd_btt = to_nd_btt(dev); in sector_size_show() local
44 return nd_size_select_show(nd_btt->lbasize, btt_lbasize_supported, buf); in sector_size_show()
50 struct nd_btt *nd_btt = to_nd_btt(dev); in sector_size_store() local
55 rc = nd_size_select_store(dev, buf, &nd_btt->lbasize, in sector_size_store()
69 struct nd_btt *nd_btt = to_nd_btt(dev); in uuid_show() local
71 if (nd_btt->uuid) in uuid_show()
72 return sprintf(buf, "%pUb\n", nd_btt->uuid); in uuid_show()
79 struct nd_btt *nd_btt = to_nd_btt(dev); in uuid_store() local
83 rc = nd_uuid_store(dev, &nd_btt->uuid, buf, len); in uuid_store()
95 struct nd_btt *nd_btt = to_nd_btt(dev); in namespace_show() local
99 rc = sprintf(buf, "%s\n", nd_btt->ndns in namespace_show()
100 ? dev_name(&nd_btt->ndns->dev) : ""); in namespace_show()
108 struct nd_btt *nd_btt = to_nd_btt(dev); in namespace_store() local
113 rc = nd_namespace_store(dev, &nd_btt->ndns, buf, len); in namespace_store()
126 struct nd_btt *nd_btt = to_nd_btt(dev); in size_show() local
131 rc = sprintf(buf, "%llu\n", nd_btt->size); in size_show()
187 struct nd_btt *nd_btt; in __nd_btt_create() local
190 nd_btt = kzalloc(sizeof(*nd_btt), GFP_KERNEL); in __nd_btt_create()
191 if (!nd_btt) in __nd_btt_create()
194 nd_btt->id = ida_simple_get(&nd_region->btt_ida, 0, 0, GFP_KERNEL); in __nd_btt_create()
195 if (nd_btt->id < 0) in __nd_btt_create()
198 nd_btt->lbasize = lbasize; in __nd_btt_create()
204 nd_btt->uuid = uuid; in __nd_btt_create()
205 dev = &nd_btt->dev; in __nd_btt_create()
206 dev_set_name(dev, "btt%d.%d", nd_region->id, nd_btt->id); in __nd_btt_create()
209 device_initialize(&nd_btt->dev); in __nd_btt_create()
210 lockdep_set_class(&nd_btt->dev.mutex, &nvdimm_btt_key); in __nd_btt_create()
211 if (ndns && !__nd_attach_ndns(&nd_btt->dev, ndns, &nd_btt->ndns)) { in __nd_btt_create()
220 ida_simple_remove(&nd_region->btt_ida, nd_btt->id); in __nd_btt_create()
223 kfree(nd_btt); in __nd_btt_create()
247 bool nd_btt_arena_is_valid(struct nd_btt *nd_btt, struct btt_sb *super) in nd_btt_arena_is_valid() argument
249 const uuid_t *ns_uuid = nd_dev_to_uuid(&nd_btt->ndns->dev); in nd_btt_arena_is_valid()
269 dev_info(&nd_btt->dev, "Found arena with an error flag\n"); in nd_btt_arena_is_valid()
275 int nd_btt_version(struct nd_btt *nd_btt, struct nd_namespace_common *ndns, in nd_btt_version() argument
280 nd_btt->initial_offset = 0; in nd_btt_version()
281 nd_btt->version_major = 2; in nd_btt_version()
282 nd_btt->version_minor = 0; in nd_btt_version()
285 if (!nd_btt_arena_is_valid(nd_btt, btt_sb)) in nd_btt_version()
295 nd_btt->initial_offset = SZ_4K; in nd_btt_version()
296 nd_btt->version_major = 1; in nd_btt_version()
297 nd_btt->version_minor = 1; in nd_btt_version()
300 if (!nd_btt_arena_is_valid(nd_btt, btt_sb)) in nd_btt_version()
310 static int __nd_btt_probe(struct nd_btt *nd_btt, in __nd_btt_probe() argument
315 if (!btt_sb || !ndns || !nd_btt) in __nd_btt_probe()
321 rc = nd_btt_version(nd_btt, ndns, btt_sb); in __nd_btt_probe()
325 nd_btt->lbasize = le32_to_cpu(btt_sb->external_lbasize); in __nd_btt_probe()
326 nd_btt->uuid = kmemdup(&btt_sb->uuid, sizeof(uuid_t), GFP_KERNEL); in __nd_btt_probe()
327 if (!nd_btt->uuid) in __nd_btt_probe()
330 nd_device_register(&nd_btt->dev); in __nd_btt_probe()
363 struct nd_btt *nd_btt = to_nd_btt(btt_dev); in nd_btt_probe() local
365 nd_detach_ndns(btt_dev, &nd_btt->ndns); in nd_btt_probe()