aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-07-14 19:05:54 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-07-16 13:57:36 -0400
commitced321bf9151535f85779b0004c93529f860b2a4 (patch)
tree34a2138580124c0a41c90c25bb450d0deba2e711 /include
parente4b63603c2a1e2c4db3de11b0f2b17360a7695bb (diff)
driver core: device.h: add RW and RO attribute macros
Make it easier to create attributes without having to always audit the mode settings. Reviewed-by: Guenter Roeck <linux@roeck-us.net> Tested-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'include')
-rw-r--r--include/linux/device.h28
1 files changed, 21 insertions, 7 deletions
diff --git a/include/linux/device.h b/include/linux/device.h
index bcf8c0d4cd98..f207a8f49f80 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -47,7 +47,11 @@ struct bus_attribute {
47}; 47};
48 48
49#define BUS_ATTR(_name, _mode, _show, _store) \ 49#define BUS_ATTR(_name, _mode, _show, _store) \
50struct bus_attribute bus_attr_##_name = __ATTR(_name, _mode, _show, _store) 50 struct bus_attribute bus_attr_##_name = __ATTR(_name, _mode, _show, _store)
51#define BUS_ATTR_RW(_name) \
52 struct bus_attribute bus_attr_##_name = __ATTR_RW(_name)
53#define BUS_ATTR_RO(_name) \
54 struct bus_attribute bus_attr_##_name = __ATTR_RO(_name)
51 55
52extern int __must_check bus_create_file(struct bus_type *, 56extern int __must_check bus_create_file(struct bus_type *,
53 struct bus_attribute *); 57 struct bus_attribute *);
@@ -261,9 +265,12 @@ struct driver_attribute {
261 size_t count); 265 size_t count);
262}; 266};
263 267
264#define DRIVER_ATTR(_name, _mode, _show, _store) \ 268#define DRIVER_ATTR(_name, _mode, _show, _store) \
265struct driver_attribute driver_attr_##_name = \ 269 struct driver_attribute driver_attr_##_name = __ATTR(_name, _mode, _show, _store)
266 __ATTR(_name, _mode, _show, _store) 270#define DRIVER_ATTR_RW(_name) \
271 struct driver_attribute driver_attr_##_name = __ATTR_RW(_name)
272#define DRIVER_ATTR_RO(_name) \
273 struct driver_attribute driver_attr_##_name = __ATTR_RO(_name)
267 274
268extern int __must_check driver_create_file(struct device_driver *driver, 275extern int __must_check driver_create_file(struct device_driver *driver,
269 const struct driver_attribute *attr); 276 const struct driver_attribute *attr);
@@ -414,8 +421,12 @@ struct class_attribute {
414 const struct class_attribute *attr); 421 const struct class_attribute *attr);
415}; 422};
416 423
417#define CLASS_ATTR(_name, _mode, _show, _store) \ 424#define CLASS_ATTR(_name, _mode, _show, _store) \
418struct class_attribute class_attr_##_name = __ATTR(_name, _mode, _show, _store) 425 struct class_attribute class_attr_##_name = __ATTR(_name, _mode, _show, _store)
426#define CLASS_ATTR_RW(_name) \
427 struct class_attribute class_attr_##_name = __ATTR_RW(_name)
428#define CLASS_ATTR_RO(_name) \
429 struct class_attribute class_attr_##_name = __ATTR_RO(_name)
419 430
420extern int __must_check class_create_file(struct class *class, 431extern int __must_check class_create_file(struct class *class,
421 const struct class_attribute *attr); 432 const struct class_attribute *attr);
@@ -423,7 +434,6 @@ extern void class_remove_file(struct class *class,
423 const struct class_attribute *attr); 434 const struct class_attribute *attr);
424 435
425/* Simple class attribute that is just a static string */ 436/* Simple class attribute that is just a static string */
426
427struct class_attribute_string { 437struct class_attribute_string {
428 struct class_attribute attr; 438 struct class_attribute attr;
429 char *str; 439 char *str;
@@ -512,6 +522,10 @@ ssize_t device_store_bool(struct device *dev, struct device_attribute *attr,
512 522
513#define DEVICE_ATTR(_name, _mode, _show, _store) \ 523#define DEVICE_ATTR(_name, _mode, _show, _store) \
514 struct device_attribute dev_attr_##_name = __ATTR(_name, _mode, _show, _store) 524 struct device_attribute dev_attr_##_name = __ATTR(_name, _mode, _show, _store)
525#define DEVICE_ATTR_RW(_name) \
526 struct device_attribute dev_attr_##_name = __ATTR_RW(_name)
527#define DEVICE_ATTR_RO(_name) \
528 struct device_attribute dev_attr_##_name = __ATTR_RO(_name)
515#define DEVICE_ULONG_ATTR(_name, _mode, _var) \ 529#define DEVICE_ULONG_ATTR(_name, _mode, _var) \
516 struct dev_ext_attribute dev_attr_##_name = \ 530 struct dev_ext_attribute dev_attr_##_name = \
517 { __ATTR(_name, _mode, device_show_ulong, device_store_ulong), &(_var) } 531 { __ATTR(_name, _mode, device_show_ulong, device_store_ulong), &(_var) }