diff options
author | Michael S. Tsirkin <mst@redhat.com> | 2018-04-20 13:51:18 -0400 |
---|---|---|
committer | Michael S. Tsirkin <mst@redhat.com> | 2018-04-25 13:41:26 -0400 |
commit | aa44ec867030a72e8aa127977e37dec551d8df19 (patch) | |
tree | 1e8845e767bec6b27cef68406c222ecd81b0a697 | |
parent | 61a8950c5c5708cf2068b29ffde94e454e528208 (diff) |
virtio_console: move removal code
Will make it reusable for error handling.
Cc: stable@vger.kernel.org
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
-rw-r--r-- | drivers/char/virtio_console.c | 72 |
1 files changed, 36 insertions, 36 deletions
diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c index 2d87ce555140..e8480fe2e1d8 100644 --- a/drivers/char/virtio_console.c +++ b/drivers/char/virtio_console.c | |||
@@ -1988,6 +1988,42 @@ static void remove_vqs(struct ports_device *portdev) | |||
1988 | kfree(portdev->out_vqs); | 1988 | kfree(portdev->out_vqs); |
1989 | } | 1989 | } |
1990 | 1990 | ||
1991 | static void virtcons_remove(struct virtio_device *vdev) | ||
1992 | { | ||
1993 | struct ports_device *portdev; | ||
1994 | struct port *port, *port2; | ||
1995 | |||
1996 | portdev = vdev->priv; | ||
1997 | |||
1998 | spin_lock_irq(&pdrvdata_lock); | ||
1999 | list_del(&portdev->list); | ||
2000 | spin_unlock_irq(&pdrvdata_lock); | ||
2001 | |||
2002 | /* Disable interrupts for vqs */ | ||
2003 | vdev->config->reset(vdev); | ||
2004 | /* Finish up work that's lined up */ | ||
2005 | if (use_multiport(portdev)) | ||
2006 | cancel_work_sync(&portdev->control_work); | ||
2007 | else | ||
2008 | cancel_work_sync(&portdev->config_work); | ||
2009 | |||
2010 | list_for_each_entry_safe(port, port2, &portdev->ports, list) | ||
2011 | unplug_port(port); | ||
2012 | |||
2013 | unregister_chrdev(portdev->chr_major, "virtio-portsdev"); | ||
2014 | |||
2015 | /* | ||
2016 | * When yanking out a device, we immediately lose the | ||
2017 | * (device-side) queues. So there's no point in keeping the | ||
2018 | * guest side around till we drop our final reference. This | ||
2019 | * also means that any ports which are in an open state will | ||
2020 | * have to just stop using the port, as the vqs are going | ||
2021 | * away. | ||
2022 | */ | ||
2023 | remove_vqs(portdev); | ||
2024 | kfree(portdev); | ||
2025 | } | ||
2026 | |||
1991 | /* | 2027 | /* |
1992 | * Once we're further in boot, we get probed like any other virtio | 2028 | * Once we're further in boot, we get probed like any other virtio |
1993 | * device. | 2029 | * device. |
@@ -2116,42 +2152,6 @@ fail: | |||
2116 | return err; | 2152 | return err; |
2117 | } | 2153 | } |
2118 | 2154 | ||
2119 | static void virtcons_remove(struct virtio_device *vdev) | ||
2120 | { | ||
2121 | struct ports_device *portdev; | ||
2122 | struct port *port, *port2; | ||
2123 | |||
2124 | portdev = vdev->priv; | ||
2125 | |||
2126 | spin_lock_irq(&pdrvdata_lock); | ||
2127 | list_del(&portdev->list); | ||
2128 | spin_unlock_irq(&pdrvdata_lock); | ||
2129 | |||
2130 | /* Disable interrupts for vqs */ | ||
2131 | vdev->config->reset(vdev); | ||
2132 | /* Finish up work that's lined up */ | ||
2133 | if (use_multiport(portdev)) | ||
2134 | cancel_work_sync(&portdev->control_work); | ||
2135 | else | ||
2136 | cancel_work_sync(&portdev->config_work); | ||
2137 | |||
2138 | list_for_each_entry_safe(port, port2, &portdev->ports, list) | ||
2139 | unplug_port(port); | ||
2140 | |||
2141 | unregister_chrdev(portdev->chr_major, "virtio-portsdev"); | ||
2142 | |||
2143 | /* | ||
2144 | * When yanking out a device, we immediately lose the | ||
2145 | * (device-side) queues. So there's no point in keeping the | ||
2146 | * guest side around till we drop our final reference. This | ||
2147 | * also means that any ports which are in an open state will | ||
2148 | * have to just stop using the port, as the vqs are going | ||
2149 | * away. | ||
2150 | */ | ||
2151 | remove_vqs(portdev); | ||
2152 | kfree(portdev); | ||
2153 | } | ||
2154 | |||
2155 | static struct virtio_device_id id_table[] = { | 2155 | static struct virtio_device_id id_table[] = { |
2156 | { VIRTIO_ID_CONSOLE, VIRTIO_DEV_ANY_ID }, | 2156 | { VIRTIO_ID_CONSOLE, VIRTIO_DEV_ANY_ID }, |
2157 | { 0 }, | 2157 | { 0 }, |