aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJiri Slaby <jslaby@suse.cz>2012-04-02 07:54:33 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-04-09 14:30:39 -0400
commit7393af808fe1564ad34289b507b950445dfc06ac (patch)
treeaa377da11b0f0c8b70718e36203f5a8bdaa7abfc
parente6df3cce07a25d7d65c7d3d2cec87cbf02fd21f0 (diff)
TTY: ipwireless, add tty_port
And use count from that. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Cc: Jiri Kosina <jkosina@suse.cz> Acked-by: David Sterba <dsterba@suse.cz> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/tty/ipwireless/tty.c29
1 files changed, 15 insertions, 14 deletions
diff --git a/drivers/tty/ipwireless/tty.c b/drivers/tty/ipwireless/tty.c
index 4270bfd59a7..0b4964d1eea 100644
--- a/drivers/tty/ipwireless/tty.c
+++ b/drivers/tty/ipwireless/tty.c
@@ -44,6 +44,7 @@
44#define TTYTYPE_RAS_RAW (2) 44#define TTYTYPE_RAS_RAW (2)
45 45
46struct ipw_tty { 46struct ipw_tty {
47 struct tty_port port;
47 int index; 48 int index;
48 struct ipw_hardware *hardware; 49 struct ipw_hardware *hardware;
49 unsigned int channel_idx; 50 unsigned int channel_idx;
@@ -51,7 +52,6 @@ struct ipw_tty {
51 int tty_type; 52 int tty_type;
52 struct ipw_network *network; 53 struct ipw_network *network;
53 struct tty_struct *linux_tty; 54 struct tty_struct *linux_tty;
54 int open_count;
55 unsigned int control_lines; 55 unsigned int control_lines;
56 struct mutex ipw_tty_mutex; 56 struct mutex ipw_tty_mutex;
57 int tx_bytes_queued; 57 int tx_bytes_queued;
@@ -100,10 +100,10 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
100 mutex_unlock(&tty->ipw_tty_mutex); 100 mutex_unlock(&tty->ipw_tty_mutex);
101 return -ENODEV; 101 return -ENODEV;
102 } 102 }
103 if (tty->open_count == 0) 103 if (tty->port.count == 0)
104 tty->tx_bytes_queued = 0; 104 tty->tx_bytes_queued = 0;
105 105
106 tty->open_count++; 106 tty->port.count++;
107 107
108 tty->linux_tty = linux_tty; 108 tty->linux_tty = linux_tty;
109 linux_tty->driver_data = tty; 109 linux_tty->driver_data = tty;
@@ -119,9 +119,9 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
119 119
120static void do_ipw_close(struct ipw_tty *tty) 120static void do_ipw_close(struct ipw_tty *tty)
121{ 121{
122 tty->open_count--; 122 tty->port.count--;
123 123
124 if (tty->open_count == 0) { 124 if (tty->port.count == 0) {
125 struct tty_struct *linux_tty = tty->linux_tty; 125 struct tty_struct *linux_tty = tty->linux_tty;
126 126
127 if (linux_tty != NULL) { 127 if (linux_tty != NULL) {
@@ -142,7 +142,7 @@ static void ipw_hangup(struct tty_struct *linux_tty)
142 return; 142 return;
143 143
144 mutex_lock(&tty->ipw_tty_mutex); 144 mutex_lock(&tty->ipw_tty_mutex);
145 if (tty->open_count == 0) { 145 if (tty->port.count == 0) {
146 mutex_unlock(&tty->ipw_tty_mutex); 146 mutex_unlock(&tty->ipw_tty_mutex);
147 return; 147 return;
148 } 148 }
@@ -171,7 +171,7 @@ void ipwireless_tty_received(struct ipw_tty *tty, unsigned char *data,
171 return; 171 return;
172 } 172 }
173 173
174 if (!tty->open_count) { 174 if (!tty->port.count) {
175 mutex_unlock(&tty->ipw_tty_mutex); 175 mutex_unlock(&tty->ipw_tty_mutex);
176 return; 176 return;
177 } 177 }
@@ -213,7 +213,7 @@ static int ipw_write(struct tty_struct *linux_tty,
213 return -ENODEV; 213 return -ENODEV;
214 214
215 mutex_lock(&tty->ipw_tty_mutex); 215 mutex_lock(&tty->ipw_tty_mutex);
216 if (!tty->open_count) { 216 if (!tty->port.count) {
217 mutex_unlock(&tty->ipw_tty_mutex); 217 mutex_unlock(&tty->ipw_tty_mutex);
218 return -EINVAL; 218 return -EINVAL;
219 } 219 }
@@ -253,7 +253,7 @@ static int ipw_write_room(struct tty_struct *linux_tty)
253 if (!tty) 253 if (!tty)
254 return -ENODEV; 254 return -ENODEV;
255 255
256 if (!tty->open_count) 256 if (!tty->port.count)
257 return -EINVAL; 257 return -EINVAL;
258 258
259 room = IPWIRELESS_TX_QUEUE_SIZE - tty->tx_bytes_queued; 259 room = IPWIRELESS_TX_QUEUE_SIZE - tty->tx_bytes_queued;
@@ -295,7 +295,7 @@ static int ipw_chars_in_buffer(struct tty_struct *linux_tty)
295 if (!tty) 295 if (!tty)
296 return 0; 296 return 0;
297 297
298 if (!tty->open_count) 298 if (!tty->port.count)
299 return 0; 299 return 0;
300 300
301 return tty->tx_bytes_queued; 301 return tty->tx_bytes_queued;
@@ -376,7 +376,7 @@ static int ipw_tiocmget(struct tty_struct *linux_tty)
376 if (!tty) 376 if (!tty)
377 return -ENODEV; 377 return -ENODEV;
378 378
379 if (!tty->open_count) 379 if (!tty->port.count)
380 return -EINVAL; 380 return -EINVAL;
381 381
382 return get_control_lines(tty); 382 return get_control_lines(tty);
@@ -392,7 +392,7 @@ ipw_tiocmset(struct tty_struct *linux_tty,
392 if (!tty) 392 if (!tty)
393 return -ENODEV; 393 return -ENODEV;
394 394
395 if (!tty->open_count) 395 if (!tty->port.count)
396 return -EINVAL; 396 return -EINVAL;
397 397
398 return set_control_lines(tty, set, clear); 398 return set_control_lines(tty, set, clear);
@@ -406,7 +406,7 @@ static int ipw_ioctl(struct tty_struct *linux_tty,
406 if (!tty) 406 if (!tty)
407 return -ENODEV; 407 return -ENODEV;
408 408
409 if (!tty->open_count) 409 if (!tty->port.count)
410 return -EINVAL; 410 return -EINVAL;
411 411
412 /* FIXME: Exactly how is the tty object locked here .. */ 412 /* FIXME: Exactly how is the tty object locked here .. */
@@ -475,6 +475,7 @@ static int add_tty(int j,
475 ttys[j]->network = network; 475 ttys[j]->network = network;
476 ttys[j]->tty_type = tty_type; 476 ttys[j]->tty_type = tty_type;
477 mutex_init(&ttys[j]->ipw_tty_mutex); 477 mutex_init(&ttys[j]->ipw_tty_mutex);
478 tty_port_init(&ttys[j]->port);
478 479
479 tty_register_device(ipw_tty_driver, j, NULL); 480 tty_register_device(ipw_tty_driver, j, NULL);
480 ipwireless_associate_network_tty(network, channel_idx, ttys[j]); 481 ipwireless_associate_network_tty(network, channel_idx, ttys[j]);
@@ -561,7 +562,7 @@ void ipwireless_tty_free(struct ipw_tty *tty)
561 * are gone */ 562 * are gone */
562 mutex_lock(&ttyj->ipw_tty_mutex); 563 mutex_lock(&ttyj->ipw_tty_mutex);
563 } 564 }
564 while (ttyj->open_count) 565 while (ttyj->port.count)
565 do_ipw_close(ttyj); 566 do_ipw_close(ttyj);
566 ipwireless_disassociate_network_ttys(network, 567 ipwireless_disassociate_network_ttys(network,
567 ttyj->channel_idx); 568 ttyj->channel_idx);