Skip to content

Commit

Permalink
mmc: initialize struct mmc_data at declaration time
Browse files Browse the repository at this point in the history
Converts from:
	struct mmc_data data;
	memset(&data, 0, sizeof(struct mmc_data));

to:
	struct mmc_data data = {0};

because it's shorter, as performant, and easier to work out whether
initialization has happened.

Signed-off-by: Chris Ball <[email protected]>
  • Loading branch information
cjb committed May 25, 2011
1 parent 1278dba commit a61ad2b
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 21 deletions.
4 changes: 1 addition & 3 deletions drivers/mmc/card/block.c
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ static u32 mmc_sd_num_wr_blocks(struct mmc_card *card)

struct mmc_request mrq;
struct mmc_command cmd = {0};
struct mmc_data data;
struct mmc_data data = {0};
unsigned int timeout_us;

struct scatterlist sg;
Expand All @@ -282,8 +282,6 @@ static u32 mmc_sd_num_wr_blocks(struct mmc_card *card)
cmd.arg = 0;
cmd.flags = MMC_RSP_SPI_R1 | MMC_RSP_R1 | MMC_CMD_ADTC;

memset(&data, 0, sizeof(struct mmc_data));

data.timeout_ns = card->csd.tacc_ns * 100;
data.timeout_clks = card->csd.tacc_clks * 100;

Expand Down
9 changes: 3 additions & 6 deletions drivers/mmc/card/mmc_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -249,12 +249,11 @@ static int mmc_test_buffer_transfer(struct mmc_test_card *test,
struct mmc_request mrq;
struct mmc_command cmd = {0};
struct mmc_command stop = {0};
struct mmc_data data;
struct mmc_data data = {0};

struct scatterlist sg;

memset(&mrq, 0, sizeof(struct mmc_request));
memset(&data, 0, sizeof(struct mmc_data));

mrq.cmd = &cmd;
mrq.data = &data;
Expand Down Expand Up @@ -732,10 +731,9 @@ static int mmc_test_simple_transfer(struct mmc_test_card *test,
struct mmc_request mrq;
struct mmc_command cmd = {0};
struct mmc_command stop = {0};
struct mmc_data data;
struct mmc_data data = {0};

memset(&mrq, 0, sizeof(struct mmc_request));
memset(&data, 0, sizeof(struct mmc_data));

mrq.cmd = &cmd;
mrq.data = &data;
Expand All @@ -760,12 +758,11 @@ static int mmc_test_broken_transfer(struct mmc_test_card *test,
struct mmc_request mrq;
struct mmc_command cmd = {0};
struct mmc_command stop = {0};
struct mmc_data data;
struct mmc_data data = {0};

struct scatterlist sg;

memset(&mrq, 0, sizeof(struct mmc_request));
memset(&data, 0, sizeof(struct mmc_data));

mrq.cmd = &cmd;
mrq.data = &data;
Expand Down
6 changes: 2 additions & 4 deletions drivers/mmc/core/mmc_ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ mmc_send_cxd_data(struct mmc_card *card, struct mmc_host *host,
{
struct mmc_request mrq;
struct mmc_command cmd = {0};
struct mmc_data data;
struct mmc_data data = {0};
struct scatterlist sg;
void *data_buf;

Expand All @@ -247,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(&data, 0, sizeof(struct mmc_data));

mrq.cmd = &cmd;
mrq.data = &data;
Expand Down Expand Up @@ -459,7 +458,7 @@ mmc_send_bus_test(struct mmc_card *card, struct mmc_host *host, u8 opcode,
{
struct mmc_request mrq;
struct mmc_command cmd = {0};
struct mmc_data data;
struct mmc_data data = {0};
struct scatterlist sg;
u8 *data_buf;
u8 *test_buf;
Expand Down Expand Up @@ -489,7 +488,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(&data, 0, sizeof(struct mmc_data));

mrq.cmd = &cmd;
mrq.data = &data;
Expand Down
9 changes: 3 additions & 6 deletions drivers/mmc/core/sd_ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ int mmc_app_send_scr(struct mmc_card *card, u32 *scr)
int err;
struct mmc_request mrq;
struct mmc_command cmd = {0};
struct mmc_data data;
struct mmc_data data = {0};
struct scatterlist sg;
void *data_buf;

Expand All @@ -267,7 +267,6 @@ int mmc_app_send_scr(struct mmc_card *card, u32 *scr)
return -ENOMEM;

memset(&mrq, 0, sizeof(struct mmc_request));
memset(&data, 0, sizeof(struct mmc_data));

mrq.cmd = &cmd;
mrq.data = &data;
Expand Down Expand Up @@ -307,7 +306,7 @@ int mmc_sd_switch(struct mmc_card *card, int mode, int group,
{
struct mmc_request mrq;
struct mmc_command cmd = {0};
struct mmc_data data;
struct mmc_data data = {0};
struct scatterlist sg;

BUG_ON(!card);
Expand All @@ -319,7 +318,6 @@ int mmc_sd_switch(struct mmc_card *card, int mode, int group,
value &= 0xF;

memset(&mrq, 0, sizeof(struct mmc_request));
memset(&data, 0, sizeof(struct mmc_data));

mrq.cmd = &cmd;
mrq.data = &data;
Expand Down Expand Up @@ -355,7 +353,7 @@ int mmc_app_sd_status(struct mmc_card *card, void *ssr)
int err;
struct mmc_request mrq;
struct mmc_command cmd = {0};
struct mmc_data data;
struct mmc_data data = {0};
struct scatterlist sg;

BUG_ON(!card);
Expand All @@ -369,7 +367,6 @@ int mmc_app_sd_status(struct mmc_card *card, void *ssr)
return err;

memset(&mrq, 0, sizeof(struct mmc_request));
memset(&data, 0, sizeof(struct mmc_data));

mrq.cmd = &cmd;
mrq.data = &data;
Expand Down
3 changes: 1 addition & 2 deletions drivers/mmc/core/sdio_ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ int mmc_io_rw_extended(struct mmc_card *card, int write, unsigned fn,
{
struct mmc_request mrq;
struct mmc_command cmd = {0};
struct mmc_data data;
struct mmc_data data = {0};
struct scatterlist sg;

BUG_ON(!card);
Expand All @@ -137,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(&data, 0, sizeof(struct mmc_data));

mrq.cmd = &cmd;
mrq.data = &data;
Expand Down

0 comments on commit a61ad2b

Please sign in to comment.