mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-11 07:30:16 +00:00
tty: n_gsm: expose gsmtty device nodes at ldisc open time
The n_gsm driver being an ldisc, does not provide a convenient method e.g. udev to create the tty device nodes automatically when the ldisc is opened. The TTY device nodes are now created via calls to tty_register_device from the ldisc open. Signed-off-by: Russ Gorby <russ.gorby@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
parent
20ae6d0b30
commit
d50f6dcaf2
@ -169,6 +169,7 @@ struct gsm_control {
|
|||||||
struct gsm_mux {
|
struct gsm_mux {
|
||||||
struct tty_struct *tty; /* The tty our ldisc is bound to */
|
struct tty_struct *tty; /* The tty our ldisc is bound to */
|
||||||
spinlock_t lock;
|
spinlock_t lock;
|
||||||
|
unsigned int num;
|
||||||
|
|
||||||
/* Events on the GSM channel */
|
/* Events on the GSM channel */
|
||||||
wait_queue_head_t event;
|
wait_queue_head_t event;
|
||||||
@ -250,6 +251,8 @@ struct gsm_mux {
|
|||||||
static struct gsm_mux *gsm_mux[MAX_MUX]; /* GSM muxes */
|
static struct gsm_mux *gsm_mux[MAX_MUX]; /* GSM muxes */
|
||||||
static spinlock_t gsm_mux_lock;
|
static spinlock_t gsm_mux_lock;
|
||||||
|
|
||||||
|
static struct tty_driver *gsm_tty_driver;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This section of the driver logic implements the GSM encodings
|
* This section of the driver logic implements the GSM encodings
|
||||||
* both the basic and the 'advanced'. Reliable transport is not
|
* both the basic and the 'advanced'. Reliable transport is not
|
||||||
@ -1996,6 +1999,7 @@ int gsm_activate_mux(struct gsm_mux *gsm)
|
|||||||
spin_lock(&gsm_mux_lock);
|
spin_lock(&gsm_mux_lock);
|
||||||
for (i = 0; i < MAX_MUX; i++) {
|
for (i = 0; i < MAX_MUX; i++) {
|
||||||
if (gsm_mux[i] == NULL) {
|
if (gsm_mux[i] == NULL) {
|
||||||
|
gsm->num = i;
|
||||||
gsm_mux[i] = gsm;
|
gsm_mux[i] = gsm;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -2101,13 +2105,20 @@ static int gsmld_output(struct gsm_mux *gsm, u8 *data, int len)
|
|||||||
|
|
||||||
static int gsmld_attach_gsm(struct tty_struct *tty, struct gsm_mux *gsm)
|
static int gsmld_attach_gsm(struct tty_struct *tty, struct gsm_mux *gsm)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret, i;
|
||||||
|
int base = gsm->num << 6; /* Base for this MUX */
|
||||||
|
|
||||||
gsm->tty = tty_kref_get(tty);
|
gsm->tty = tty_kref_get(tty);
|
||||||
gsm->output = gsmld_output;
|
gsm->output = gsmld_output;
|
||||||
ret = gsm_activate_mux(gsm);
|
ret = gsm_activate_mux(gsm);
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
tty_kref_put(gsm->tty);
|
tty_kref_put(gsm->tty);
|
||||||
|
else {
|
||||||
|
/* Don't register device 0 - this is the control channel and not
|
||||||
|
a usable tty interface */
|
||||||
|
for (i = 1; i < NUM_DLCI; i++)
|
||||||
|
tty_register_device(gsm_tty_driver, base + i, NULL);
|
||||||
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2122,7 +2133,12 @@ static int gsmld_attach_gsm(struct tty_struct *tty, struct gsm_mux *gsm)
|
|||||||
|
|
||||||
static void gsmld_detach_gsm(struct tty_struct *tty, struct gsm_mux *gsm)
|
static void gsmld_detach_gsm(struct tty_struct *tty, struct gsm_mux *gsm)
|
||||||
{
|
{
|
||||||
|
int i;
|
||||||
|
int base = gsm->num << 6; /* Base for this MUX */
|
||||||
|
|
||||||
WARN_ON(tty != gsm->tty);
|
WARN_ON(tty != gsm->tty);
|
||||||
|
for (i = 1; i < NUM_DLCI; i++)
|
||||||
|
tty_unregister_device(gsm_tty_driver, base + i);
|
||||||
gsm_cleanup_mux(gsm);
|
gsm_cleanup_mux(gsm);
|
||||||
tty_kref_put(gsm->tty);
|
tty_kref_put(gsm->tty);
|
||||||
gsm->tty = NULL;
|
gsm->tty = NULL;
|
||||||
@ -2712,7 +2728,6 @@ static int gsmtty_break_ctl(struct tty_struct *tty, int state)
|
|||||||
return gsmtty_modem_update(dlci, encode);
|
return gsmtty_modem_update(dlci, encode);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct tty_driver *gsm_tty_driver;
|
|
||||||
|
|
||||||
/* Virtual ttys for the demux */
|
/* Virtual ttys for the demux */
|
||||||
static const struct tty_operations gsmtty_ops = {
|
static const struct tty_operations gsmtty_ops = {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user