[RFC 4/6] Driver core: Easy macros to encourage const attributes

From: Phil Carmody
Date: Thu Dec 17 2009 - 13:13:56 EST


It's too easy to type DEVICE_ATTR and not think of adding
a 'const', make it just as easy to get const as part of the
macro.

Signed-off-by: Phil Carmody <ext-phil.2.carmody@xxxxxxxxx>
---
include/linux/device.h | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/include/linux/device.h b/include/linux/device.h
index d07f90f..ea8ced6 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -165,6 +165,10 @@ struct driver_attribute {
struct driver_attribute driver_attr_##_name = \
__ATTR(_name, _mode, _show, _store)

+#define DRIVER_CATTR(_name, _mode, _show, _store) \
+const struct driver_attribute driver_attr_##_name = \
+ __ATTR(_name, _mode, _show, _store)
+
extern int __must_check driver_create_file(struct device_driver *driver,
const struct driver_attribute *attr);
extern void driver_remove_file(struct device_driver *driver,
@@ -318,6 +322,10 @@ struct device_attribute {
#define DEVICE_ATTR(_name, _mode, _show, _store) \
struct device_attribute dev_attr_##_name = __ATTR(_name, _mode, _show, _store)

+#define DEVICE_CATTR(_name, _mode, _show, _store) \
+const struct device_attribute dev_attr_##_name = \
+ __ATTR(_name, _mode, _show, _store)
+
extern int __must_check device_create_file(struct device *device,
const struct device_attribute *entry);
extern void device_remove_file(struct device *dev,
--
1.6.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/