diff mbox

hw/arm/pxa2xx_gpio: Correct and register vmstate

Message ID 1401820219-1746-1-git-send-email-peter.maydell@linaro.org
State Superseded
Headers show

Commit Message

Peter Maydell June 3, 2014, 6:30 p.m. UTC
The pxa2xx-gpio device has a VMStateDescription, but it was accidentally
never actually registered, and it wasn't quite correct. Remove the
'lines' field (this is a device property, not mutable state), add
the missing 'gpsr' and 'prev_level' fields, and set dc->vmsd so it
actually gets used.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 hw/arm/pxa2xx_gpio.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Peter Maydell June 3, 2014, 6:58 p.m. UTC | #1
On 3 June 2014 19:30, Peter Maydell <peter.maydell@linaro.org> wrote:
> The pxa2xx-gpio device has a VMStateDescription, but it was accidentally
> never actually registered, and it wasn't quite correct. Remove the
> 'lines' field (this is a device property, not mutable state), add
> the missing 'gpsr' and 'prev_level' fields, and set dc->vmsd so it
> actually gets used.
>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
>  hw/arm/pxa2xx_gpio.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/hw/arm/pxa2xx_gpio.c b/hw/arm/pxa2xx_gpio.c
> index 7f75f05..ccf6e44 100644
> --- a/hw/arm/pxa2xx_gpio.c
> +++ b/hw/arm/pxa2xx_gpio.c
> @@ -314,14 +314,15 @@ static const VMStateDescription vmstate_pxa2xx_gpio_regs = {
>      .version_id = 1,
>      .minimum_version_id = 1,
>      .fields = (VMStateField[]) {
> -        VMSTATE_INT32(lines, PXA2xxGPIOInfo),
>          VMSTATE_UINT32_ARRAY(ilevel, PXA2xxGPIOInfo, PXA2XX_GPIO_BANKS),
>          VMSTATE_UINT32_ARRAY(olevel, PXA2xxGPIOInfo, PXA2XX_GPIO_BANKS),
>          VMSTATE_UINT32_ARRAY(dir, PXA2xxGPIOInfo, PXA2XX_GPIO_BANKS),
>          VMSTATE_UINT32_ARRAY(rising, PXA2xxGPIOInfo, PXA2XX_GPIO_BANKS),
>          VMSTATE_UINT32_ARRAY(falling, PXA2xxGPIOInfo, PXA2XX_GPIO_BANKS),
>          VMSTATE_UINT32_ARRAY(status, PXA2xxGPIOInfo, PXA2XX_GPIO_BANKS),
> +        VMSTATE_UINT32_ARRAY(gpsr, PXA2xxGPIOInfo, PXA2XX_GPIO_BANKS),
>          VMSTATE_UINT32_ARRAY(gafr, PXA2xxGPIOInfo, PXA2XX_GPIO_BANKS * 2),
> +        VMSTATE_UINT32_ARRAY(prev_level, PXA2xxGPIOInfo, PXA2XX_GPIO_BANKS),
>          VMSTATE_END_OF_LIST(),
>      },
>  };
> @@ -340,6 +341,7 @@ static void pxa2xx_gpio_class_init(ObjectClass *klass, void *data)
>      k->init = pxa2xx_gpio_initfn;
>      dc->desc = "PXA2xx GPIO controller";
>      dc->props = pxa2xx_gpio_properties;
> +    dc->vmsd = vmstate_pxa2xx_gpio_regs;

Doh, missing '&', or we don't compile. I'm not going
to bother resending just for that :-)

