Lines Matching refs:nd_pfn
27 struct nd_pfn *nd_pfn = to_nd_pfn(dev); in nd_pfn_release() local
30 nd_detach_ndns(&nd_pfn->dev, &nd_pfn->ndns); in nd_pfn_release()
31 ida_simple_remove(&nd_region->pfn_ida, nd_pfn->id); in nd_pfn_release()
32 kfree(nd_pfn->uuid); in nd_pfn_release()
33 kfree(nd_pfn); in nd_pfn_release()
47 struct nd_pfn *to_nd_pfn(struct device *dev) in to_nd_pfn()
49 struct nd_pfn *nd_pfn = container_of(dev, struct nd_pfn, dev); in to_nd_pfn() local
52 return nd_pfn; in to_nd_pfn()
59 struct nd_pfn *nd_pfn = to_nd_pfn(dev); in mode_show() local
61 switch (nd_pfn->mode) { in mode_show()
74 struct nd_pfn *nd_pfn = to_nd_pfn(dev); in mode_store() local
90 nd_pfn->mode = PFN_MODE_RAM; in mode_store()
93 nd_pfn->mode = PFN_MODE_NONE; in mode_store()
109 struct nd_pfn *nd_pfn = to_nd_pfn(dev); in uuid_show() local
111 if (nd_pfn->uuid) in uuid_show()
112 return sprintf(buf, "%pUb\n", nd_pfn->uuid); in uuid_show()
119 struct nd_pfn *nd_pfn = to_nd_pfn(dev); in uuid_store() local
123 rc = nd_uuid_store(dev, &nd_pfn->uuid, buf, len); in uuid_store()
135 struct nd_pfn *nd_pfn = to_nd_pfn(dev); in namespace_show() local
139 rc = sprintf(buf, "%s\n", nd_pfn->ndns in namespace_show()
140 ? dev_name(&nd_pfn->ndns->dev) : ""); in namespace_show()
148 struct nd_pfn *nd_pfn = to_nd_pfn(dev); in namespace_store() local
153 rc = nd_namespace_store(dev, &nd_pfn->ndns, buf, len); in namespace_store()
185 struct nd_pfn *nd_pfn; in __nd_pfn_create() local
192 nd_pfn = kzalloc(sizeof(*nd_pfn), GFP_KERNEL); in __nd_pfn_create()
193 if (!nd_pfn) in __nd_pfn_create()
196 nd_pfn->id = ida_simple_get(&nd_region->pfn_ida, 0, 0, GFP_KERNEL); in __nd_pfn_create()
197 if (nd_pfn->id < 0) { in __nd_pfn_create()
198 kfree(nd_pfn); in __nd_pfn_create()
202 nd_pfn->mode = mode; in __nd_pfn_create()
205 nd_pfn->uuid = uuid; in __nd_pfn_create()
206 dev = &nd_pfn->dev; in __nd_pfn_create()
207 dev_set_name(dev, "pfn%d.%d", nd_region->id, nd_pfn->id); in __nd_pfn_create()
211 device_initialize(&nd_pfn->dev); in __nd_pfn_create()
212 if (ndns && !__nd_attach_ndns(&nd_pfn->dev, ndns, &nd_pfn->ndns)) { in __nd_pfn_create()
231 int nd_pfn_validate(struct nd_pfn *nd_pfn) in nd_pfn_validate() argument
233 struct nd_namespace_common *ndns = nd_pfn->ndns; in nd_pfn_validate()
234 struct nd_pfn_sb *pfn_sb = nd_pfn->pfn_sb; in nd_pfn_validate()
241 if (!is_nd_pmem(nd_pfn->dev.parent)) in nd_pfn_validate()
270 if (!nd_pfn->uuid) { in nd_pfn_validate()
272 nd_pfn->uuid = kmemdup(pfn_sb->uuid, 16, GFP_KERNEL); in nd_pfn_validate()
273 if (!nd_pfn->uuid) in nd_pfn_validate()
277 if (memcmp(nd_pfn->uuid, pfn_sb->uuid, 16) != 0) in nd_pfn_validate()
290 dev_err(&nd_pfn->dev, in nd_pfn_validate()
295 dev_err(&nd_pfn->dev, "pfn array size exceeds capacity of %s\n", in nd_pfn_validate()
308 struct nd_pfn *nd_pfn; in nd_pfn_probe() local
322 nd_pfn = to_nd_pfn(dev); in nd_pfn_probe()
323 nd_pfn->pfn_sb = pfn_sb; in nd_pfn_probe()
324 rc = nd_pfn_validate(nd_pfn); in nd_pfn_probe()
325 nd_pfn->pfn_sb = NULL; in nd_pfn_probe()
330 __nd_detach_ndns(dev, &nd_pfn->ndns); in nd_pfn_probe()
333 __nd_device_register(&nd_pfn->dev); in nd_pfn_probe()