lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20110120153528.4a535065.akpm@linux-foundation.org>
Date:	Thu, 20 Jan 2011 15:35:28 -0800
From:	Andrew Morton <akpm@...ux-foundation.org>
To:	Mark Brown <broonie@...nsource.wolfsonmicro.com>
Cc:	Kim Kyuwon <q1.kim@...sung.com>, Kim Kyuwon <chammoru@...il.com>,
	Richard Purdie <rpurdie@...ys.net>,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH] leds: Convert bd2802 driver to dev_pm_ops

On Thu, 20 Jan 2011 23:24:09 +0000
Mark Brown <broonie@...nsource.wolfsonmicro.com> wrote:

> On Thu, Jan 20, 2011 at 03:12:01PM -0800, Andrew Morton wrote:
> 
> > CONFIG_PM=n:
> 
> To be honest I've been forming the opinion that this is just cruft these
> days - it's hard to see a modern Linux system where you're sufficiently
> space constrained to want to turn it off without also being sufficiently
> power constrained to want to turn it on and it's hassle to maintain it.

Could be.  It's hard to think of a machine which is small enough to
care about ~10k of kernel text but which doesn't care about power
consumption.

> That said...
> 
> > It would be nice to fix all this via automagic within the
> > SIMPLE_DEV_PM_OPS() implementation but I can't see a way of doing that :(
> 
> ...the problem here is that the macro is doing roughly the right magic
> but the original driver wasn't ifdefing the suspend and resume stuff at
> all.  If the were only defining the suspend and resume functions under
> CONFIG_PM_SLEEP it should build cleanly.  Since the original driver
> didn't have the ifdefs I didn't add or update them.
> 
> This means the pm_ops can be unconditionally defined which seems to be
> the preferred idiom for this stuff.  If SIMPLE_DEV_PM_OPS() didn't do
> the stuff it's doing then the warnings would vanish in the same way they
> did originally, by virtue of the functions being unconditionally
> referenced from the vtable.

It's tricky to get the compiler/linker to discard code and data without
triggering an unused-var warning.  cpu_notifier() does it by emitting a
reference:

static void foo(..)
{
	...
}

bar()
{	
	...
	do { (void)(foo); } while (0)
	...
}

but this is only possible because cpu_notifier() is "called" within a
function.  Whereas SIMPLE_DEV_PM_OPS() is a static initialisation
thingy.

We could emit a dummy function but then we get a warning about the
unused dummy function.

Can the dummy function refer to itself and thus squish the warning?

akpm:/home/akpm> cat t.c
static void foo(void)
{
	        do { (void)(foo); } while (0);
}
akpm:/home/akpm> gcc -c -Wall t.c
t.c:1: warning: 'foo' defined but not used

Nope.


This works.  lol.

akpm:/home/akpm> cat t.c
static void bar(void);
static void foo(void)
{
        do { (void)(bar); } while (0);
}
static void bar(void)
{
        do { (void)(foo); } while (0);
}
akpm:/home/akpm> gcc -O2 -c -Wall t.c
akpm:/home/akpm> size t.o
   text    data     bss     dec     hex filename
      0       0       0       0       0 t.o

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