From mboxrd@z Thu Jan 1 00:00:00 1970 From: fser@code-libre.org (=?iso-8859-1?Q?Fran=E7ois?=) Date: Wed, 5 Oct 2016 14:44:31 +0200 Subject: Char device write repeating In-Reply-To: References: <20161004150557.GB25308@kroah.com> Message-ID: <20161005124430.GB22768@sith> To: kernelnewbies@lists.kernelnewbies.org List-Id: kernelnewbies.lists.kernelnewbies.org On Tue, Oct 04, 2016 at 03:42:52PM -0300, Daniel. wrote: > Because the libc is calling it again based on what has been passed as > argument and what was received as return value. Here is one example > https://gist.github.com/gkos/5479135. I don't really know if this code is > working since I made it a long time ago. Your test to check wether the device is already open looks weak to me. You should rather use atomic operations such as described in [1] or mutex like in [2]. [1] http://www.oreilly.com/openbook/linuxdrive3/book/ch06.pdf p 40 [2] http://pete.akeo.ie/2011/08/writing-linux-device-driver-for-kernels.html -- Fran?ois