Re: [RFC PATCH 2/2] drivers/base: add managed token devres interfaces

2014-04-17 Thread Shuah Khan
Hi Tejun, On 04/16/2014 03:58 PM, Tejun Heo wrote: Hello, Thanks for the review. A brief description of the use-case first. Token is intended to be used as a large grain lock and once locked, it can be held in the locked state for long periods of time. For instance, application will request

Re: [RFC PATCH 2/2] drivers/base: add managed token devres interfaces

2014-04-17 Thread Tejun Heo
On Thu, Apr 17, 2014 at 02:01:32PM -0600, Shuah Khan wrote: Operating on the lock should be atomic, which is what devres_update() is doing. It can be simplified as follows by holding devres_lock in devm_token_lock(). spin_lock_irqsave(dev-devres_lock, flags); if (tkn_ptr-status ==

Re: [RFC PATCH 2/2] drivers/base: add managed token devres interfaces

2014-04-17 Thread Tejun Heo
On Thu, Apr 17, 2014 at 04:10:34PM -0400, Tejun Heo wrote: On Thu, Apr 17, 2014 at 02:01:32PM -0600, Shuah Khan wrote: Operating on the lock should be atomic, which is what devres_update() is doing. It can be simplified as follows by holding devres_lock in devm_token_lock().

Re: [RFC PATCH 2/2] drivers/base: add managed token devres interfaces

2014-04-17 Thread Shuah Khan
On 04/17/2014 02:10 PM, Tejun Heo wrote: On Thu, Apr 17, 2014 at 02:01:32PM -0600, Shuah Khan wrote: Operating on the lock should be atomic, which is what devres_update() is doing. It can be simplified as follows by holding devres_lock in devm_token_lock(). spin_lock_irqsave(dev-devres_lock,

Re: [RFC PATCH 2/2] drivers/base: add managed token devres interfaces

2014-04-17 Thread Shuah Khan
On 04/17/2014 02:22 PM, Tejun Heo wrote: On Thu, Apr 17, 2014 at 04:10:34PM -0400, Tejun Heo wrote: Please do not implement locking primitive directly if at all avoidable. Why can't it use a mutex embedded in the data area of a devres entry? And if you for some reason have to implement it

Re: [RFC PATCH 2/2] drivers/base: add managed token devres interfaces

2014-04-16 Thread Tejun Heo
Hello, On Wed, Apr 09, 2014 at 09:21:08AM -0600, Shuah Khan wrote: +#define TOKEN_DEVRES_FREE0 +#define TOKEN_DEVRES_BUSY1 + +struct token_devres { + int status; + charid[]; +}; Please just do bool busy and drop the constants. +struct tkn_match { + int