Skip to content

Commit 134c6ea

Browse files
djbwgregkh
authored andcommitted
driver core: Add a guard() definition for the device_lock()
At present there are ~200 usages of device_lock() in the kernel. Some of those usages lead to "goto unlock;" patterns which have proven to be error prone. Define a "device" guard() definition to allow for those to be cleaned up and prevent new ones from appearing. Link: http://lore.kernel.org/r/657897453dda8_269bd29492@dwillia2-mobl3.amr.corp.intel.com.notmuch Link: http://lore.kernel.org/r/[email protected] Cc: Vishal Verma <[email protected]> Cc: Ira Weiny <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Greg Kroah-Hartman <[email protected]> Cc: Andrew Morton <[email protected]> Signed-off-by: Dan Williams <[email protected]> Reviewed-by: Ira Weiny <[email protected]> Reviewed-by: Dave Jiang <[email protected]> Reviewed-by: Vishal Verma <[email protected]> Link: https://lore.kernel.org/r/170250854466.1522182.17555361077409628655.stgit@dwillia2-xfh.jf.intel.com Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 76101fa commit 134c6ea

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

include/linux/device.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1007,6 +1007,8 @@ static inline void device_unlock(struct device *dev)
10071007
mutex_unlock(&dev->mutex);
10081008
}
10091009

1010+
DEFINE_GUARD(device, struct device *, device_lock(_T), device_unlock(_T))
1011+
10101012
static inline void device_lock_assert(struct device *dev)
10111013
{
10121014
lockdep_assert_held(&dev->mutex);

0 commit comments

Comments
 (0)