Commit 24f5b53b authored by Chris Ball's avatar Chris Ball

mmc: initialize struct mmc_request at declaration time

Converts from:
	struct mmc_request mrq;
	memset(&mrq, 0, sizeof(struct mmc_request));

to:
	struct mmc_request mrq = {0};

because it's shorter, as performant, and easier to work out whether
initialization has happened.
Signed-off-by: default avatarChris Ball <cjb@laptop.org>
parent a61ad2b4
...@@ -259,7 +259,7 @@ static u32 mmc_sd_num_wr_blocks(struct mmc_card *card) ...@@ -259,7 +259,7 @@ static u32 mmc_sd_num_wr_blocks(struct mmc_card *card)
u32 result; u32 result;
__be32 *blocks; __be32 *blocks;
struct mmc_request mrq; struct mmc_request mrq = {0};
struct mmc_command cmd = {0}; struct mmc_command cmd = {0};
struct mmc_data data = {0}; struct mmc_data data = {0};
unsigned int timeout_us; unsigned int timeout_us;
...@@ -300,8 +300,6 @@ static u32 mmc_sd_num_wr_blocks(struct mmc_card *card) ...@@ -300,8 +300,6 @@ static u32 mmc_sd_num_wr_blocks(struct mmc_card *card)
data.sg = &sg; data.sg = &sg;
data.sg_len = 1; data.sg_len = 1;
memset(&mrq, 0, sizeof(struct mmc_request));
mrq.cmd = &cmd; mrq.cmd = &cmd;
mrq.data = &data; mrq.data = &data;
......
...@@ -246,15 +246,13 @@ static int mmc_test_buffer_transfer(struct mmc_test_card *test, ...@@ -246,15 +246,13 @@ static int mmc_test_buffer_transfer(struct mmc_test_card *test,
{ {
int ret; int ret;
struct mmc_request mrq; struct mmc_request mrq = {0};
struct mmc_command cmd = {0}; struct mmc_command cmd = {0};
struct mmc_command stop = {0}; struct mmc_command stop = {0};
struct mmc_data data = {0}; struct mmc_data data = {0};
struct scatterlist sg; struct scatterlist sg;
memset(&mrq, 0, sizeof(struct mmc_request));
mrq.cmd = &cmd; mrq.cmd = &cmd;
mrq.data = &data; mrq.data = &data;
mrq.stop = &stop; mrq.stop = &stop;
...@@ -728,13 +726,11 @@ static int mmc_test_simple_transfer(struct mmc_test_card *test, ...@@ -728,13 +726,11 @@ static int mmc_test_simple_transfer(struct mmc_test_card *test,
struct scatterlist *sg, unsigned sg_len, unsigned dev_addr, struct scatterlist *sg, unsigned sg_len, unsigned dev_addr,
unsigned blocks, unsigned blksz, int write) unsigned blocks, unsigned blksz, int write)
{ {
struct mmc_request mrq; struct mmc_request mrq = {0};
struct mmc_command cmd = {0}; struct mmc_command cmd = {0};
struct mmc_command stop = {0}; struct mmc_command stop = {0};
struct mmc_data data = {0}; struct mmc_data data = {0};
memset(&mrq, 0, sizeof(struct mmc_request));
mrq.cmd = &cmd; mrq.cmd = &cmd;
mrq.data = &data; mrq.data = &data;
mrq.stop = &stop; mrq.stop = &stop;
...@@ -755,15 +751,13 @@ static int mmc_test_simple_transfer(struct mmc_test_card *test, ...@@ -755,15 +751,13 @@ static int mmc_test_simple_transfer(struct mmc_test_card *test,
static int mmc_test_broken_transfer(struct mmc_test_card *test, static int mmc_test_broken_transfer(struct mmc_test_card *test,
unsigned blocks, unsigned blksz, int write) unsigned blocks, unsigned blksz, int write)
{ {
struct mmc_request mrq; struct mmc_request mrq = {0};
struct mmc_command cmd = {0}; struct mmc_command cmd = {0};
struct mmc_command stop = {0}; struct mmc_command stop = {0};
struct mmc_data data = {0}; struct mmc_data data = {0};
struct scatterlist sg; struct scatterlist sg;
memset(&mrq, 0, sizeof(struct mmc_request));
mrq.cmd = &cmd; mrq.cmd = &cmd;
mrq.data = &data; mrq.data = &data;
mrq.stop = &stop; mrq.stop = &stop;
......
...@@ -236,12 +236,10 @@ EXPORT_SYMBOL(mmc_wait_for_req); ...@@ -236,12 +236,10 @@ EXPORT_SYMBOL(mmc_wait_for_req);
*/ */
int mmc_wait_for_cmd(struct mmc_host *host, struct mmc_command *cmd, int retries) int mmc_wait_for_cmd(struct mmc_host *host, struct mmc_command *cmd, int retries)
{ {
struct mmc_request mrq; struct mmc_request mrq = {0};
WARN_ON(!host->claimed); WARN_ON(!host->claimed);
memset(&mrq, 0, sizeof(struct mmc_request));
memset(cmd->resp, 0, sizeof(cmd->resp)); memset(cmd->resp, 0, sizeof(cmd->resp));
cmd->retries = retries; cmd->retries = retries;
......
...@@ -233,7 +233,7 @@ static int ...@@ -233,7 +233,7 @@ static int
mmc_send_cxd_data(struct mmc_card *card, struct mmc_host *host, mmc_send_cxd_data(struct mmc_card *card, struct mmc_host *host,
u32 opcode, void *buf, unsigned len) u32 opcode, void *buf, unsigned len)
{ {
struct mmc_request mrq; struct mmc_request mrq = {0};
struct mmc_command cmd = {0}; struct mmc_command cmd = {0};
struct mmc_data data = {0}; struct mmc_data data = {0};
struct scatterlist sg; struct scatterlist sg;
...@@ -246,8 +246,6 @@ mmc_send_cxd_data(struct mmc_card *card, struct mmc_host *host, ...@@ -246,8 +246,6 @@ mmc_send_cxd_data(struct mmc_card *card, struct mmc_host *host,
if (data_buf == NULL) if (data_buf == NULL)
return -ENOMEM; return -ENOMEM;
memset(&mrq, 0, sizeof(struct mmc_request));
mrq.cmd = &cmd; mrq.cmd = &cmd;
mrq.data = &data; mrq.data = &data;
...@@ -456,7 +454,7 @@ static int ...@@ -456,7 +454,7 @@ static int
mmc_send_bus_test(struct mmc_card *card, struct mmc_host *host, u8 opcode, mmc_send_bus_test(struct mmc_card *card, struct mmc_host *host, u8 opcode,
u8 len) u8 len)
{ {
struct mmc_request mrq; struct mmc_request mrq = {0};
struct mmc_command cmd = {0}; struct mmc_command cmd = {0};
struct mmc_data data = {0}; struct mmc_data data = {0};
struct scatterlist sg; struct scatterlist sg;
...@@ -487,8 +485,6 @@ mmc_send_bus_test(struct mmc_card *card, struct mmc_host *host, u8 opcode, ...@@ -487,8 +485,6 @@ mmc_send_bus_test(struct mmc_card *card, struct mmc_host *host, u8 opcode,
if (opcode == MMC_BUS_TEST_W) if (opcode == MMC_BUS_TEST_W)
memcpy(data_buf, test_buf, len); memcpy(data_buf, test_buf, len);
memset(&mrq, 0, sizeof(struct mmc_request));
mrq.cmd = &cmd; mrq.cmd = &cmd;
mrq.data = &data; mrq.data = &data;
cmd.opcode = opcode; cmd.opcode = opcode;
......
...@@ -66,7 +66,7 @@ static int mmc_app_cmd(struct mmc_host *host, struct mmc_card *card) ...@@ -66,7 +66,7 @@ static int mmc_app_cmd(struct mmc_host *host, struct mmc_card *card)
int mmc_wait_for_app_cmd(struct mmc_host *host, struct mmc_card *card, int mmc_wait_for_app_cmd(struct mmc_host *host, struct mmc_card *card,
struct mmc_command *cmd, int retries) struct mmc_command *cmd, int retries)
{ {
struct mmc_request mrq; struct mmc_request mrq = {0};
int i, err; int i, err;
...@@ -243,7 +243,7 @@ int mmc_send_relative_addr(struct mmc_host *host, unsigned int *rca) ...@@ -243,7 +243,7 @@ int mmc_send_relative_addr(struct mmc_host *host, unsigned int *rca)
int mmc_app_send_scr(struct mmc_card *card, u32 *scr) int mmc_app_send_scr(struct mmc_card *card, u32 *scr)
{ {
int err; int err;
struct mmc_request mrq; struct mmc_request mrq = {0};
struct mmc_command cmd = {0}; struct mmc_command cmd = {0};
struct mmc_data data = {0}; struct mmc_data data = {0};
struct scatterlist sg; struct scatterlist sg;
...@@ -266,8 +266,6 @@ int mmc_app_send_scr(struct mmc_card *card, u32 *scr) ...@@ -266,8 +266,6 @@ int mmc_app_send_scr(struct mmc_card *card, u32 *scr)
if (data_buf == NULL) if (data_buf == NULL)
return -ENOMEM; return -ENOMEM;
memset(&mrq, 0, sizeof(struct mmc_request));
mrq.cmd = &cmd; mrq.cmd = &cmd;
mrq.data = &data; mrq.data = &data;
...@@ -304,7 +302,7 @@ int mmc_app_send_scr(struct mmc_card *card, u32 *scr) ...@@ -304,7 +302,7 @@ int mmc_app_send_scr(struct mmc_card *card, u32 *scr)
int mmc_sd_switch(struct mmc_card *card, int mode, int group, int mmc_sd_switch(struct mmc_card *card, int mode, int group,
u8 value, u8 *resp) u8 value, u8 *resp)
{ {
struct mmc_request mrq; struct mmc_request mrq = {0};
struct mmc_command cmd = {0}; struct mmc_command cmd = {0};
struct mmc_data data = {0}; struct mmc_data data = {0};
struct scatterlist sg; struct scatterlist sg;
...@@ -317,8 +315,6 @@ int mmc_sd_switch(struct mmc_card *card, int mode, int group, ...@@ -317,8 +315,6 @@ int mmc_sd_switch(struct mmc_card *card, int mode, int group,
mode = !!mode; mode = !!mode;
value &= 0xF; value &= 0xF;
memset(&mrq, 0, sizeof(struct mmc_request));
mrq.cmd = &cmd; mrq.cmd = &cmd;
mrq.data = &data; mrq.data = &data;
...@@ -351,7 +347,7 @@ int mmc_sd_switch(struct mmc_card *card, int mode, int group, ...@@ -351,7 +347,7 @@ int mmc_sd_switch(struct mmc_card *card, int mode, int group,
int mmc_app_sd_status(struct mmc_card *card, void *ssr) int mmc_app_sd_status(struct mmc_card *card, void *ssr)
{ {
int err; int err;
struct mmc_request mrq; struct mmc_request mrq = {0};
struct mmc_command cmd = {0}; struct mmc_command cmd = {0};
struct mmc_data data = {0}; struct mmc_data data = {0};
struct scatterlist sg; struct scatterlist sg;
...@@ -366,8 +362,6 @@ int mmc_app_sd_status(struct mmc_card *card, void *ssr) ...@@ -366,8 +362,6 @@ int mmc_app_sd_status(struct mmc_card *card, void *ssr)
if (err) if (err)
return err; return err;
memset(&mrq, 0, sizeof(struct mmc_request));
mrq.cmd = &cmd; mrq.cmd = &cmd;
mrq.data = &data; mrq.data = &data;
......
...@@ -121,7 +121,7 @@ int mmc_io_rw_direct(struct mmc_card *card, int write, unsigned fn, ...@@ -121,7 +121,7 @@ int mmc_io_rw_direct(struct mmc_card *card, int write, unsigned fn,
int mmc_io_rw_extended(struct mmc_card *card, int write, unsigned fn, int mmc_io_rw_extended(struct mmc_card *card, int write, unsigned fn,
unsigned addr, int incr_addr, u8 *buf, unsigned blocks, unsigned blksz) unsigned addr, int incr_addr, u8 *buf, unsigned blocks, unsigned blksz)
{ {
struct mmc_request mrq; struct mmc_request mrq = {0};
struct mmc_command cmd = {0}; struct mmc_command cmd = {0};
struct mmc_data data = {0}; struct mmc_data data = {0};
struct scatterlist sg; struct scatterlist sg;
...@@ -136,8 +136,6 @@ int mmc_io_rw_extended(struct mmc_card *card, int write, unsigned fn, ...@@ -136,8 +136,6 @@ int mmc_io_rw_extended(struct mmc_card *card, int write, unsigned fn,
if (addr & ~0x1FFFF) if (addr & ~0x1FFFF)
return -EINVAL; return -EINVAL;
memset(&mrq, 0, sizeof(struct mmc_request));
mrq.cmd = &cmd; mrq.cmd = &cmd;
mrq.data = &data; mrq.data = &data;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment