Skip to content

Commit

Permalink
driver core: Provide an wrapper around the mutex to do lockdep warnings
Browse files Browse the repository at this point in the history
Instead of open-coding it in drivers that want to double check
that their functions are indeed holding the device lock.

Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Suggested-by: David Vrabel <david.vrabel@citrix.com>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: David Vrabel <david.vrabel@citrix.com>
  • Loading branch information
Konrad Rzeszutek Wilk authored and David Vrabel committed Dec 4, 2014
1 parent e8801a7 commit ac80102
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/xen/xen-pciback/pci_stub.c
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ void pcistub_put_pci_dev(struct pci_dev *dev)
/* Cleanup our device
* (so it's ready for the next domain)
*/
lockdep_assert_held(&dev->dev.mutex);
device_lock_assert(&dev->dev);
__pci_reset_function_locked(dev);
pci_restore_state(dev);

Expand Down
5 changes: 5 additions & 0 deletions include/linux/device.h
Original file line number Diff line number Diff line change
Expand Up @@ -911,6 +911,11 @@ static inline void device_unlock(struct device *dev)
mutex_unlock(&dev->mutex);
}

static inline void device_lock_assert(struct device *dev)
{
lockdep_assert_held(&dev->mutex);
}

void driver_init(void);

/*
Expand Down

0 comments on commit ac80102

Please sign in to comment.