adm1026 driver port for kernel 2.6.10-rc2 [RE-REVISED DRIVER]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 22 Nov 2004, Arjan van de Ven wrote:

>
>>> this locking construct is rahter awkward; is it possible to refactor the
>>> code such that you can down and up in the same function ?
>>
>> Yes, at the cost of some minor code duplication or the introduction of
>> another variable.  Is that preferable?  Is holding the lock across function
>> calls a Bad Idea?
>
> holding lock across function calls isn't, unlocking in another function
> than you take the lock is.
> For one it makes auditing the code a lot harder.
>

Also, code like:

 	down(&mylock);
 	do_something();
         if(fail) {
             up(&mylock);
             return retval;
         }

.. is prone to errors where a lock never gets released on some
corner cases. It's often better to "goto" a common exit point where
the lock is released.


Cheers,
Dick Johnson
Penguin : Linux version 2.6.9 on an i686 machine (5537.79 BogoMips).
  Notice : All mail here is now cached for review by John Ashcroft.
                  98.36% of all statistics are fiction.



[Index of Archives]     [Linux Kernel]     [Linux Hardware Monitoring]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux