Skip to content

Commit

Permalink
char-parallel: convert parallel to finalize
Browse files Browse the repository at this point in the history
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
  • Loading branch information
elmarco committed Jan 31, 2017
1 parent 9fa2f7a commit c930572
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions qemu-char.c
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit c930572

Please sign in to comment.