aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRuss Gorby <russ.gorby@intel.com>2011-06-14 16:35:32 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2011-07-01 18:33:11 -0400
commitd50f6dcaf22a3234a65ae4f6087173e66b7fff56 (patch)
tree31ebf5b0c30438942ba541cb442984321c882109
parent20ae6d0b307963416db0e8433602e5d5c95e942b (diff)
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>
-rw-r--r--drivers/tty/n_gsm.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
index 09e8c7d53af3..b288ff6cb812 100644
--- a/drivers/tty/n_gsm.c
+++ b/drivers/tty/n_gsm.c
@@ -169,6 +169,7 @@ struct gsm_control {
169struct gsm_mux { 169struct gsm_mux {
170 struct tty_struct *tty; /* The tty our ldisc is bound to */ 170 struct tty_struct *tty; /* The tty our ldisc is bound to */
171 spinlock_t lock; 171 spinlock_t lock;
172 unsigned int num;
172 173
173 /* Events on the GSM channel */ 174 /* Events on the GSM channel */
174 wait_queue_head_t event; 175 wait_queue_head_t event;
@@ -250,6 +251,8 @@ struct gsm_mux {
250static struct gsm_mux *gsm_mux[MAX_MUX]; /* GSM muxes */ 251static struct gsm_mux *gsm_mux[MAX_MUX]; /* GSM muxes */
251static spinlock_t gsm_mux_lock; 252static spinlock_t gsm_mux_lock;
252 253
254static struct tty_driver *gsm_tty_driver;
255
253/* 256/*
254 * This section of the driver logic implements the GSM encodings 257 * This section of the driver logic implements the GSM encodings
255 * both the basic and the 'advanced'. Reliable transport is not 258 * both the basic and the 'advanced'. Reliable transport is not
@@ -1996,6 +1999,7 @@ int gsm_activate_mux(struct gsm_mux *gsm)
1996 spin_lock(&gsm_mux_lock); 1999 spin_lock(&gsm_mux_lock);
1997 for (i = 0; i < MAX_MUX; i++) { 2000 for (i = 0; i < MAX_MUX; i++) {
1998 if (gsm_mux[i] == NULL) { 2001 if (gsm_mux[i] == NULL) {
2002 gsm->num = i;
1999 gsm_mux[i] = gsm; 2003 gsm_mux[i] = gsm;
2000 break; 2004 break;
2001 } 2005 }
@@ -2101,13 +2105,20 @@ static int gsmld_output(struct gsm_mux *gsm, u8 *data, int len)
2101 2105
2102static int gsmld_attach_gsm(struct tty_struct *tty, struct gsm_mux *gsm) 2106static int gsmld_attach_gsm(struct tty_struct *tty, struct gsm_mux *gsm)
2103{ 2107{
2104 int ret; 2108 int ret, i;
2109 int base = gsm->num << 6; /* Base for this MUX */
2105 2110
2106 gsm->tty = tty_kref_get(tty); 2111 gsm->tty = tty_kref_get(tty);
2107 gsm->output = gsmld_output; 2112 gsm->output = gsmld_output;
2108 ret = gsm_activate_mux(gsm); 2113 ret = gsm_activate_mux(gsm);
2109 if (ret != 0) 2114 if (ret != 0)
2110 tty_kref_put(gsm->tty); 2115 tty_kref_put(gsm->tty);
2116 else {
2117 /* Don't register device 0 - this is the control channel and not
2118 a usable tty interface */
2119 for (i = 1; i < NUM_DLCI; i++)
2120 tty_register_device(gsm_tty_driver, base + i, NULL);
2121 }
2111 return ret; 2122 return ret;
2112} 2123}
2113 2124
@@ -2122,7 +2133,12 @@ static int gsmld_attach_gsm(struct tty_struct *tty, struct gsm_mux *gsm)
2122 2133
2123static void gsmld_detach_gsm(struct tty_struct *tty, struct gsm_mux *gsm) 2134static void gsmld_detach_gsm(struct tty_struct *tty, struct gsm_mux *gsm)
2124{ 2135{
2136 int i;
2137 int base = gsm->num << 6; /* Base for this MUX */
2138
2125 WARN_ON(tty != gsm->tty); 2139 WARN_ON(tty != gsm->tty);
2140 for (i = 1; i < NUM_DLCI; i++)
2141 tty_unregister_device(gsm_tty_driver, base + i);
2126 gsm_cleanup_mux(gsm); 2142 gsm_cleanup_mux(gsm);
2127 tty_kref_put(gsm->tty); 2143 tty_kref_put(gsm->tty);
2128 gsm->tty = NULL; 2144 gsm->tty = NULL;
@@ -2712,7 +2728,6 @@ static int gsmtty_break_ctl(struct tty_struct *tty, int state)
2712 return gsmtty_modem_update(dlci, encode); 2728 return gsmtty_modem_update(dlci, encode);
2713} 2729}
2714 2730
2715static struct tty_driver *gsm_tty_driver;
2716 2731
2717/* Virtual ttys for the demux */ 2732/* Virtual ttys for the demux */
2718static const struct tty_operations gsmtty_ops = { 2733static const struct tty_operations gsmtty_ops = {