Return-path: Received: from pentafluge.infradead.org ([213.146.154.40]:50149 "EHLO pentafluge.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751218AbXG3DGm (ORCPT ); Sun, 29 Jul 2007 23:06:42 -0400 Date: Mon, 30 Jul 2007 08:48:57 +0530 (IST) From: Satyam Sharma To: Michael Buesch cc: Matthias Kaehlcke , linville@tuxdriver.com, linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, akpm@linux-foundation.org Subject: Re: [PATCH 1/5] Use mutex instead of semaphore in the Host AP driver In-Reply-To: <200707300006.42397.mb@bu3sch.de> Message-ID: References: <20070729212909.GC3432@traven> <20070729213434.GD3432@traven> <200707300006.42397.mb@bu3sch.de> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=us-ascii Sender: linux-wireless-owner@vger.kernel.org List-ID: On Mon, 30 Jul 2007, Michael Buesch wrote: > On Sunday 29 July 2007 23:34, Matthias Kaehlcke wrote: > > The Host AP driver uses a semaphore as mutex. Use the mutex API > > instead of the (binary) semaphore. > > > > Signed-off-by: Matthias Kaehlcke [ Something seems to have gone wrong with your diff / patch / script. There was no diff header here, which should have been. ] > > - res = down_interruptible(&local->rid_bap_sem); > > + res = mutex_lock_interruptible(&local->rid_bap_mtx); > > if (res) > > return res; > > > > @@ -902,7 +902,7 @@ static int hfa384x_set_rid(struct net_device *dev, u16 rid, void *buf, int len) > > /* RID len in words and +1 for rec.rid */ > > rec.len = cpu_to_le16(len / 2 + len % 2 + 1); > > > > - res = down_interruptible(&local->rid_bap_sem); > > + res = mutex_lock_interruptible(&local->rid_bap_mtx); > > if (res) > > return res; > > > > Is res returned to userspace? If yes, that's not right. Yup, that's not right. > On a interrupted mutex allocation you should return > -ERESTARTSYS to userspace. Nope, userspace must not see ERESTARTSYS (I /think/ this is the third time I'm participating in this exact same discussion :-) If the return would be caught by a previous in-kernel caller in the call chain, ERESTARTSYS is okay and it could try to restart the operation. However, if the return goes unfiltered directly to userspace, EINTR is the correct choice. Satyam