Lines Matching refs:nvdimm_bus
58 struct nvdimm_bus *nvdimm_bus = walk_to_nvdimm_bus(dev); in to_bus_provider() local
60 return nvdimm_bus->nd_desc->module; in to_bus_provider()
65 static void nvdimm_bus_probe_start(struct nvdimm_bus *nvdimm_bus) in nvdimm_bus_probe_start() argument
67 nvdimm_bus_lock(&nvdimm_bus->dev); in nvdimm_bus_probe_start()
68 nvdimm_bus->probe_active++; in nvdimm_bus_probe_start()
69 nvdimm_bus_unlock(&nvdimm_bus->dev); in nvdimm_bus_probe_start()
72 static void nvdimm_bus_probe_end(struct nvdimm_bus *nvdimm_bus) in nvdimm_bus_probe_end() argument
74 nvdimm_bus_lock(&nvdimm_bus->dev); in nvdimm_bus_probe_end()
75 if (--nvdimm_bus->probe_active == 0) in nvdimm_bus_probe_end()
76 wake_up(&nvdimm_bus->wait); in nvdimm_bus_probe_end()
77 nvdimm_bus_unlock(&nvdimm_bus->dev); in nvdimm_bus_probe_end()
84 struct nvdimm_bus *nvdimm_bus = walk_to_nvdimm_bus(dev); in nvdimm_bus_probe() local
90 dev_dbg(&nvdimm_bus->dev, "START: %s.probe(%s)\n", in nvdimm_bus_probe()
93 nvdimm_bus_probe_start(nvdimm_bus); in nvdimm_bus_probe()
101 nvdimm_bus_probe_end(nvdimm_bus); in nvdimm_bus_probe()
103 dev_dbg(&nvdimm_bus->dev, "END: %s.probe(%s) = %d\n", dev->driver->name, in nvdimm_bus_probe()
115 struct nvdimm_bus *nvdimm_bus = walk_to_nvdimm_bus(dev); in nvdimm_bus_remove() local
124 dev_dbg(&nvdimm_bus->dev, "%s.remove(%s) = %d\n", dev->driver->name, in nvdimm_bus_remove()
132 struct nvdimm_bus *nvdimm_bus = walk_to_nvdimm_bus(dev); in nvdimm_bus_shutdown() local
140 dev_dbg(&nvdimm_bus->dev, "%s.shutdown(%s)\n", in nvdimm_bus_shutdown()
161 struct nvdimm_bus *nvdimm_bus = walk_to_nvdimm_bus(&nd_region->dev); in nvdimm_region_notify() local
163 if (!nvdimm_bus) in nvdimm_region_notify()
203 static void nvdimm_clear_badblocks_regions(struct nvdimm_bus *nvdimm_bus, in nvdimm_clear_badblocks_regions() argument
211 device_for_each_child(&nvdimm_bus->dev, &ctx, in nvdimm_clear_badblocks_regions()
215 static void nvdimm_account_cleared_poison(struct nvdimm_bus *nvdimm_bus, in nvdimm_account_cleared_poison() argument
219 badrange_forget(&nvdimm_bus->badrange, phys, cleared); in nvdimm_account_cleared_poison()
222 nvdimm_clear_badblocks_regions(nvdimm_bus, phys, cleared); in nvdimm_account_cleared_poison()
228 struct nvdimm_bus *nvdimm_bus = walk_to_nvdimm_bus(dev); in nvdimm_clear_poison() local
236 if (!nvdimm_bus) in nvdimm_clear_poison()
239 nd_desc = nvdimm_bus->nd_desc; in nvdimm_clear_poison()
277 nvdimm_account_cleared_poison(nvdimm_bus, phys, clear_err.cleared); in nvdimm_clear_poison()
296 struct nvdimm_bus *nvdimm_bus; in nvdimm_bus_release() local
298 nvdimm_bus = container_of(dev, struct nvdimm_bus, dev); in nvdimm_bus_release()
299 ida_simple_remove(&nd_ida, nvdimm_bus->id); in nvdimm_bus_release()
300 kfree(nvdimm_bus); in nvdimm_bus_release()
313 struct nvdimm_bus *walk_to_nvdimm_bus(struct device *nd_dev) in walk_to_nvdimm_bus()
326 struct nvdimm_bus *to_nvdimm_bus(struct device *dev) in to_nvdimm_bus()
328 struct nvdimm_bus *nvdimm_bus; in to_nvdimm_bus() local
330 nvdimm_bus = container_of(dev, struct nvdimm_bus, dev); in to_nvdimm_bus()
332 return nvdimm_bus; in to_nvdimm_bus()
336 struct nvdimm_bus *nvdimm_to_bus(struct nvdimm *nvdimm) in nvdimm_to_bus()
342 struct nvdimm_bus *nvdimm_bus_register(struct device *parent, in nvdimm_bus_register()
345 struct nvdimm_bus *nvdimm_bus; in nvdimm_bus_register() local
348 nvdimm_bus = kzalloc(sizeof(*nvdimm_bus), GFP_KERNEL); in nvdimm_bus_register()
349 if (!nvdimm_bus) in nvdimm_bus_register()
351 INIT_LIST_HEAD(&nvdimm_bus->list); in nvdimm_bus_register()
352 INIT_LIST_HEAD(&nvdimm_bus->mapping_list); in nvdimm_bus_register()
353 init_waitqueue_head(&nvdimm_bus->wait); in nvdimm_bus_register()
354 nvdimm_bus->id = ida_simple_get(&nd_ida, 0, 0, GFP_KERNEL); in nvdimm_bus_register()
355 if (nvdimm_bus->id < 0) { in nvdimm_bus_register()
356 kfree(nvdimm_bus); in nvdimm_bus_register()
359 mutex_init(&nvdimm_bus->reconfig_mutex); in nvdimm_bus_register()
360 badrange_init(&nvdimm_bus->badrange); in nvdimm_bus_register()
361 nvdimm_bus->nd_desc = nd_desc; in nvdimm_bus_register()
362 nvdimm_bus->dev.parent = parent; in nvdimm_bus_register()
363 nvdimm_bus->dev.type = &nvdimm_bus_dev_type; in nvdimm_bus_register()
364 nvdimm_bus->dev.groups = nd_desc->attr_groups; in nvdimm_bus_register()
365 nvdimm_bus->dev.bus = &nvdimm_bus_type; in nvdimm_bus_register()
366 nvdimm_bus->dev.of_node = nd_desc->of_node; in nvdimm_bus_register()
367 dev_set_name(&nvdimm_bus->dev, "ndbus%d", nvdimm_bus->id); in nvdimm_bus_register()
368 rc = device_register(&nvdimm_bus->dev); in nvdimm_bus_register()
370 dev_dbg(&nvdimm_bus->dev, "registration failed: %d\n", rc); in nvdimm_bus_register()
374 return nvdimm_bus; in nvdimm_bus_register()
376 put_device(&nvdimm_bus->dev); in nvdimm_bus_register()
381 void nvdimm_bus_unregister(struct nvdimm_bus *nvdimm_bus) in nvdimm_bus_unregister() argument
383 if (!nvdimm_bus) in nvdimm_bus_unregister()
385 device_unregister(&nvdimm_bus->dev); in nvdimm_bus_unregister()
432 struct nvdimm_bus *nvdimm_bus = to_nvdimm_bus(dev); in nd_bus_remove() local
435 list_del_init(&nvdimm_bus->list); in nd_bus_remove()
438 wait_event(nvdimm_bus->wait, in nd_bus_remove()
439 atomic_read(&nvdimm_bus->ioctl_active) == 0); in nd_bus_remove()
442 device_for_each_child(&nvdimm_bus->dev, NULL, child_unregister); in nd_bus_remove()
444 spin_lock(&nvdimm_bus->badrange.lock); in nd_bus_remove()
445 free_badrange_list(&nvdimm_bus->badrange.list); in nd_bus_remove()
446 spin_unlock(&nvdimm_bus->badrange.lock); in nd_bus_remove()
448 nvdimm_bus_destroy_ndctl(nvdimm_bus); in nd_bus_remove()
455 struct nvdimm_bus *nvdimm_bus = to_nvdimm_bus(dev); in nd_bus_probe() local
458 rc = nvdimm_bus_create_ndctl(nvdimm_bus); in nd_bus_probe()
463 list_add_tail(&nvdimm_bus->list, &nvdimm_bus_list); in nd_bus_probe()
467 dev_set_drvdata(dev, nvdimm_bus->nd_desc); in nd_bus_probe()
736 int nvdimm_bus_create_ndctl(struct nvdimm_bus *nvdimm_bus) in nvdimm_bus_create_ndctl() argument
738 dev_t devt = MKDEV(nvdimm_bus_major, nvdimm_bus->id); in nvdimm_bus_create_ndctl()
741 dev = device_create(nd_class, &nvdimm_bus->dev, devt, nvdimm_bus, in nvdimm_bus_create_ndctl()
742 "ndctl%d", nvdimm_bus->id); in nvdimm_bus_create_ndctl()
745 dev_dbg(&nvdimm_bus->dev, "failed to register ndctl%d: %ld\n", in nvdimm_bus_create_ndctl()
746 nvdimm_bus->id, PTR_ERR(dev)); in nvdimm_bus_create_ndctl()
750 void nvdimm_bus_destroy_ndctl(struct nvdimm_bus *nvdimm_bus) in nvdimm_bus_destroy_ndctl() argument
752 device_destroy(nd_class, MKDEV(nvdimm_bus_major, nvdimm_bus->id)); in nvdimm_bus_destroy_ndctl()
918 struct nvdimm_bus *nvdimm_bus = walk_to_nvdimm_bus(dev); in wait_nvdimm_bus_probe_idle() local
921 if (nvdimm_bus->probe_active == 0) in wait_nvdimm_bus_probe_idle()
925 wait_event(nvdimm_bus->wait, in wait_nvdimm_bus_probe_idle()
926 nvdimm_bus->probe_active == 0); in wait_nvdimm_bus_probe_idle()
979 static int nd_cmd_clear_to_send(struct nvdimm_bus *nvdimm_bus, in nd_cmd_clear_to_send() argument
982 struct nvdimm_bus_descriptor *nd_desc = nvdimm_bus->nd_desc; in nd_cmd_clear_to_send()
994 return device_for_each_child(&nvdimm_bus->dev, data, in nd_cmd_clear_to_send()
1001 wait_nvdimm_bus_probe_idle(&nvdimm_bus->dev); in nd_cmd_clear_to_send()
1007 static int __nd_ioctl(struct nvdimm_bus *nvdimm_bus, struct nvdimm *nvdimm, in __nd_ioctl() argument
1010 struct nvdimm_bus_descriptor *nd_desc = nvdimm_bus->nd_desc; in __nd_ioctl()
1013 struct device *dev = &nvdimm_bus->dev; in __nd_ioctl()
1163 rc = nd_cmd_clear_to_send(nvdimm_bus, nvdimm, func, buf); in __nd_ioctl()
1174 nvdimm_account_cleared_poison(nvdimm_bus, clear_err->address, in __nd_ioctl()
1213 struct nvdimm_bus *nvdimm_bus, *found = NULL; in nd_ioctl() local
1220 list_for_each_entry(nvdimm_bus, &nvdimm_bus_list, list) { in nd_ioctl()
1224 dev = device_find_child(&nvdimm_bus->dev, in nd_ioctl()
1229 found = nvdimm_bus; in nd_ioctl()
1230 } else if (nvdimm_bus->id == id) { in nd_ioctl()
1231 found = nvdimm_bus; in nd_ioctl()
1235 atomic_inc(&nvdimm_bus->ioctl_active); in nd_ioctl()
1244 nvdimm_bus = found; in nd_ioctl()
1245 rc = __nd_ioctl(nvdimm_bus, nvdimm, ro, cmd, arg); in nd_ioctl()
1249 if (atomic_dec_and_test(&nvdimm_bus->ioctl_active)) in nd_ioctl()
1250 wake_up(&nvdimm_bus->wait); in nd_ioctl()