* [PATCH 1/3] mmc: initialize struct mmc_command at declaration time
@ 2011-04-14 3:57 Chris Ball
2011-04-14 4:07 ` [PATCHv2 " Chris Ball
2011-04-14 23:37 ` [PATCH " Nicolas Pitre
0 siblings, 2 replies; 6+ messages in thread
From: Chris Ball @ 2011-04-14 3:57 UTC (permalink / raw)
To: linux-mmc; +Cc: Chris Ball
Converts from:
struct mmc_command cmd;
memset(&cmd, 0, sizeof(struct mmc_command));
to:
struct mmc_command cmd = {0};
because it's shorter, as performant, and easier to work out whether
initialization has happened.
Signed-off-by: Chris Ball <cjb@laptop.org>
---
drivers/mmc/card/block.c | 13 +++-------
drivers/mmc/card/mmc_test.c | 22 +++++++------------
drivers/mmc/core/core.c | 6 +---
drivers/mmc/core/mmc_ops.c | 50 +++++++++++-------------------------------
drivers/mmc/core/sd_ops.c | 29 +++++++------------------
drivers/mmc/core/sdio_ops.c | 11 ++-------
6 files changed, 38 insertions(+), 93 deletions(-)
diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
index 9e30cf6..93a7efc 100644
--- a/drivers/mmc/card/block.c
+++ b/drivers/mmc/card/block.c
@@ -260,14 +260,12 @@ static u32 mmc_sd_num_wr_blocks(struct mmc_card *card)
__be32 *blocks;
struct mmc_request mrq;
- struct mmc_command cmd;
+ struct mmc_command cmd = {0};
struct mmc_data data;
unsigned int timeout_us;
struct scatterlist sg;
- memset(&cmd, 0, sizeof(struct mmc_command));
-
cmd.opcode = MMC_APP_CMD;
cmd.arg = card->rca << 16;
cmd.flags = MMC_RSP_SPI_R1 | MMC_RSP_R1 | MMC_CMD_AC;
@@ -328,10 +326,9 @@ static u32 mmc_sd_num_wr_blocks(struct mmc_card *card)
static u32 get_card_status(struct mmc_card *card, struct request *req)
{
- struct mmc_command cmd;
+ struct mmc_command cmd = {0};
int err;
- memset(&cmd, 0, sizeof(struct mmc_command));
cmd.opcode = MMC_SEND_STATUS;
if (!mmc_host_is_spi(card->host))
cmd.arg = card->rca << 16;
@@ -460,7 +457,7 @@ static inline int mmc_apply_rel_rw(struct mmc_blk_request *brq,
struct request *req)
{
int err;
- struct mmc_command set_count;
+ struct mmc_command set_count = {0};
if (!(card->ext_csd.rel_param & EXT_CSD_WR_REL_PARAM_EN)) {
/* Legacy mode imposes restrictions on transfers. */
@@ -473,7 +470,6 @@ static inline int mmc_apply_rel_rw(struct mmc_blk_request *brq,
brq->data.blocks = 1;
}
- memset(&set_count, 0, sizeof(struct mmc_command));
set_count.opcode = MMC_SET_BLOCK_COUNT;
set_count.arg = brq->data.blocks | (1 << 31);
set_count.flags = MMC_RSP_R1 | MMC_CMD_AC;
@@ -501,10 +497,9 @@ static int mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *req)
REL_WRITES_SUPPORTED(card);
do {
- struct mmc_command cmd;
+ struct mmc_command cmd = {0};
u32 readcmd, writecmd, status = 0;
- memset(&cmd, 0, sizeof(struct mmc_command));
memset(&brq, 0, sizeof(struct mmc_blk_request));
brq.mrq.cmd = &brq.cmd;
brq.mrq.data = &brq.data;
diff --git a/drivers/mmc/card/mmc_test.c b/drivers/mmc/card/mmc_test.c
index f5cedec..cc09be8 100644
--- a/drivers/mmc/card/mmc_test.c
+++ b/drivers/mmc/card/mmc_test.c
@@ -201,7 +201,7 @@ static void mmc_test_prepare_mrq(struct mmc_test_card *test,
}
static int mmc_test_busy(struct mmc_command *cmd)
-{
+
return !(cmd->resp[0] & R1_READY_FOR_DATA) ||
(R1_CURRENT_STATE(cmd->resp[0]) == 7);
}
@@ -212,7 +212,7 @@ static int mmc_test_busy(struct mmc_command *cmd)
static int mmc_test_wait_busy(struct mmc_test_card *test)
{
int ret, busy;
- struct mmc_command cmd;
+ struct mmc_command cmd = {0};
busy = 0;
do {
@@ -247,16 +247,14 @@ static int mmc_test_buffer_transfer(struct mmc_test_card *test,
int ret;
struct mmc_request mrq;
- struct mmc_command cmd;
- struct mmc_command stop;
+ struct mmc_command cmd = {0};
+ struct mmc_command stop = {0};
struct mmc_data data;
struct scatterlist sg;
memset(&mrq, 0, sizeof(struct mmc_request));
- memset(&cmd, 0, sizeof(struct mmc_command));
memset(&data, 0, sizeof(struct mmc_data));
- memset(&stop, 0, sizeof(struct mmc_command));
mrq.cmd = &cmd;
mrq.data = &data;
@@ -732,14 +730,12 @@ static int mmc_test_simple_transfer(struct mmc_test_card *test,
unsigned blocks, unsigned blksz, int write)
{
struct mmc_request mrq;
- struct mmc_command cmd;
- struct mmc_command stop;
+ struct mmc_command cmd = {0};
+ struct mmc_command stop = {0};
struct mmc_data data;
memset(&mrq, 0, sizeof(struct mmc_request));
- memset(&cmd, 0, sizeof(struct mmc_command));
memset(&data, 0, sizeof(struct mmc_data));
- memset(&stop, 0, sizeof(struct mmc_command));
mrq.cmd = &cmd;
mrq.data = &data;
@@ -762,16 +758,14 @@ static int mmc_test_broken_transfer(struct mmc_test_card *test,
unsigned blocks, unsigned blksz, int write)
{
struct mmc_request mrq;
- struct mmc_command cmd;
- struct mmc_command stop;
+ struct mmc_command cmd = {0};
+ struct mmc_command stop = {0};
struct mmc_data data;
struct scatterlist sg;
memset(&mrq, 0, sizeof(struct mmc_request));
- memset(&cmd, 0, sizeof(struct mmc_command));
memset(&data, 0, sizeof(struct mmc_data));
- memset(&stop, 0, sizeof(struct mmc_command));
mrq.cmd = &cmd;
mrq.data = &data;
diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index 5178d5d..f273ffd 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -1286,7 +1286,7 @@ static unsigned int mmc_erase_timeout(struct mmc_card *card,
static int mmc_do_erase(struct mmc_card *card, unsigned int from,
unsigned int to, unsigned int arg)
{
- struct mmc_command cmd;
+ struct mmc_command cmd = {0};
unsigned int qty = 0;
int err;
@@ -1320,7 +1320,6 @@ static int mmc_do_erase(struct mmc_card *card, unsigned int from,
to <<= 9;
}
- memset(&cmd, 0, sizeof(struct mmc_command));
if (mmc_card_sd(card))
cmd.opcode = SD_ERASE_WR_BLK_START;
else
@@ -1490,12 +1489,11 @@ EXPORT_SYMBOL(mmc_erase_group_aligned);
int mmc_set_blocklen(struct mmc_card *card, unsigned int blocklen)
{
- struct mmc_command cmd;
+ struct mmc_command cmd = {0};
if (mmc_card_blockaddr(card) || mmc_card_ddr_mode(card))
return 0;
- memset(&cmd, 0, sizeof(struct mmc_command));
cmd.opcode = MMC_SET_BLOCKLEN;
cmd.arg = blocklen;
cmd.flags = MMC_RSP_SPI_R1 | MMC_RSP_R1 | MMC_CMD_AC;
diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c
index 5f18919..3631ed6 100644
--- a/drivers/mmc/core/mmc_ops.c
+++ b/drivers/mmc/core/mmc_ops.c
@@ -23,12 +23,10 @@
static int _mmc_select_card(struct mmc_host *host, struct mmc_card *card)
{
int err;
- struct mmc_command cmd;
+ struct mmc_command cmd = {0};
BUG_ON(!host);
- memset(&cmd, 0, sizeof(struct mmc_command));
-
cmd.opcode = MMC_SELECT_CARD;
if (card) {
@@ -60,15 +58,13 @@ int mmc_deselect_cards(struct mmc_host *host)
int mmc_card_sleepawake(struct mmc_host *host, int sleep)
{
- struct mmc_command cmd;
+ struct mmc_command cmd = {0};
struct mmc_card *card = host->card;
int err;
if (sleep)
mmc_deselect_cards(host);
- memset(&cmd, 0, sizeof(struct mmc_command));
-
cmd.opcode = MMC_SLEEP_AWAKE;
cmd.arg = card->rca << 16;
if (sleep)
@@ -97,7 +93,7 @@ int mmc_card_sleepawake(struct mmc_host *host, int sleep)
int mmc_go_idle(struct mmc_host *host)
{
int err;
- struct mmc_command cmd;
+ struct mmc_command cmd = {0};
/*
* Non-SPI hosts need to prevent chipselect going active during
@@ -113,8 +109,6 @@ int mmc_go_idle(struct mmc_host *host)
mmc_delay(1);
}
- memset(&cmd, 0, sizeof(struct mmc_command));
-
cmd.opcode = MMC_GO_IDLE_STATE;
cmd.arg = 0;
cmd.flags = MMC_RSP_SPI_R1 | MMC_RSP_NONE | MMC_CMD_BC;
@@ -135,13 +129,11 @@ int mmc_go_idle(struct mmc_host *host)
int mmc_send_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr)
{
- struct mmc_command cmd;
+ struct mmc_command cmd = {0};
int i, err = 0;
BUG_ON(!host);
- memset(&cmd, 0, sizeof(struct mmc_command));
-
cmd.opcode = MMC_SEND_OP_COND;
cmd.arg = mmc_host_is_spi(host) ? 0 : ocr;
cmd.flags = MMC_RSP_SPI_R1 | MMC_RSP_R3 | MMC_CMD_BCR;
@@ -178,13 +170,11 @@ int mmc_send_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr)
int mmc_all_send_cid(struct mmc_host *host, u32 *cid)
{
int err;
- struct mmc_command cmd;
+ struct mmc_command cmd = {0};
BUG_ON(!host);
BUG_ON(!cid);
- memset(&cmd, 0, sizeof(struct mmc_command));
-
cmd.opcode = MMC_ALL_SEND_CID;
cmd.arg = 0;
cmd.flags = MMC_RSP_R2 | MMC_CMD_BCR;
@@ -201,13 +191,11 @@ int mmc_all_send_cid(struct mmc_host *host, u32 *cid)
int mmc_set_relative_addr(struct mmc_card *card)
{
int err;
- struct mmc_command cmd;
+ struct mmc_command cmd = {0};
BUG_ON(!card);
BUG_ON(!card->host);
- memset(&cmd, 0, sizeof(struct mmc_command));
-
cmd.opcode = MMC_SET_RELATIVE_ADDR;
cmd.arg = card->rca << 16;
cmd.flags = MMC_RSP_R1 | MMC_CMD_AC;
@@ -223,13 +211,11 @@ static int
mmc_send_cxd_native(struct mmc_host *host, u32 arg, u32 *cxd, int opcode)
{
int err;
- struct mmc_command cmd;
+ struct mmc_command cmd = {0};
BUG_ON(!host);
BUG_ON(!cxd);
- memset(&cmd, 0, sizeof(struct mmc_command));
-
cmd.opcode = opcode;
cmd.arg = arg;
cmd.flags = MMC_RSP_R2 | MMC_CMD_AC;
@@ -248,7 +234,7 @@ mmc_send_cxd_data(struct mmc_card *card, struct mmc_host *host,
u32 opcode, void *buf, unsigned len)
{
struct mmc_request mrq;
- struct mmc_command cmd;
+ struct mmc_command cmd = {0};
struct mmc_data data;
struct scatterlist sg;
void *data_buf;
@@ -261,7 +247,6 @@ mmc_send_cxd_data(struct mmc_card *card, struct mmc_host *host,
return -ENOMEM;
memset(&mrq, 0, sizeof(struct mmc_request));
- memset(&cmd, 0, sizeof(struct mmc_command));
memset(&data, 0, sizeof(struct mmc_data));
mrq.cmd = &cmd;
@@ -355,11 +340,9 @@ int mmc_send_ext_csd(struct mmc_card *card, u8 *ext_csd)
int mmc_spi_read_ocr(struct mmc_host *host, int highcap, u32 *ocrp)
{
- struct mmc_command cmd;
+ struct mmc_command cmd = {0};
int err;
- memset(&cmd, 0, sizeof(struct mmc_command));
-
cmd.opcode = MMC_SPI_READ_OCR;
cmd.arg = highcap ? (1 << 30) : 0;
cmd.flags = MMC_RSP_SPI_R3;
@@ -372,11 +355,9 @@ int mmc_spi_read_ocr(struct mmc_host *host, int highcap, u32 *ocrp)
int mmc_spi_set_crc(struct mmc_host *host, int use_crc)
{
- struct mmc_command cmd;
+ struct mmc_command cmd = {0};
int err;
- memset(&cmd, 0, sizeof(struct mmc_command));
-
cmd.opcode = MMC_SPI_CRC_ON_OFF;
cmd.flags = MMC_RSP_SPI_R1;
cmd.arg = use_crc;
@@ -402,14 +383,12 @@ int mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value,
unsigned int timeout_ms)
{
int err;
- struct mmc_command cmd;
+ struct mmc_command cmd = {0};
u32 status;
BUG_ON(!card);
BUG_ON(!card->host);
- memset(&cmd, 0, sizeof(struct mmc_command));
-
cmd.opcode = MMC_SWITCH;
cmd.arg = (MMC_SWITCH_MODE_WRITE_BYTE << 24) |
(index << 16) |
@@ -451,13 +430,11 @@ EXPORT_SYMBOL_GPL(mmc_switch);
int mmc_send_status(struct mmc_card *card, u32 *status)
{
int err;
- struct mmc_command cmd;
+ struct mmc_command cmd = {0};
BUG_ON(!card);
BUG_ON(!card->host);
- memset(&cmd, 0, sizeof(struct mmc_command));
-
cmd.opcode = MMC_SEND_STATUS;
if (!mmc_host_is_spi(card->host))
cmd.arg = card->rca << 16;
@@ -481,7 +458,7 @@ mmc_send_bus_test(struct mmc_card *card, struct mmc_host *host, u8 opcode,
u8 len)
{
struct mmc_request mrq;
- struct mmc_command cmd;
+ struct mmc_command cmd = {0};
struct mmc_data data;
struct scatterlist sg;
u8 *data_buf;
@@ -512,7 +489,6 @@ mmc_send_bus_test(struct mmc_card *card, struct mmc_host *host, u8 opcode,
memcpy(data_buf, test_buf, len);
memset(&mrq, 0, sizeof(struct mmc_request));
- memset(&cmd, 0, sizeof(struct mmc_command));
memset(&data, 0, sizeof(struct mmc_data));
mrq.cmd = &cmd;
diff --git a/drivers/mmc/core/sd_ops.c b/drivers/mmc/core/sd_ops.c
index da50849..dfe9a9c 100644
--- a/drivers/mmc/core/sd_ops.c
+++ b/drivers/mmc/core/sd_ops.c
@@ -24,13 +24,11 @@
static int mmc_app_cmd(struct mmc_host *host, struct mmc_card *card)
{
int err;
- struct mmc_command cmd;
+ struct mmc_command cmd = {0};
BUG_ON(!host);
BUG_ON(card && (card->host != host));
- memset(&cmd, 0, sizeof(struct mmc_command));
-
cmd.opcode = MMC_APP_CMD;
if (card) {
@@ -121,13 +119,11 @@ EXPORT_SYMBOL(mmc_wait_for_app_cmd);
int mmc_app_set_bus_width(struct mmc_card *card, int width)
{
int err;
- struct mmc_command cmd;
+ struct mmc_command cmd = {0};
BUG_ON(!card);
BUG_ON(!card->host);
- memset(&cmd, 0, sizeof(struct mmc_command));
-
cmd.opcode = SD_APP_SET_BUS_WIDTH;
cmd.flags = MMC_RSP_R1 | MMC_CMD_AC;
@@ -151,13 +147,11 @@ int mmc_app_set_bus_width(struct mmc_card *card, int width)
int mmc_send_app_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr)
{
- struct mmc_command cmd;
+ struct mmc_command cmd = {0};
int i, err = 0;
BUG_ON(!host);
- memset(&cmd, 0, sizeof(struct mmc_command));
-
cmd.opcode = SD_APP_OP_COND;
if (mmc_host_is_spi(host))
cmd.arg = ocr & (1 << 30); /* SPI only defines one bit */
@@ -196,13 +190,11 @@ int mmc_send_app_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr)
int mmc_send_if_cond(struct mmc_host *host, u32 ocr)
{
- struct mmc_command cmd;
+ struct mmc_command cmd = {0};
int err;
static const u8 test_pattern = 0xAA;
u8 result_pattern;
- memset(&cmd, 0, sizeof(struct mmc_command));
-
/*
* To support SD 2.0 cards, we must always invoke SD_SEND_IF_COND
* before SD_APP_OP_COND. This command will harmlessly fail for
@@ -230,13 +222,11 @@ int mmc_send_if_cond(struct mmc_host *host, u32 ocr)
int mmc_send_relative_addr(struct mmc_host *host, unsigned int *rca)
{
int err;
- struct mmc_command cmd;
+ struct mmc_command cmd = {0};
BUG_ON(!host);
BUG_ON(!rca);
- memset(&cmd, 0, sizeof(struct mmc_command));
-
cmd.opcode = SD_SEND_RELATIVE_ADDR;
cmd.arg = 0;
cmd.flags = MMC_RSP_R6 | MMC_CMD_BCR;
@@ -254,7 +244,7 @@ int mmc_app_send_scr(struct mmc_card *card, u32 *scr)
{
int err;
struct mmc_request mrq;
- struct mmc_command cmd;
+ struct mmc_command cmd = {0};
struct mmc_data data;
struct scatterlist sg;
void *data_buf;
@@ -277,7 +267,6 @@ int mmc_app_send_scr(struct mmc_card *card, u32 *scr)
return -ENOMEM;
memset(&mrq, 0, sizeof(struct mmc_request));
- memset(&cmd, 0, sizeof(struct mmc_command));
memset(&data, 0, sizeof(struct mmc_data));
mrq.cmd = &cmd;
@@ -317,7 +306,7 @@ int mmc_sd_switch(struct mmc_card *card, int mode, int group,
u8 value, u8 *resp)
{
struct mmc_request mrq;
- struct mmc_command cmd;
+ struct mmc_command cmd = {0};
struct mmc_data data;
struct scatterlist sg;
@@ -330,7 +319,6 @@ int mmc_sd_switch(struct mmc_card *card, int mode, int group,
value &= 0xF;
memset(&mrq, 0, sizeof(struct mmc_request));
- memset(&cmd, 0, sizeof(struct mmc_command));
memset(&data, 0, sizeof(struct mmc_data));
mrq.cmd = &cmd;
@@ -366,7 +354,7 @@ int mmc_app_sd_status(struct mmc_card *card, void *ssr)
{
int err;
struct mmc_request mrq;
- struct mmc_command cmd;
+ struct mmc_command cmd = {0};
struct mmc_data data;
struct scatterlist sg;
@@ -381,7 +369,6 @@ int mmc_app_sd_status(struct mmc_card *card, void *ssr)
return err;
memset(&mrq, 0, sizeof(struct mmc_request));
- memset(&cmd, 0, sizeof(struct mmc_command));
memset(&data, 0, sizeof(struct mmc_data));
mrq.cmd = &cmd;
diff --git a/drivers/mmc/core/sdio_ops.c b/drivers/mmc/core/sdio_ops.c
index dea36d9..f77b1bc 100644
--- a/drivers/mmc/core/sdio_ops.c
+++ b/drivers/mmc/core/sdio_ops.c
@@ -21,13 +21,11 @@
int mmc_send_io_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr)
{
- struct mmc_command cmd;
+ struct mmc_command cmd = {0};
int i, err = 0;
BUG_ON(!host);
- memset(&cmd, 0, sizeof(struct mmc_command));
-
cmd.opcode = SD_IO_SEND_OP_COND;
cmd.arg = ocr;
cmd.flags = MMC_RSP_SPI_R4 | MMC_RSP_R4 | MMC_CMD_BCR;
@@ -70,7 +68,7 @@ int mmc_send_io_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr)
static int mmc_io_rw_direct_host(struct mmc_host *host, int write, unsigned fn,
unsigned addr, u8 in, u8 *out)
{
- struct mmc_command cmd;
+ struct mmc_command cmd = {0};
int err;
BUG_ON(!host);
@@ -80,8 +78,6 @@ static int mmc_io_rw_direct_host(struct mmc_host *host, int write, unsigned fn,
if (addr & ~0x1FFFF)
return -EINVAL;
- memset(&cmd, 0, sizeof(struct mmc_command));
-
cmd.opcode = SD_IO_RW_DIRECT;
cmd.arg = write ? 0x80000000 : 0x00000000;
cmd.arg |= fn << 28;
@@ -126,7 +122,7 @@ int mmc_io_rw_extended(struct mmc_card *card, int write, unsigned fn,
unsigned addr, int incr_addr, u8 *buf, unsigned blocks, unsigned blksz)
{
struct mmc_request mrq;
- struct mmc_command cmd;
+ struct mmc_command cmd = {0};
struct mmc_data data;
struct scatterlist sg;
@@ -141,7 +137,6 @@ int mmc_io_rw_extended(struct mmc_card *card, int write, unsigned fn,
return -EINVAL;
memset(&mrq, 0, sizeof(struct mmc_request));
- memset(&cmd, 0, sizeof(struct mmc_command));
memset(&data, 0, sizeof(struct mmc_data));
mrq.cmd = &cmd;
--
1.7.0.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCHv2 1/3] mmc: initialize struct mmc_command at declaration time
2011-04-14 3:57 [PATCH 1/3] mmc: initialize struct mmc_command at declaration time Chris Ball
@ 2011-04-14 4:07 ` Chris Ball
2011-04-14 23:37 ` [PATCH " Nicolas Pitre
1 sibling, 0 replies; 6+ messages in thread
From: Chris Ball @ 2011-04-14 4:07 UTC (permalink / raw)
To: linux-mmc
Converts from:
struct mmc_command cmd;
memset(&cmd, 0, sizeof(struct mmc_command));
to:
struct mmc_command cmd = {0};
because it's shorter, as performant, and easier to work out whether
initialization has happened.
Signed-off-by: Chris Ball <cjb@laptop.org>
---
v2: Sorry, there was a rogue hunk in the previous version of this patch,
inside mmc_test_busy(). Fixed/tested.
drivers/mmc/card/block.c | 13 +++-------
drivers/mmc/card/mmc_test.c | 20 ++++++-----------
drivers/mmc/core/core.c | 6 +---
drivers/mmc/core/mmc_ops.c | 50 +++++++++++-------------------------------
drivers/mmc/core/sd_ops.c | 29 +++++++------------------
drivers/mmc/core/sdio_ops.c | 11 ++-------
6 files changed, 37 insertions(+), 92 deletions(-)
diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
index 9e30cf6..93a7efc 100644
--- a/drivers/mmc/card/block.c
+++ b/drivers/mmc/card/block.c
@@ -260,14 +260,12 @@ static u32 mmc_sd_num_wr_blocks(struct mmc_card *card)
__be32 *blocks;
struct mmc_request mrq;
- struct mmc_command cmd;
+ struct mmc_command cmd = {0};
struct mmc_data data;
unsigned int timeout_us;
struct scatterlist sg;
- memset(&cmd, 0, sizeof(struct mmc_command));
-
cmd.opcode = MMC_APP_CMD;
cmd.arg = card->rca << 16;
cmd.flags = MMC_RSP_SPI_R1 | MMC_RSP_R1 | MMC_CMD_AC;
@@ -328,10 +326,9 @@ static u32 mmc_sd_num_wr_blocks(struct mmc_card *card)
static u32 get_card_status(struct mmc_card *card, struct request *req)
{
- struct mmc_command cmd;
+ struct mmc_command cmd = {0};
int err;
- memset(&cmd, 0, sizeof(struct mmc_command));
cmd.opcode = MMC_SEND_STATUS;
if (!mmc_host_is_spi(card->host))
cmd.arg = card->rca << 16;
@@ -460,7 +457,7 @@ static inline int mmc_apply_rel_rw(struct mmc_blk_request *brq,
struct request *req)
{
int err;
- struct mmc_command set_count;
+ struct mmc_command set_count = {0};
if (!(card->ext_csd.rel_param & EXT_CSD_WR_REL_PARAM_EN)) {
/* Legacy mode imposes restrictions on transfers. */
@@ -473,7 +470,6 @@ static inline int mmc_apply_rel_rw(struct mmc_blk_request *brq,
brq->data.blocks = 1;
}
- memset(&set_count, 0, sizeof(struct mmc_command));
set_count.opcode = MMC_SET_BLOCK_COUNT;
set_count.arg = brq->data.blocks | (1 << 31);
set_count.flags = MMC_RSP_R1 | MMC_CMD_AC;
@@ -501,10 +497,9 @@ static int mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *req)
REL_WRITES_SUPPORTED(card);
do {
- struct mmc_command cmd;
+ struct mmc_command cmd = {0};
u32 readcmd, writecmd, status = 0;
- memset(&cmd, 0, sizeof(struct mmc_command));
memset(&brq, 0, sizeof(struct mmc_blk_request));
brq.mrq.cmd = &brq.cmd;
brq.mrq.data = &brq.data;
diff --git a/drivers/mmc/card/mmc_test.c b/drivers/mmc/card/mmc_test.c
index f5cedec..83c394c 100644
--- a/drivers/mmc/card/mmc_test.c
+++ b/drivers/mmc/card/mmc_test.c
@@ -212,7 +212,7 @@ static int mmc_test_busy(struct mmc_command *cmd)
static int mmc_test_wait_busy(struct mmc_test_card *test)
{
int ret, busy;
- struct mmc_command cmd;
+ struct mmc_command cmd = {0};
busy = 0;
do {
@@ -247,16 +247,14 @@ static int mmc_test_buffer_transfer(struct mmc_test_card *test,
int ret;
struct mmc_request mrq;
- struct mmc_command cmd;
- struct mmc_command stop;
+ struct mmc_command cmd = {0};
+ struct mmc_command stop = {0};
struct mmc_data data;
struct scatterlist sg;
memset(&mrq, 0, sizeof(struct mmc_request));
- memset(&cmd, 0, sizeof(struct mmc_command));
memset(&data, 0, sizeof(struct mmc_data));
- memset(&stop, 0, sizeof(struct mmc_command));
mrq.cmd = &cmd;
mrq.data = &data;
@@ -732,14 +730,12 @@ static int mmc_test_simple_transfer(struct mmc_test_card *test,
unsigned blocks, unsigned blksz, int write)
{
struct mmc_request mrq;
- struct mmc_command cmd;
- struct mmc_command stop;
+ struct mmc_command cmd = {0};
+ struct mmc_command stop = {0};
struct mmc_data data;
memset(&mrq, 0, sizeof(struct mmc_request));
- memset(&cmd, 0, sizeof(struct mmc_command));
memset(&data, 0, sizeof(struct mmc_data));
- memset(&stop, 0, sizeof(struct mmc_command));
mrq.cmd = &cmd;
mrq.data = &data;
@@ -762,16 +758,14 @@ static int mmc_test_broken_transfer(struct mmc_test_card *test,
unsigned blocks, unsigned blksz, int write)
{
struct mmc_request mrq;
- struct mmc_command cmd;
- struct mmc_command stop;
+ struct mmc_command cmd = {0};
+ struct mmc_command stop = {0};
struct mmc_data data;
struct scatterlist sg;
memset(&mrq, 0, sizeof(struct mmc_request));
- memset(&cmd, 0, sizeof(struct mmc_command));
memset(&data, 0, sizeof(struct mmc_data));
- memset(&stop, 0, sizeof(struct mmc_command));
mrq.cmd = &cmd;
mrq.data = &data;
diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index 5178d5d..f273ffd 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -1286,7 +1286,7 @@ static unsigned int mmc_erase_timeout(struct mmc_card *card,
static int mmc_do_erase(struct mmc_card *card, unsigned int from,
unsigned int to, unsigned int arg)
{
- struct mmc_command cmd;
+ struct mmc_command cmd = {0};
unsigned int qty = 0;
int err;
@@ -1320,7 +1320,6 @@ static int mmc_do_erase(struct mmc_card *card, unsigned int from,
to <<= 9;
}
- memset(&cmd, 0, sizeof(struct mmc_command));
if (mmc_card_sd(card))
cmd.opcode = SD_ERASE_WR_BLK_START;
else
@@ -1490,12 +1489,11 @@ EXPORT_SYMBOL(mmc_erase_group_aligned);
int mmc_set_blocklen(struct mmc_card *card, unsigned int blocklen)
{
- struct mmc_command cmd;
+ struct mmc_command cmd = {0};
if (mmc_card_blockaddr(card) || mmc_card_ddr_mode(card))
return 0;
- memset(&cmd, 0, sizeof(struct mmc_command));
cmd.opcode = MMC_SET_BLOCKLEN;
cmd.arg = blocklen;
cmd.flags = MMC_RSP_SPI_R1 | MMC_RSP_R1 | MMC_CMD_AC;
diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c
index 5f18919..3631ed6 100644
--- a/drivers/mmc/core/mmc_ops.c
+++ b/drivers/mmc/core/mmc_ops.c
@@ -23,12 +23,10 @@
static int _mmc_select_card(struct mmc_host *host, struct mmc_card *card)
{
int err;
- struct mmc_command cmd;
+ struct mmc_command cmd = {0};
BUG_ON(!host);
- memset(&cmd, 0, sizeof(struct mmc_command));
-
cmd.opcode = MMC_SELECT_CARD;
if (card) {
@@ -60,15 +58,13 @@ int mmc_deselect_cards(struct mmc_host *host)
int mmc_card_sleepawake(struct mmc_host *host, int sleep)
{
- struct mmc_command cmd;
+ struct mmc_command cmd = {0};
struct mmc_card *card = host->card;
int err;
if (sleep)
mmc_deselect_cards(host);
- memset(&cmd, 0, sizeof(struct mmc_command));
-
cmd.opcode = MMC_SLEEP_AWAKE;
cmd.arg = card->rca << 16;
if (sleep)
@@ -97,7 +93,7 @@ int mmc_card_sleepawake(struct mmc_host *host, int sleep)
int mmc_go_idle(struct mmc_host *host)
{
int err;
- struct mmc_command cmd;
+ struct mmc_command cmd = {0};
/*
* Non-SPI hosts need to prevent chipselect going active during
@@ -113,8 +109,6 @@ int mmc_go_idle(struct mmc_host *host)
mmc_delay(1);
}
- memset(&cmd, 0, sizeof(struct mmc_command));
-
cmd.opcode = MMC_GO_IDLE_STATE;
cmd.arg = 0;
cmd.flags = MMC_RSP_SPI_R1 | MMC_RSP_NONE | MMC_CMD_BC;
@@ -135,13 +129,11 @@ int mmc_go_idle(struct mmc_host *host)
int mmc_send_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr)
{
- struct mmc_command cmd;
+ struct mmc_command cmd = {0};
int i, err = 0;
BUG_ON(!host);
- memset(&cmd, 0, sizeof(struct mmc_command));
-
cmd.opcode = MMC_SEND_OP_COND;
cmd.arg = mmc_host_is_spi(host) ? 0 : ocr;
cmd.flags = MMC_RSP_SPI_R1 | MMC_RSP_R3 | MMC_CMD_BCR;
@@ -178,13 +170,11 @@ int mmc_send_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr)
int mmc_all_send_cid(struct mmc_host *host, u32 *cid)
{
int err;
- struct mmc_command cmd;
+ struct mmc_command cmd = {0};
BUG_ON(!host);
BUG_ON(!cid);
- memset(&cmd, 0, sizeof(struct mmc_command));
-
cmd.opcode = MMC_ALL_SEND_CID;
cmd.arg = 0;
cmd.flags = MMC_RSP_R2 | MMC_CMD_BCR;
@@ -201,13 +191,11 @@ int mmc_all_send_cid(struct mmc_host *host, u32 *cid)
int mmc_set_relative_addr(struct mmc_card *card)
{
int err;
- struct mmc_command cmd;
+ struct mmc_command cmd = {0};
BUG_ON(!card);
BUG_ON(!card->host);
- memset(&cmd, 0, sizeof(struct mmc_command));
-
cmd.opcode = MMC_SET_RELATIVE_ADDR;
cmd.arg = card->rca << 16;
cmd.flags = MMC_RSP_R1 | MMC_CMD_AC;
@@ -223,13 +211,11 @@ static int
mmc_send_cxd_native(struct mmc_host *host, u32 arg, u32 *cxd, int opcode)
{
int err;
- struct mmc_command cmd;
+ struct mmc_command cmd = {0};
BUG_ON(!host);
BUG_ON(!cxd);
- memset(&cmd, 0, sizeof(struct mmc_command));
-
cmd.opcode = opcode;
cmd.arg = arg;
cmd.flags = MMC_RSP_R2 | MMC_CMD_AC;
@@ -248,7 +234,7 @@ mmc_send_cxd_data(struct mmc_card *card, struct mmc_host *host,
u32 opcode, void *buf, unsigned len)
{
struct mmc_request mrq;
- struct mmc_command cmd;
+ struct mmc_command cmd = {0};
struct mmc_data data;
struct scatterlist sg;
void *data_buf;
@@ -261,7 +247,6 @@ mmc_send_cxd_data(struct mmc_card *card, struct mmc_host *host,
return -ENOMEM;
memset(&mrq, 0, sizeof(struct mmc_request));
- memset(&cmd, 0, sizeof(struct mmc_command));
memset(&data, 0, sizeof(struct mmc_data));
mrq.cmd = &cmd;
@@ -355,11 +340,9 @@ int mmc_send_ext_csd(struct mmc_card *card, u8 *ext_csd)
int mmc_spi_read_ocr(struct mmc_host *host, int highcap, u32 *ocrp)
{
- struct mmc_command cmd;
+ struct mmc_command cmd = {0};
int err;
- memset(&cmd, 0, sizeof(struct mmc_command));
-
cmd.opcode = MMC_SPI_READ_OCR;
cmd.arg = highcap ? (1 << 30) : 0;
cmd.flags = MMC_RSP_SPI_R3;
@@ -372,11 +355,9 @@ int mmc_spi_read_ocr(struct mmc_host *host, int highcap, u32 *ocrp)
int mmc_spi_set_crc(struct mmc_host *host, int use_crc)
{
- struct mmc_command cmd;
+ struct mmc_command cmd = {0};
int err;
- memset(&cmd, 0, sizeof(struct mmc_command));
-
cmd.opcode = MMC_SPI_CRC_ON_OFF;
cmd.flags = MMC_RSP_SPI_R1;
cmd.arg = use_crc;
@@ -402,14 +383,12 @@ int mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value,
unsigned int timeout_ms)
{
int err;
- struct mmc_command cmd;
+ struct mmc_command cmd = {0};
u32 status;
BUG_ON(!card);
BUG_ON(!card->host);
- memset(&cmd, 0, sizeof(struct mmc_command));
-
cmd.opcode = MMC_SWITCH;
cmd.arg = (MMC_SWITCH_MODE_WRITE_BYTE << 24) |
(index << 16) |
@@ -451,13 +430,11 @@ EXPORT_SYMBOL_GPL(mmc_switch);
int mmc_send_status(struct mmc_card *card, u32 *status)
{
int err;
- struct mmc_command cmd;
+ struct mmc_command cmd = {0};
BUG_ON(!card);
BUG_ON(!card->host);
- memset(&cmd, 0, sizeof(struct mmc_command));
-
cmd.opcode = MMC_SEND_STATUS;
if (!mmc_host_is_spi(card->host))
cmd.arg = card->rca << 16;
@@ -481,7 +458,7 @@ mmc_send_bus_test(struct mmc_card *card, struct mmc_host *host, u8 opcode,
u8 len)
{
struct mmc_request mrq;
- struct mmc_command cmd;
+ struct mmc_command cmd = {0};
struct mmc_data data;
struct scatterlist sg;
u8 *data_buf;
@@ -512,7 +489,6 @@ mmc_send_bus_test(struct mmc_card *card, struct mmc_host *host, u8 opcode,
memcpy(data_buf, test_buf, len);
memset(&mrq, 0, sizeof(struct mmc_request));
- memset(&cmd, 0, sizeof(struct mmc_command));
memset(&data, 0, sizeof(struct mmc_data));
mrq.cmd = &cmd;
diff --git a/drivers/mmc/core/sd_ops.c b/drivers/mmc/core/sd_ops.c
index da50849..dfe9a9c 100644
--- a/drivers/mmc/core/sd_ops.c
+++ b/drivers/mmc/core/sd_ops.c
@@ -24,13 +24,11 @@
static int mmc_app_cmd(struct mmc_host *host, struct mmc_card *card)
{
int err;
- struct mmc_command cmd;
+ struct mmc_command cmd = {0};
BUG_ON(!host);
BUG_ON(card && (card->host != host));
- memset(&cmd, 0, sizeof(struct mmc_command));
-
cmd.opcode = MMC_APP_CMD;
if (card) {
@@ -121,13 +119,11 @@ EXPORT_SYMBOL(mmc_wait_for_app_cmd);
int mmc_app_set_bus_width(struct mmc_card *card, int width)
{
int err;
- struct mmc_command cmd;
+ struct mmc_command cmd = {0};
BUG_ON(!card);
BUG_ON(!card->host);
- memset(&cmd, 0, sizeof(struct mmc_command));
-
cmd.opcode = SD_APP_SET_BUS_WIDTH;
cmd.flags = MMC_RSP_R1 | MMC_CMD_AC;
@@ -151,13 +147,11 @@ int mmc_app_set_bus_width(struct mmc_card *card, int width)
int mmc_send_app_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr)
{
- struct mmc_command cmd;
+ struct mmc_command cmd = {0};
int i, err = 0;
BUG_ON(!host);
- memset(&cmd, 0, sizeof(struct mmc_command));
-
cmd.opcode = SD_APP_OP_COND;
if (mmc_host_is_spi(host))
cmd.arg = ocr & (1 << 30); /* SPI only defines one bit */
@@ -196,13 +190,11 @@ int mmc_send_app_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr)
int mmc_send_if_cond(struct mmc_host *host, u32 ocr)
{
- struct mmc_command cmd;
+ struct mmc_command cmd = {0};
int err;
static const u8 test_pattern = 0xAA;
u8 result_pattern;
- memset(&cmd, 0, sizeof(struct mmc_command));
-
/*
* To support SD 2.0 cards, we must always invoke SD_SEND_IF_COND
* before SD_APP_OP_COND. This command will harmlessly fail for
@@ -230,13 +222,11 @@ int mmc_send_if_cond(struct mmc_host *host, u32 ocr)
int mmc_send_relative_addr(struct mmc_host *host, unsigned int *rca)
{
int err;
- struct mmc_command cmd;
+ struct mmc_command cmd = {0};
BUG_ON(!host);
BUG_ON(!rca);
- memset(&cmd, 0, sizeof(struct mmc_command));
-
cmd.opcode = SD_SEND_RELATIVE_ADDR;
cmd.arg = 0;
cmd.flags = MMC_RSP_R6 | MMC_CMD_BCR;
@@ -254,7 +244,7 @@ int mmc_app_send_scr(struct mmc_card *card, u32 *scr)
{
int err;
struct mmc_request mrq;
- struct mmc_command cmd;
+ struct mmc_command cmd = {0};
struct mmc_data data;
struct scatterlist sg;
void *data_buf;
@@ -277,7 +267,6 @@ int mmc_app_send_scr(struct mmc_card *card, u32 *scr)
return -ENOMEM;
memset(&mrq, 0, sizeof(struct mmc_request));
- memset(&cmd, 0, sizeof(struct mmc_command));
memset(&data, 0, sizeof(struct mmc_data));
mrq.cmd = &cmd;
@@ -317,7 +306,7 @@ int mmc_sd_switch(struct mmc_card *card, int mode, int group,
u8 value, u8 *resp)
{
struct mmc_request mrq;
- struct mmc_command cmd;
+ struct mmc_command cmd = {0};
struct mmc_data data;
struct scatterlist sg;
@@ -330,7 +319,6 @@ int mmc_sd_switch(struct mmc_card *card, int mode, int group,
value &= 0xF;
memset(&mrq, 0, sizeof(struct mmc_request));
- memset(&cmd, 0, sizeof(struct mmc_command));
memset(&data, 0, sizeof(struct mmc_data));
mrq.cmd = &cmd;
@@ -366,7 +354,7 @@ int mmc_app_sd_status(struct mmc_card *card, void *ssr)
{
int err;
struct mmc_request mrq;
- struct mmc_command cmd;
+ struct mmc_command cmd = {0};
struct mmc_data data;
struct scatterlist sg;
@@ -381,7 +369,6 @@ int mmc_app_sd_status(struct mmc_card *card, void *ssr)
return err;
memset(&mrq, 0, sizeof(struct mmc_request));
- memset(&cmd, 0, sizeof(struct mmc_command));
memset(&data, 0, sizeof(struct mmc_data));
mrq.cmd = &cmd;
diff --git a/drivers/mmc/core/sdio_ops.c b/drivers/mmc/core/sdio_ops.c
index dea36d9..f77b1bc 100644
--- a/drivers/mmc/core/sdio_ops.c
+++ b/drivers/mmc/core/sdio_ops.c
@@ -21,13 +21,11 @@
int mmc_send_io_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr)
{
- struct mmc_command cmd;
+ struct mmc_command cmd = {0};
int i, err = 0;
BUG_ON(!host);
- memset(&cmd, 0, sizeof(struct mmc_command));
-
cmd.opcode = SD_IO_SEND_OP_COND;
cmd.arg = ocr;
cmd.flags = MMC_RSP_SPI_R4 | MMC_RSP_R4 | MMC_CMD_BCR;
@@ -70,7 +68,7 @@ int mmc_send_io_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr)
static int mmc_io_rw_direct_host(struct mmc_host *host, int write, unsigned fn,
unsigned addr, u8 in, u8 *out)
{
- struct mmc_command cmd;
+ struct mmc_command cmd = {0};
int err;
BUG_ON(!host);
@@ -80,8 +78,6 @@ static int mmc_io_rw_direct_host(struct mmc_host *host, int write, unsigned fn,
if (addr & ~0x1FFFF)
return -EINVAL;
- memset(&cmd, 0, sizeof(struct mmc_command));
-
cmd.opcode = SD_IO_RW_DIRECT;
cmd.arg = write ? 0x80000000 : 0x00000000;
cmd.arg |= fn << 28;
@@ -126,7 +122,7 @@ int mmc_io_rw_extended(struct mmc_card *card, int write, unsigned fn,
unsigned addr, int incr_addr, u8 *buf, unsigned blocks, unsigned blksz)
{
struct mmc_request mrq;
- struct mmc_command cmd;
+ struct mmc_command cmd = {0};
struct mmc_data data;
struct scatterlist sg;
@@ -141,7 +137,6 @@ int mmc_io_rw_extended(struct mmc_card *card, int write, unsigned fn,
return -EINVAL;
memset(&mrq, 0, sizeof(struct mmc_request));
- memset(&cmd, 0, sizeof(struct mmc_command));
memset(&data, 0, sizeof(struct mmc_data));
mrq.cmd = &cmd;
--
Chris Ball <cjb@laptop.org> <http://printf.net/>
One Laptop Per Child
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 1/3] mmc: initialize struct mmc_command at declaration time
2011-04-14 3:57 [PATCH 1/3] mmc: initialize struct mmc_command at declaration time Chris Ball
2011-04-14 4:07 ` [PATCHv2 " Chris Ball
@ 2011-04-14 23:37 ` Nicolas Pitre
2011-04-15 3:11 ` Chris Ball
1 sibling, 1 reply; 6+ messages in thread
From: Nicolas Pitre @ 2011-04-14 23:37 UTC (permalink / raw)
To: Chris Ball; +Cc: linux-mmc
On Wed, 13 Apr 2011, Chris Ball wrote:
> Converts from:
> struct mmc_command cmd;
> memset(&cmd, 0, sizeof(struct mmc_command));
>
> to:
> struct mmc_command cmd = {0};
>
> because it's shorter, as performant, and easier to work out whether
> initialization has happened.
Did you disassemble the resulting binary to make sure this is actually
as performant?
I'm asking because gcc used to do a horrible dumb job with such patterns
where it would allocate two instances of the structure on the stack i.e.
one for the named variable and one for the initializer, then fill the
later with zeroes, and then call memcpy() to copy the initializer over
to the named instance.
Nicolas
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/3] mmc: initialize struct mmc_command at declaration time
2011-04-14 23:37 ` [PATCH " Nicolas Pitre
@ 2011-04-15 3:11 ` Chris Ball
2011-04-15 18:06 ` Chris Ball
0 siblings, 1 reply; 6+ messages in thread
From: Chris Ball @ 2011-04-15 3:11 UTC (permalink / raw)
To: Nicolas Pitre; +Cc: linux-mmc
Hi,
On Thu, Apr 14 2011, Nicolas Pitre wrote:
> Did you disassemble the resulting binary to make sure this is actually
> as performant?
>
> I'm asking because gcc used to do a horrible dumb job with such patterns
> where it would allocate two instances of the structure on the stack i.e.
> one for the named variable and one for the initializer, then fill the
> later with zeroes, and then call memcpy() to copy the initializer over
> to the named instance.
Nothing horrible as far as I can tell; in fact, the code size on ARM
(stripped mmc_core.ko) decreases by 216 bytes after the patchset here.
Here's a sample disassembly of one function on ARM with gcc-4.6.0, and
diff -y. Explicit memset (which calls __memzero) on the left, and {0}
initializer (which calls memset) on the right:
00000698 <mmc_set_relative_addr>: | 000006c8 <mmc_set_relative_addr>:
698: e92d4010 push {r4, lr} | 6c8: e92d4010 push {r4, lr}
69c: e2504000 subs r4, r0, #0 | 6cc: e24dd030 sub sp, sp, #48 ; 0x30
6a0: e24dd030 sub sp, sp, #48 ; 0x30 | 6d0: e1a04000 mov r4, r0
6a4: 059f0058 ldreq r0, [pc, #88] ; 704 <mmc_se | 6d4: e3a01000 mov r1, #0
6a8: 03a010ce moveq r1, #206 ; 0xce | 6d8: e1a0000d mov r0, sp
6ac: 0a000004 beq 6c4 <mmc_set_relative_addr+0x | 6dc: e3a02030 mov r2, #48 ; 0x30
6b0: e5943000 ldr r3, [r4] | 6e0: ebfffffe bl 0 <memset>
6b4: e3530000 cmp r3, #0 | 6e4: e3540000 cmp r4, #0
6b8: 1a000002 bne 6c8 <mmc_set_relative_addr+0x | 6e8: 059f0048 ldreq r0, [pc, #72] ; 738 <mmc_se
6bc: e59f0040 ldr r0, [pc, #64] ; 704 <mmc_se | 6ec: 03a010c4 moveq r1, #196 ; 0xc4
6c0: e3a010cf mov r1, #207 ; 0xcf | 6f0: 0a000004 beq 708 <mmc_set_relative_addr+0x
6c4: ebfffffe bl 0 <__bug> | 6f4: e5940000 ldr r0, [r4]
6c8: e1a0000d mov r0, sp | 6f8: e3500000 cmp r0, #0
6cc: e3a01030 mov r1, #48 ; 0x30 | 6fc: 1a000002 bne 70c <mmc_set_relative_addr+0x
6d0: ebfffffe bl 0 <__memzero> | 700: e59f0030 ldr r0, [pc, #48] ; 738 <mmc_se
6d4: e59430c8 ldr r3, [r4, #200] ; 0xc8 | 704: e3a010c5 mov r1, #197 ; 0xc5
6d8: e3a02003 mov r2, #3 | 708: ebfffffe bl 0 <__bug>
6dc: e1a03803 lsl r3, r3, #16 | 70c: e59430c8 ldr r3, [r4, #200] ; 0xc8
6e0: e58d3004 str r3, [sp, #4] | 710: e3a02003 mov r2, #3
6e4: e5940000 ldr r0, [r4] | 714: e1a03803 lsl r3, r3, #16
6e8: e3a03015 mov r3, #21 | 718: e58d3004 str r3, [sp, #4]
6ec: e1a0100d mov r1, sp | 71c: e1a0100d mov r1, sp
6f0: e58d2000 str r2, [sp] | 720: e3a03015 mov r3, #21
6f4: e58d3018 str r3, [sp, #24] | 724: e58d2000 str r2, [sp]
6f8: ebfffffe bl 0 <mmc_wait_for_cmd> | 728: e58d3018 str r3, [sp, #24]
6fc: e28dd030 add sp, sp, #48 ; 0x30 | 72c: ebfffffe bl 0 <mmc_wait_for_cmd>
700: e8bd8010 pop {r4, pc} | 730: e28dd030 add sp, sp, #48 ; 0x30
704: 0000001d .word 0x0000001d | 734: e8bd8010 pop {r4, pc}
> 738: 0000001d .word 0x0000001d
Thanks,
- Chris.
--
Chris Ball <cjb@laptop.org> <http://printf.net/>
One Laptop Per Child
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/3] mmc: initialize struct mmc_command at declaration time
2011-04-15 3:11 ` Chris Ball
@ 2011-04-15 18:06 ` Chris Ball
2011-04-15 22:37 ` Nicolas Pitre
0 siblings, 1 reply; 6+ messages in thread
From: Chris Ball @ 2011-04-15 18:06 UTC (permalink / raw)
To: Nicolas Pitre; +Cc: linux-mmc
Hi,
On Thu, Apr 14 2011, Chris Ball wrote:
> Here's a sample disassembly of one function on ARM with gcc-4.6.0, and
> diff -y. Explicit memset (which calls __memzero) on the left, and {0}
> initializer (which calls memset) on the right:
(I checked on x86_64 too, and the code's identical -- it's inlined into
a "rep stos %eax,%es:(%rdi)" either way.)
- Chris.
--
Chris Ball <cjb@laptop.org> <http://printf.net/>
One Laptop Per Child
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/3] mmc: initialize struct mmc_command at declaration time
2011-04-15 18:06 ` Chris Ball
@ 2011-04-15 22:37 ` Nicolas Pitre
0 siblings, 0 replies; 6+ messages in thread
From: Nicolas Pitre @ 2011-04-15 22:37 UTC (permalink / raw)
To: Chris Ball; +Cc: linux-mmc
On Fri, 15 Apr 2011, Chris Ball wrote:
> Hi,
>
> On Thu, Apr 14 2011, Chris Ball wrote:
> > Here's a sample disassembly of one function on ARM with gcc-4.6.0, and
> > diff -y. Explicit memset (which calls __memzero) on the left, and {0}
> > initializer (which calls memset) on the right:
>
> (I checked on x86_64 too, and the code's identical -- it's inlined into
> a "rep stos %eax,%es:(%rdi)" either way.)
Glad to know that gcc is not as dumb as it used to be.
Nicolas
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2011-04-15 22:37 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-14 3:57 [PATCH 1/3] mmc: initialize struct mmc_command at declaration time Chris Ball
2011-04-14 4:07 ` [PATCHv2 " Chris Ball
2011-04-14 23:37 ` [PATCH " Nicolas Pitre
2011-04-15 3:11 ` Chris Ball
2011-04-15 18:06 ` Chris Ball
2011-04-15 22:37 ` Nicolas Pitre
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).