STM32F205: Remove the individual device variables
Cleanup the individual DeviceState and SysBusDevice variables to re-use the same variable for each device. Signed-off-by: Alistair Francis <alistair@alistair23.me> Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com> Message-id: fc5d75a57d320b69704df2c1146ff0fd482e4a88.1474742262.git.alistair@alistair23.me Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
parent
1bb4710705
commit
81fed1d017
|
@ -62,8 +62,8 @@ static void stm32f205_soc_initfn(Object *obj)
|
|||
static void stm32f205_soc_realize(DeviceState *dev_soc, Error **errp)
|
||||
{
|
||||
STM32F205State *s = STM32F205_SOC(dev_soc);
|
||||
DeviceState *syscfgdev, *usartdev, *timerdev, *nvic;
|
||||
SysBusDevice *syscfgbusdev, *usartbusdev, *timerbusdev;
|
||||
DeviceState *dev, *nvic;
|
||||
SysBusDevice *busdev;
|
||||
Error *err = NULL;
|
||||
int i;
|
||||
|
||||
|
@ -94,44 +94,43 @@ static void stm32f205_soc_realize(DeviceState *dev_soc, Error **errp)
|
|||
s->kernel_filename, s->cpu_model);
|
||||
|
||||
/* System configuration controller */
|
||||
syscfgdev = DEVICE(&s->syscfg);
|
||||
dev = DEVICE(&s->syscfg);
|
||||
object_property_set_bool(OBJECT(&s->syscfg), true, "realized", &err);
|
||||
if (err != NULL) {
|
||||
error_propagate(errp, err);
|
||||
return;
|
||||
}
|
||||
syscfgbusdev = SYS_BUS_DEVICE(syscfgdev);
|
||||
sysbus_mmio_map(syscfgbusdev, 0, 0x40013800);
|
||||
sysbus_connect_irq(syscfgbusdev, 0, qdev_get_gpio_in(nvic, 71));
|
||||
busdev = SYS_BUS_DEVICE(dev);
|
||||
sysbus_mmio_map(busdev, 0, 0x40013800);
|
||||
sysbus_connect_irq(busdev, 0, qdev_get_gpio_in(nvic, 71));
|
||||
|
||||
/* Attach UART (uses USART registers) and USART controllers */
|
||||
for (i = 0; i < STM_NUM_USARTS; i++) {
|
||||
usartdev = DEVICE(&(s->usart[i]));
|
||||
qdev_prop_set_chr(usartdev, "chardev", i < MAX_SERIAL_PORTS ? serial_hds[i] : NULL);
|
||||
dev = DEVICE(&(s->usart[i]));
|
||||
qdev_prop_set_chr(dev, "chardev",
|
||||
i < MAX_SERIAL_PORTS ? serial_hds[i] : NULL);
|
||||
object_property_set_bool(OBJECT(&s->usart[i]), true, "realized", &err);
|
||||
if (err != NULL) {
|
||||
error_propagate(errp, err);
|
||||
return;
|
||||
}
|
||||
usartbusdev = SYS_BUS_DEVICE(usartdev);
|
||||
sysbus_mmio_map(usartbusdev, 0, usart_addr[i]);
|
||||
sysbus_connect_irq(usartbusdev, 0,
|
||||
qdev_get_gpio_in(nvic, usart_irq[i]));
|
||||
busdev = SYS_BUS_DEVICE(dev);
|
||||
sysbus_mmio_map(busdev, 0, usart_addr[i]);
|
||||
sysbus_connect_irq(busdev, 0, qdev_get_gpio_in(nvic, usart_irq[i]));
|
||||
}
|
||||
|
||||
/* Timer 2 to 5 */
|
||||
for (i = 0; i < STM_NUM_TIMERS; i++) {
|
||||
timerdev = DEVICE(&(s->timer[i]));
|
||||
qdev_prop_set_uint64(timerdev, "clock-frequency", 1000000000);
|
||||
dev = DEVICE(&(s->timer[i]));
|
||||
qdev_prop_set_uint64(dev, "clock-frequency", 1000000000);
|
||||
object_property_set_bool(OBJECT(&s->timer[i]), true, "realized", &err);
|
||||
if (err != NULL) {
|
||||
error_propagate(errp, err);
|
||||
return;
|
||||
}
|
||||
timerbusdev = SYS_BUS_DEVICE(timerdev);
|
||||
sysbus_mmio_map(timerbusdev, 0, timer_addr[i]);
|
||||
sysbus_connect_irq(timerbusdev, 0,
|
||||
qdev_get_gpio_in(nvic, timer_irq[i]));
|
||||
busdev = SYS_BUS_DEVICE(dev);
|
||||
sysbus_mmio_map(busdev, 0, timer_addr[i]);
|
||||
sysbus_connect_irq(busdev, 0, qdev_get_gpio_in(nvic, timer_irq[i]));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue