diff options
-rw-r--r-- | drivers/tty/tty_ldisc.c | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c index f26ef1ace4f1..4e46c1721b9d 100644 --- a/drivers/tty/tty_ldisc.c +++ b/drivers/tty/tty_ldisc.c | |||
@@ -179,6 +179,29 @@ static struct tty_ldisc *tty_ldisc_get(int disc) | |||
179 | return ld; | 179 | return ld; |
180 | } | 180 | } |
181 | 181 | ||
182 | /** | ||
183 | * tty_ldisc_put - release the ldisc | ||
184 | * | ||
185 | * Complement of tty_ldisc_get(). | ||
186 | */ | ||
187 | static inline void tty_ldisc_put(struct tty_ldisc *ld) | ||
188 | { | ||
189 | unsigned long flags; | ||
190 | |||
191 | if (WARN_ON_ONCE(!ld)) | ||
192 | return; | ||
193 | |||
194 | raw_spin_lock_irqsave(&tty_ldisc_lock, flags); | ||
195 | |||
196 | /* unreleased reader reference(s) will cause this WARN */ | ||
197 | WARN_ON(!atomic_dec_and_test(&ld->users)); | ||
198 | |||
199 | ld->ops->refcount--; | ||
200 | module_put(ld->ops->owner); | ||
201 | kfree(ld); | ||
202 | raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags); | ||
203 | } | ||
204 | |||
182 | static void *tty_ldiscs_seq_start(struct seq_file *m, loff_t *pos) | 205 | static void *tty_ldiscs_seq_start(struct seq_file *m, loff_t *pos) |
183 | { | 206 | { |
184 | return (*pos < NR_LDISCS) ? pos : NULL; | 207 | return (*pos < NR_LDISCS) ? pos : NULL; |
@@ -329,29 +352,6 @@ void tty_ldisc_deref(struct tty_ldisc *ld) | |||
329 | EXPORT_SYMBOL_GPL(tty_ldisc_deref); | 352 | EXPORT_SYMBOL_GPL(tty_ldisc_deref); |
330 | 353 | ||
331 | /** | 354 | /** |
332 | * tty_ldisc_put - release the ldisc | ||
333 | * | ||
334 | * Complement of tty_ldisc_get(). | ||
335 | */ | ||
336 | static inline void tty_ldisc_put(struct tty_ldisc *ld) | ||
337 | { | ||
338 | unsigned long flags; | ||
339 | |||
340 | if (WARN_ON_ONCE(!ld)) | ||
341 | return; | ||
342 | |||
343 | raw_spin_lock_irqsave(&tty_ldisc_lock, flags); | ||
344 | |||
345 | /* unreleased reader reference(s) will cause this WARN */ | ||
346 | WARN_ON(!atomic_dec_and_test(&ld->users)); | ||
347 | |||
348 | ld->ops->refcount--; | ||
349 | module_put(ld->ops->owner); | ||
350 | kfree(ld); | ||
351 | raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags); | ||
352 | } | ||
353 | |||
354 | /** | ||
355 | * tty_ldisc_enable - allow ldisc use | 355 | * tty_ldisc_enable - allow ldisc use |
356 | * @tty: terminal to activate ldisc on | 356 | * @tty: terminal to activate ldisc on |
357 | * | 357 | * |