Skip to content

Commit

Permalink
cs5535-mfgpt: reuse timers that have never been set up
Browse files Browse the repository at this point in the history
The MFGPT hardware may be set up only once, therefore
cs5535_mfgpt_free_timer() didn't re-set the timer's "avail" bit.  However
if a timer is freed before it has actually been in use then it may be made
available again.

Signed-off-by: Jens Rottmann <[email protected]>
Acked-by: Andres Salomon <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: Jordan Crouse <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Jens Rottmann authored and torvalds committed Aug 11, 2010
1 parent e73790a commit ecd6269
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions drivers/misc/cs5535-mfgpt.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,17 @@ EXPORT_SYMBOL_GPL(cs5535_mfgpt_alloc_timer);
*/
void cs5535_mfgpt_free_timer(struct cs5535_mfgpt_timer *timer)
{
unsigned long flags;
uint16_t val;

/* timer can be made available again only if never set up */
val = cs5535_mfgpt_read(timer, MFGPT_REG_SETUP);
if (!(val & MFGPT_SETUP_SETUP)) {
spin_lock_irqsave(&timer->chip->lock, flags);
__set_bit(timer->nr, timer->chip->avail);
spin_unlock_irqrestore(&timer->chip->lock, flags);
}

kfree(timer);
}
EXPORT_SYMBOL_GPL(cs5535_mfgpt_free_timer);
Expand Down

0 comments on commit ecd6269

Please sign in to comment.