aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mmc/card/sdio_uart.c
diff options
context:
space:
mode:
authorJiri Slaby <jslaby@suse.cz>2012-11-15 03:49:52 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-11-15 20:20:57 -0500
commite70c67713cdabf55e05db7f1c4fc38085da333a5 (patch)
tree64e9a0939767882d2b5514033431174a0549597e /drivers/mmc/card/sdio_uart.c
parent9753eb8de8a36de41f3b5e217e995cccfbecdada (diff)
MMC: sdio, use kref from tty_port
After commit "TTY: move tty buffers to tty_port", the tty buffers are not freed in some drivers. This is because tty_port_destructor is not called whenever a tty_port is freed. This was an assumption I counted with but was unfortunately untrue. So fix the drivers to fulfil this assumption. Here it is enough to switch to refcounting in tty_port. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/mmc/card/sdio_uart.c')
-rw-r--r--drivers/mmc/card/sdio_uart.c23
1 files changed, 11 insertions, 12 deletions
diff --git a/drivers/mmc/card/sdio_uart.c b/drivers/mmc/card/sdio_uart.c
index 369f7ba1d216..bd57a11acc79 100644
--- a/drivers/mmc/card/sdio_uart.c
+++ b/drivers/mmc/card/sdio_uart.c
@@ -66,7 +66,6 @@ struct uart_icount {
66 66
67struct sdio_uart_port { 67struct sdio_uart_port {
68 struct tty_port port; 68 struct tty_port port;
69 struct kref kref;
70 unsigned int index; 69 unsigned int index;
71 struct sdio_func *func; 70 struct sdio_func *func;
72 struct mutex func_lock; 71 struct mutex func_lock;
@@ -92,7 +91,6 @@ static int sdio_uart_add_port(struct sdio_uart_port *port)
92{ 91{
93 int index, ret = -EBUSY; 92 int index, ret = -EBUSY;
94 93
95 kref_init(&port->kref);
96 mutex_init(&port->func_lock); 94 mutex_init(&port->func_lock);
97 spin_lock_init(&port->write_lock); 95 spin_lock_init(&port->write_lock);
98 if (kfifo_alloc(&port->xmit_fifo, FIFO_SIZE, GFP_KERNEL)) 96 if (kfifo_alloc(&port->xmit_fifo, FIFO_SIZE, GFP_KERNEL))
@@ -122,23 +120,15 @@ static struct sdio_uart_port *sdio_uart_port_get(unsigned index)
122 spin_lock(&sdio_uart_table_lock); 120 spin_lock(&sdio_uart_table_lock);
123 port = sdio_uart_table[index]; 121 port = sdio_uart_table[index];
124 if (port) 122 if (port)
125 kref_get(&port->kref); 123 tty_port_get(&port->port);
126 spin_unlock(&sdio_uart_table_lock); 124 spin_unlock(&sdio_uart_table_lock);
127 125
128 return port; 126 return port;
129} 127}
130 128
131static void sdio_uart_port_destroy(struct kref *kref)
132{
133 struct sdio_uart_port *port =
134 container_of(kref, struct sdio_uart_port, kref);
135 kfifo_free(&port->xmit_fifo);
136 kfree(port);
137}
138
139static void sdio_uart_port_put(struct sdio_uart_port *port) 129static void sdio_uart_port_put(struct sdio_uart_port *port)
140{ 130{
141 kref_put(&port->kref, sdio_uart_port_destroy); 131 tty_port_put(&port->port);
142} 132}
143 133
144static void sdio_uart_port_remove(struct sdio_uart_port *port) 134static void sdio_uart_port_remove(struct sdio_uart_port *port)
@@ -736,6 +726,14 @@ static void sdio_uart_shutdown(struct tty_port *tport)
736 sdio_uart_release_func(port); 726 sdio_uart_release_func(port);
737} 727}
738 728
729static void sdio_uart_port_destroy(struct tty_port *tport)
730{
731 struct sdio_uart_port *port =
732 container_of(tport, struct sdio_uart_port, port);
733 kfifo_free(&port->xmit_fifo);
734 kfree(port);
735}
736
739/** 737/**
740 * sdio_uart_install - install method 738 * sdio_uart_install - install method
741 * @driver: the driver in use (sdio_uart in our case) 739 * @driver: the driver in use (sdio_uart in our case)
@@ -1044,6 +1042,7 @@ static const struct tty_port_operations sdio_uart_port_ops = {
1044 .carrier_raised = uart_carrier_raised, 1042 .carrier_raised = uart_carrier_raised,
1045 .shutdown = sdio_uart_shutdown, 1043 .shutdown = sdio_uart_shutdown,
1046 .activate = sdio_uart_activate, 1044 .activate = sdio_uart_activate,
1045 .destruct = sdio_uart_port_destroy,
1047}; 1046};
1048 1047
1049static const struct tty_operations sdio_uart_ops = { 1048static const struct tty_operations sdio_uart_ops = {