Patchwork baum: add destroy hook

login
register
mail settings
Submitter Samuel Thibault
Date March 28, 2010, 6:39 p.m.
Message ID <20100328183942.GN7497@const.famille.thibault.fr>
Download mbox | patch
Permalink /patch/48788/
State New
Headers show

Comments

Samuel Thibault - March 28, 2010, 6:39 p.m.
Hello,

This adds a destroy hook for the baum character device, to properly
close the BrlAPI connection and free resources.

Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
 
commit 447c41758cfda0022ea6e09aaf81137b2b27b915
Author: Samuel Thibault <samuel.thibault@ens-lyon.org>
Date:   Sun Mar 28 20:38:38 2010 +0200

    baum: add destroy hook
    
    Add a destroy hook for the baum character device, to properly close the BrlAPI
    connection.
Aurelien Jarno - April 8, 2010, 7:17 p.m.
On Sun, Mar 28, 2010 at 08:39:42PM +0200, Samuel Thibault wrote:
> Hello,
> 
> This adds a destroy hook for the baum character device, to properly
> close the BrlAPI connection and free resources.
> 
> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>

Thanks, applied.

> commit 447c41758cfda0022ea6e09aaf81137b2b27b915
> Author: Samuel Thibault <samuel.thibault@ens-lyon.org>
> Date:   Sun Mar 28 20:38:38 2010 +0200
> 
>     baum: add destroy hook
>     
>     Add a destroy hook for the baum character device, to properly close the BrlAPI
>     connection.
> 
> diff --git a/hw/baum.c b/hw/baum.c
> index 18633f4..21326ae 100644
> --- a/hw/baum.c
> +++ b/hw/baum.c
> @@ -564,6 +564,18 @@ static void baum_chr_read(void *opaque)
>      }
>  }
>  
> +static void baum_close(struct CharDriverState *chr)
> +{
> +    BaumDriverState *baum = chr->opaque;
> +
> +    qemu_free_timer(baum->cellCount_timer);
> +    if (baum->brlapi) {
> +        brlapi__closeConnection(baum->brlapi);
> +        qemu_free(baum->brlapi);
> +    }
> +    qemu_free(baum);
> +}
> +
>  CharDriverState *chr_baum_init(QemuOpts *opts)
>  {
>      BaumDriverState *baum;
> @@ -581,6 +593,7 @@ CharDriverState *chr_baum_init(QemuOpts *opts)
>      chr->chr_write = baum_write;
>      chr->chr_send_event = baum_send_event;
>      chr->chr_accept_input = baum_accept_input;
> +    chr->chr_close = baum_close;
>  
>      handle = qemu_mallocz(brlapi_getHandleSize());
>      baum->brlapi = handle;
> 
> 
>

Patch

diff --git a/hw/baum.c b/hw/baum.c
index 18633f4..21326ae 100644
--- a/hw/baum.c
+++ b/hw/baum.c
@@ -564,6 +564,18 @@  static void baum_chr_read(void *opaque)
     }
 }
 
+static void baum_close(struct CharDriverState *chr)
+{
+    BaumDriverState *baum = chr->opaque;
+
+    qemu_free_timer(baum->cellCount_timer);
+    if (baum->brlapi) {
+        brlapi__closeConnection(baum->brlapi);
+        qemu_free(baum->brlapi);
+    }
+    qemu_free(baum);
+}
+
 CharDriverState *chr_baum_init(QemuOpts *opts)
 {
     BaumDriverState *baum;
@@ -581,6 +593,7 @@  CharDriverState *chr_baum_init(QemuOpts *opts)
     chr->chr_write = baum_write;
     chr->chr_send_event = baum_send_event;
     chr->chr_accept_input = baum_accept_input;
+    chr->chr_close = baum_close;
 
     handle = qemu_mallocz(brlapi_getHandleSize());
     baum->brlapi = handle;