aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@redhat.com>2016-12-08 17:57:35 +0300
committerMarc-André Lureau <marcandre.lureau@redhat.com>2017-01-31 13:01:47 +0400
commitc930572883aa8c38ddf194bdcbfe3b75056feaa8 (patch)
tree281c42acbc56e92d6277c79153cb99879fbecd37
parent9fa2f7a4ed2bd4db7de64374692385dd0852dbe7 (diff)
char-parallel: convert parallel to finalize
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
-rw-r--r--qemu-char.c30
1 files changed, 17 insertions, 13 deletions
diff --git a/qemu-char.c b/qemu-char.c
index 74e78b56d1..1981058f45 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -2025,17 +2025,6 @@ static int pp_ioctl(Chardev *chr, int cmd, void *arg)
return 0;
}
-static void pp_free(Chardev *chr)
-{
- ParallelChardev *drv = PARALLEL_CHARDEV(chr);
- int fd = drv->fd;
-
- pp_hw_mode(drv, IEEE1284_MODE_COMPAT);
- ioctl(fd, PPRELEASE);
- close(fd);
- qemu_chr_be_event(chr, CHR_EVENT_CLOSED);
-}
-
static void qemu_chr_open_pp_fd(Chardev *chr,
int fd,
bool *be_opened,
@@ -4699,18 +4688,33 @@ static void char_parallel_class_init(ObjectClass *oc, void *data)
#if defined(__linux__)
cc->chr_write = null_chr_write;
cc->chr_ioctl = pp_ioctl;
- cc->chr_free = pp_free;
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
- /* FIXME: no chr_free */
cc->chr_write = null_chr_write;
cc->chr_ioctl = pp_ioctl;
#endif
}
+static void char_parallel_finalize(Object *obj)
+{
+#if defined(__linux__)
+ Chardev *chr = CHARDEV(obj);
+ ParallelChardev *drv = PARALLEL_CHARDEV(chr);
+ int fd = drv->fd;
+
+ pp_hw_mode(drv, IEEE1284_MODE_COMPAT);
+ ioctl(fd, PPRELEASE);
+ close(fd);
+ qemu_chr_be_event(chr, CHR_EVENT_CLOSED);
+#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
+ /* FIXME: close fd? */
+#endif
+}
+
static const TypeInfo char_parallel_type_info = {
.name = TYPE_CHARDEV_PARALLEL,
.parent = TYPE_CHARDEV,
.instance_size = sizeof(ParallelChardev),
+ .instance_finalize = char_parallel_finalize,
.class_init = char_parallel_class_init,
};
#endif