-/* Get a reference to our struct, taking into account locks/refcounts.
- * This is to ensure ordering in case we are shutting down, and to ensure
- * there is a refcount at all (otherwise tty->disc_data may be freed and
- * before we increment the refcount).
- * Use this for anything that can race against elmcan_ldisc_close().
- */
-static struct elmcan *get_elm(struct tty_struct *tty)
-{
- struct elmcan *elm;
- bool got_ref;
-
- spin_lock_bh(&elmcan_discdata_lock);
- elm = (struct elmcan *)tty->disc_data;
-
- if (!elm) {
- spin_unlock_bh(&elmcan_discdata_lock);
- return NULL;
- }
-
- got_ref = atomic_inc_not_zero(&elm->refcount);
- spin_unlock_bh(&elmcan_discdata_lock);
-
- if (!got_ref)
- return NULL;
-
- return elm;
-}
-
-static void put_elm(struct elmcan *elm)
-{
- atomic_dec(&elm->refcount);
-}
-