mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-30 12:13:51 -04:00
hwmon: Support guard() and scoped_guard for subsystem locks
Add support for guard() and scoped_guard() for the hwmon subsystem lock to simplify its use. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
This commit is contained in:
@@ -85,9 +85,10 @@ removal.
|
|||||||
When using ``[devm_]hwmon_device_register_with_info()`` to register the
|
When using ``[devm_]hwmon_device_register_with_info()`` to register the
|
||||||
hardware monitoring device, accesses using the associated access functions
|
hardware monitoring device, accesses using the associated access functions
|
||||||
are serialised by the hardware monitoring core. If a driver needs locking
|
are serialised by the hardware monitoring core. If a driver needs locking
|
||||||
for other functions such as interrupt handlers or for attributes which are
|
for other functions such as interrupt handlers, attributes which are fully
|
||||||
fully implemented in the driver, hwmon_lock() and hwmon_unlock() can be used
|
implemented in the driver, or debugfs functions, hwmon_lock() and hwmon_unlock()
|
||||||
to ensure that calls to those functions are serialized.
|
can be used to ensure that calls to those functions are serialized. Those
|
||||||
|
functions also support guard() and scoped_guard() variants.
|
||||||
|
|
||||||
Using devm_hwmon_device_register_with_info()
|
Using devm_hwmon_device_register_with_info()
|
||||||
--------------------------------------------
|
--------------------------------------------
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
#define _HWMON_H_
|
#define _HWMON_H_
|
||||||
|
|
||||||
#include <linux/bitops.h>
|
#include <linux/bitops.h>
|
||||||
|
#include <linux/cleanup.h>
|
||||||
|
|
||||||
struct device;
|
struct device;
|
||||||
struct attribute_group;
|
struct attribute_group;
|
||||||
@@ -495,6 +496,8 @@ char *devm_hwmon_sanitize_name(struct device *dev, const char *name);
|
|||||||
void hwmon_lock(struct device *dev);
|
void hwmon_lock(struct device *dev);
|
||||||
void hwmon_unlock(struct device *dev);
|
void hwmon_unlock(struct device *dev);
|
||||||
|
|
||||||
|
DEFINE_GUARD(hwmon_lock, struct device *, hwmon_lock(_T), hwmon_unlock(_T))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* hwmon_is_bad_char - Is the char invalid in a hwmon name
|
* hwmon_is_bad_char - Is the char invalid in a hwmon name
|
||||||
* @ch: the char to be considered
|
* @ch: the char to be considered
|
||||||
|
|||||||
Reference in New Issue
Block a user