提交 b4948be9 编写于 作者: M Marc-André Lureau 提交者: Paolo Bonzini

char: remove init callback

The CharDriverState.init() callback is no longer set since commit
a61ae7f8 and thus unused. The only user, the malta FGPA display has
been converted to use an event "opened" callback instead.
Signed-off-by: NMarc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20161022095318.17775-7-marcandre.lureau@redhat.com>
Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
上级 9850b05d
...@@ -1745,7 +1745,7 @@ int gdbserver_start(const char *device) ...@@ -1745,7 +1745,7 @@ int gdbserver_start(const char *device)
sigaction(SIGINT, &act, NULL); sigaction(SIGINT, &act, NULL);
} }
#endif #endif
chr = qemu_chr_new_noreplay("gdb", device, NULL); chr = qemu_chr_new_noreplay("gdb", device);
if (!chr) if (!chr)
return -1; return -1;
......
...@@ -2002,7 +2002,7 @@ void hmp_chardev_add(Monitor *mon, const QDict *qdict) ...@@ -2002,7 +2002,7 @@ void hmp_chardev_add(Monitor *mon, const QDict *qdict)
if (opts == NULL) { if (opts == NULL) {
error_setg(&err, "Parsing chardev args failed"); error_setg(&err, "Parsing chardev args failed");
} else { } else {
qemu_chr_new_from_opts(opts, NULL, &err); qemu_chr_new_from_opts(opts, &err);
qemu_opts_del(opts); qemu_opts_del(opts);
} }
hmp_handle_error(mon, &err); hmp_handle_error(mon, &err);
......
...@@ -125,7 +125,7 @@ static void fsl_imx25_realize(DeviceState *dev, Error **errp) ...@@ -125,7 +125,7 @@ static void fsl_imx25_realize(DeviceState *dev, Error **errp)
if (!chr) { if (!chr) {
char label[20]; char label[20];
snprintf(label, sizeof(label), "imx31.uart%d", i); snprintf(label, sizeof(label), "imx31.uart%d", i);
chr = qemu_chr_new(label, "null", NULL); chr = qemu_chr_new(label, "null");
} }
qdev_prop_set_chr(DEVICE(&s->uart[i]), "chardev", chr); qdev_prop_set_chr(DEVICE(&s->uart[i]), "chardev", chr);
......
...@@ -114,7 +114,7 @@ static void fsl_imx31_realize(DeviceState *dev, Error **errp) ...@@ -114,7 +114,7 @@ static void fsl_imx31_realize(DeviceState *dev, Error **errp)
if (!chr) { if (!chr) {
char label[20]; char label[20];
snprintf(label, sizeof(label), "imx31.uart%d", i); snprintf(label, sizeof(label), "imx31.uart%d", i);
chr = qemu_chr_new(label, "null", NULL); chr = qemu_chr_new(label, "null");
} }
qdev_prop_set_chr(DEVICE(&s->uart[i]), "chardev", chr); qdev_prop_set_chr(DEVICE(&s->uart[i]), "chardev", chr);
......
...@@ -193,7 +193,7 @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp) ...@@ -193,7 +193,7 @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp)
if (!chr) { if (!chr) {
char *label = g_strdup_printf("imx6.uart%d", i + 1); char *label = g_strdup_printf("imx6.uart%d", i + 1);
chr = qemu_chr_new(label, "null", NULL); chr = qemu_chr_new(label, "null");
g_free(label); g_free(label);
serial_hds[i] = chr; serial_hds[i] = chr;
} }
......
...@@ -798,7 +798,7 @@ static struct omap_sti_s *omap_sti_init(struct omap_target_agent_s *ta, ...@@ -798,7 +798,7 @@ static struct omap_sti_s *omap_sti_init(struct omap_target_agent_s *ta,
s->irq = irq; s->irq = irq;
omap_sti_reset(s); omap_sti_reset(s);
s->chr = chr ?: qemu_chr_new("null", "null", NULL); s->chr = chr ?: qemu_chr_new("null", "null");
memory_region_init_io(&s->iomem, NULL, &omap_sti_ops, s, "omap.sti", memory_region_init_io(&s->iomem, NULL, &omap_sti_ops, s, "omap.sti",
omap_l4_region_size(ta, 0)); omap_l4_region_size(ta, 0));
......
...@@ -606,7 +606,7 @@ DeviceState *exynos4210_uart_create(hwaddr addr, ...@@ -606,7 +606,7 @@ DeviceState *exynos4210_uart_create(hwaddr addr,
chr = serial_hds[channel]; chr = serial_hds[channel];
if (!chr) { if (!chr) {
snprintf(label, ARRAY_SIZE(label), "%s%d", chr_name, channel); snprintf(label, ARRAY_SIZE(label), "%s%d", chr_name, channel);
chr = qemu_chr_new(label, "null", NULL); chr = qemu_chr_new(label, "null");
if (!(chr)) { if (!(chr)) {
error_report("Can't assign serial port to UART%d", channel); error_report("Can't assign serial port to UART%d", channel);
exit(1); exit(1);
......
...@@ -63,7 +63,7 @@ struct omap_uart_s *omap_uart_init(hwaddr base, ...@@ -63,7 +63,7 @@ struct omap_uart_s *omap_uart_init(hwaddr base,
s->irq = irq; s->irq = irq;
s->serial = serial_mm_init(get_system_memory(), base, 2, irq, s->serial = serial_mm_init(get_system_memory(), base, 2, irq,
omap_clk_getrate(fclk)/16, omap_clk_getrate(fclk)/16,
chr ?: qemu_chr_new(label, "null", NULL), chr ?: qemu_chr_new(label, "null"),
DEVICE_NATIVE_ENDIAN); DEVICE_NATIVE_ENDIAN);
return s; return s;
} }
...@@ -183,6 +183,6 @@ void omap_uart_attach(struct omap_uart_s *s, CharDriverState *chr) ...@@ -183,6 +183,6 @@ void omap_uart_attach(struct omap_uart_s *s, CharDriverState *chr)
/* TODO: Should reuse or destroy current s->serial */ /* TODO: Should reuse or destroy current s->serial */
s->serial = serial_mm_init(get_system_memory(), s->base, 2, s->irq, s->serial = serial_mm_init(get_system_memory(), s->base, 2, s->irq,
omap_clk_getrate(s->fclk) / 16, omap_clk_getrate(s->fclk) / 16,
chr ?: qemu_chr_new("null", "null", NULL), chr ?: qemu_chr_new("null", "null"),
DEVICE_NATIVE_ENDIAN); DEVICE_NATIVE_ENDIAN);
} }
...@@ -199,7 +199,7 @@ static int con_init(struct XenDevice *xendev) ...@@ -199,7 +199,7 @@ static int con_init(struct XenDevice *xendev)
con->chr = serial_hds[con->xendev.dev]; con->chr = serial_hds[con->xendev.dev];
} else { } else {
snprintf(label, sizeof(label), "xencons%d", con->xendev.dev); snprintf(label, sizeof(label), "xencons%d", con->xendev.dev);
con->chr = qemu_chr_new(label, output, NULL); con->chr = qemu_chr_new(label, output);
} }
xenstore_store_pv_console_info(con->xendev.dev, con->chr); xenstore_store_pv_console_info(con->xendev.dev, con->chr);
......
...@@ -283,7 +283,7 @@ static void pc87312_realize(DeviceState *dev, Error **errp) ...@@ -283,7 +283,7 @@ static void pc87312_realize(DeviceState *dev, Error **errp)
/* FIXME use a qdev chardev prop instead of parallel_hds[] */ /* FIXME use a qdev chardev prop instead of parallel_hds[] */
chr = parallel_hds[0]; chr = parallel_hds[0];
if (chr == NULL) { if (chr == NULL) {
chr = qemu_chr_new("par0", "null", NULL); chr = qemu_chr_new("par0", "null");
} }
isa = isa_create(bus, "isa-parallel"); isa = isa_create(bus, "isa-parallel");
d = DEVICE(isa); d = DEVICE(isa);
...@@ -303,7 +303,7 @@ static void pc87312_realize(DeviceState *dev, Error **errp) ...@@ -303,7 +303,7 @@ static void pc87312_realize(DeviceState *dev, Error **errp)
chr = serial_hds[i]; chr = serial_hds[i];
if (chr == NULL) { if (chr == NULL) {
snprintf(name, sizeof(name), "ser%d", i); snprintf(name, sizeof(name), "ser%d", i);
chr = qemu_chr_new(name, "null", NULL); chr = qemu_chr_new(name, "null");
} }
isa = isa_create(bus, "isa-serial"); isa = isa_create(bus, "isa-serial");
d = DEVICE(isa); d = DEVICE(isa);
......
...@@ -566,7 +566,7 @@ static MaltaFPGAState *malta_fpga_init(MemoryRegion *address_space, ...@@ -566,7 +566,7 @@ static MaltaFPGAState *malta_fpga_init(MemoryRegion *address_space,
memory_region_add_subregion(address_space, base, &s->iomem_lo); memory_region_add_subregion(address_space, base, &s->iomem_lo);
memory_region_add_subregion(address_space, base + 0xa00, &s->iomem_hi); memory_region_add_subregion(address_space, base + 0xa00, &s->iomem_hi);
s->display = qemu_chr_new("fpga", "vc:320x200", NULL); s->display = qemu_chr_new("fpga", "vc:320x200");
qemu_chr_add_handlers(s->display, NULL, NULL, qemu_chr_add_handlers(s->display, NULL, NULL,
malta_fgpa_display_event, s); malta_fgpa_display_event, s);
...@@ -1033,7 +1033,7 @@ void mips_malta_init(MachineState *machine) ...@@ -1033,7 +1033,7 @@ void mips_malta_init(MachineState *machine)
if (!serial_hds[i]) { if (!serial_hds[i]) {
char label[32]; char label[32];
snprintf(label, sizeof(label), "serial%d", i); snprintf(label, sizeof(label), "serial%d", i);
serial_hds[i] = qemu_chr_new(label, "null", NULL); serial_hds[i] = qemu_chr_new(label, "null");
} }
} }
......
...@@ -547,7 +547,7 @@ static USBDevice *usb_serial_init(USBBus *bus, const char *filename) ...@@ -547,7 +547,7 @@ static USBDevice *usb_serial_init(USBBus *bus, const char *filename)
filename++; filename++;
snprintf(label, sizeof(label), "usbserial%d", index++); snprintf(label, sizeof(label), "usbserial%d", index++);
cdrv = qemu_chr_new(label, filename, NULL); cdrv = qemu_chr_new(label, filename);
if (!cdrv) if (!cdrv)
return NULL; return NULL;
...@@ -565,7 +565,7 @@ static USBDevice *usb_braille_init(USBBus *bus, const char *unused) ...@@ -565,7 +565,7 @@ static USBDevice *usb_braille_init(USBBus *bus, const char *unused)
USBDevice *dev; USBDevice *dev;
CharDriverState *cdrv; CharDriverState *cdrv;
cdrv = qemu_chr_new("braille", "braille", NULL); cdrv = qemu_chr_new("braille", "braille");
if (!cdrv) if (!cdrv)
return NULL; return NULL;
......
...@@ -265,7 +265,7 @@ static void lx_init(const LxBoardDesc *board, MachineState *machine) ...@@ -265,7 +265,7 @@ static void lx_init(const LxBoardDesc *board, MachineState *machine)
} }
if (!serial_hds[0]) { if (!serial_hds[0]) {
serial_hds[0] = qemu_chr_new("serial0", "null", NULL); serial_hds[0] = qemu_chr_new("serial0", "null");
} }
serial_mm_init(system_io, 0x0d050020, 2, xtensa_get_extint(env, 0), serial_mm_init(system_io, 0x0d050020, 2, xtensa_get_extint(env, 0),
......
...@@ -75,7 +75,6 @@ typedef enum { ...@@ -75,7 +75,6 @@ typedef enum {
struct CharDriverState { struct CharDriverState {
QemuMutex chr_write_lock; QemuMutex chr_write_lock;
void (*init)(struct CharDriverState *s);
int (*chr_write)(struct CharDriverState *s, const uint8_t *buf, int len); int (*chr_write)(struct CharDriverState *s, const uint8_t *buf, int len);
int (*chr_sync_read)(struct CharDriverState *s, int (*chr_sync_read)(struct CharDriverState *s,
const uint8_t *buf, int len); const uint8_t *buf, int len);
...@@ -130,13 +129,11 @@ CharDriverState *qemu_chr_alloc(ChardevCommon *backend, Error **errp); ...@@ -130,13 +129,11 @@ CharDriverState *qemu_chr_alloc(ChardevCommon *backend, Error **errp);
* Create a new character backend from a QemuOpts list. * Create a new character backend from a QemuOpts list.
* *
* @opts see qemu-config.c for a list of valid options * @opts see qemu-config.c for a list of valid options
* @init not sure..
* *
* Returns: a new character backend * Returns: a new character backend
*/ */
CharDriverState *qemu_chr_new_from_opts(QemuOpts *opts, CharDriverState *qemu_chr_new_from_opts(QemuOpts *opts,
void (*init)(struct CharDriverState *s), Error **errp);
Error **errp);
/** /**
* @qemu_chr_parse_common: * @qemu_chr_parse_common:
...@@ -155,12 +152,10 @@ void qemu_chr_parse_common(QemuOpts *opts, ChardevCommon *backend); ...@@ -155,12 +152,10 @@ void qemu_chr_parse_common(QemuOpts *opts, ChardevCommon *backend);
* *
* @label the name of the backend * @label the name of the backend
* @filename the URI * @filename the URI
* @init not sure..
* *
* Returns: a new character backend * Returns: a new character backend
*/ */
CharDriverState *qemu_chr_new(const char *label, const char *filename, CharDriverState *qemu_chr_new(const char *label, const char *filename);
void (*init)(struct CharDriverState *s));
/** /**
* @qemu_chr_disconnect: * @qemu_chr_disconnect:
* *
...@@ -191,12 +186,10 @@ int qemu_chr_wait_connected(CharDriverState *chr, Error **errp); ...@@ -191,12 +186,10 @@ int qemu_chr_wait_connected(CharDriverState *chr, Error **errp);
* *
* @label the name of the backend * @label the name of the backend
* @filename the URI * @filename the URI
* @init not sure..
* *
* Returns: a new character backend * Returns: a new character backend
*/ */
CharDriverState *qemu_chr_new_noreplay(const char *label, const char *filename, CharDriverState *qemu_chr_new_noreplay(const char *label, const char *filename);
void (*init)(struct CharDriverState *s));
/** /**
* @qemu_chr_delete: * @qemu_chr_delete:
......
...@@ -747,7 +747,7 @@ static int slirp_guestfwd(SlirpState *s, const char *config_str, ...@@ -747,7 +747,7 @@ static int slirp_guestfwd(SlirpState *s, const char *config_str,
} }
} else { } else {
fwd = g_new(struct GuestFwd, 1); fwd = g_new(struct GuestFwd, 1);
fwd->hd = qemu_chr_new(buf, p, NULL); fwd->hd = qemu_chr_new(buf, p);
if (!fwd->hd) { if (!fwd->hd) {
error_report("could not open guest forwarding device '%s'", buf); error_report("could not open guest forwarding device '%s'", buf);
g_free(fwd); g_free(fwd);
......
...@@ -3909,8 +3909,7 @@ void register_char_driver(const char *name, ChardevBackendKind kind, ...@@ -3909,8 +3909,7 @@ void register_char_driver(const char *name, ChardevBackendKind kind,
} }
CharDriverState *qemu_chr_new_from_opts(QemuOpts *opts, CharDriverState *qemu_chr_new_from_opts(QemuOpts *opts,
void (*init)(struct CharDriverState *s), Error **errp)
Error **errp)
{ {
Error *local_err = NULL; Error *local_err = NULL;
CharDriver *cd; CharDriver *cd;
...@@ -4007,8 +4006,7 @@ err: ...@@ -4007,8 +4006,7 @@ err:
return NULL; return NULL;
} }
CharDriverState *qemu_chr_new_noreplay(const char *label, const char *filename, CharDriverState *qemu_chr_new_noreplay(const char *label, const char *filename)
void (*init)(struct CharDriverState *s))
{ {
const char *p; const char *p;
CharDriverState *chr; CharDriverState *chr;
...@@ -4023,7 +4021,7 @@ CharDriverState *qemu_chr_new_noreplay(const char *label, const char *filename, ...@@ -4023,7 +4021,7 @@ CharDriverState *qemu_chr_new_noreplay(const char *label, const char *filename,
if (!opts) if (!opts)
return NULL; return NULL;
chr = qemu_chr_new_from_opts(opts, init, &err); chr = qemu_chr_new_from_opts(opts, &err);
if (err) { if (err) {
error_report_err(err); error_report_err(err);
} }
...@@ -4035,10 +4033,10 @@ CharDriverState *qemu_chr_new_noreplay(const char *label, const char *filename, ...@@ -4035,10 +4033,10 @@ CharDriverState *qemu_chr_new_noreplay(const char *label, const char *filename,
return chr; return chr;
} }
CharDriverState *qemu_chr_new(const char *label, const char *filename, void (*init)(struct CharDriverState *s)) CharDriverState *qemu_chr_new(const char *label, const char *filename)
{ {
CharDriverState *chr; CharDriverState *chr;
chr = qemu_chr_new_noreplay(label, filename, init); chr = qemu_chr_new_noreplay(label, filename);
if (chr) { if (chr) {
chr->replay = replay_mode != REPLAY_MODE_NONE; chr->replay = replay_mode != REPLAY_MODE_NONE;
if (chr->replay && chr->chr_ioctl) { if (chr->replay && chr->chr_ioctl) {
......
...@@ -670,7 +670,7 @@ void qtest_init(const char *qtest_chrdev, const char *qtest_log, Error **errp) ...@@ -670,7 +670,7 @@ void qtest_init(const char *qtest_chrdev, const char *qtest_log, Error **errp)
{ {
CharDriverState *chr; CharDriverState *chr;
chr = qemu_chr_new("qtest", qtest_chrdev, NULL); chr = qemu_chr_new("qtest", qtest_chrdev);
if (chr == NULL) { if (chr == NULL) {
error_setg(errp, "Failed to initialize device for qtest: \"%s\"", error_setg(errp, "Failed to initialize device for qtest: \"%s\"",
......
...@@ -455,7 +455,7 @@ static void test_server_create_chr(TestServer *server, const gchar *opt) ...@@ -455,7 +455,7 @@ static void test_server_create_chr(TestServer *server, const gchar *opt)
gchar *chr_path; gchar *chr_path;
chr_path = g_strdup_printf("unix:%s%s", server->socket_path, opt); chr_path = g_strdup_printf("unix:%s%s", server->socket_path, opt);
server->chr = qemu_chr_new(server->chr_name, chr_path, NULL); server->chr = qemu_chr_new(server->chr_name, chr_path);
g_free(chr_path); g_free(chr_path);
qemu_chr_add_handlers(server->chr, chr_can_read, chr_read, qemu_chr_add_handlers(server->chr, chr_can_read, chr_read,
......
...@@ -2033,8 +2033,6 @@ static void text_console_do_init(CharDriverState *chr, DisplayState *ds) ...@@ -2033,8 +2033,6 @@ static void text_console_do_init(CharDriverState *chr, DisplayState *ds)
} }
qemu_chr_be_generic_open(chr); qemu_chr_be_generic_open(chr);
if (chr->init)
chr->init(chr);
} }
static CharDriverState *text_console_init(ChardevVC *vc, Error **errp) static CharDriverState *text_console_init(ChardevVC *vc, Error **errp)
......
...@@ -1789,9 +1789,6 @@ static GSList *gd_vc_vte_init(GtkDisplayState *s, VirtualConsole *vc, ...@@ -1789,9 +1789,6 @@ static GSList *gd_vc_vte_init(GtkDisplayState *s, VirtualConsole *vc,
gtk_label_new(vc->label)); gtk_label_new(vc->label));
qemu_chr_be_generic_open(vc->vte.chr); qemu_chr_be_generic_open(vc->vte.chr);
if (vc->vte.chr->init) {
vc->vte.chr->init(vc->vte.chr);
}
return group; return group;
} }
......
...@@ -2369,7 +2369,7 @@ static int chardev_init_func(void *opaque, QemuOpts *opts, Error **errp) ...@@ -2369,7 +2369,7 @@ static int chardev_init_func(void *opaque, QemuOpts *opts, Error **errp)
{ {
Error *local_err = NULL; Error *local_err = NULL;
qemu_chr_new_from_opts(opts, NULL, &local_err); qemu_chr_new_from_opts(opts, &local_err);
if (local_err) { if (local_err) {
error_report_err(local_err); error_report_err(local_err);
return -1; return -1;
...@@ -2514,7 +2514,7 @@ static int serial_parse(const char *devname) ...@@ -2514,7 +2514,7 @@ static int serial_parse(const char *devname)
exit(1); exit(1);
} }
snprintf(label, sizeof(label), "serial%d", index); snprintf(label, sizeof(label), "serial%d", index);
serial_hds[index] = qemu_chr_new(label, devname, NULL); serial_hds[index] = qemu_chr_new(label, devname);
if (!serial_hds[index]) { if (!serial_hds[index]) {
error_report("could not connect serial device" error_report("could not connect serial device"
" to character backend '%s'", devname); " to character backend '%s'", devname);
...@@ -2536,7 +2536,7 @@ static int parallel_parse(const char *devname) ...@@ -2536,7 +2536,7 @@ static int parallel_parse(const char *devname)
exit(1); exit(1);
} }
snprintf(label, sizeof(label), "parallel%d", index); snprintf(label, sizeof(label), "parallel%d", index);
parallel_hds[index] = qemu_chr_new(label, devname, NULL); parallel_hds[index] = qemu_chr_new(label, devname);
if (!parallel_hds[index]) { if (!parallel_hds[index]) {
error_report("could not connect parallel device" error_report("could not connect parallel device"
" to character backend '%s'", devname); " to character backend '%s'", devname);
...@@ -2567,7 +2567,7 @@ static int virtcon_parse(const char *devname) ...@@ -2567,7 +2567,7 @@ static int virtcon_parse(const char *devname)
qemu_opt_set(dev_opts, "driver", "virtconsole", &error_abort); qemu_opt_set(dev_opts, "driver", "virtconsole", &error_abort);
snprintf(label, sizeof(label), "virtcon%d", index); snprintf(label, sizeof(label), "virtcon%d", index);
virtcon_hds[index] = qemu_chr_new(label, devname, NULL); virtcon_hds[index] = qemu_chr_new(label, devname);
if (!virtcon_hds[index]) { if (!virtcon_hds[index]) {
error_report("could not connect virtio console" error_report("could not connect virtio console"
" to character backend '%s'", devname); " to character backend '%s'", devname);
...@@ -2600,7 +2600,7 @@ static int sclp_parse(const char *devname) ...@@ -2600,7 +2600,7 @@ static int sclp_parse(const char *devname)
qemu_opt_set(dev_opts, "driver", "sclpconsole", &error_abort); qemu_opt_set(dev_opts, "driver", "sclpconsole", &error_abort);
snprintf(label, sizeof(label), "sclpcon%d", index); snprintf(label, sizeof(label), "sclpcon%d", index);
sclp_hds[index] = qemu_chr_new(label, devname, NULL); sclp_hds[index] = qemu_chr_new(label, devname);
if (!sclp_hds[index]) { if (!sclp_hds[index]) {
error_report("could not connect sclp console" error_report("could not connect sclp console"
" to character backend '%s'", devname); " to character backend '%s'", devname);
...@@ -2616,7 +2616,7 @@ static int debugcon_parse(const char *devname) ...@@ -2616,7 +2616,7 @@ static int debugcon_parse(const char *devname)
{ {
QemuOpts *opts; QemuOpts *opts;
if (!qemu_chr_new("debugcon", devname, NULL)) { if (!qemu_chr_new("debugcon", devname)) {
exit(1); exit(1);
} }
opts = qemu_opts_create(qemu_find_opts("device"), "debugcon", 1, NULL); opts = qemu_opts_create(qemu_find_opts("device"), "debugcon", 1, NULL);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册