All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: linux-fbdev@vger.kernel.org, Greg KH <gregkh@suse.de>,
	Lars-Peter Clausen <lars@metafoo.de>,
	James Hogan <james@albanarts.com>,
	David Airlie <airlied@linux.ie>,
	Daniel Vetter <daniel.vetter@ffwll.ch>,
	linux-omap@vger.kernel.org,
	Jesse Barnes <jbarnes@virtuousgeek.org>,
	"James E.J. Bottomley" <jejb@parisc-linux.org>,
	"David S. Miller" <davem@davemloft.net>,
	Paul Mackerras <paulus@samba.org>,
	Liam Girdwood <lrg@slimlogic.co.uk>,
	Kyle McMartin <kyle@mcmartin.ca>, Jiri Slaby <jslaby@suse.cz>,
	Thomas Gleixner <tglx@linutronix.de>,
	Caglar Akyuz <caglar@bilkon-kontrol.com.tr>,
	devel@driverdev.osuosl.org,
	Alberto Panizzo <maramaopercheseimorto@gmail.com>,
	Phil Edworthy <phil.edworthy@renesas.com>,
	xen-devel@lists.xensource.com,
	Russell King <linux@arm.linux.org.uk>,
	Kuninor
Subject: Re: [PATCH] change acquire/release_console_sem() to console_lock/unlock()
Date: Fri, 21 Jan 2011 00:23:23 -0800	[thread overview]
Message-ID: <20110121002323.e9cbf9ae.akpm@linux-foundation.org> (raw)
In-Reply-To: <AANLkTinN2+pNGk1hwrcMhH5qDNZK=Egrw7P6c-cdJTmH@mail.gmail.com>

On Fri, 21 Jan 2011 09:10:06 +0100 Geert Uytterhoeven <geert@linux-m68k.org> 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);
 
_

WARNING: multiple messages have this Message-ID (diff)
From: Andrew Morton <akpm@linux-foundation.org>
To: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: linux-fbdev@vger.kernel.org, "Greg KH" <gregkh@suse.de>,
	"Lars-Peter Clausen" <lars@metafoo.de>,
	"James Hogan" <james@albanarts.com>,
	"David Airlie" <airlied@linux.ie>,
	"Daniel Vetter" <daniel.vetter@ffwll.ch>,
	linux-omap@vger.kernel.org,
	"Jesse Barnes" <jbarnes@virtuousgeek.org>,
	"James E.J. Bottomley" <jejb@parisc-linux.org>,
	"David S. Miller" <davem@davemloft.net>,
	"Paul Mackerras" <paulus@samba.org>,
	"Liam Girdwood" <lrg@slimlogic.co.uk>,
	"Kyle McMartin" <kyle@mcmartin.ca>, "Jiri Slaby" <jslaby@suse.cz>,
	"Thomas Gleixner" <tglx@linutronix.de>,
	"Caglar Akyuz" <caglar@bilkon-kontrol.com.tr>,
	devel@driverdev.osuosl.org,
	"Alberto Panizzo" <maramaopercheseimorto@gmail.com>,
	"Phil Edworthy" <phil.edworthy@renesas.com>,
	xen-devel@lists.xensource.com,
	"Russell King" <linux@arm.linux.org.uk>,
	"Kuninori Morimoto" <kuninori.morimoto.gx@renesas.com>,
	"Wu Zhangjin" <wuzhangjin@gmail.com>,
	"Florian Tobias Schandinat" <FlorianSchandinat@gmx.de>,
	"Lionel Debroux" <lionel_debroux@yahoo.fr>,
	"Helge Deller" <deller@gmx.de>,
	"Kay Sievers" <kay.sievers@vrfy.org>,
	"James Morris" <jmorris@namei.org>,
	"Kevin Hilman" <khilman@deeprootsystems.com>,
	"Tony Lindgren" <tony@atomide.com>,
	"Ben Skeggs" <bskeggs@redhat.com>,
	"Andres Salomon" <dilinger@queued.net>,
	"Julia Lawall" <julia@diku.dk>,
	"Dave Airlie" <airlied@redhat.com>,
	"Kees Cook" <kees.cook@canonical.com>,
	"Francisco Jerez" <currojerez@riseup.net>,
	"Abhijeet Dharmapurikar" <adharmap@codeaurora.org>,
	"Marcin Slusarz" <marcin.slusarz@gmail.com>,
	cbe-oss-dev@lists.ozlabs.org, linuxppc-dev@lists.ozlabs.org,
	"Ondrej Zary" <linux@rainbow-software.org>,
	"Denys Vlasenko" <vda.linux@googlemail.com>,
	"Konrad Rzeszutek Wilk" <konrad.wilk@oracle.com>,
	linux-kernel@vger.kernel.org, "Namhyung Kim" <namhyung@gmail.com>,
	"Rusty Russell" <rusty@rustcorp.com.au>,
	"Werner Fink" <werner@suse.de>,
	linux-geode@lists.infradead.org, torbenh <torbenh@gmx.de>,
	"Jean Delvare" <khali@linux-fr.org>,
	"Magnus Damm" <damm@opensource.se>,
	"Jeremy Fitzhardinge" <jeremy.fitzhardinge@citrix.com>,
	dri-devel@lists.freedesktop.org, "Daniel Mack" <daniel@caiaq.de>,
	"Nicolas Pitre" <nicolas.pitre@canonical.com>,
	"Dan Williams" <dan.j.williams@intel.com>,
	virtualization@lists.linux-foundation.org,
	"Ingo Molnar" <mingo@elte.hu>,
	linux-arm-kernel@lists.infradead.org,
	"Thomas Gleixner" <tglx@tglx.de>,
	"Daniel Walker" <dwalker@codeaurora.org>,
	"Linus Walleij" <linus.walleij@stericsson.com>,
	linux-parisc@vger.kernel.org,
	"Geoff Levand" <geoff@infradead.org>,
	"Jiri Kosina" <jkosina@suse.cz>,
	"Mark Brown" <broonie@opensource.wolfsonmicro.com>,
	"Jerome Glisse" <jglisse@redhat.com>,
	"Ralf Baechle" <ralf@linux-mips.org>,
	"Alexey Dobriyan" <adobriyan@gmail.com>,
	"Guy Martin" <gmsoft@tuxicoman.be>,
	"Ondrej Zajicek" <santiago@crfreenet.org>,
	"Paul Mundt" <lethal@linux-sh.org>,
	"Arnd Bergmann" <arnd@arndb.de>, "Takashi Iwai" <tiwai@suse.de>,
	"Jason Wessel" <jason.wessel@windriver.com>,
	"Alex Deucher" <alexdeucher@gmail.com>,
	"Tejun Heo" <tj@kernel.org>,
	"Antonino Daplas" <adaplas@gmail.com>,
	"Guennadi Liakhovetski" <g.liakhovetski@gmx.de>,
	"Marcin Kościelnicki" <koriakin@0x04.net>,
	"David Brown" <davidb@codeaurora.org>
