drivers/base: Add a DEVICE_BOOL_ATTR macro
... which, analogous to DEVICE_INT_ATTR provides functionality to set/clear bools. Its purpose is to be used where values need to be used as booleans in configuration context. Next patch uses this. Signed-off-by: Borislav Petkov <bp@alien8.de> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Acked-by: Tony Luck <tony.luck@intel.com>
Šī revīzija ir iekļauta:
@@ -171,6 +171,27 @@ ssize_t device_show_int(struct device *dev,
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(device_show_int);
|
||||
|
||||
ssize_t device_store_bool(struct device *dev, struct device_attribute *attr,
|
||||
const char *buf, size_t size)
|
||||
{
|
||||
struct dev_ext_attribute *ea = to_ext_attr(attr);
|
||||
|
||||
if (strtobool(buf, ea->var) < 0)
|
||||
return -EINVAL;
|
||||
|
||||
return size;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(device_store_bool);
|
||||
|
||||
ssize_t device_show_bool(struct device *dev, struct device_attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
struct dev_ext_attribute *ea = to_ext_attr(attr);
|
||||
|
||||
return snprintf(buf, PAGE_SIZE, "%d\n", *(bool *)(ea->var));
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(device_show_bool);
|
||||
|
||||
/**
|
||||
* device_release - free device structure.
|
||||
* @kobj: device's kobject.
|
||||
|
Atsaukties uz šo jaunā problēmā
Block a user