mirror of https://gitee.com/openkylin/linux.git
libnvdimm: replace mutex_is_locked() warnings with lockdep_assert_held
For warnings that should only ever trigger during development and testing replace WARN statements with lockdep_assert_held. The lockdep pattern is prevalent, and these paths are are well covered by libnvdimm unit tests. Reported-by: Johannes Thumshirn <jthumshirn@suse.de> Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
This commit is contained in:
parent
af7d9f0c57
commit
9cf8bd529c
|
@ -22,9 +22,8 @@ void __nd_detach_ndns(struct device *dev, struct nd_namespace_common **_ndns)
|
||||||
{
|
{
|
||||||
struct nd_namespace_common *ndns = *_ndns;
|
struct nd_namespace_common *ndns = *_ndns;
|
||||||
|
|
||||||
dev_WARN_ONCE(dev, !mutex_is_locked(&ndns->dev.mutex)
|
lockdep_assert_held(&ndns->dev.mutex);
|
||||||
|| ndns->claim != dev,
|
dev_WARN_ONCE(dev, ndns->claim != dev, "%s: invalid claim\n", __func__);
|
||||||
"%s: invalid claim\n", __func__);
|
|
||||||
ndns->claim = NULL;
|
ndns->claim = NULL;
|
||||||
*_ndns = NULL;
|
*_ndns = NULL;
|
||||||
put_device(&ndns->dev);
|
put_device(&ndns->dev);
|
||||||
|
@ -49,9 +48,8 @@ bool __nd_attach_ndns(struct device *dev, struct nd_namespace_common *attach,
|
||||||
{
|
{
|
||||||
if (attach->claim)
|
if (attach->claim)
|
||||||
return false;
|
return false;
|
||||||
dev_WARN_ONCE(dev, !mutex_is_locked(&attach->dev.mutex)
|
lockdep_assert_held(&attach->dev.mutex);
|
||||||
|| *_ndns,
|
dev_WARN_ONCE(dev, *_ndns, "%s: invalid claim\n", __func__);
|
||||||
"%s: invalid claim\n", __func__);
|
|
||||||
attach->claim = dev;
|
attach->claim = dev;
|
||||||
*_ndns = attach;
|
*_ndns = attach;
|
||||||
get_device(&attach->dev);
|
get_device(&attach->dev);
|
||||||
|
|
|
@ -1653,7 +1653,7 @@ static int select_pmem_id(struct nd_region *nd_region, u8 *pmem_id)
|
||||||
u64 hw_start, hw_end, pmem_start, pmem_end;
|
u64 hw_start, hw_end, pmem_start, pmem_end;
|
||||||
struct nd_label_ent *label_ent;
|
struct nd_label_ent *label_ent;
|
||||||
|
|
||||||
WARN_ON(!mutex_is_locked(&nd_mapping->lock));
|
lockdep_assert_held(&nd_mapping->lock);
|
||||||
list_for_each_entry(label_ent, &nd_mapping->labels, list) {
|
list_for_each_entry(label_ent, &nd_mapping->labels, list) {
|
||||||
nd_label = label_ent->label;
|
nd_label = label_ent->label;
|
||||||
if (!nd_label)
|
if (!nd_label)
|
||||||
|
|
|
@ -509,7 +509,7 @@ void nd_mapping_free_labels(struct nd_mapping *nd_mapping)
|
||||||
{
|
{
|
||||||
struct nd_label_ent *label_ent, *e;
|
struct nd_label_ent *label_ent, *e;
|
||||||
|
|
||||||
WARN_ON(!mutex_is_locked(&nd_mapping->lock));
|
lockdep_assert_held(&nd_mapping->lock);
|
||||||
list_for_each_entry_safe(label_ent, e, &nd_mapping->labels, list) {
|
list_for_each_entry_safe(label_ent, e, &nd_mapping->labels, list) {
|
||||||
list_del(&label_ent->list);
|
list_del(&label_ent->list);
|
||||||
kfree(label_ent);
|
kfree(label_ent);
|
||||||
|
|
Loading…
Reference in New Issue