diff mbox series

[2/6] allwinner-i2c, adm1272: Use device_cold_reset() for software-triggered reset

Message ID 20240412160809.1260625-3-peter.maydell@linaro.org
State Superseded
Headers show
Series reset: Add RESET_TYPE_SNAPSHOT_LOAD | expand

Commit Message

Peter Maydell April 12, 2024, 4:08 p.m. UTC
Rather than directly calling the device's implementation of its 'hold'
reset phase, call device_cold_reset(). This means we don't have to
adjust this callsite when we add another argument to the function
signature for the hold and exit reset methods.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 hw/i2c/allwinner-i2c.c | 3 +--
 hw/sensor/adm1272.c    | 2 +-
 2 files changed, 2 insertions(+), 3 deletions(-)

Comments

Richard Henderson April 12, 2024, 5:22 p.m. UTC | #1
On 4/12/24 09:08, Peter Maydell wrote:
> Rather than directly calling the device's implementation of its 'hold'
> reset phase, call device_cold_reset(). This means we don't have to
> adjust this callsite when we add another argument to the function
> signature for the hold and exit reset methods.
> 
> Signed-off-by: Peter Maydell<peter.maydell@linaro.org>
> ---
>   hw/i2c/allwinner-i2c.c | 3 +--
>   hw/sensor/adm1272.c    | 2 +-
>   2 files changed, 2 insertions(+), 3 deletions(-)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~
Luc Michel April 16, 2024, 9:09 a.m. UTC | #2
On 17:08 Fri 12 Apr     , Peter Maydell wrote:
> Rather than directly calling the device's implementation of its 'hold'
> reset phase, call device_cold_reset(). This means we don't have to
> adjust this callsite when we add another argument to the function
> signature for the hold and exit reset methods.
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

Reviewed-by: Luc Michel <luc.michel@amd.com>

> ---
>  hw/i2c/allwinner-i2c.c | 3 +--
>  hw/sensor/adm1272.c    | 2 +-
>  2 files changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/hw/i2c/allwinner-i2c.c b/hw/i2c/allwinner-i2c.c
> index 8abcc39a5c2..96c20c86372 100644
> --- a/hw/i2c/allwinner-i2c.c
> +++ b/hw/i2c/allwinner-i2c.c
> @@ -385,8 +385,7 @@ static void allwinner_i2c_write(void *opaque, hwaddr offset,
>          break;
>      case TWI_SRST_REG:
>          if (((value & TWI_SRST_MASK) == 0) && (s->srst & TWI_SRST_MASK)) {
> -            /* Perform reset */
> -            allwinner_i2c_reset_hold(OBJECT(s));
> +            device_cold_reset(DEVICE(s));
>          }
>          s->srst = value & TWI_SRST_MASK;
>          break;
> diff --git a/hw/sensor/adm1272.c b/hw/sensor/adm1272.c
> index 1f7c8abb838..a19557ec9ea 100644
> --- a/hw/sensor/adm1272.c
> +++ b/hw/sensor/adm1272.c
> @@ -386,7 +386,7 @@ static int adm1272_write_data(PMBusDevice *pmdev, const uint8_t *buf,
>          break;
> 
>      case ADM1272_MFR_POWER_CYCLE:
> -        adm1272_exit_reset((Object *)s);
> +        device_cold_reset(DEVICE(s));
>          break;
> 
>      case ADM1272_HYSTERESIS_LOW:
> --
> 2.34.1
> 
> 

--
diff mbox series

Patch

diff --git a/hw/i2c/allwinner-i2c.c b/hw/i2c/allwinner-i2c.c
index 8abcc39a5c2..96c20c86372 100644
--- a/hw/i2c/allwinner-i2c.c
+++ b/hw/i2c/allwinner-i2c.c
@@ -385,8 +385,7 @@  static void allwinner_i2c_write(void *opaque, hwaddr offset,
         break;
     case TWI_SRST_REG:
         if (((value & TWI_SRST_MASK) == 0) && (s->srst & TWI_SRST_MASK)) {
-            /* Perform reset */
-            allwinner_i2c_reset_hold(OBJECT(s));
+            device_cold_reset(DEVICE(s));
         }
         s->srst = value & TWI_SRST_MASK;
         break;
diff --git a/hw/sensor/adm1272.c b/hw/sensor/adm1272.c
index 1f7c8abb838..a19557ec9ea 100644
--- a/hw/sensor/adm1272.c
+++ b/hw/sensor/adm1272.c
@@ -386,7 +386,7 @@  static int adm1272_write_data(PMBusDevice *pmdev, const uint8_t *buf,
         break;
 
     case ADM1272_MFR_POWER_CYCLE:
-        adm1272_exit_reset((Object *)s);
+        device_cold_reset(DEVICE(s));
         break;
 
     case ADM1272_HYSTERESIS_LOW: