[v1,1/7] STM32F205: Remove the individual device variables
diff mbox

Message ID bfefc3e77c75c895e0e02e63750a558d46923452.1429949062.git.alistair@alistair23.me
State New
Headers show

Commit Message

Alistair Francis April 25, 2015, 8:18 a.m. UTC
Cleanup the individual DeviceState and SysBusDevice
variables to re-use the same variable for each
device.

Signed-off-by: Alistair Francis <alistair@alistair23.me>
---

 hw/arm/stm32f205_soc.c | 30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)

Comments

Peter Crosthwaite April 25, 2015, 6:34 p.m. UTC | #1
On Sat, Apr 25, 2015 at 1:18 AM, Alistair Francis <alistair23@gmail.com> wrote:
> 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>

> ---
>
>  hw/arm/stm32f205_soc.c | 30 +++++++++++++++---------------
>  1 file changed, 15 insertions(+), 15 deletions(-)
>
> diff --git a/hw/arm/stm32f205_soc.c b/hw/arm/stm32f205_soc.c
> index 0f3bdc7..63893f3 100644
> --- a/hw/arm/stm32f205_soc.c
> +++ b/hw/arm/stm32f205_soc.c
> @@ -59,8 +59,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;
> -    SysBusDevice *syscfgbusdev, *usartbusdev, *timerbusdev;
> +    DeviceState *dev;
> +    SysBusDevice *busdev;
>      qemu_irq *pic;
>      Error *err = NULL;
>      int i;
> @@ -92,41 +92,41 @@ 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, pic[71]);
> +    busdev = SYS_BUS_DEVICE(dev);
> +    sysbus_mmio_map(busdev, 0, 0x40013800);
> +    sysbus_connect_irq(busdev, 0, pic[71]);
>
>      /* Attach UART (uses USART registers) and USART controllers */
>      for (i = 0; i < STM_NUM_USARTS; i++) {
> -        usartdev = DEVICE(&(s->usart[i]));
> +        dev = DEVICE(&(s->usart[i]));
>          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, pic[usart_irq[i]]);
> +        busdev = SYS_BUS_DEVICE(dev);
> +        sysbus_mmio_map(busdev, 0, usart_addr[i]);
> +        sysbus_connect_irq(busdev, 0, pic[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, pic[timer_irq[i]]);
> +        busdev = SYS_BUS_DEVICE(dev);
> +        sysbus_mmio_map(busdev, 0, timer_addr[i]);
> +        sysbus_connect_irq(busdev, 0, pic[timer_irq[i]]);
>      }
>  }
>
> --
> 2.1.4
>
>
Alistair Francis April 26, 2015, 1:57 a.m. UTC | #2
On Sun, Apr 26, 2015 at 4:34 AM, Peter Crosthwaite
<peter.crosthwaite@xilinx.com> wrote:
> On Sat, Apr 25, 2015 at 1:18 AM, Alistair Francis <alistair23@gmail.com> wrote:
>> 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>

Thanks

Alistair

>
>> ---
>>
>>  hw/arm/stm32f205_soc.c | 30 +++++++++++++++---------------
>>  1 file changed, 15 insertions(+), 15 deletions(-)
>>
>> diff --git a/hw/arm/stm32f205_soc.c b/hw/arm/stm32f205_soc.c
>> index 0f3bdc7..63893f3 100644
>> --- a/hw/arm/stm32f205_soc.c
>> +++ b/hw/arm/stm32f205_soc.c
>> @@ -59,8 +59,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;
>> -    SysBusDevice *syscfgbusdev, *usartbusdev, *timerbusdev;
>> +    DeviceState *dev;
>> +    SysBusDevice *busdev;
>>      qemu_irq *pic;
>>      Error *err = NULL;
>>      int i;
>> @@ -92,41 +92,41 @@ 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, pic[71]);
>> +    busdev = SYS_BUS_DEVICE(dev);
>> +    sysbus_mmio_map(busdev, 0, 0x40013800);
>> +    sysbus_connect_irq(busdev, 0, pic[71]);
>>
>>      /* Attach UART (uses USART registers) and USART controllers */
>>      for (i = 0; i < STM_NUM_USARTS; i++) {
>> -        usartdev = DEVICE(&(s->usart[i]));
>> +        dev = DEVICE(&(s->usart[i]));
>>          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, pic[usart_irq[i]]);
>> +        busdev = SYS_BUS_DEVICE(dev);
>> +        sysbus_mmio_map(busdev, 0, usart_addr[i]);
>> +        sysbus_connect_irq(busdev, 0, pic[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, pic[timer_irq[i]]);
>> +        busdev = SYS_BUS_DEVICE(dev);
>> +        sysbus_mmio_map(busdev, 0, timer_addr[i]);
>> +        sysbus_connect_irq(busdev, 0, pic[timer_irq[i]]);
>>      }
>>  }
>>
>> --
>> 2.1.4
>>
>>

Patch
diff mbox

diff --git a/hw/arm/stm32f205_soc.c b/hw/arm/stm32f205_soc.c
index 0f3bdc7..63893f3 100644
--- a/hw/arm/stm32f205_soc.c
+++ b/hw/arm/stm32f205_soc.c
@@ -59,8 +59,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;
-    SysBusDevice *syscfgbusdev, *usartbusdev, *timerbusdev;
+    DeviceState *dev;
+    SysBusDevice *busdev;
     qemu_irq *pic;
     Error *err = NULL;
     int i;
@@ -92,41 +92,41 @@  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, pic[71]);
+    busdev = SYS_BUS_DEVICE(dev);
+    sysbus_mmio_map(busdev, 0, 0x40013800);
+    sysbus_connect_irq(busdev, 0, pic[71]);
 
     /* Attach UART (uses USART registers) and USART controllers */
     for (i = 0; i < STM_NUM_USARTS; i++) {
-        usartdev = DEVICE(&(s->usart[i]));
+        dev = DEVICE(&(s->usart[i]));
         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, pic[usart_irq[i]]);
+        busdev = SYS_BUS_DEVICE(dev);
+        sysbus_mmio_map(busdev, 0, usart_addr[i]);
+        sysbus_connect_irq(busdev, 0, pic[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, pic[timer_irq[i]]);
+        busdev = SYS_BUS_DEVICE(dev);
+        sysbus_mmio_map(busdev, 0, timer_addr[i]);
+        sysbus_connect_irq(busdev, 0, pic[timer_irq[i]]);
     }
 }