@@ -360,6 +360,7 @@ struct nvdimm_bus *nvdimm_bus_register(struct device *parent,
if (rc)
goto err;
+ nvdimm_set_lock_class(&nvdimm_bus->dev);
rc = device_add(&nvdimm_bus->dev);
if (rc) {
dev_dbg(&nvdimm_bus->dev, "registration failed: %d\n", rc);
@@ -485,6 +486,7 @@ static void nd_async_device_register(void *d, async_cookie_t cookie)
{
struct device *dev = d;
+ nvdimm_set_lock_class(dev);
if (device_add(dev) != 0) {
dev_err(dev, "%s: failed\n", __func__);
put_device(dev);
@@ -738,6 +740,7 @@ int nvdimm_bus_create_ndctl(struct nvdimm_bus *nvdimm_bus)
if (rc)
goto err;
+ nvdimm_set_lock_class(dev);
rc = device_add(dev);
if (rc) {
dev_dbg(&nvdimm_bus->dev, "failed to register ndctl%d: %d\n",
@@ -191,5 +191,14 @@ static inline int nvdimm_lock_class(struct device *dev)
else
return -1;
}
+
+static inline void nvdimm_set_lock_class(struct device *dev)
+{
+ device_set_lock_class(dev, nvdimm_lock_class(dev));
+}
+#else
+static inline void nvdimm_set_lock_class(struct device *dev)
+{
+}
#endif
#endif /* __ND_CORE_H__ */