Subject: Re: [PATCH] change acquire/release_console_sem() to console_lock/unlock()
Date: Fri, 21 Jan 2011 00:23:23 -0800	[thread overview]
Message-ID: <20110121002323.e9cbf9ae.akpm@linux-foundation.org> (raw)
In-Reply-To: <AANLkTinN2+pNGk1hwrcMhH5qDNZK=Egrw7P6c-cdJTmH@mail.gmail.com>

On Fri, 21 Jan 2011 09:10:06 +0100 Geert Uytterhoeven <geert@linux-m68k.org> 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);
 
_

WARNING: multiple messages have this Message-ID (diff)
From: akpm@linux-foundation.org (Andrew Morton)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] change acquire/release_console_sem() to console_lock/unlock()
Date: Fri, 21 Jan 2011 00:23:23 -0800	[thread overview]
Message-ID: <20110121002323.e9cbf9ae.akpm@linux-foundation.org> (raw)
In-Reply-To: <AANLkTinN2+pNGk1hwrcMhH5qDNZK=Egrw7P6c-cdJTmH@mail.gmail.com>

On Fri, 21 Jan 2011 09:10:06 +0100 Geert Uytterhoeven <geert@linux-m68k.org> 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);
 
_

  reply	other threads:[~2011-01-21  8:23 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-20 15:58 [PATCH] change acquire/release_console_sem() to console_lock/unlock() Torben Hohn
2011-01-20 15:58 ` Torben Hohn
2011-01-20 15:58 ` Torben Hohn
2011-01-20 15:58 ` Torben Hohn
2011-01-20 16:34 ` Greg KH
2011-01-20 16:34   ` Greg KH
2011-01-20 16:34   ` Greg KH
2011-01-20 16:55   ` torbenh
2011-01-20 16:55   ` torbenh
2011-01-20 16:55     ` torbenh
2011-01-20 16:55     ` torbenh
2011-01-20 16:55     ` torbenh
2011-01-20 20:35     ` Andrew Morton
2011-01-20 20:35       ` Andrew Morton
2011-01-20 20:35       ` Andrew Morton
2011-01-20 20:35       ` Andrew Morton
2011-01-21  8:10       ` Geert Uytterhoeven
2011-01-21  8:10         ` Geert Uytterhoeven
2011-01-21  8:10         ` Geert Uytterhoeven
2011-01-21  8:10         ` Geert Uytterhoeven
2011-01-21  8:23         ` Andrew Morton [this message]
2011-01-21  8:23           ` Andrew Morton
2011-01-21  8:23           ` Andrew Morton
2011-01-21  8:10       ` Geert Uytterhoeven
  -- strict thread matches above, loose matches on Subject: below --
2011-01-20 15:58 Torben Hohn

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=20110121002323.e9cbf9ae.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=airlied@linux.ie \
    --cc=caglar@bilkon-kontrol.com.tr \
    --cc=daniel.vetter@ffwll.ch \
    --cc=davem@davemloft.net \
    --cc=devel@driverdev.osuosl.org \
    --cc=geert@linux-m68k.org \
    --cc=gregkh@suse.de \
    --cc=james@albanarts.com \
    --cc=jbarnes@virtuousgeek.org \
    --cc=jejb@parisc-linux.org \
    --cc=jslaby@suse.cz \
    --cc=kyle@mcmartin.ca \
    --cc=lars@metafoo.de \
    --cc=linux-fbdev@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=lrg@slimlogic.co.uk \
    --cc=maramaopercheseimorto@gmail.com \
    --cc=paulus@samba.org \
    --cc=phil.edworthy@renesas.com \
    --cc=tglx@linutronix.de \
    --cc=xen-devel@lists.xensource.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.