diff options
Diffstat (limited to 'drivers/mmc/core/sd_ops.c')
| -rw-r--r-- | drivers/mmc/core/sd_ops.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/drivers/mmc/core/sd_ops.c b/drivers/mmc/core/sd_ops.c index 797cdb5887f..76af349c14b 100644 --- a/drivers/mmc/core/sd_ops.c +++ b/drivers/mmc/core/sd_ops.c | |||
| @@ -9,6 +9,7 @@ | |||
| 9 | * your option) any later version. | 9 | * your option) any later version. |
| 10 | */ | 10 | */ |
| 11 | 11 | ||
| 12 | #include <linux/slab.h> | ||
| 12 | #include <linux/types.h> | 13 | #include <linux/types.h> |
| 13 | #include <linux/scatterlist.h> | 14 | #include <linux/scatterlist.h> |
| 14 | 15 | ||
| @@ -252,6 +253,7 @@ int mmc_app_send_scr(struct mmc_card *card, u32 *scr) | |||
| 252 | struct mmc_command cmd; | 253 | struct mmc_command cmd; |
| 253 | struct mmc_data data; | 254 | struct mmc_data data; |
| 254 | struct scatterlist sg; | 255 | struct scatterlist sg; |
| 256 | void *data_buf; | ||
| 255 | 257 | ||
| 256 | BUG_ON(!card); | 258 | BUG_ON(!card); |
| 257 | BUG_ON(!card->host); | 259 | BUG_ON(!card->host); |
| @@ -263,6 +265,13 @@ int mmc_app_send_scr(struct mmc_card *card, u32 *scr) | |||
| 263 | if (err) | 265 | if (err) |
| 264 | return err; | 266 | return err; |
| 265 | 267 | ||
| 268 | /* dma onto stack is unsafe/nonportable, but callers to this | ||
| 269 | * routine normally provide temporary on-stack buffers ... | ||
| 270 | */ | ||
| 271 | data_buf = kmalloc(sizeof(card->raw_scr), GFP_KERNEL); | ||
| 272 | if (data_buf == NULL) | ||
| 273 | return -ENOMEM; | ||
| 274 | |||
| 266 | memset(&mrq, 0, sizeof(struct mmc_request)); | 275 | memset(&mrq, 0, sizeof(struct mmc_request)); |
| 267 | memset(&cmd, 0, sizeof(struct mmc_command)); | 276 | memset(&cmd, 0, sizeof(struct mmc_command)); |
| 268 | memset(&data, 0, sizeof(struct mmc_data)); | 277 | memset(&data, 0, sizeof(struct mmc_data)); |
| @@ -280,12 +289,15 @@ int mmc_app_send_scr(struct mmc_card *card, u32 *scr) | |||
| 280 | data.sg = &sg; | 289 | data.sg = &sg; |
| 281 | data.sg_len = 1; | 290 | data.sg_len = 1; |
| 282 | 291 | ||
| 283 | sg_init_one(&sg, scr, 8); | 292 | sg_init_one(&sg, data_buf, 8); |
| 284 | 293 | ||
| 285 | mmc_set_data_timeout(&data, card); | 294 | mmc_set_data_timeout(&data, card); |
| 286 | 295 | ||
| 287 | mmc_wait_for_req(card->host, &mrq); | 296 | mmc_wait_for_req(card->host, &mrq); |
| 288 | 297 | ||
| 298 | memcpy(scr, data_buf, sizeof(card->raw_scr)); | ||
| 299 | kfree(data_buf); | ||
| 300 | |||
| 289 | if (cmd.error) | 301 | if (cmd.error) |
| 290 | return cmd.error; | 302 | return cmd.error; |
| 291 | if (data.error) | 303 | if (data.error) |