thanks
-- PMM
Peter Maydell June 4, 2014, 1:13 p.m. UTC | #2
On 4 June 2014 13:28, Peter Crosthwaite <peter.crosthwaite@xilinx.com> wrote:
> On Wed, Jun 4, 2014 at 4:58 AM, Peter Maydell <peter.maydell@linaro.org> wrote:
>> On 3 June 2014 19:30, Peter Maydell <peter.maydell@linaro.org> wrote:
>>> The pxa2xx-gpio device has a VMStateDescription, but it was accidentally
>>> never actually registered, and it wasn't quite correct. Remove the
>>> 'lines' field (this is a device property, not mutable state), add
>>> the missing 'gpsr' and 'prev_level' fields, and set dc->vmsd so it
>>> actually gets used.
>>>
>>> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
>>> ---
>>>  hw/arm/pxa2xx_gpio.c | 4 +++-
>>>  1 file changed, 3 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/hw/arm/pxa2xx_gpio.c b/hw/arm/pxa2xx_gpio.c
>>> index 7f75f05..ccf6e44 100644
>>> --- a/hw/arm/pxa2xx_gpio.c
>>> +++ b/hw/arm/pxa2xx_gpio.c
>>> @@ -314,14 +314,15 @@ static const VMStateDescription vmstate_pxa2xx_gpio_regs = {
>>>      .version_id = 1,
>>>      .minimum_version_id = 1,
>>>      .fields = (VMStateField[]) {
>>> -        VMSTATE_INT32(lines, PXA2xxGPIOInfo),
>>>          VMSTATE_UINT32_ARRAY(ilevel, PXA2xxGPIOInfo, PXA2XX_GPIO_BANKS),
>>>          VMSTATE_UINT32_ARRAY(olevel, PXA2xxGPIOInfo, PXA2XX_GPIO_BANKS),
>>>          VMSTATE_UINT32_ARRAY(dir, PXA2xxGPIOInfo, PXA2XX_GPIO_BANKS),
>>>          VMSTATE_UINT32_ARRAY(rising, PXA2xxGPIOInfo, PXA2XX_GPIO_BANKS),
>>>          VMSTATE_UINT32_ARRAY(falling, PXA2xxGPIOInfo, PXA2XX_GPIO_BANKS),
>>>          VMSTATE_UINT32_ARRAY(status, PXA2xxGPIOInfo, PXA2XX_GPIO_BANKS),
>>> +        VMSTATE_UINT32_ARRAY(gpsr, PXA2xxGPIOInfo, PXA2XX_GPIO_BANKS),
>
> According to documentation, reading gpsr is undefined, and the only
> reason for this gpsr state as implemented in QEMU is return some
> arbitrary default when reading the write-only register.

> All, in all, I think GPSR is not legitimate device state at all and
> probably should be removed

Seems reasonable.

thanks
-- PMM
diff mbox

Patch

diff --git a/hw/arm/pxa2xx_gpio.c b/hw/arm/pxa2xx_gpio.c
index 7f75f05..ccf6e44 100644
--- a/hw/arm/pxa2xx_gpio.c
+++ b/hw/arm/pxa2xx_gpio.c
@@ -314,14 +314,15 @@  static const VMStateDescription vmstate_pxa2xx_gpio_regs = {
     .version_id = 1,
     .minimum_version_id = 1,
     .fields = (VMStateField[]) {
-        VMSTATE_INT32(lines, PXA2xxGPIOInfo),
         VMSTATE_UINT32_ARRAY(ilevel, PXA2xxGPIOInfo, PXA2XX_GPIO_BANKS),
         VMSTATE_UINT32_ARRAY(olevel, PXA2xxGPIOInfo, PXA2XX_GPIO_BANKS),
         VMSTATE_UINT32_ARRAY(dir, PXA2xxGPIOInfo, PXA2XX_GPIO_BANKS),
         VMSTATE_UINT32_ARRAY(rising, PXA2xxGPIOInfo, PXA2XX_GPIO_BANKS),
         VMSTATE_UINT32_ARRAY(falling, PXA2xxGPIOInfo, PXA2XX_GPIO_BANKS),
         VMSTATE_UINT32_ARRAY(status, PXA2xxGPIOInfo, PXA2XX_GPIO_BANKS),
+        VMSTATE_UINT32_ARRAY(gpsr, PXA2xxGPIOInfo, PXA2XX_GPIO_BANKS),
         VMSTATE_UINT32_ARRAY(gafr, PXA2xxGPIOInfo, PXA2XX_GPIO_BANKS * 2),
+        VMSTATE_UINT32_ARRAY(prev_level, PXA2xxGPIOInfo, PXA2XX_GPIO_BANKS),
         VMSTATE_END_OF_LIST(),
     },
 };
@@ -340,6 +341,7 @@  static void pxa2xx_gpio_class_init(ObjectClass *klass, void *data)
     k->init = pxa2xx_gpio_initfn;
     dc->desc = "PXA2xx GPIO controller";
     dc->props = pxa2xx_gpio_properties;
+    dc->vmsd = vmstate_pxa2xx_gpio_regs;
 }
 
 static const TypeInfo pxa2xx_gpio_info = {