提交 ba3ed0fa 编写于 作者: P Peter Maydell

hw/sd/sd.c: Convert sd_reset() function into Device reset method

Convert the sd_reset() function into a proper Device reset method.
Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
Reviewed-by: NAlistair Francis <alistair.francis@xilinx.com>
Reviewed-by: NPeter Crosthwaite <crosthwaite.peter@gmail.com>
Message-id: 1455646193-13238-4-git-send-email-peter.maydell@linaro.org
上级 260bc9d8
...@@ -394,8 +394,9 @@ static inline uint64_t sd_addr_to_wpnum(uint64_t addr) ...@@ -394,8 +394,9 @@ static inline uint64_t sd_addr_to_wpnum(uint64_t addr)
return addr >> (HWBLOCK_SHIFT + SECTOR_SHIFT + WPGROUP_SHIFT); return addr >> (HWBLOCK_SHIFT + SECTOR_SHIFT + WPGROUP_SHIFT);
} }
static void sd_reset(SDState *sd) static void sd_reset(DeviceState *dev)
{ {
SDState *sd = SD_CARD(dev);
uint64_t size; uint64_t size;
uint64_t sect; uint64_t sect;
...@@ -436,7 +437,7 @@ static void sd_cardchange(void *opaque, bool load) ...@@ -436,7 +437,7 @@ static void sd_cardchange(void *opaque, bool load)
qemu_set_irq(sd->inserted_cb, blk_is_inserted(sd->blk)); qemu_set_irq(sd->inserted_cb, blk_is_inserted(sd->blk));
if (blk_is_inserted(sd->blk)) { if (blk_is_inserted(sd->blk)) {
sd_reset(sd); sd_reset(DEVICE(sd));
qemu_set_irq(sd->readonly_cb, sd->wp_switch); qemu_set_irq(sd->readonly_cb, sd->wp_switch);
} }
} }
...@@ -680,7 +681,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, ...@@ -680,7 +681,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd,
default: default:
sd->state = sd_idle_state; sd->state = sd_idle_state;
sd_reset(sd); sd_reset(DEVICE(sd));
return sd->spi ? sd_r1 : sd_r0; return sd->spi ? sd_r1 : sd_r0;
} }
break; break;
...@@ -1787,8 +1788,6 @@ static void sd_realize(DeviceState *dev, Error **errp) ...@@ -1787,8 +1788,6 @@ static void sd_realize(DeviceState *dev, Error **errp)
if (sd->blk) { if (sd->blk) {
blk_set_dev_ops(sd->blk, &sd_block_ops, sd); blk_set_dev_ops(sd->blk, &sd_block_ops, sd);
} }
sd_reset(sd);
} }
static Property sd_properties[] = { static Property sd_properties[] = {
...@@ -1808,6 +1807,7 @@ static void sd_class_init(ObjectClass *klass, void *data) ...@@ -1808,6 +1807,7 @@ static void sd_class_init(ObjectClass *klass, void *data)
dc->realize = sd_realize; dc->realize = sd_realize;
dc->props = sd_properties; dc->props = sd_properties;
dc->vmsd = &sd_vmstate; dc->vmsd = &sd_vmstate;
dc->reset = sd_reset;
} }
static const TypeInfo sd_info = { static const TypeInfo sd_info = {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册