[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 2/3] hw/sd.c: add SD card save/load support
From: |
Andreas Färber |
Subject: |
Re: [Qemu-devel] [PATCH 2/3] hw/sd.c: add SD card save/load support |
Date: |
Tue, 27 Dec 2011 14:27:39 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:9.0) Gecko/20111220 Thunderbird/9.0 |
Am 26.12.2011 15:58, schrieb Peter Maydell:
>> diff --git a/hw/sd.c b/hw/sd.c
>> index 07eb263..2b489d3 100644
>> --- a/hw/sd.c
>> +++ b/hw/sd.c
>> @@ -81,22 +85,22 @@ struct SDState {
>> uint8_t sd_status[64];
>> uint32_t vhs;
>> int wp_switch;
>> - int *wp_groups;
>> + uint8_t *wp_groups;
>> uint64_t size;
>> - int blk_len;
>> + uint32_t blk_len;
>> uint32_t erase_start;
>> uint32_t erase_end;
>> uint8_t pwd[16];
>> - int pwd_len;
>> - int function_group[6];
>> + uint32_t pwd_len;
>> + uint8_t function_group[6];
>>
>> - int spi;
>> - int current_cmd;
>> + uint8_t spi;
>> + uint8_t current_cmd;
>> /* True if we will handle the next command as an ACMD. Note that this
>> does
>> * *not* track the APP_CMD status bit!
>> */
>> - int expecting_acmd;
>> - int blk_written;
>> + bool expecting_acmd;
>
> Why have you changed expecting_acmd and enable to bool, but spi
> to a uint8_t and wp_groups[] to a uint8_t[] ? This isn't very
> consistent. (I'm vaguely against bool because you then end up
> making other changes to change '1' to 'true' and so on.)
>> @@ -1706,5 +1710,44 @@ int sd_data_ready(SDState *sd)
>>
>> void sd_enable(SDState *sd, int enable)
>> {
>> - sd->enable = enable;
>> + sd->enable = enable ? true : false;
>
> This kind of thing is why I don't like bool :-)
x = 1 should work with bool when not doing x == true anywhere, here
!!enable would be an alternative. Maybe change int enable to bool, too?
Andreas
--
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
[Qemu-devel] [PATCH 2/3] hw/sd.c: add SD card save/load support, Mitsyanko Igor, 2011/12/26
[Qemu-devel] [PATCH 3/3] hw/: Introduce spec. ver. 2.00 compliant SD host controller, Mitsyanko Igor, 2011/12/26
[Qemu-devel] [PATCH V2 0/3] Improve SD controllers emulation, Mitsyanko Igor, 2011/12/28