[PATCH] hw/i2c: pca954x: enable vmstate

Stevie Alvarez posted 1 patch 1 month, 4 weeks ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20250916165859.1718787-1-steviea@google.com
Maintainers: Patrick Leis <venture@google.com>
hw/i2c/i2c_mux_pca954x.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
[PATCH] hw/i2c: pca954x: enable vmstate
Posted by Stevie Alvarez 1 month, 4 weeks ago
From: Patrick Venture <venture@google.com>

Add missing vmstate support.

Signed-off-by: Patrick Venture <venture@google.com>
---
 hw/i2c/i2c_mux_pca954x.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/hw/i2c/i2c_mux_pca954x.c b/hw/i2c/i2c_mux_pca954x.c
index a8ef640cd2..78828acafb 100644
--- a/hw/i2c/i2c_mux_pca954x.c
+++ b/hw/i2c/i2c_mux_pca954x.c
@@ -22,6 +22,7 @@
 #include "hw/qdev-core.h"
 #include "hw/qdev-properties.h"
 #include "hw/sysbus.h"
+#include "migration/vmstate.h"
 #include "qemu/log.h"
 #include "qemu/module.h"
 #include "qemu/queue.h"
@@ -211,6 +212,18 @@ static void pca954x_init(Object *obj)
     }
 }
 
+static const VMStateDescription pca954x_vmstate = {
+    .name = TYPE_PCA954X,
+    .version_id = 0,
+    .minimum_version_id = 0,
+    .fields = (VMStateField[]) {
+        VMSTATE_SMBUS_DEVICE(parent, Pca954xState),
+        VMSTATE_UINT8(control, Pca954xState),
+        VMSTATE_BOOL_ARRAY(enabled, Pca954xState, PCA9548_CHANNEL_COUNT),
+        VMSTATE_END_OF_LIST()
+    }
+};
+
 static const Property pca954x_props[] = {
     DEFINE_PROP_STRING("name", Pca954xState, name),
 };
@@ -228,6 +241,7 @@ static void pca954x_class_init(ObjectClass *klass, const void *data)
 
     dc->desc = "Pca954x i2c-mux";
     dc->realize = pca954x_realize;
+    dc->vmsd = &pca954x_vmstate;
 
     k->write_data = pca954x_write_data;
     k->receive_byte = pca954x_read_byte;
-- 
2.51.0.384.g4c02a37b29-goog
Re: [PATCH] hw/i2c: pca954x: enable vmstate
Posted by Stevie Alvarez 1 month, 3 weeks ago
On Tue, Sep 16, 2025 at 9:59 AM Stevie Alvarez <steviea@google.com> wrote:
+ CC Corey Minyard for I2C maintainers.
>
> From: Patrick Venture <venture@google.com>
>
> Add missing vmstate support.
>
> Signed-off-by: Patrick Venture <venture@google.com>
> ---
>  hw/i2c/i2c_mux_pca954x.c | 14 ++++++++++++++
>  1 file changed, 14 insertions(+)
>
> diff --git a/hw/i2c/i2c_mux_pca954x.c b/hw/i2c/i2c_mux_pca954x.c
> index a8ef640cd2..78828acafb 100644
> --- a/hw/i2c/i2c_mux_pca954x.c
> +++ b/hw/i2c/i2c_mux_pca954x.c
> @@ -22,6 +22,7 @@
>  #include "hw/qdev-core.h"
>  #include "hw/qdev-properties.h"
>  #include "hw/sysbus.h"
> +#include "migration/vmstate.h"
>  #include "qemu/log.h"
>  #include "qemu/module.h"
>  #include "qemu/queue.h"
> @@ -211,6 +212,18 @@ static void pca954x_init(Object *obj)
>      }
>  }
>
> +static const VMStateDescription pca954x_vmstate = {
> +    .name = TYPE_PCA954X,
> +    .version_id = 0,
> +    .minimum_version_id = 0,
> +    .fields = (VMStateField[]) {
> +        VMSTATE_SMBUS_DEVICE(parent, Pca954xState),
> +        VMSTATE_UINT8(control, Pca954xState),
> +        VMSTATE_BOOL_ARRAY(enabled, Pca954xState, PCA9548_CHANNEL_COUNT),
> +        VMSTATE_END_OF_LIST()
> +    }
> +};
> +
>  static const Property pca954x_props[] = {
>      DEFINE_PROP_STRING("name", Pca954xState, name),
>  };
> @@ -228,6 +241,7 @@ static void pca954x_class_init(ObjectClass *klass, const void *data)
>
>      dc->desc = "Pca954x i2c-mux";
>      dc->realize = pca954x_realize;
> +    dc->vmsd = &pca954x_vmstate;
>
>      k->write_data = pca954x_write_data;
>      k->receive_byte = pca954x_read_byte;
> --
> 2.51.0.384.g4c02a37b29-goog
>
Re: [PATCH] hw/i2c: pca954x: enable vmstate
Posted by Stevie Alvarez 1 month, 4 weeks ago
On Tue, Sep 16, 2025 at 9:59 AM Stevie Alvarez <steviea@google.com> wrote:
+ CC Corey Minyard for I2C maintainers.
>
> From: Patrick Venture <venture@google.com>
>
> Add missing vmstate support.
>
> Signed-off-by: Patrick Venture <venture@google.com>
> ---
>  hw/i2c/i2c_mux_pca954x.c | 14 ++++++++++++++
>  1 file changed, 14 insertions(+)
>
> diff --git a/hw/i2c/i2c_mux_pca954x.c b/hw/i2c/i2c_mux_pca954x.c
> index a8ef640cd2..78828acafb 100644
> --- a/hw/i2c/i2c_mux_pca954x.c
> +++ b/hw/i2c/i2c_mux_pca954x.c
> @@ -22,6 +22,7 @@
>  #include "hw/qdev-core.h"
>  #include "hw/qdev-properties.h"
>  #include "hw/sysbus.h"
> +#include "migration/vmstate.h"
>  #include "qemu/log.h"
>  #include "qemu/module.h"
>  #include "qemu/queue.h"
> @@ -211,6 +212,18 @@ static void pca954x_init(Object *obj)
>      }
>  }
>
> +static const VMStateDescription pca954x_vmstate = {
> +    .name = TYPE_PCA954X,
> +    .version_id = 0,
> +    .minimum_version_id = 0,
> +    .fields = (VMStateField[]) {
> +        VMSTATE_SMBUS_DEVICE(parent, Pca954xState),
> +        VMSTATE_UINT8(control, Pca954xState),
> +        VMSTATE_BOOL_ARRAY(enabled, Pca954xState, PCA9548_CHANNEL_COUNT),
> +        VMSTATE_END_OF_LIST()
> +    }
> +};
> +
>  static const Property pca954x_props[] = {
>      DEFINE_PROP_STRING("name", Pca954xState, name),
>  };
> @@ -228,6 +241,7 @@ static void pca954x_class_init(ObjectClass *klass, const void *data)
>
>      dc->desc = "Pca954x i2c-mux";
>      dc->realize = pca954x_realize;
> +    dc->vmsd = &pca954x_vmstate;
>
>      k->write_data = pca954x_write_data;
>      k->receive_byte = pca954x_read_byte;
> --
> 2.51.0.384.g4c02a37b29-goog
>