diff options
author | balrog <balrog@c046a42c-6fe2-441c-8c8c-71466251a162> | 2007-11-17 14:34:44 +0000 |
---|---|---|
committer | balrog <balrog@c046a42c-6fe2-441c-8c8c-71466251a162> | 2007-11-17 14:34:44 +0000 |
commit | 02ce600c1e485a7da4a26166b5a75b68c6013fe1 (patch) | |
tree | bbaf336b9ed4300dc842ab6f1ed3beaeec66a5fd /hw/sd.c | |
parent | 38641a52f2335c470349c55d9b1679112da99399 (diff) | |
download | qemu-02ce600c1e485a7da4a26166b5a75b68c6013fe1.zip qemu-02ce600c1e485a7da4a26166b5a75b68c6013fe1.tar.gz qemu-02ce600c1e485a7da4a26166b5a75b68c6013fe1.tar.bz2 |
Convert SD cards code to use qemu_irq too.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3671 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'hw/sd.c')
-rw-r--r-- | hw/sd.c | 30 |
1 files changed, 12 insertions, 18 deletions
@@ -90,9 +90,8 @@ struct SDState { uint32_t data_start; uint32_t data_offset; uint8_t data[512]; - void (*readonly_cb)(void *, int); - void (*inserted_cb)(void *, int); - void *opaque; + qemu_irq readonly_cb; + qemu_irq inserted_cb; BlockDriverState *bdrv; }; @@ -372,6 +371,8 @@ static void sd_reset(SDState *sd, BlockDriverState *bdrv) sd->bdrv = bdrv; + if (s->wp_groups) + qemu_free(s->wp_groups); sd->wp_switch = bdrv_is_read_only(bdrv); sd->wp_groups = (int *) qemu_mallocz(sizeof(int) * sect); memset(sd->wp_groups, 0, sizeof(int) * sect); @@ -386,12 +387,10 @@ static void sd_reset(SDState *sd, BlockDriverState *bdrv) static void sd_cardchange(void *opaque) { SDState *sd = opaque; - if (sd->inserted_cb) - sd->inserted_cb(sd->opaque, bdrv_is_inserted(sd->bdrv)); + qemu_set_irq(sd->inserted_cb, bdrv_is_inserted(sd->bdrv)); if (bdrv_is_inserted(sd->bdrv)) { sd_reset(sd, sd->bdrv); - if (sd->readonly_cb) - sd->readonly_cb(sd->opaque, sd->wp_switch); + qemu_set_irq(s->readonly_cb, sd->wp_switch); } } @@ -401,21 +400,16 @@ SDState *sd_init(BlockDriverState *bs) sd = (SDState *) qemu_mallocz(sizeof(SDState)); sd_reset(sd, bs); + bdrv_set_change_cb(sd->bdrv, sd_cardchange, sd); return sd; } -void sd_set_cb(SDState *sd, void *opaque, - void (*readonly_cb)(void *, int), - void (*inserted_cb)(void *, int)) +void sd_set_cb(SDState *sd, qemu_irq readonly, qemu_irq insert) { - sd->opaque = opaque; - sd->readonly_cb = readonly_cb; - sd->inserted_cb = inserted_cb; - if (sd->readonly_cb) - sd->readonly_cb(sd->opaque, bdrv_is_read_only(sd->bdrv)); - if (sd->inserted_cb) - sd->inserted_cb(sd->opaque, bdrv_is_inserted(sd->bdrv)); - bdrv_set_change_cb(sd->bdrv, sd_cardchange, sd); + sd->readonly_cb = readonly; + sd->inserted_cb = insert; + qemu_set_irq(readonly, bdrv_is_read_only(sd->bdrv)); + qemu_set_irq(insert, bdrv_is_inserted(sd->bdrv)); } static void sd_erase(SDState *sd) |