Kaynağa Gözat

hw/input/lm832x: Convert reset handler to DeviceReset

The LM8323 key-scan controller is a I2C device, it will be reset
when the I2C bus it stands on is reset.

Convert its reset handler into a proper Device reset method.

Reviewed-by: Li Qiang <liq3ea@gmail.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <20191010131527.32513-8-philmd@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Philippe Mathieu-Daudé 5 yıl önce
ebeveyn
işleme
f7030d0031
1 değiştirilmiş dosya ile 5 ekleme ve 7 silme
  1. 5 7
      hw/input/lm832x.c

+ 5 - 7
hw/input/lm832x.c

@@ -24,7 +24,6 @@
 #include "migration/vmstate.h"
 #include "migration/vmstate.h"
 #include "qemu/module.h"
 #include "qemu/module.h"
 #include "qemu/timer.h"
 #include "qemu/timer.h"
-#include "sysemu/reset.h"
 #include "ui/console.h"
 #include "ui/console.h"
 
 
 #define TYPE_LM8323 "lm8323"
 #define TYPE_LM8323 "lm8323"
@@ -94,8 +93,10 @@ static void lm_kbd_gpio_update(LM823KbdState *s)
 {
 {
 }
 }
 
 
-static void lm_kbd_reset(LM823KbdState *s)
+static void lm_kbd_reset(DeviceState *dev)
 {
 {
+    LM823KbdState *s = LM8323(dev);
+
     s->config = 0x80;
     s->config = 0x80;
     s->status = INT_NOINIT;
     s->status = INT_NOINIT;
     s->acttime = 125;
     s->acttime = 125;
@@ -273,7 +274,7 @@ static void lm_kbd_write(LM823KbdState *s, int reg, int byte, uint8_t value)
 
 
     case LM832x_CMD_RESET:
     case LM832x_CMD_RESET:
         if (value == 0xaa)
         if (value == 0xaa)
-            lm_kbd_reset(s);
+            lm_kbd_reset(DEVICE(s));
         else
         else
             lm_kbd_error(s, ERR_BADPAR);
             lm_kbd_error(s, ERR_BADPAR);
         s->reg = LM832x_GENERAL_ERROR;
         s->reg = LM832x_GENERAL_ERROR;
@@ -476,10 +477,6 @@ static void lm8323_realize(DeviceState *dev, Error **errp)
     s->pwm.tm[1] = timer_new_ns(QEMU_CLOCK_VIRTUAL, lm_kbd_pwm1_tick, s);
     s->pwm.tm[1] = timer_new_ns(QEMU_CLOCK_VIRTUAL, lm_kbd_pwm1_tick, s);
     s->pwm.tm[2] = timer_new_ns(QEMU_CLOCK_VIRTUAL, lm_kbd_pwm2_tick, s);
     s->pwm.tm[2] = timer_new_ns(QEMU_CLOCK_VIRTUAL, lm_kbd_pwm2_tick, s);
     qdev_init_gpio_out(dev, &s->nirq, 1);
     qdev_init_gpio_out(dev, &s->nirq, 1);
-
-    lm_kbd_reset(s);
-
-    qemu_register_reset((void *) lm_kbd_reset, s);
 }
 }
 
 
 void lm832x_key_event(DeviceState *dev, int key, int state)
 void lm832x_key_event(DeviceState *dev, int key, int state)
@@ -507,6 +504,7 @@ static void lm8323_class_init(ObjectClass *klass, void *data)
     DeviceClass *dc = DEVICE_CLASS(klass);
     DeviceClass *dc = DEVICE_CLASS(klass);
     I2CSlaveClass *k = I2C_SLAVE_CLASS(klass);
     I2CSlaveClass *k = I2C_SLAVE_CLASS(klass);
 
 
+    dc->reset = lm_kbd_reset;
     dc->realize = lm8323_realize;
     dc->realize = lm8323_realize;
     k->event = lm_i2c_event;
     k->event = lm_i2c_event;
     k->recv = lm_i2c_rx;
     k->recv = lm_i2c_rx;