summaryrefslogtreecommitdiffstats
path: root/drivers/mmc/card
diff options
context:
space:
mode:
authorChris Ball <cjb@laptop.org>2011-04-14 05:40:30 +0200
committerChris Ball <cjb@laptop.org>2011-05-25 03:01:52 +0200
commit1278dba167f01bb3c6626d16450d31129d041087 (patch)
tree6fb3af716e5437cb558ae37fd8a58db23b9b173e /drivers/mmc/card
parentmmc: card: Fix use of uninitialized data in mmc_blk_issue_rw_rq. (diff)
downloadlinux-1278dba167f01bb3c6626d16450d31129d041087.tar.xz
linux-1278dba167f01bb3c6626d16450d31129d041087.zip
mmc: initialize struct mmc_command at declaration time
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>
Diffstat (limited to 'drivers/mmc/card')
-rw-r--r--drivers/mmc/card/block.c13
-rw-r--r--drivers/mmc/card/mmc_test.c20
2 files changed, 11 insertions, 22 deletions
diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
index 9e30cf6db53c..93a7efcbfde9 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 abc1a63bcc5e..95c298faeb48 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;