Skip to content

Commit a1e9ca6

Browse files
committed
PM / sleep: Add support for read-only sysfs attributes
Some sysfs attributes in /sys/power/ should really be read-only, so add support for that, convert those attributes to read-only and drop the stub .show() routines from them. Original-by: Sergey Senozhatsky <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 013c074 commit a1e9ca6

File tree

2 files changed

+11
-15
lines changed

2 files changed

+11
-15
lines changed

kernel/power/main.c

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -280,13 +280,7 @@ static ssize_t pm_wakeup_irq_show(struct kobject *kobj,
280280
return pm_wakeup_irq ? sprintf(buf, "%u\n", pm_wakeup_irq) : -ENODATA;
281281
}
282282

283-
static ssize_t pm_wakeup_irq_store(struct kobject *kobj,
284-
struct kobj_attribute *attr,
285-
const char *buf, size_t n)
286-
{
287-
return -EINVAL;
288-
}
289-
power_attr(pm_wakeup_irq);
283+
power_attr_ro(pm_wakeup_irq);
290284

291285
#else /* !CONFIG_PM_SLEEP_DEBUG */
292286
static inline void pm_print_times_init(void) {}
@@ -564,14 +558,7 @@ static ssize_t pm_trace_dev_match_show(struct kobject *kobj,
564558
return show_trace_dev_match(buf, PAGE_SIZE);
565559
}
566560

567-
static ssize_t
568-
pm_trace_dev_match_store(struct kobject *kobj, struct kobj_attribute *attr,
569-
const char *buf, size_t n)
570-
{
571-
return -EINVAL;
572-
}
573-
574-
power_attr(pm_trace_dev_match);
561+
power_attr_ro(pm_trace_dev_match);
575562

576563
#endif /* CONFIG_PM_TRACE */
577564

kernel/power/power.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,15 @@ static struct kobj_attribute _name##_attr = { \
7777
.store = _name##_store, \
7878
}
7979

80+
#define power_attr_ro(_name) \
81+
static struct kobj_attribute _name##_attr = { \
82+
.attr = { \
83+
.name = __stringify(_name), \
84+
.mode = S_IRUGO, \
85+
}, \
86+
.show = _name##_show, \
87+
}
88+
8089
/* Preferred image size in bytes (default 500 MB) */
8190
extern unsigned long image_size;
8291
/* Size of memory reserved for drivers (default SPARE_PAGES x PAGE_SIZE) */

0 commit comments

Comments
 (0)