Skip to contentSkip to conversation

power/poweroff.c: mark variables with __initdata and __maybe_unused

PATCH In review Nikitas Angelinas 2 participants 4 messages May 2, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 power/poweroff.c: mark variables with __initdata and __maybe_unused

There is no need to keep sysrq_poweroff_op after initialization, so mark it with __initdata. Mark some of the function parameters with __maybe_unused to avoid compilation warnings.

---
 kernel/power/poweroff.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
kernel/power/poweroff.c +4 -3
index 7ef6866..d507152 100644
@@ -11,26 +11,27 @@
 #include <linux/workqueue.h>
 #include <linux/reboot.h>
 #include <linux/cpumask.h>
+#include <linux/compiler_attributes.h>
 
 /*
  * When the user hits Sys-Rq o to power down the machine this is the
  * callback we use.
  */
 
-static void do_poweroff(struct work_struct *dummy)
+static void do_poweroff(struct work_struct *dummy __maybe_unused)
 {
 	kernel_power_off();
 }
 
 static DECLARE_WORK(poweroff_work, do_poweroff);
 
-static void handle_poweroff(int key)
+static void handle_poweroff(int key __maybe_unused)
 {
 	/* run sysrq poweroff on boot cpu */
 	schedule_work_on(cpumask_first(cpu_online_mask), &poweroff_work);
 }
 
-static struct sysrq_key_op	sysrq_poweroff_op = {
+static struct sysrq_key_op sysrq_poweroff_op __initdata = {
 	.handler        = handle_poweroff,
 	.help_msg       = "poweroff(o)",
 	.action_msg     = "Power Off",
Signature · 1 line
2.10.0
#1 lore raw
Quoted 2 lines · Nikitas Angelinas

There is no need to keep sysrq_poweroff_op after initialization, so mark it with __initdata.

Are you sure?

pavel@duo:/data/l/k$ grep -ri sysrq_key_op . | grep initdata
pavel@duo:/data/l/k$

Pavel

Quoted 6 lines
kernel/power/poweroff.c +1 -1
-static struct sysrq_key_op	sysrq_poweroff_op = {
+static struct sysrq_key_op sysrq_poweroff_op __initdata = {
 	.handler        = handle_poweroff,
 	.help_msg       = "poweroff(o)",
 	.action_msg     = "Power Off",
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#2 lore raw
Quoted 4 lines · Pavel Machek
Quoted 2 lines · Nikitas Angelinas

There is no need to keep sysrq_poweroff_op after initialization, so mark it with __initdata.

Quoted 8 lines

Are you sure?

pavel@duo:/data/l/k$ grep -ri sysrq_key_op . | grep initdata
pavel@duo:/data/l/k$

Pavel

I am sorry about this. I completely missed the point of registering this structure. Please ignore this patch.

Cheers,
Nikitas

Quoted 10 lines
Quoted 6 lines
kernel/power/poweroff.c +1 -1
-static struct sysrq_key_op	sysrq_poweroff_op = {
+static struct sysrq_key_op sysrq_poweroff_op __initdata = {
 	.handler        = handle_poweroff,
 	.help_msg       = "poweroff(o)",
 	.action_msg     = "Power Off",
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#3 lore raw
Quoted 7 lines · Nikitas Angelinas
Quoted 6 lines · Pavel Machek
Quoted 2 lines · Nikitas Angelinas

There is no need to keep sysrq_poweroff_op after initialization, so mark it with __initdata.

Are you sure?

Quoted 9 lines
Quoted 6 lines
pavel@duo:/data/l/k$ grep -ri sysrq_key_op . | grep initdata
pavel@duo:/data/l/k$

Pavel

I am sorry about this. I completely missed the point of registering this structure. Please ignore this patch.

Yup. You can have Acked-by: for the other parts.

Pavel

Quoted 11 lines
Quoted 10 lines
Quoted 6 lines
kernel/power/poweroff.c +1 -1
-static struct sysrq_key_op	sysrq_poweroff_op = {
+static struct sysrq_key_op sysrq_poweroff_op __initdata = {
 	.handler        = handle_poweroff,
 	.help_msg       = "poweroff(o)",
 	.action_msg     = "Power Off",
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html