diff options
author | Jiri Slaby <jslaby@suse.cz> | 2012-04-02 07:54:24 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-04-09 14:28:18 -0400 |
commit | 1997cf044853a2d83cd0ebc307e292fa9fa819de (patch) | |
tree | 4bbf936c53864db4fedbe4916b88d5e035d5bb1c /drivers/tty/hvc/hvcs.c | |
parent | 0146b6939074ebe14ece3604fd00e7be128a3812 (diff) |
TTY: hvcs, add tty_port
And use count from there.
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: linuxppc-dev@lists.ozlabs.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty/hvc/hvcs.c')
-rw-r--r-- | drivers/tty/hvc/hvcs.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/drivers/tty/hvc/hvcs.c b/drivers/tty/hvc/hvcs.c index 3436436fe2d7..a049ced97430 100644 --- a/drivers/tty/hvc/hvcs.c +++ b/drivers/tty/hvc/hvcs.c | |||
@@ -261,6 +261,7 @@ static DEFINE_SPINLOCK(hvcs_pi_lock); | |||
261 | 261 | ||
262 | /* One vty-server per hvcs_struct */ | 262 | /* One vty-server per hvcs_struct */ |
263 | struct hvcs_struct { | 263 | struct hvcs_struct { |
264 | struct tty_port port; | ||
264 | spinlock_t lock; | 265 | spinlock_t lock; |
265 | 266 | ||
266 | /* | 267 | /* |
@@ -270,7 +271,6 @@ struct hvcs_struct { | |||
270 | unsigned int index; | 271 | unsigned int index; |
271 | 272 | ||
272 | struct tty_struct *tty; | 273 | struct tty_struct *tty; |
273 | int open_count; | ||
274 | 274 | ||
275 | /* | 275 | /* |
276 | * Used to tell the driver kernel_thread what operations need to take | 276 | * Used to tell the driver kernel_thread what operations need to take |
@@ -422,7 +422,7 @@ static ssize_t hvcs_vterm_state_store(struct device *dev, struct device_attribut | |||
422 | 422 | ||
423 | spin_lock_irqsave(&hvcsd->lock, flags); | 423 | spin_lock_irqsave(&hvcsd->lock, flags); |
424 | 424 | ||
425 | if (hvcsd->open_count > 0) { | 425 | if (hvcsd->port.count > 0) { |
426 | spin_unlock_irqrestore(&hvcsd->lock, flags); | 426 | spin_unlock_irqrestore(&hvcsd->lock, flags); |
427 | printk(KERN_INFO "HVCS: vterm state unchanged. " | 427 | printk(KERN_INFO "HVCS: vterm state unchanged. " |
428 | "The hvcs device node is still in use.\n"); | 428 | "The hvcs device node is still in use.\n"); |
@@ -789,7 +789,7 @@ static int __devinit hvcs_probe( | |||
789 | if (!hvcsd) | 789 | if (!hvcsd) |
790 | return -ENODEV; | 790 | return -ENODEV; |
791 | 791 | ||
792 | 792 | tty_port_init(&hvcsd->port); | |
793 | spin_lock_init(&hvcsd->lock); | 793 | spin_lock_init(&hvcsd->lock); |
794 | /* Automatically incs the refcount the first time */ | 794 | /* Automatically incs the refcount the first time */ |
795 | kref_init(&hvcsd->kref); | 795 | kref_init(&hvcsd->kref); |
@@ -1138,7 +1138,7 @@ static int hvcs_open(struct tty_struct *tty, struct file *filp) | |||
1138 | if ((retval = hvcs_partner_connect(hvcsd))) | 1138 | if ((retval = hvcs_partner_connect(hvcsd))) |
1139 | goto error_release; | 1139 | goto error_release; |
1140 | 1140 | ||
1141 | hvcsd->open_count = 1; | 1141 | hvcsd->port.count = 1; |
1142 | hvcsd->tty = tty; | 1142 | hvcsd->tty = tty; |
1143 | tty->driver_data = hvcsd; | 1143 | tty->driver_data = hvcsd; |
1144 | 1144 | ||
@@ -1172,7 +1172,7 @@ fast_open: | |||
1172 | 1172 | ||
1173 | spin_lock_irqsave(&hvcsd->lock, flags); | 1173 | spin_lock_irqsave(&hvcsd->lock, flags); |
1174 | kref_get(&hvcsd->kref); | 1174 | kref_get(&hvcsd->kref); |
1175 | hvcsd->open_count++; | 1175 | hvcsd->port.count++; |
1176 | hvcsd->todo_mask |= HVCS_SCHED_READ; | 1176 | hvcsd->todo_mask |= HVCS_SCHED_READ; |
1177 | spin_unlock_irqrestore(&hvcsd->lock, flags); | 1177 | spin_unlock_irqrestore(&hvcsd->lock, flags); |
1178 | 1178 | ||
@@ -1216,7 +1216,7 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp) | |||
1216 | hvcsd = tty->driver_data; | 1216 | hvcsd = tty->driver_data; |
1217 | 1217 | ||
1218 | spin_lock_irqsave(&hvcsd->lock, flags); | 1218 | spin_lock_irqsave(&hvcsd->lock, flags); |
1219 | if (--hvcsd->open_count == 0) { | 1219 | if (--hvcsd->port.count == 0) { |
1220 | 1220 | ||
1221 | vio_disable_interrupts(hvcsd->vdev); | 1221 | vio_disable_interrupts(hvcsd->vdev); |
1222 | 1222 | ||
@@ -1242,10 +1242,10 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp) | |||
1242 | free_irq(irq, hvcsd); | 1242 | free_irq(irq, hvcsd); |
1243 | kref_put(&hvcsd->kref, destroy_hvcs_struct); | 1243 | kref_put(&hvcsd->kref, destroy_hvcs_struct); |
1244 | return; | 1244 | return; |
1245 | } else if (hvcsd->open_count < 0) { | 1245 | } else if (hvcsd->port.count < 0) { |
1246 | printk(KERN_ERR "HVCS: vty-server@%X open_count: %d" | 1246 | printk(KERN_ERR "HVCS: vty-server@%X open_count: %d" |
1247 | " is missmanaged.\n", | 1247 | " is missmanaged.\n", |
1248 | hvcsd->vdev->unit_address, hvcsd->open_count); | 1248 | hvcsd->vdev->unit_address, hvcsd->port.count); |
1249 | } | 1249 | } |
1250 | 1250 | ||
1251 | spin_unlock_irqrestore(&hvcsd->lock, flags); | 1251 | spin_unlock_irqrestore(&hvcsd->lock, flags); |
@@ -1261,7 +1261,7 @@ static void hvcs_hangup(struct tty_struct * tty) | |||
1261 | 1261 | ||
1262 | spin_lock_irqsave(&hvcsd->lock, flags); | 1262 | spin_lock_irqsave(&hvcsd->lock, flags); |
1263 | /* Preserve this so that we know how many kref refs to put */ | 1263 | /* Preserve this so that we know how many kref refs to put */ |
1264 | temp_open_count = hvcsd->open_count; | 1264 | temp_open_count = hvcsd->port.count; |
1265 | 1265 | ||
1266 | /* | 1266 | /* |
1267 | * Don't kref put inside the spinlock because the destruction | 1267 | * Don't kref put inside the spinlock because the destruction |
@@ -1276,7 +1276,7 @@ static void hvcs_hangup(struct tty_struct * tty) | |||
1276 | hvcsd->tty->driver_data = NULL; | 1276 | hvcsd->tty->driver_data = NULL; |
1277 | hvcsd->tty = NULL; | 1277 | hvcsd->tty = NULL; |
1278 | 1278 | ||
1279 | hvcsd->open_count = 0; | 1279 | hvcsd->port.count = 0; |
1280 | 1280 | ||
1281 | /* This will drop any buffered data on the floor which is OK in a hangup | 1281 | /* This will drop any buffered data on the floor which is OK in a hangup |
1282 | * scenario. */ | 1282 | * scenario. */ |
@@ -1347,7 +1347,7 @@ static int hvcs_write(struct tty_struct *tty, | |||
1347 | * the middle of a write operation? This is a crummy place to do this | 1347 | * the middle of a write operation? This is a crummy place to do this |
1348 | * but we want to keep it all in the spinlock. | 1348 | * but we want to keep it all in the spinlock. |
1349 | */ | 1349 | */ |
1350 | if (hvcsd->open_count <= 0) { | 1350 | if (hvcsd->port.count <= 0) { |
1351 | spin_unlock_irqrestore(&hvcsd->lock, flags); | 1351 | spin_unlock_irqrestore(&hvcsd->lock, flags); |
1352 | return -ENODEV; | 1352 | return -ENODEV; |
1353 | } | 1353 | } |
@@ -1421,7 +1421,7 @@ static int hvcs_write_room(struct tty_struct *tty) | |||
1421 | { | 1421 | { |
1422 | struct hvcs_struct *hvcsd = tty->driver_data; | 1422 | struct hvcs_struct *hvcsd = tty->driver_data; |
1423 | 1423 | ||
1424 | if (!hvcsd || hvcsd->open_count <= 0) | 1424 | if (!hvcsd || hvcsd->port.count <= 0) |
1425 | return 0; | 1425 | return 0; |
1426 | 1426 | ||
1427 | return HVCS_BUFF_LEN - hvcsd->chars_in_buffer; | 1427 | return HVCS_BUFF_LEN - hvcsd->chars_in_buffer; |