2019-05-02 07:45:47

by Nikitas Angelinas

[permalink] [raw]
Subject: [PATCH] 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.

Signed-off-by: Nikitas Angelinas <[email protected]>
---
kernel/power/poweroff.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/kernel/power/poweroff.c b/kernel/power/poweroff.c
index 7ef6866..d507152 100644
--- a/kernel/power/poweroff.c
+++ b/kernel/power/poweroff.c
@@ -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",
--
2.10.0


2019-05-02 10:16:59

by Pavel Machek

[permalink] [raw]
Subject: Re: [PATCH] power/poweroff.c: mark variables with __initdata and __maybe_unused

On Thu 2019-05-02 00:43:05, Nikitas Angelinas wrote:
> 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

>
> -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",

--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html


Attachments:
(No filename) (655.00 B)
signature.asc (188.00 B)
Digital signature
Download all attachments

2019-05-02 18:03:41

by Nikitas Angelinas

[permalink] [raw]
Subject: Re: [PATCH] power/poweroff.c: mark variables with __initdata and __maybe_unused

On Thu, May 02, 2019 at 12:15:00PM +0200, Pavel Machek wrote:
> On Thu 2019-05-02 00:43:05, Nikitas Angelinas wrote:
> > 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
>
I am sorry about this. I completely missed the point of registering this
structure. Please ignore this patch.



Cheers,
Nikitas
> >
> > -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",
>
> --
> (english) http://www.livejournal.com/~pavelmachek
> (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html


2019-05-02 18:24:46

by Pavel Machek

[permalink] [raw]
Subject: Re: [PATCH] power/poweroff.c: mark variables with __initdata and __maybe_unused

On Thu 2019-05-02 10:59:58, Nikitas Angelinas wrote:
> On Thu, May 02, 2019 at 12:15:00PM +0200, Pavel Machek wrote:
> > On Thu 2019-05-02 00:43:05, Nikitas Angelinas wrote:
> > > 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
> >
> 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

> > >
> > > -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",
> >
> > --
> > (english) http://www.livejournal.com/~pavelmachek
> > (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
>

--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html


Attachments:
(No filename) (1.17 kB)
signature.asc (188.00 B)
Digital signature
Download all attachments