qemu/include/hw/char
Markus Armbruster 3e80f6902c qdev: Convert uses of qdev_create() with Coccinelle
This is the transformation explained in the commit before previous.
Takes care of just one pattern that needs conversion.  More to come in
this series.

Coccinelle script:

    @ depends on !(file in "hw/arm/highbank.c")@
    expression bus, type_name, dev, expr;
    @@
    -    dev = qdev_create(bus, type_name);
    +    dev = qdev_new(type_name);
         ... when != dev = expr
    -    qdev_init_nofail(dev);
    +    qdev_realize_and_unref(dev, bus, &error_fatal);

    @@
    expression bus, type_name, dev, expr;
    identifier DOWN;
    @@
    -    dev = DOWN(qdev_create(bus, type_name));
    +    dev = DOWN(qdev_new(type_name));
         ... when != dev = expr
    -    qdev_init_nofail(DEVICE(dev));
    +    qdev_realize_and_unref(DEVICE(dev), bus, &error_fatal);

    @@
    expression bus, type_name, expr;
    identifier dev;
    @@
    -    DeviceState *dev = qdev_create(bus, type_name);
    +    DeviceState *dev = qdev_new(type_name);
         ... when != dev = expr
    -    qdev_init_nofail(dev);
    +    qdev_realize_and_unref(dev, bus, &error_fatal);

    @@
    expression bus, type_name, dev, expr, errp;
    symbol true;
    @@
    -    dev = qdev_create(bus, type_name);
    +    dev = qdev_new(type_name);
         ... when != dev = expr
    -    object_property_set_bool(OBJECT(dev), true, "realized", errp);
    +    qdev_realize_and_unref(dev, bus, errp);

    @@
    expression bus, type_name, expr, errp;
    identifier dev;
    symbol true;
    @@
    -    DeviceState *dev = qdev_create(bus, type_name);
    +    DeviceState *dev = qdev_new(type_name);
         ... when != dev = expr
    -    object_property_set_bool(OBJECT(dev), true, "realized", errp);
    +    qdev_realize_and_unref(dev, bus, errp);

The first rule exempts hw/arm/highbank.c, because it matches along two
control flow paths there, with different @type_name.  Covered by the
next commit's manual conversions.

Missing #include "qapi/error.h" added manually.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20200610053247.1583243-10-armbru@redhat.com>
[Conflicts in hw/misc/empty_slot.c and hw/sparc/leon3.c resolved]
2020-06-15 22:00:10 +02:00
..
bcm2835_aux.h hw/arm/bcm283x: Correct the license text 2020-03-23 17:22:30 +00:00
cadence_uart.h qdev: Convert uses of qdev_create() with Coccinelle 2020-06-15 22:00:10 +02:00
cmsdk-apb-uart.h qdev: Convert uses of qdev_create() with Coccinelle 2020-06-15 22:00:10 +02:00
digic-uart.h char: move CharBackend handling in char-fe unit 2017-06-02 11:33:53 +04:00
escc.h escc: introduce a selector for the register bit 2019-09-07 08:32:12 +02:00
imx_serial.h imx_serial: Generate interrupt on receive data ready if enabled 2018-08-20 11:24:31 +01:00
lm32_juart.h Include hw/qdev-properties.h less 2019-08-16 13:31:53 +02:00
nrf51_uart.h arm: Add header to host common definition for nRF51 SOC peripherals 2019-01-07 15:23:47 +00:00
parallel.h Include exec/memory.h slightly less 2019-08-16 13:31:52 +02:00
pl011.h qdev: Convert uses of qdev_create() with Coccinelle 2020-06-15 22:00:10 +02:00
serial.h mips: inline serial_init() 2020-01-07 17:24:29 +04:00
stm32f2xx_usart.h Include hw/hw.h exactly where needed 2019-08-16 13:31:52 +02:00
xilinx_uartlite.h qdev: Convert uses of qdev_create() with Coccinelle 2020-06-15 22:00:10 +02:00