From: Peter Maydell <peter.maydell@linaro.org>
To: Anthony Liguori <aliguori@us.ibm.com>, Blue Swirl <blauwirbel@gmail.com>
Cc: qemu-devel@nongnu.org, Paul Brook <paul@codesourcery.com>
Subject: [Qemu-devel] [PATCH 06/10] hw/sd.c: convert binary variables to bool
Date: Mon, 13 Aug 2012 16:31:55 +0100 [thread overview]
Message-ID: <1344871919-31559-7-git-send-email-peter.maydell@linaro.org> (raw)
In-Reply-To: <1344871919-31559-1-git-send-email-peter.maydell@linaro.org>
From: Mitsyanko Igor <i.mitsyanko@samsung.com>
Several members of SDState have type int when they actually are binary variables.
Change type of these variables to bool to improve code readability. Change SD API
to be in consistency with new variables type.
Signed-off-by: Igor Mitsyanko <i.mitsyanko@samsung.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
hw/sd.c | 24 ++++++++++++------------
hw/sd.h | 4 ++--
2 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/hw/sd.c b/hw/sd.c
index d0674d5..ebc4e7c 100644
--- a/hw/sd.c
+++ b/hw/sd.c
@@ -81,7 +81,7 @@ struct SDState {
uint32_t card_status;
uint8_t sd_status[64];
uint32_t vhs;
- int wp_switch;
+ bool wp_switch;
unsigned long *wp_groups;
uint64_t size;
int blk_len;
@@ -91,12 +91,12 @@ struct SDState {
int pwd_len;
int function_group[6];
- int spi;
+ bool spi;
int 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;
+ bool expecting_acmd;
int blk_written;
uint64_t data_start;
uint32_t data_offset;
@@ -106,7 +106,7 @@ struct SDState {
BlockDriverState *bdrv;
uint8_t *buf;
- int enable;
+ bool enable;
};
static void sd_set_mode(SDState *sd)
@@ -420,7 +420,7 @@ static void sd_reset(SDState *sd, BlockDriverState *bdrv)
if (sd->wp_groups)
g_free(sd->wp_groups);
- sd->wp_switch = bdrv ? bdrv_is_read_only(bdrv) : 0;
+ sd->wp_switch = bdrv ? bdrv_is_read_only(bdrv) : false;
sd->wp_groups = bitmap_new(sect);
memset(sd->function_group, 0, sizeof(int) * 6);
sd->erase_start = 0;
@@ -428,7 +428,7 @@ static void sd_reset(SDState *sd, BlockDriverState *bdrv)
sd->size = size;
sd->blk_len = 0x200;
sd->pwd_len = 0;
- sd->expecting_acmd = 0;
+ sd->expecting_acmd = false;
}
static void sd_cardchange(void *opaque, bool load)
@@ -450,14 +450,14 @@ static const BlockDevOps sd_block_ops = {
whether card should be in SSI or MMC/SD mode. It is also up to the
board to ensure that ssi transfers only occur when the chip select
is asserted. */
-SDState *sd_init(BlockDriverState *bs, int is_spi)
+SDState *sd_init(BlockDriverState *bs, bool is_spi)
{
SDState *sd;
sd = (SDState *) g_malloc0(sizeof(SDState));
sd->buf = qemu_blockalign(bs, 512);
sd->spi = is_spi;
- sd->enable = 1;
+ sd->enable = true;
sd_reset(sd, bs);
if (sd->bdrv) {
bdrv_attach_dev_nofail(sd->bdrv, sd);
@@ -1129,7 +1129,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd,
if (sd->rca != rca)
return sd_r0;
- sd->expecting_acmd = 1;
+ sd->expecting_acmd = true;
sd->card_status |= APP_CMD;
return sd_r1;
@@ -1311,7 +1311,7 @@ int sd_do_command(SDState *sd, SDRequest *req,
if (sd->card_status & CARD_IS_LOCKED) {
if (!cmd_valid_while_locked(sd, req)) {
sd->card_status |= ILLEGAL_COMMAND;
- sd->expecting_acmd = 0;
+ sd->expecting_acmd = false;
fprintf(stderr, "SD: Card is locked\n");
rtype = sd_illegal;
goto send_response;
@@ -1322,7 +1322,7 @@ int sd_do_command(SDState *sd, SDRequest *req,
sd_set_mode(sd);
if (sd->expecting_acmd) {
- sd->expecting_acmd = 0;
+ sd->expecting_acmd = false;
rtype = sd_app_command(sd, *req);
} else {
rtype = sd_normal_command(sd, *req);
@@ -1708,7 +1708,7 @@ int sd_data_ready(SDState *sd)
return sd->state == sd_sendingdata_state;
}
-void sd_enable(SDState *sd, int enable)
+void sd_enable(SDState *sd, bool enable)
{
sd->enable = enable;
}
diff --git a/hw/sd.h b/hw/sd.h
index ac4b7c4..d25342f 100644
--- a/hw/sd.h
+++ b/hw/sd.h
@@ -67,13 +67,13 @@ typedef struct {
typedef struct SDState SDState;
-SDState *sd_init(BlockDriverState *bs, int is_spi);
+SDState *sd_init(BlockDriverState *bs, bool is_spi);
int sd_do_command(SDState *sd, SDRequest *req,
uint8_t *response);
void sd_write_data(SDState *sd, uint8_t value);
uint8_t sd_read_data(SDState *sd);
void sd_set_cb(SDState *sd, qemu_irq readonly, qemu_irq insert);
int sd_data_ready(SDState *sd);
-void sd_enable(SDState *sd, int enable);
+void sd_enable(SDState *sd, bool enable);
#endif /* __hw_sd_h */
--
1.7.9.5
next prev parent reply other threads:[~2012-08-13 15:56 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-13 15:31 [Qemu-devel] [PULL for-1.2 00/10] arm-devs queue Peter Maydell
2012-08-13 15:31 ` [Qemu-devel] [PATCH 01/10] hw/armv7m_nvic: Fix incorrect default for num-irqs property Peter Maydell
2012-08-13 20:34 ` Meador Inge
2012-08-13 15:31 ` [Qemu-devel] [PATCH 02/10] armv7m: Guard against no -kernel argument Peter Maydell
2012-08-13 15:31 ` [Qemu-devel] [PATCH 03/10] hw/sd.c: convert wp_groups in SDState to bitfield Peter Maydell
2012-08-13 15:31 ` [Qemu-devel] [PATCH 04/10] hw/sd.c: make sd_wp_addr() accept 64 bit address argument Peter Maydell
2012-08-13 15:31 ` [Qemu-devel] [PATCH 05/10] hw/sd.c: introduce wrapper for conversion address to wp group Peter Maydell
2012-08-13 15:31 ` Peter Maydell [this message]
2012-08-13 15:31 ` [Qemu-devel] [PATCH 07/10] hw/sd.c: make sd_dataready() return bool Peter Maydell
2012-08-13 15:31 ` [Qemu-devel] [PATCH 08/10] hw/sd.c: make sd_wp_addr() " Peter Maydell
2012-08-13 15:31 ` [Qemu-devel] [PATCH 09/10] ssd0323: abort() instead of exit(1) on error Peter Maydell
2012-08-13 15:31 ` [Qemu-devel] [PATCH 10/10] arm: Move some ARM devices into libhw Peter Maydell
2012-08-14 0:12 ` [Qemu-devel] [PULL for-1.2 00/10] arm-devs queue Anthony Liguori
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1344871919-31559-7-git-send-email-peter.maydell@linaro.org \
--to=peter.maydell@linaro.org \
--cc=aliguori@us.ibm.com \
--cc=blauwirbel@gmail.com \
--cc=paul@codesourcery.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).