diff options
author | Chris Ball <cjb@laptop.org> | 2011-04-13 23:40:30 -0400 |
---|---|---|
committer | Chris Ball <cjb@laptop.org> | 2011-05-24 21:01:52 -0400 |
commit | 1278dba167f01bb3c6626d16450d31129d041087 (patch) | |
tree | 6fb3af716e5437cb558ae37fd8a58db23b9b173e /drivers/mmc/core/mmc_ops.c | |
parent | 62929e4be3fe4cc632b3b03645e083c6548de531 (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/mmc_ops.c')
-rw-r--r-- | drivers/mmc/core/mmc_ops.c | 50 |
1 files changed, 13 insertions, 37 deletions
diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c index a2bae625332a..de4e1855b8ed 100644 --- a/drivers/mmc/core/mmc_ops.c +++ b/drivers/mmc/core/mmc_ops.c | |||
@@ -23,12 +23,10 @@ | |||
23 | static int _mmc_select_card(struct mmc_host *host, struct mmc_card *card) | 23 | static 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 | ||
61 | int mmc_card_sleepawake(struct mmc_host *host, int sleep) | 59 | int 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) | |||
97 | int mmc_go_idle(struct mmc_host *host) | 93 | int 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 | ||
136 | int mmc_send_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr) | 130 | int 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) | |||
178 | int mmc_all_send_cid(struct mmc_host *host, u32 *cid) | 170 | int 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) | |||
201 | int mmc_set_relative_addr(struct mmc_card *card) | 191 | int 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 | |||
223 | mmc_send_cxd_native(struct mmc_host *host, u32 arg, u32 *cxd, int opcode) | 211 | mmc_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 | ||
356 | int mmc_spi_read_ocr(struct mmc_host *host, int highcap, u32 *ocrp) | 341 | int 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 | ||
373 | int mmc_spi_set_crc(struct mmc_host *host, int use_crc) | 356 | int 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); | |||
451 | int mmc_send_status(struct mmc_card *card, u32 *status) | 430 | int 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; |