From: linux@arm.linux.org.uk (Russell King - ARM Linux)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] arm: mach-omap2: pm: cleanup !CONFIG_SUSPEND handling
Date: Thu, 6 Jan 2011 11:19:57 +0000 [thread overview]
Message-ID: <20110106111957.GA1198@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <874o9mvpxf.fsf@ti.com>
On Wed, Jan 05, 2011 at 04:25:32PM -0800, Kevin Hilman wrote:
> As you likely noticed, removing the const leads to checkpatch warnings:
>
> WARNING: struct platform_suspend_ops should normally be const
>
> so the choice is between a checkpatch warning or a bunch of compiler
> warnings.
checkpatch should not be checking that data declarations are const.
That's a decision for those people declaring them to decide upon, as
they may need to modify the structure before registration.
By doing so, we end up encouraging people to write more code - such
as declaring it __initconst, and then kmalloc'ing, memcpy'ing and
modifying that before registering it.
> > -static struct platform_suspend_ops omap_pm_ops = {
> > - .begin = omap2_pm_begin,
> > - .enter = omap2_pm_enter,
> > - .end = omap2_pm_end,
> > - .valid = suspend_valid_only_mem,
> > +static const struct platform_suspend_ops omap_pm_ops[] = {
> > + {
> > + .begin = omap2_pm_begin,
> > + .enter = omap2_pm_enter,
> > + .end = omap2_pm_end,
> > + .valid = suspend_valid_only_mem,
> > + }
> > };
> > -#else
> > -static const struct platform_suspend_ops __initdata omap_pm_ops;
> > #endif /* CONFIG_SUSPEND */
> >
> > /* XXX This function should be shareable between OMAP2xxx and OMAP3 */
> > @@ -582,7 +582,7 @@ static int __init omap2_pm_init(void)
> > omap24xx_cpu_suspend_sz);
> > }
> >
> > - suspend_set_ops(&omap_pm_ops);
> > + suspend_set_ops(omap_pm_ops);
Utterly yuck. Declaring it as a single element array just to avoid an
ifdef. That's worse than having an ifdef here.
There's another solution. Don't mess about with sticking such stuff in
the header either.
#ifdef WHATEVER
static const struct platform_suspend_ops omap_pm_ops = {
.begin = omap2_pm_begin,
.enter = omap2_pm_enter,
.end = omap2_pm_end,
.valid = suspend_valid_only_mem,
};
#define PM_OPS omap_pm_ops
#else
#define PM_OPS NULL
#endif
...
suspend_set_ops(PM_OPS);
That keeps it all nice and local, and you can see exactly what's going on
without having it spread across many different random files.
next prev parent reply other threads:[~2011-01-06 11:19 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-29 16:34 [PATCH] arm: mach-omap2: pm: cleanup !CONFIG_SUSPEND handling Aaro Koskinen
2011-01-04 22:41 ` Kevin Hilman
2011-01-06 0:25 ` Kevin Hilman
2011-01-06 10:15 ` aaro.koskinen at nokia.com
2011-01-06 17:03 ` Kevin Hilman
2011-01-06 22:31 ` Kevin Hilman
2011-01-06 11:19 ` Russell King - ARM Linux [this message]
2011-01-06 12:05 ` aaro.koskinen at nokia.com
2011-01-06 13:58 ` Russell King - ARM Linux
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110106111957.GA1198@n2100.arm.linux.org.uk \
--to=linux@arm.linux.org.uk \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).