From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Date: Fri, 21 Jan 2011 00:23:23 -0800 From: Andrew Morton To: Geert Uytterhoeven Subject: Re: [PATCH] change acquire/release_console_sem() to console_lock/unlock() Message-Id: <20110121002323.e9cbf9ae.akpm@linux-foundation.org> In-Reply-To: References: <1295539104-13210-1-git-send-email-torbenh@gmx.de> <20110120163448.GA30588@suse.de> <20110120165502.GA10832@siel.b> <20110120123507.ac89c034.akpm@linux-foundation.org> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Cc: linux-fbdev@vger.kernel.org, Greg KH , Lars-Peter Clausen , James Hogan , David Airlie , Daniel Vetter , linux-omap@vger.kernel.org, Jesse Barnes , "James E.J. Bottomley" , "David S. Miller" , Paul Mackerras , Liam Girdwood , Kyle McMartin , Jiri Slaby , Thomas Gleixner , Caglar Akyuz , devel@driverdev.osuosl.org, Alberto Panizzo , Phil Edworthy , xen-devel@lists.xensource.com, Russell King , Kuninori Morimoto , Wu Zhangjin , Florian Tobias Schandinat , Lionel Debroux , Helge Deller , Kay Sievers , James Morris , Kevin Hilman , Tony Lindgren , Ben Skeggs , Andres Salomon , Julia Lawall , Dave Airlie , Kees Cook , Francisco Jerez , Abhijeet Dharmapurikar , Marcin Slusarz , cbe-oss-dev@lists.ozlabs.org, linuxppc-dev@lists.ozlabs.org, Ondrej Zary , Denys Vlasenko , Konrad Rzeszutek Wilk , linux-kernel@vger.kernel.org, Namhyung Kim , Rusty Russell , Werner Fink , linux-geode@lists.infradead.org, torbenh , Jean Delvare , Magnus Damm , Jeremy Fitzhardinge , dri-devel@lists.freedesktop.org, Daniel Mack , Nicolas Pitre , Dan Williams , virtualization@lists.linux-foundation.org, Ingo Molnar , linux-arm-kernel@lists.infradead.org, Thomas Gleixner , Daniel Walker , Linus Walleij , linux-parisc@vger.kernel.org, Geoff Levand , Jiri Kosina , Mark Brown , Jerome Glisse , Ralf Baechle , Alexey Dobriyan , Guy Martin , Ondrej Zajicek , Paul Mundt , Arnd Bergmann , Takashi Iwai , Jason Wessel , Alex Deucher , Tejun Heo , Antonino Daplas , Guennadi Liakhovetski , Marcin =?UTF-8?Q?Ko=C5=9Bcielnicki?= , David Brown List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , On Fri, 21 Jan 2011 09:10:06 +0100 Geert Uytterhoeven 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); _