diff options
author | Felipe Balbi <balbi@ti.com> | 2013-02-20 03:31:42 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-03-15 12:39:15 -0400 |
commit | 8f46baaa7ec6cd0851794020b31958e64679dd26 (patch) | |
tree | d075f91c3a8ef47237df697664efb22b7e676a14 /drivers/base/core.c | |
parent | be871b7e54711479d3b9d3617d49898770830db2 (diff) |
base: core: WARN() about bogus permissions on device attributes
Whenever a struct device_attribute is registered
with mismatched permissions - read permission without
a show routine or write permission without store
routine - we will issue a big warning so we catch
those early enough.
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/base/core.c')
-rw-r--r-- | drivers/base/core.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/drivers/base/core.c b/drivers/base/core.c index 56536f4b0f6b..a7391a30cb29 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c | |||
@@ -563,8 +563,15 @@ int device_create_file(struct device *dev, | |||
563 | const struct device_attribute *attr) | 563 | const struct device_attribute *attr) |
564 | { | 564 | { |
565 | int error = 0; | 565 | int error = 0; |
566 | if (dev) | 566 | |
567 | if (dev) { | ||
568 | WARN(((attr->attr.mode & S_IWUGO) && !attr->store), | ||
569 | "Write permission without 'store'\n"); | ||
570 | WARN(((attr->attr.mode & S_IRUGO) && !attr->show), | ||
571 | "Read permission without 'show'\n"); | ||
567 | error = sysfs_create_file(&dev->kobj, &attr->attr); | 572 | error = sysfs_create_file(&dev->kobj, &attr->attr); |
573 | } | ||
574 | |||
568 | return error; | 575 | return error; |
569 | } | 576 | } |
570 | 577 | ||