diff options
author | Borislav Petkov <bp@alien8.de> | 2012-10-09 13:52:05 -0400 |
---|---|---|
committer | Borislav Petkov <bp@alien8.de> | 2012-10-26 08:37:55 -0400 |
commit | 91872392f08486f692887d2f06a333f512648f22 (patch) | |
tree | 24f82690f04c3282c36bc81d60763687badf33c6 /drivers/base | |
parent | 6f0c0580b70c89094b3422ba81118c7b959c7556 (diff) |
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>
Diffstat (limited to 'drivers/base')
-rw-r--r-- | drivers/base/core.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/drivers/base/core.c b/drivers/base/core.c index abea76c36a4b..c8ae1f6b01b9 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c | |||
@@ -171,6 +171,27 @@ ssize_t device_show_int(struct device *dev, | |||
171 | } | 171 | } |
172 | EXPORT_SYMBOL_GPL(device_show_int); | 172 | EXPORT_SYMBOL_GPL(device_show_int); |
173 | 173 | ||
174 | ssize_t device_store_bool(struct device *dev, struct device_attribute *attr, | ||
175 | const char *buf, size_t size) | ||
176 | { | ||
177 | struct dev_ext_attribute *ea = to_ext_attr(attr); | ||
178 | |||
179 | if (strtobool(buf, ea->var) < 0) | ||
180 | return -EINVAL; | ||
181 | |||
182 | return size; | ||
183 | } | ||
184 | EXPORT_SYMBOL_GPL(device_store_bool); | ||
185 | |||
186 | ssize_t device_show_bool(struct device *dev, struct device_attribute *attr, | ||
187 | char *buf) | ||
188 | { | ||
189 | struct dev_ext_attribute *ea = to_ext_attr(attr); | ||
190 | |||
191 | return snprintf(buf, PAGE_SIZE, "%d\n", *(bool *)(ea->var)); | ||
192 | } | ||
193 | EXPORT_SYMBOL_GPL(device_show_bool); | ||
194 | |||
174 | /** | 195 | /** |
175 | * device_release - free device structure. | 196 | * device_release - free device structure. |
176 | * @kobj: device's kobject. | 197 | * @kobj: device's kobject. |