aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mmc/core
diff options
context:
space:
mode:
authorChris Ball <cjb@laptop.org>2011-04-13 23:40:30 -0400
committerChris Ball <cjb@laptop.org>2011-05-24 21:01:52 -0400
commit1278dba167f01bb3c6626d16450d31129d041087 (patch)
tree6fb3af716e5437cb558ae37fd8a58db23b9b173e /drivers/mmc/core
parent62929e4be3fe4cc632b3b03645e083c6548de531 (diff)
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/core')
-rw-r--r--drivers/mmc/core/core.c6
-rw-r--r--drivers/mmc/core/mmc_ops.c50
-rw-r--r--drivers/mmc/core/sd_ops.c29
-rw-r--r--drivers/mmc/core/sdio_ops.c11
4 files changed, 26 insertions, 70 deletions
diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index 5178d5daa5f..f273ffd6557 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,
1286static int mmc_do_erase(struct mmc_card *card, unsigned int from, 1286static int mmc_do_erase(struct mmc_card *card, unsigned int from,
1287 unsigned int to, unsigned int arg) 1287 unsigned int to, unsigned int arg)
1288{ 1288{
1289 struct mmc_command cmd; 1289 struct mmc_command cmd = {0};
1290 unsigned int qty = 0; 1290 unsigned int qty = 0;
1291 int err; 1291 int err;
1292 1292
@@ -1320,7 +1320,6 @@ static int mmc_do_erase(struct mmc_card *card, unsigned int from,
1320 to <<= 9; 1320 to <<= 9;
1321 } 1321 }
1322 1322
1323 memset(&cmd, 0, sizeof(struct mmc_command));
1324 if (mmc_card_sd(card)) 1323 if (mmc_card_sd(card))
1325 cmd.opcode = SD_ERASE_WR_BLK_START; 1324 cmd.opcode = SD_ERASE_WR_BLK_START;
1326 else 1325 else
@@ -1490,12 +1489,11 @@ EXPORT_SYMBOL(mmc_erase_group_aligned);
1490 1489
1491int mmc_set_blocklen(struct mmc_card *card, unsigned int blocklen) 1490int mmc_set_blocklen(struct mmc_card *card, unsigned int blocklen)
1492{ 1491{
1493 struct mmc_command cmd; 1492 struct mmc_command cmd = {0};
1494 1493
1495 if (mmc_card_blockaddr(card) || mmc_card_ddr_mode(card)) 1494 if (mmc_card_blockaddr(card) || mmc_card_ddr_mode(card))
1496 return 0; 1495 return 0;
1497 1496
1498 memset(&cmd, 0, sizeof(struct mmc_command));
1499 cmd.opcode = MMC_SET_BLOCKLEN; 1497 cmd.opcode = MMC_SET_BLOCKLEN;
1500 cmd.arg = blocklen; 1498 cmd.arg = blocklen;
1501 cmd.flags = MMC_RSP_SPI_R1 | MMC_RSP_R1 | MMC_CMD_AC; 1499 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 a2bae625332..de4e1855b8e 100644
--- a/drivers/mmc/core/mmc_ops.c
+++ b/drivers/mmc/core/mmc_ops.c
@@ -23,12 +23,10 @@
23static int _mmc_select_card(struct mmc_host *host, struct mmc_card *card) 23static int _mmc_select_card(struct mmc_host *host, struct mmc_card *card)
24{ 24{
25 int err; 25 int err;
26 struct mmc_command cmd; 26 struct mmc_command cmd = {0};
27 27
28 BUG_ON(!host); 28 BUG_ON(!host);
29 29
30 memset(&cmd, 0, sizeof(struct mmc_command));
31
32 cmd.opcode = MMC_SELECT_CARD; 30 cmd.opcode = MMC_SELECT_CARD;
33 31
34 if (card) { 32 if (card) {
@@ -60,15 +58,13 @@ int mmc_deselect_cards(struct mmc_host *host)
60 58
61int mmc_card_sleepawake(struct mmc_host *host, int sleep) 59int mmc_card_sleepawake(struct mmc_host *host, int sleep)
62{ 60{
63 struct mmc_command cmd; 61 struct mmc_command cmd = {0};
64 struct mmc_card *card = host->card; 62 struct mmc_card *card = host->card;
65 int err; 63 int err;
66 64
67 if (sleep) 65 if (sleep)
68 mmc_deselect_cards(host); 66 mmc_deselect_cards(host);
69 67
70 memset(&cmd, 0, sizeof(struct mmc_command));
71
72 cmd.opcode = MMC_SLEEP_AWAKE; 68 cmd.opcode = MMC_SLEEP_AWAKE;
73 cmd.arg = card->rca << 16; 69 cmd.arg = card->rca << 16;
74 if (sleep) 70 if (sleep)
@@ -97,7 +93,7 @@ int mmc_card_sleepawake(struct mmc_host *host, int sleep)
97int mmc_go_idle(struct mmc_host *host) 93int mmc_go_idle(struct mmc_host *host)
98{ 94{
99 int err; 95 int err;
100 struct mmc_command cmd; 96 struct mmc_command cmd = {0};
101 97
102 /* 98 /*
103 * Non-SPI hosts need to prevent chipselect going active during 99 * Non-SPI hosts need to prevent chipselect going active during
@@ -113,8 +109,6 @@ int mmc_go_idle(struct mmc_host *host)
113 mmc_delay(1); 109 mmc_delay(1);
114 } 110 }
115 111
116 memset(&cmd, 0, sizeof(struct mmc_command));
117
118 cmd.opcode = MMC_GO_IDLE_STATE; 112 cmd.opcode = MMC_GO_IDLE_STATE;
119 cmd.arg = 0; 113 cmd.arg = 0;
120 cmd.flags = MMC_RSP_SPI_R1 | MMC_RSP_NONE | MMC_CMD_BC; 114 cmd.flags = MMC_RSP_SPI_R1 | MMC_RSP_NONE | MMC_CMD_BC;
@@ -135,13 +129,11 @@ int mmc_go_idle(struct mmc_host *host)
135 129
136int mmc_send_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr) 130int mmc_send_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr)
137{ 131{
138 struct mmc_command cmd; 132 struct mmc_command cmd = {0};
139 int i, err = 0; 133 int i, err = 0;
140 134
141 BUG_ON(!host); 135 BUG_ON(!host);
142 136
143 memset(&cmd, 0, sizeof(struct mmc_command));
144
145 cmd.opcode = MMC_SEND_OP_COND; 137 cmd.opcode = MMC_SEND_OP_COND;
146 cmd.arg = mmc_host_is_spi(host) ? 0 : ocr; 138 cmd.arg = mmc_host_is_spi(host) ? 0 : ocr;
147 cmd.flags = MMC_RSP_SPI_R1 | MMC_RSP_R3 | MMC_CMD_BCR; 139 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)
178int mmc_all_send_cid(struct mmc_host *host, u32 *cid) 170int mmc_all_send_cid(struct mmc_host *host, u32 *cid)
179{ 171{
180 int err; 172 int err;
181 struct mmc_command cmd; 173 struct mmc_command cmd = {0};
182 174
183 BUG_ON(!host); 175 BUG_ON(!host);
184 BUG_ON(!cid); 176 BUG_ON(!cid);
185 177
186 memset(&cmd, 0, sizeof(struct mmc_command));
187
188 cmd.opcode = MMC_ALL_SEND_CID; 178 cmd.opcode = MMC_ALL_SEND_CID;
189 cmd.arg = 0; 179 cmd.arg = 0;
190 cmd.flags = MMC_RSP_R2 | MMC_CMD_BCR; 180 cmd.flags = MMC_RSP_R2 | MMC_CMD_BCR;
@@ -201,13 +191,11 @@ int mmc_all_send_cid(struct mmc_host *host, u32 *cid)
201int mmc_set_relative_addr(struct mmc_card *card) 191int mmc_set_relative_addr(struct mmc_card *card)
202{ 192{
203 int err; 193 int err;
204 struct mmc_command cmd; 194 struct mmc_command cmd = {0};
205 195
206 BUG_ON(!card); 196 BUG_ON(!card);
207 BUG_ON(!card->host); 197 BUG_ON(!card->host);
208 198
209 memset(&cmd, 0, sizeof(struct mmc_command));
210
211 cmd.opcode = MMC_SET_RELATIVE_ADDR; 199 cmd.opcode = MMC_SET_RELATIVE_ADDR;
212 cmd.arg = card->rca << 16; 200 cmd.arg = card->rca << 16;
213 cmd.flags = MMC_RSP_R1 | MMC_CMD_AC; 201 cmd.flags = MMC_RSP_R1 | MMC_CMD_AC;
@@ -223,13 +211,11 @@ static int
223mmc_send_cxd_native(struct mmc_host *host, u32 arg, u32 *cxd, int opcode) 211mmc_send_cxd_native(struct mmc_host *host, u32 arg, u32 *cxd, int opcode)
224{ 212{
225 int err; 213 int err;
226 struct mmc_command cmd; 214 struct mmc_command cmd = {0};
227 215
228 BUG_ON(!host); 216 BUG_ON(!host);
229 BUG_ON(!cxd); 217 BUG_ON(!cxd);
230 218
231 memset(&cmd, 0, sizeof(struct mmc_command));
232
233 cmd.opcode = opcode; 219 cmd.opcode = opcode;
234 cmd.arg = arg; 220 cmd.arg = arg;
235 cmd.flags = MMC_RSP_R2 | MMC_CMD_AC; 221 cmd.flags = MMC_RSP_R2 | MMC_CMD_AC;
@@ -248,7 +234,7 @@ mmc_send_cxd_data(struct mmc_card *card, struct mmc_host *host,
248 u32 opcode, void *buf, unsigned len) 234 u32 opcode, void *buf, unsigned len)
249{ 235{
250 struct mmc_request mrq; 236 struct mmc_request mrq;
251 struct mmc_command cmd; 237 struct mmc_command cmd = {0};
252 struct mmc_data data; 238 struct mmc_data data;
253 struct scatterlist sg; 239 struct scatterlist sg;
254 void *data_buf; 240 void *data_buf;
@@ -261,7 +247,6 @@ mmc_send_cxd_data(struct mmc_card *card, struct mmc_host *host,
261 return -ENOMEM; 247 return -ENOMEM;
262 248
263 memset(&mrq, 0, sizeof(struct mmc_request)); 249 memset(&mrq, 0, sizeof(struct mmc_request));
264 memset(&cmd, 0, sizeof(struct mmc_command));
265 memset(&data, 0, sizeof(struct mmc_data)); 250 memset(&data, 0, sizeof(struct mmc_data));
266 251
267 mrq.cmd = &cmd; 252 mrq.cmd = &cmd;
@@ -355,11 +340,9 @@ int mmc_send_ext_csd(struct mmc_card *card, u8 *ext_csd)
355 340
356int mmc_spi_read_ocr(struct mmc_host *host, int highcap, u32 *ocrp) 341int mmc_spi_read_ocr(struct mmc_host *host, int highcap, u32 *ocrp)
357{ 342{
358 struct mmc_command cmd; 343 struct mmc_command cmd = {0};
359 int err; 344 int err;
360 345
361 memset(&cmd, 0, sizeof(struct mmc_command));
362
363 cmd.opcode = MMC_SPI_READ_OCR; 346 cmd.opcode = MMC_SPI_READ_OCR;
364 cmd.arg = highcap ? (1 << 30) : 0; 347 cmd.arg = highcap ? (1 << 30) : 0;
365 cmd.flags = MMC_RSP_SPI_R3; 348 cmd.flags = MMC_RSP_SPI_R3;
@@ -372,11 +355,9 @@ int mmc_spi_read_ocr(struct mmc_host *host, int highcap, u32 *ocrp)
372 355
373int mmc_spi_set_crc(struct mmc_host *host, int use_crc) 356int mmc_spi_set_crc(struct mmc_host *host, int use_crc)
374{ 357{
375 struct mmc_command cmd; 358 struct mmc_command cmd = {0};
376 int err; 359 int err;
377 360
378 memset(&cmd, 0, sizeof(struct mmc_command));
379
380 cmd.opcode = MMC_SPI_CRC_ON_OFF; 361 cmd.opcode = MMC_SPI_CRC_ON_OFF;
381 cmd.flags = MMC_RSP_SPI_R1; 362 cmd.flags = MMC_RSP_SPI_R1;
382 cmd.arg = use_crc; 363 cmd.arg = use_crc;
@@ -402,14 +383,12 @@ int mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value,
402 unsigned int timeout_ms) 383 unsigned int timeout_ms)
403{ 384{
404 int err; 385 int err;
405 struct mmc_command cmd; 386 struct mmc_command cmd = {0};
406 u32 status; 387 u32 status;
407 388
408 BUG_ON(!card); 389 BUG_ON(!card);
409 BUG_ON(!card->host); 390 BUG_ON(!card->host);
410 391
411 memset(&cmd, 0, sizeof(struct mmc_command));
412
413 cmd.opcode = MMC_SWITCH; 392 cmd.opcode = MMC_SWITCH;
414 cmd.arg = (MMC_SWITCH_MODE_WRITE_BYTE << 24) | 393 cmd.arg = (MMC_SWITCH_MODE_WRITE_BYTE << 24) |
415 (index << 16) | 394 (index << 16) |
@@ -451,13 +430,11 @@ EXPORT_SYMBOL_GPL(mmc_switch);
451int mmc_send_status(struct mmc_card *card, u32 *status) 430int mmc_send_status(struct mmc_card *card, u32 *status)
452{ 431{
453 int err; 432 int err;
454 struct mmc_command cmd; 433 struct mmc_command cmd = {0};
455 434
456 BUG_ON(!card); 435 BUG_ON(!card);
457 BUG_ON(!card->host); 436 BUG_ON(!card->host);
458 437
459 memset(&cmd, 0, sizeof(struct mmc_command));
460
461 cmd.opcode = MMC_SEND_STATUS; 438 cmd.opcode = MMC_SEND_STATUS;
462 if (!mmc_host_is_spi(card->host)) 439 if (!mmc_host_is_spi(card->host))
463 cmd.arg = card->rca << 16; 440 cmd.arg = card->rca << 16;
@@ -481,7 +458,7 @@ mmc_send_bus_test(struct mmc_card *card, struct mmc_host *host, u8 opcode,
481 u8 len) 458 u8 len)
482{ 459{
483 struct mmc_request mrq; 460 struct mmc_request mrq;
484 struct mmc_command cmd; 461 struct mmc_command cmd = {0};
485 struct mmc_data data; 462 struct mmc_data data;
486 struct scatterlist sg; 463 struct scatterlist sg;
487 u8 *data_buf; 464 u8 *data_buf;
@@ -512,7 +489,6 @@ mmc_send_bus_test(struct mmc_card *card, struct mmc_host *host, u8 opcode,
512 memcpy(data_buf, test_buf, len); 489 memcpy(data_buf, test_buf, len);
513 490
514 memset(&mrq, 0, sizeof(struct mmc_request)); 491 memset(&mrq, 0, sizeof(struct mmc_request));
515 memset(&cmd, 0, sizeof(struct mmc_command));
516 memset(&data, 0, sizeof(struct mmc_data)); 492 memset(&data, 0, sizeof(struct mmc_data));
517 493
518 mrq.cmd = &cmd; 494 mrq.cmd = &cmd;
diff --git a/drivers/mmc/core/sd_ops.c b/drivers/mmc/core/sd_ops.c
index da508497a6e..dfe9a9c3f95 100644
--- a/drivers/mmc/core/sd_ops.c
+++ b/drivers/mmc/core/sd_ops.c
@@ -24,13 +24,11 @@
24static int mmc_app_cmd(struct mmc_host *host, struct mmc_card *card) 24static int mmc_app_cmd(struct mmc_host *host, struct mmc_card *card)
25{ 25{
26 int err; 26 int err;
27 struct mmc_command cmd; 27 struct mmc_command cmd = {0};
28 28
29 BUG_ON(!host); 29 BUG_ON(!host);
30 BUG_ON(card && (card->host != host)); 30 BUG_ON(card && (card->host != host));
31 31
32 memset(&cmd, 0, sizeof(struct mmc_command));
33
34 cmd.opcode = MMC_APP_CMD; 32 cmd.opcode = MMC_APP_CMD;
35 33
36 if (card) { 34 if (card) {
@@ -121,13 +119,11 @@ EXPORT_SYMBOL(mmc_wait_for_app_cmd);
121int mmc_app_set_bus_width(struct mmc_card *card, int width) 119int mmc_app_set_bus_width(struct mmc_card *card, int width)
122{ 120{
123 int err; 121 int err;
124 struct mmc_command cmd; 122 struct mmc_command cmd = {0};
125 123
126 BUG_ON(!card); 124 BUG_ON(!card);
127 BUG_ON(!card->host); 125 BUG_ON(!card->host);
128 126
129 memset(&cmd, 0, sizeof(struct mmc_command));
130
131 cmd.opcode = SD_APP_SET_BUS_WIDTH; 127 cmd.opcode = SD_APP_SET_BUS_WIDTH;
132 cmd.flags = MMC_RSP_R1 | MMC_CMD_AC; 128 cmd.flags = MMC_RSP_R1 | MMC_CMD_AC;
133 129
@@ -151,13 +147,11 @@ int mmc_app_set_bus_width(struct mmc_card *card, int width)
151 147
152int mmc_send_app_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr) 148int mmc_send_app_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr)
153{ 149{
154 struct mmc_command cmd; 150 struct mmc_command cmd = {0};
155 int i, err = 0; 151 int i, err = 0;
156 152
157 BUG_ON(!host); 153 BUG_ON(!host);
158 154
159 memset(&cmd, 0, sizeof(struct mmc_command));
160
161 cmd.opcode = SD_APP_OP_COND; 155 cmd.opcode = SD_APP_OP_COND;
162 if (mmc_host_is_spi(host)) 156 if (mmc_host_is_spi(host))
163 cmd.arg = ocr & (1 << 30); /* SPI only defines one bit */ 157 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)
196 190
197int mmc_send_if_cond(struct mmc_host *host, u32 ocr) 191int mmc_send_if_cond(struct mmc_host *host, u32 ocr)
198{ 192{
199 struct mmc_command cmd; 193 struct mmc_command cmd = {0};
200 int err; 194 int err;
201 static const u8 test_pattern = 0xAA; 195 static const u8 test_pattern = 0xAA;
202 u8 result_pattern; 196 u8 result_pattern;
203 197
204 memset(&cmd, 0, sizeof(struct mmc_command));
205
206 /* 198 /*
207 * To support SD 2.0 cards, we must always invoke SD_SEND_IF_COND 199 * To support SD 2.0 cards, we must always invoke SD_SEND_IF_COND
208 * before SD_APP_OP_COND. This command will harmlessly fail for 200 * 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)
230int mmc_send_relative_addr(struct mmc_host *host, unsigned int *rca) 222int mmc_send_relative_addr(struct mmc_host *host, unsigned int *rca)
231{ 223{
232 int err; 224 int err;
233 struct mmc_command cmd; 225 struct mmc_command cmd = {0};
234 226
235 BUG_ON(!host); 227 BUG_ON(!host);
236 BUG_ON(!rca); 228 BUG_ON(!rca);
237 229
238 memset(&cmd, 0, sizeof(struct mmc_command));
239
240 cmd.opcode = SD_SEND_RELATIVE_ADDR; 230 cmd.opcode = SD_SEND_RELATIVE_ADDR;
241 cmd.arg = 0; 231 cmd.arg = 0;
242 cmd.flags = MMC_RSP_R6 | MMC_CMD_BCR; 232 cmd.flags = MMC_RSP_R6 | MMC_CMD_BCR;
@@ -254,7 +244,7 @@ int mmc_app_send_scr(struct mmc_card *card, u32 *scr)
254{ 244{
255 int err; 245 int err;
256 struct mmc_request mrq; 246 struct mmc_request mrq;
257 struct mmc_command cmd; 247 struct mmc_command cmd = {0};
258 struct mmc_data data; 248 struct mmc_data data;
259 struct scatterlist sg; 249 struct scatterlist sg;
260 void *data_buf; 250 void *data_buf;
@@ -277,7 +267,6 @@ int mmc_app_send_scr(struct mmc_card *card, u32 *scr)
277 return -ENOMEM; 267 return -ENOMEM;
278 268
279 memset(&mrq, 0, sizeof(struct mmc_request)); 269 memset(&mrq, 0, sizeof(struct mmc_request));
280 memset(&cmd, 0, sizeof(struct mmc_command));
281 memset(&data, 0, sizeof(struct mmc_data)); 270 memset(&data, 0, sizeof(struct mmc_data));
282 271
283 mrq.cmd = &cmd; 272 mrq.cmd = &cmd;
@@ -317,7 +306,7 @@ int mmc_sd_switch(struct mmc_card *card, int mode, int group,
317 u8 value, u8 *resp) 306 u8 value, u8 *resp)
318{ 307{
319 struct mmc_request mrq; 308 struct mmc_request mrq;
320 struct mmc_command cmd; 309 struct mmc_command cmd = {0};
321 struct mmc_data data; 310 struct mmc_data data;
322 struct scatterlist sg; 311 struct scatterlist sg;
323 312
@@ -330,7 +319,6 @@ int mmc_sd_switch(struct mmc_card *card, int mode, int group,
330 value &= 0xF; 319 value &= 0xF;
331 320
332 memset(&mrq, 0, sizeof(struct mmc_request)); 321 memset(&mrq, 0, sizeof(struct mmc_request));
333 memset(&cmd, 0, sizeof(struct mmc_command));
334 memset(&data, 0, sizeof(struct mmc_data)); 322 memset(&data, 0, sizeof(struct mmc_data));
335 323
336 mrq.cmd = &cmd; 324 mrq.cmd = &cmd;
@@ -366,7 +354,7 @@ int mmc_app_sd_status(struct mmc_card *card, void *ssr)
366{ 354{
367 int err; 355 int err;
368 struct mmc_request mrq; 356 struct mmc_request mrq;
369 struct mmc_command cmd; 357 struct mmc_command cmd = {0};
370 struct mmc_data data; 358 struct mmc_data data;
371 struct scatterlist sg; 359 struct scatterlist sg;
372 360
@@ -381,7 +369,6 @@ int mmc_app_sd_status(struct mmc_card *card, void *ssr)
381 return err; 369 return err;
382 370
383 memset(&mrq, 0, sizeof(struct mmc_request)); 371 memset(&mrq, 0, sizeof(struct mmc_request));
384 memset(&cmd, 0, sizeof(struct mmc_command));
385 memset(&data, 0, sizeof(struct mmc_data)); 372 memset(&data, 0, sizeof(struct mmc_data));
386 373
387 mrq.cmd = &cmd; 374 mrq.cmd = &cmd;
diff --git a/drivers/mmc/core/sdio_ops.c b/drivers/mmc/core/sdio_ops.c
index dea36d9c22e..f77b1bc318e 100644
--- a/drivers/mmc/core/sdio_ops.c
+++ b/drivers/mmc/core/sdio_ops.c
@@ -21,13 +21,11 @@
21 21
22int mmc_send_io_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr) 22int mmc_send_io_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr)
23{ 23{
24 struct mmc_command cmd; 24 struct mmc_command cmd = {0};
25 int i, err = 0; 25 int i, err = 0;
26 26
27 BUG_ON(!host); 27 BUG_ON(!host);
28 28
29 memset(&cmd, 0, sizeof(struct mmc_command));
30
31 cmd.opcode = SD_IO_SEND_OP_COND; 29 cmd.opcode = SD_IO_SEND_OP_COND;
32 cmd.arg = ocr; 30 cmd.arg = ocr;
33 cmd.flags = MMC_RSP_SPI_R4 | MMC_RSP_R4 | MMC_CMD_BCR; 31 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)
70static int mmc_io_rw_direct_host(struct mmc_host *host, int write, unsigned fn, 68static int mmc_io_rw_direct_host(struct mmc_host *host, int write, unsigned fn,
71 unsigned addr, u8 in, u8 *out) 69 unsigned addr, u8 in, u8 *out)
72{ 70{
73 struct mmc_command cmd; 71 struct mmc_command cmd = {0};
74 int err; 72 int err;
75 73
76 BUG_ON(!host); 74 BUG_ON(!host);
@@ -80,8 +78,6 @@ static int mmc_io_rw_direct_host(struct mmc_host *host, int write, unsigned fn,
80 if (addr & ~0x1FFFF) 78 if (addr & ~0x1FFFF)
81 return -EINVAL; 79 return -EINVAL;
82 80
83 memset(&cmd, 0, sizeof(struct mmc_command));
84
85 cmd.opcode = SD_IO_RW_DIRECT; 81 cmd.opcode = SD_IO_RW_DIRECT;
86 cmd.arg = write ? 0x80000000 : 0x00000000; 82 cmd.arg = write ? 0x80000000 : 0x00000000;
87 cmd.arg |= fn << 28; 83 cmd.arg |= fn << 28;
@@ -126,7 +122,7 @@ int mmc_io_rw_extended(struct mmc_card *card, int write, unsigned fn,
126 unsigned addr, int incr_addr, u8 *buf, unsigned blocks, unsigned blksz) 122 unsigned addr, int incr_addr, u8 *buf, unsigned blocks, unsigned blksz)
127{ 123{
128 struct mmc_request mrq; 124 struct mmc_request mrq;
129 struct mmc_command cmd; 125 struct mmc_command cmd = {0};
130 struct mmc_data data; 126 struct mmc_data data;
131 struct scatterlist sg; 127 struct scatterlist sg;
132 128
@@ -141,7 +137,6 @@ int mmc_io_rw_extended(struct mmc_card *card, int write, unsigned fn,
141 return -EINVAL; 137 return -EINVAL;
142 138
143 memset(&mrq, 0, sizeof(struct mmc_request)); 139 memset(&mrq, 0, sizeof(struct mmc_request));
144 memset(&cmd, 0, sizeof(struct mmc_command));
145 memset(&data, 0, sizeof(struct mmc_data)); 140 memset(&data, 0, sizeof(struct mmc_data));
146 141
147 mrq.cmd = &cmd; 142 mrq.cmd = &cmd;