diff options
Diffstat (limited to 'drivers/mmc/core/sd_ops.c')
-rw-r--r-- | drivers/mmc/core/sd_ops.c | 51 |
1 files changed, 17 insertions, 34 deletions
diff --git a/drivers/mmc/core/sd_ops.c b/drivers/mmc/core/sd_ops.c index 76af349c14b4..021fed153804 100644 --- a/drivers/mmc/core/sd_ops.c +++ b/drivers/mmc/core/sd_ops.c | |||
@@ -21,10 +21,10 @@ | |||
21 | #include "core.h" | 21 | #include "core.h" |
22 | #include "sd_ops.h" | 22 | #include "sd_ops.h" |
23 | 23 | ||
24 | static int mmc_app_cmd(struct mmc_host *host, struct mmc_card *card) | 24 | 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)); |
@@ -49,6 +49,7 @@ static int mmc_app_cmd(struct mmc_host *host, struct mmc_card *card) | |||
49 | 49 | ||
50 | return 0; | 50 | return 0; |
51 | } | 51 | } |
52 | EXPORT_SYMBOL_GPL(mmc_app_cmd); | ||
52 | 53 | ||
53 | /** | 54 | /** |
54 | * mmc_wait_for_app_cmd - start an application command and wait for | 55 | * mmc_wait_for_app_cmd - start an application command and wait for |
@@ -66,7 +67,7 @@ static int mmc_app_cmd(struct mmc_host *host, struct mmc_card *card) | |||
66 | int mmc_wait_for_app_cmd(struct mmc_host *host, struct mmc_card *card, | 67 | int mmc_wait_for_app_cmd(struct mmc_host *host, struct mmc_card *card, |
67 | struct mmc_command *cmd, int retries) | 68 | struct mmc_command *cmd, int retries) |
68 | { | 69 | { |
69 | struct mmc_request mrq; | 70 | struct mmc_request mrq = {0}; |
70 | 71 | ||
71 | int i, err; | 72 | int i, err; |
72 | 73 | ||
@@ -119,13 +120,11 @@ EXPORT_SYMBOL(mmc_wait_for_app_cmd); | |||
119 | int mmc_app_set_bus_width(struct mmc_card *card, int width) | 120 | int mmc_app_set_bus_width(struct mmc_card *card, int width) |
120 | { | 121 | { |
121 | int err; | 122 | int err; |
122 | struct mmc_command cmd; | 123 | struct mmc_command cmd = {0}; |
123 | 124 | ||
124 | BUG_ON(!card); | 125 | BUG_ON(!card); |
125 | BUG_ON(!card->host); | 126 | BUG_ON(!card->host); |
126 | 127 | ||
127 | memset(&cmd, 0, sizeof(struct mmc_command)); | ||
128 | |||
129 | cmd.opcode = SD_APP_SET_BUS_WIDTH; | 128 | cmd.opcode = SD_APP_SET_BUS_WIDTH; |
130 | cmd.flags = MMC_RSP_R1 | MMC_CMD_AC; | 129 | cmd.flags = MMC_RSP_R1 | MMC_CMD_AC; |
131 | 130 | ||
@@ -149,13 +148,11 @@ int mmc_app_set_bus_width(struct mmc_card *card, int width) | |||
149 | 148 | ||
150 | int mmc_send_app_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr) | 149 | int mmc_send_app_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr) |
151 | { | 150 | { |
152 | struct mmc_command cmd; | 151 | struct mmc_command cmd = {0}; |
153 | int i, err = 0; | 152 | int i, err = 0; |
154 | 153 | ||
155 | BUG_ON(!host); | 154 | BUG_ON(!host); |
156 | 155 | ||
157 | memset(&cmd, 0, sizeof(struct mmc_command)); | ||
158 | |||
159 | cmd.opcode = SD_APP_OP_COND; | 156 | cmd.opcode = SD_APP_OP_COND; |
160 | if (mmc_host_is_spi(host)) | 157 | if (mmc_host_is_spi(host)) |
161 | cmd.arg = ocr & (1 << 30); /* SPI only defines one bit */ | 158 | cmd.arg = ocr & (1 << 30); /* SPI only defines one bit */ |
@@ -194,7 +191,7 @@ int mmc_send_app_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr) | |||
194 | 191 | ||
195 | int mmc_send_if_cond(struct mmc_host *host, u32 ocr) | 192 | int mmc_send_if_cond(struct mmc_host *host, u32 ocr) |
196 | { | 193 | { |
197 | struct mmc_command cmd; | 194 | struct mmc_command cmd = {0}; |
198 | int err; | 195 | int err; |
199 | static const u8 test_pattern = 0xAA; | 196 | static const u8 test_pattern = 0xAA; |
200 | u8 result_pattern; | 197 | u8 result_pattern; |
@@ -226,13 +223,11 @@ int mmc_send_if_cond(struct mmc_host *host, u32 ocr) | |||
226 | int mmc_send_relative_addr(struct mmc_host *host, unsigned int *rca) | 223 | int mmc_send_relative_addr(struct mmc_host *host, unsigned int *rca) |
227 | { | 224 | { |
228 | int err; | 225 | int err; |
229 | struct mmc_command cmd; | 226 | struct mmc_command cmd = {0}; |
230 | 227 | ||
231 | BUG_ON(!host); | 228 | BUG_ON(!host); |
232 | BUG_ON(!rca); | 229 | BUG_ON(!rca); |
233 | 230 | ||
234 | memset(&cmd, 0, sizeof(struct mmc_command)); | ||
235 | |||
236 | cmd.opcode = SD_SEND_RELATIVE_ADDR; | 231 | cmd.opcode = SD_SEND_RELATIVE_ADDR; |
237 | cmd.arg = 0; | 232 | cmd.arg = 0; |
238 | cmd.flags = MMC_RSP_R6 | MMC_CMD_BCR; | 233 | cmd.flags = MMC_RSP_R6 | MMC_CMD_BCR; |
@@ -249,9 +244,9 @@ int mmc_send_relative_addr(struct mmc_host *host, unsigned int *rca) | |||
249 | int mmc_app_send_scr(struct mmc_card *card, u32 *scr) | 244 | int mmc_app_send_scr(struct mmc_card *card, u32 *scr) |
250 | { | 245 | { |
251 | int err; | 246 | int err; |
252 | struct mmc_request mrq; | 247 | struct mmc_request mrq = {0}; |
253 | struct mmc_command cmd; | 248 | struct mmc_command cmd = {0}; |
254 | struct mmc_data data; | 249 | struct mmc_data data = {0}; |
255 | struct scatterlist sg; | 250 | struct scatterlist sg; |
256 | void *data_buf; | 251 | void *data_buf; |
257 | 252 | ||
@@ -272,10 +267,6 @@ int mmc_app_send_scr(struct mmc_card *card, u32 *scr) | |||
272 | if (data_buf == NULL) | 267 | if (data_buf == NULL) |
273 | return -ENOMEM; | 268 | return -ENOMEM; |
274 | 269 | ||
275 | memset(&mrq, 0, sizeof(struct mmc_request)); | ||
276 | memset(&cmd, 0, sizeof(struct mmc_command)); | ||
277 | memset(&data, 0, sizeof(struct mmc_data)); | ||
278 | |||
279 | mrq.cmd = &cmd; | 270 | mrq.cmd = &cmd; |
280 | mrq.data = &data; | 271 | mrq.data = &data; |
281 | 272 | ||
@@ -312,9 +303,9 @@ int mmc_app_send_scr(struct mmc_card *card, u32 *scr) | |||
312 | int mmc_sd_switch(struct mmc_card *card, int mode, int group, | 303 | int mmc_sd_switch(struct mmc_card *card, int mode, int group, |
313 | u8 value, u8 *resp) | 304 | u8 value, u8 *resp) |
314 | { | 305 | { |
315 | struct mmc_request mrq; | 306 | struct mmc_request mrq = {0}; |
316 | struct mmc_command cmd; | 307 | struct mmc_command cmd = {0}; |
317 | struct mmc_data data; | 308 | struct mmc_data data = {0}; |
318 | struct scatterlist sg; | 309 | struct scatterlist sg; |
319 | 310 | ||
320 | BUG_ON(!card); | 311 | BUG_ON(!card); |
@@ -325,10 +316,6 @@ int mmc_sd_switch(struct mmc_card *card, int mode, int group, | |||
325 | mode = !!mode; | 316 | mode = !!mode; |
326 | value &= 0xF; | 317 | value &= 0xF; |
327 | 318 | ||
328 | memset(&mrq, 0, sizeof(struct mmc_request)); | ||
329 | memset(&cmd, 0, sizeof(struct mmc_command)); | ||
330 | memset(&data, 0, sizeof(struct mmc_data)); | ||
331 | |||
332 | mrq.cmd = &cmd; | 319 | mrq.cmd = &cmd; |
333 | mrq.data = &data; | 320 | mrq.data = &data; |
334 | 321 | ||
@@ -361,9 +348,9 @@ int mmc_sd_switch(struct mmc_card *card, int mode, int group, | |||
361 | int mmc_app_sd_status(struct mmc_card *card, void *ssr) | 348 | int mmc_app_sd_status(struct mmc_card *card, void *ssr) |
362 | { | 349 | { |
363 | int err; | 350 | int err; |
364 | struct mmc_request mrq; | 351 | struct mmc_request mrq = {0}; |
365 | struct mmc_command cmd; | 352 | struct mmc_command cmd = {0}; |
366 | struct mmc_data data; | 353 | struct mmc_data data = {0}; |
367 | struct scatterlist sg; | 354 | struct scatterlist sg; |
368 | 355 | ||
369 | BUG_ON(!card); | 356 | BUG_ON(!card); |
@@ -376,10 +363,6 @@ int mmc_app_sd_status(struct mmc_card *card, void *ssr) | |||
376 | if (err) | 363 | if (err) |
377 | return err; | 364 | return err; |
378 | 365 | ||
379 | memset(&mrq, 0, sizeof(struct mmc_request)); | ||
380 | memset(&cmd, 0, sizeof(struct mmc_command)); | ||
381 | memset(&data, 0, sizeof(struct mmc_data)); | ||
382 | |||
383 | mrq.cmd = &cmd; | 366 | mrq.cmd = &cmd; |
384 | mrq.data = &data; | 367 | mrq.data = &data; |
385 | 368 | ||