chardev: clean up chardev-parallel.c

Replace HAVE_CHARDEV_PARPORT with a Meson conditional, remove unnecessary
defines, and close the file descriptor on FreeBSD/DragonFly.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
Paolo Bonzini 2022-12-19 10:17:09 +01:00
parent c0a6665c3c
commit 1baf34a136
3 changed files with 6 additions and 19 deletions

View File

@ -238,7 +238,6 @@ static void qemu_chr_open_pp_fd(Chardev *chr,
} }
#endif #endif
#ifdef HAVE_CHARDEV_PARPORT
static void qmp_chardev_open_parallel(Chardev *chr, static void qmp_chardev_open_parallel(Chardev *chr,
ChardevBackend *backend, ChardevBackend *backend,
bool *be_opened, bool *be_opened,
@ -276,29 +275,21 @@ static void char_parallel_class_init(ObjectClass *oc, void *data)
cc->parse = qemu_chr_parse_parallel; cc->parse = qemu_chr_parse_parallel;
cc->open = qmp_chardev_open_parallel; cc->open = qmp_chardev_open_parallel;
#if defined(__linux__)
cc->chr_ioctl = pp_ioctl; cc->chr_ioctl = pp_ioctl;
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || \
defined(__DragonFly__)
cc->chr_ioctl = pp_ioctl;
#endif
} }
static void char_parallel_finalize(Object *obj) static void char_parallel_finalize(Object *obj)
{ {
#if defined(__linux__)
Chardev *chr = CHARDEV(obj); Chardev *chr = CHARDEV(obj);
ParallelChardev *drv = PARALLEL_CHARDEV(chr); ParallelChardev *drv = PARALLEL_CHARDEV(chr);
int fd = drv->fd; int fd = drv->fd;
#if defined(__linux__)
pp_hw_mode(drv, IEEE1284_MODE_COMPAT); pp_hw_mode(drv, IEEE1284_MODE_COMPAT);
ioctl(fd, PPRELEASE); ioctl(fd, PPRELEASE);
#endif
close(fd); close(fd);
qemu_chr_be_event(chr, CHR_EVENT_CLOSED); 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 = { static const TypeInfo char_parallel_type_info = {
@ -315,5 +306,3 @@ static void register_types(void)
} }
type_init(register_types); type_init(register_types);
#endif

View File

@ -14,9 +14,12 @@ chardev_ss.add(files(
)) ))
chardev_ss.add(when: 'CONFIG_POSIX', if_true: [files( chardev_ss.add(when: 'CONFIG_POSIX', if_true: [files(
'char-fd.c', 'char-fd.c',
'char-parallel.c',
'char-pty.c', 'char-pty.c',
), util]) ), util])
if targetos in ['linux', 'gnu/kfreebsd', 'freebsd', 'dragonfly']
chardev_ss.add(files('char-parallel.c'))
endif
chardev_ss.add(when: 'CONFIG_WIN32', if_true: files( chardev_ss.add(when: 'CONFIG_WIN32', if_true: files(
'char-console.c', 'char-console.c',
'char-win-stdio.c', 'char-win-stdio.c',

View File

@ -427,11 +427,6 @@ void qemu_anon_ram_free(void *ptr, size_t size);
#define HAVE_CHARDEV_SERIAL 1 #define HAVE_CHARDEV_SERIAL 1
#endif #endif
#if defined(__linux__) || defined(__FreeBSD__) || \
defined(__FreeBSD_kernel__) || defined(__DragonFly__)
#define HAVE_CHARDEV_PARPORT 1
#endif
#if defined(__HAIKU__) #if defined(__HAIKU__)
#define SIGIO SIGPOLL #define SIGIO SIGPOLL
#endif #endif