- Subject: Re: [PATCH] change acquire/release_console_sem() to console_lock/unlock()
- From: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 21 Jan 2011 00:23:23 -0800
- Cc: linux-fbdev@xxxxxxxxxxxxxxx, Greg KH <gregkh@xxxxxxx>, Lars-Peter Clausen <lars@xxxxxxxxxx>, James Hogan <james@xxxxxxxxxxxxx>, David Airlie <airlied@xxxxxxxx>, Daniel Vetter <daniel.vetter@xxxxxxxx>, linux-omap@xxxxxxxxxxxxxxx, Jesse Barnes <jbarnes@xxxxxxxxxxxxxxxx>, "James E.J. Bottomley" <jejb@xxxxxxxxxxxxxxxx>, "David S. Miller" <davem@xxxxxxxxxxxxx>, Paul Mackerras <paulus@xxxxxxxxx>, Liam Girdwood <lrg@xxxxxxxxxxxxxxx>, Kyle McMartin <kyle@xxxxxxxxxxx>, Jiri Slaby <jslaby@xxxxxxx>, Thomas Gleixner <tglx@xxxxxxxxxxxxx>, Caglar Akyuz <caglar@xxxxxxxxxxxxxxxxxxxxx>, devel@xxxxxxxxxxxxxxxxxxxx, Alberto Panizzo <maramaopercheseimorto@xxxxxxxxx>, Phil Edworthy <phil.edworthy@xxxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxx, Russell King <linux@xxxxxxxxxxxxxxxx>, Kuninori Morimoto <kuninori.morimoto.gx@xxxxxxxxxxx>, Wu Zhangjin <wuzhangjin@xxxxxxxxx>, Florian Tobias Schandinat <FlorianSchandinat@xxxxxx>, Lionel Debroux <lionel_debroux@xxxxxxxx>, Helge Deller <deller@xxxxxx>, Kay Sievers <kay.sievers@xxxxxxxx>, James Morris <jmorris@xxxxxxxxx>, Kevin Hilman <khilman@xxxxxxxxxxxxxxxxxxx>, Tony Lindgren <tony@xxxxxxxxxxx>, Ben Skeggs <bskeggs@xxxxxxxxxx>, Andres Salomon <dilinger@xxxxxxxxxx>, Julia Lawall <julia@xxxxxxx>, Dave Airlie <airlied@xxxxxxxxxx>, Kees Cook <kees.cook@xxxxxxxxxxxxx>, Francisco Jerez <currojerez@xxxxxxxxxx>, Abhijeet Dharmapurikar <adharmap@xxxxxxxxxxxxxx>, Marcin Slusarz <marcin.slusarz@xxxxxxxxx>, cbe-oss-dev@xxxxxxxxxxxxxxxx, linuxppc-dev@xxxxxxxxxxxxxxxx, Ondrej Zary <linux@xxxxxxxxxxxxxxxxxxxx>, Denys Vlasenko <vda.linux@xxxxxxxxxxxxxx>, Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx>, linux-kernel@xxxxxxxxxxxxxxx, Namhyung Kim <namhyung@xxxxxxxxx>, Rusty Russell <rusty@xxxxxxxxxxxxxxx>, Werner Fink <werner@xxxxxxx>, linux-geode@xxxxxxxxxxxxxxxxxxx, torbenh <torbenh@xxxxxx>, Jean Delvare <khali@xxxxxxxxxxxx>, Magnus Damm <damm@xxxxxxxxxxxxx>, Jeremy Fitzhardinge <jeremy.fitzhardinge@xxxxxxxxxx>, dri-devel@xxxxxxxxxxxxxxxxxxxxx, Daniel Mack <daniel@xxxxxxxx>, Nicolas Pitre <nicolas.pitre@xxxxxxxxxxxxx>, Dan Williams <dan.j.williams@xxxxxxxxx>, virtualization@xxxxxxxxxxxxxxxxxxxxxxxxxx, Ingo Molnar <mingo@xxxxxxx>, linux-arm-kernel@xxxxxxxxxxxxxxxxxxx, Thomas Gleixner <tglx@xxxxxxx>, Daniel Walker <dwalker@xxxxxxxxxxxxxx>, Linus Walleij <linus.walleij@xxxxxxxxxxxxxx>, linux-parisc@xxxxxxxxxxxxxxx, Geoff Levand <geoff@xxxxxxxxxxxxx>, Jiri Kosina <jkosina@xxxxxxx>, Mark Brown <broonie@xxxxxxxxxxxxxxxxxxxxxxxxxxx>, Jerome Glisse <jglisse@xxxxxxxxxx>, Ralf Baechle <ralf@xxxxxxxxxxxxxx>, Alexey Dobriyan <adobriyan@xxxxxxxxx>, Guy Martin <gmsoft@xxxxxxxxxxxx>, Ondrej Zajicek <santiago@xxxxxxxxxxxxx>, Paul Mundt <lethal@xxxxxxxxxxxx>, Arnd Bergmann <arnd@xxxxxxxx>, Takashi Iwai <tiwai@xxxxxxx>, Jason Wessel <jason.wessel@xxxxxxxxxxxxx>, Tejun Heo <tj@xxxxxxxxxx>, Antonino Daplas <adaplas@xxxxxxxxx>, Guennadi Liakhovetski <g.liakhovetski@xxxxxx>, Marcin Kościelnicki <koriakin@xxxxxxxx>, David Brown <davidb@xxxxxxxxxxxxxx>
- Delivered-to: devel@xxxxxxxxxxxxxxxxxxxx
- In-reply-to: <AANLkTinN2+pNGk1hwrcMhH5qDNZK=Egrw7P6c-cdJTmH@mail.gmail.com>
On Fri, 21 Jan 2011 09:10:06 +0100 Geert Uytterhoeven <geert@xxxxxxxxxxxxxx> wrote:
> include/linux/mutex.h:
>
> /*
> * NOTE: mutex_trylock() follows the spin_trylock() convention,
> * not the down_trylock() convention!
> *
> * Returns 1 if the mutex has been acquired successfully, and 0 on contention.
> */
> extern int mutex_trylock(struct mutex *lock);
>
> So that's why the return value was inverted (when treating it as a boolean).
> I can understand that.
>
> However:
>
> +/**
> + * console_trylock - try to lock the console system for exclusive use.
> + *
> + * Tried to acquire a lock which guarantees that the caller has
> + * exclusive access to the console system and the console_drivers list.
> + *
> + * returns -1 on success, and 0 on failure to acquire the lock.
> + */
> +int console_trylock(void)
>
> So this one returns -1 on success, not 1? Why?
Yup. All callers just test for non-zero, so...
--- a/kernel/printk.c~change-acquire-release_console_sem-to-console_lock-unlock-fix-2
+++ a/kernel/printk.c
@@ -1058,7 +1058,7 @@ EXPORT_SYMBOL(console_lock);
* Tried to acquire a lock which guarantees that the caller has
* exclusive access to the console system and the console_drivers list.
*
- * returns -1 on success, and 0 on failure to acquire the lock.
+ * returns 1 on success, and 0 on failure to acquire the lock.
*/
int console_trylock(void)
{
@@ -1070,7 +1070,7 @@ int console_trylock(void)
}
console_locked = 1;
console_may_schedule = 0;
- return -1;
+ return 1;
}
EXPORT_SYMBOL(console_trylock);
_
_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/devel
[Video for Linux]
[Mplayer Users]
[Linux USB Devel]
[Linux Audio Users]
[Photos]
[Yosemite Photos]
[Free Singles Community]
[Linux Kernel]
[Linux SCSI]
[XFree86]
[Devices]
[Yosemite Backpacking]