diff options
author | Pierre Ossman <drzeus@drzeus.cx> | 2007-07-22 16:18:46 -0400 |
---|---|---|
committer | Pierre Ossman <drzeus@drzeus.cx> | 2007-09-23 02:46:48 -0400 |
commit | 17b0429dde9ab60f9cee8e07ab28c7dc6cfe6efd (patch) | |
tree | 9f87df1ffbeca4c6f828b7979f2e45ef898a3ef0 /drivers/mmc/core | |
parent | b7e113dc9d52c4a37d2da6fafe77959f3a28eccf (diff) |
mmc: remove custom error codes
Convert the MMC layer to use standard error codes and not its own,
incompatible values.
Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
Diffstat (limited to 'drivers/mmc/core')
-rw-r--r-- | drivers/mmc/core/core.c | 4 | ||||
-rw-r--r-- | drivers/mmc/core/mmc.c | 36 | ||||
-rw-r--r-- | drivers/mmc/core/mmc_ops.c | 34 | ||||
-rw-r--r-- | drivers/mmc/core/sd.c | 56 | ||||
-rw-r--r-- | drivers/mmc/core/sd_ops.c | 46 |
5 files changed, 88 insertions, 88 deletions
diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index bfd2ae5bd669..63b67296e92d 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c | |||
@@ -598,7 +598,7 @@ void mmc_rescan(struct work_struct *work) | |||
598 | mmc_send_if_cond(host, host->ocr_avail); | 598 | mmc_send_if_cond(host, host->ocr_avail); |
599 | 599 | ||
600 | err = mmc_send_app_op_cond(host, 0, &ocr); | 600 | err = mmc_send_app_op_cond(host, 0, &ocr); |
601 | if (err == MMC_ERR_NONE) { | 601 | if (!err) { |
602 | if (mmc_attach_sd(host, ocr)) | 602 | if (mmc_attach_sd(host, ocr)) |
603 | mmc_power_off(host); | 603 | mmc_power_off(host); |
604 | } else { | 604 | } else { |
@@ -607,7 +607,7 @@ void mmc_rescan(struct work_struct *work) | |||
607 | * searching for MMC cards. | 607 | * searching for MMC cards. |
608 | */ | 608 | */ |
609 | err = mmc_send_op_cond(host, 0, &ocr); | 609 | err = mmc_send_op_cond(host, 0, &ocr); |
610 | if (err == MMC_ERR_NONE) { | 610 | if (!err) { |
611 | if (mmc_attach_mmc(host, ocr)) | 611 | if (mmc_attach_mmc(host, ocr)) |
612 | mmc_power_off(host); | 612 | mmc_power_off(host); |
613 | } else { | 613 | } else { |
diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index 21d7f48e1d4e..fe483d5af744 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c | |||
@@ -164,10 +164,10 @@ static int mmc_read_ext_csd(struct mmc_card *card) | |||
164 | 164 | ||
165 | BUG_ON(!card); | 165 | BUG_ON(!card); |
166 | 166 | ||
167 | err = MMC_ERR_FAILED; | 167 | err = -EIO; |
168 | 168 | ||
169 | if (card->csd.mmca_vsn < CSD_SPEC_VER_4) | 169 | if (card->csd.mmca_vsn < CSD_SPEC_VER_4) |
170 | return MMC_ERR_NONE; | 170 | return 0; |
171 | 171 | ||
172 | /* | 172 | /* |
173 | * As the ext_csd is so large and mostly unused, we don't store the | 173 | * As the ext_csd is so large and mostly unused, we don't store the |
@@ -178,11 +178,11 @@ static int mmc_read_ext_csd(struct mmc_card *card) | |||
178 | printk(KERN_ERR "%s: could not allocate a buffer to " | 178 | printk(KERN_ERR "%s: could not allocate a buffer to " |
179 | "receive the ext_csd. mmc v4 cards will be " | 179 | "receive the ext_csd. mmc v4 cards will be " |
180 | "treated as v3.\n", mmc_hostname(card->host)); | 180 | "treated as v3.\n", mmc_hostname(card->host)); |
181 | return MMC_ERR_FAILED; | 181 | return -ENOMEM; |
182 | } | 182 | } |
183 | 183 | ||
184 | err = mmc_send_ext_csd(card, ext_csd); | 184 | err = mmc_send_ext_csd(card, ext_csd); |
185 | if (err != MMC_ERR_NONE) { | 185 | if (err) { |
186 | /* | 186 | /* |
187 | * High capacity cards should have this "magic" size | 187 | * High capacity cards should have this "magic" size |
188 | * stored in their CSD. | 188 | * stored in their CSD. |
@@ -197,7 +197,7 @@ static int mmc_read_ext_csd(struct mmc_card *card) | |||
197 | "EXT_CSD, performance might " | 197 | "EXT_CSD, performance might " |
198 | "suffer.\n", | 198 | "suffer.\n", |
199 | mmc_hostname(card->host)); | 199 | mmc_hostname(card->host)); |
200 | err = MMC_ERR_NONE; | 200 | err = 0; |
201 | } | 201 | } |
202 | goto out; | 202 | goto out; |
203 | } | 203 | } |
@@ -258,14 +258,14 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr, | |||
258 | 258 | ||
259 | /* The extra bit indicates that we support high capacity */ | 259 | /* The extra bit indicates that we support high capacity */ |
260 | err = mmc_send_op_cond(host, ocr | (1 << 30), NULL); | 260 | err = mmc_send_op_cond(host, ocr | (1 << 30), NULL); |
261 | if (err != MMC_ERR_NONE) | 261 | if (err) |
262 | goto err; | 262 | goto err; |
263 | 263 | ||
264 | /* | 264 | /* |
265 | * Fetch CID from card. | 265 | * Fetch CID from card. |
266 | */ | 266 | */ |
267 | err = mmc_all_send_cid(host, cid); | 267 | err = mmc_all_send_cid(host, cid); |
268 | if (err != MMC_ERR_NONE) | 268 | if (err) |
269 | goto err; | 269 | goto err; |
270 | 270 | ||
271 | if (oldcard) { | 271 | if (oldcard) { |
@@ -290,7 +290,7 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr, | |||
290 | * Set card RCA. | 290 | * Set card RCA. |
291 | */ | 291 | */ |
292 | err = mmc_set_relative_addr(card); | 292 | err = mmc_set_relative_addr(card); |
293 | if (err != MMC_ERR_NONE) | 293 | if (err) |
294 | goto free_card; | 294 | goto free_card; |
295 | 295 | ||
296 | mmc_set_bus_mode(host, MMC_BUSMODE_PUSHPULL); | 296 | mmc_set_bus_mode(host, MMC_BUSMODE_PUSHPULL); |
@@ -300,7 +300,7 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr, | |||
300 | * Fetch CSD from card. | 300 | * Fetch CSD from card. |
301 | */ | 301 | */ |
302 | err = mmc_send_csd(card, card->raw_csd); | 302 | err = mmc_send_csd(card, card->raw_csd); |
303 | if (err != MMC_ERR_NONE) | 303 | if (err) |
304 | goto free_card; | 304 | goto free_card; |
305 | 305 | ||
306 | err = mmc_decode_csd(card); | 306 | err = mmc_decode_csd(card); |
@@ -315,7 +315,7 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr, | |||
315 | * Select card, as all following commands rely on that. | 315 | * Select card, as all following commands rely on that. |
316 | */ | 316 | */ |
317 | err = mmc_select_card(card); | 317 | err = mmc_select_card(card); |
318 | if (err != MMC_ERR_NONE) | 318 | if (err) |
319 | goto free_card; | 319 | goto free_card; |
320 | 320 | ||
321 | if (!oldcard) { | 321 | if (!oldcard) { |
@@ -323,7 +323,7 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr, | |||
323 | * Fetch and process extened CSD. | 323 | * Fetch and process extened CSD. |
324 | */ | 324 | */ |
325 | err = mmc_read_ext_csd(card); | 325 | err = mmc_read_ext_csd(card); |
326 | if (err != MMC_ERR_NONE) | 326 | if (err) |
327 | goto free_card; | 327 | goto free_card; |
328 | } | 328 | } |
329 | 329 | ||
@@ -334,7 +334,7 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr, | |||
334 | (host->caps & MMC_CAP_MMC_HIGHSPEED)) { | 334 | (host->caps & MMC_CAP_MMC_HIGHSPEED)) { |
335 | err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, | 335 | err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, |
336 | EXT_CSD_HS_TIMING, 1); | 336 | EXT_CSD_HS_TIMING, 1); |
337 | if (err != MMC_ERR_NONE) | 337 | if (err) |
338 | goto free_card; | 338 | goto free_card; |
339 | 339 | ||
340 | mmc_card_set_highspeed(card); | 340 | mmc_card_set_highspeed(card); |
@@ -363,7 +363,7 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr, | |||
363 | (host->caps & MMC_CAP_4_BIT_DATA)) { | 363 | (host->caps & MMC_CAP_4_BIT_DATA)) { |
364 | err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, | 364 | err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, |
365 | EXT_CSD_BUS_WIDTH, EXT_CSD_BUS_WIDTH_4); | 365 | EXT_CSD_BUS_WIDTH, EXT_CSD_BUS_WIDTH_4); |
366 | if (err != MMC_ERR_NONE) | 366 | if (err) |
367 | goto free_card; | 367 | goto free_card; |
368 | 368 | ||
369 | mmc_set_bus_width(card->host, MMC_BUS_WIDTH_4); | 369 | mmc_set_bus_width(card->host, MMC_BUS_WIDTH_4); |
@@ -372,14 +372,14 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr, | |||
372 | if (!oldcard) | 372 | if (!oldcard) |
373 | host->card = card; | 373 | host->card = card; |
374 | 374 | ||
375 | return MMC_ERR_NONE; | 375 | return 0; |
376 | 376 | ||
377 | free_card: | 377 | free_card: |
378 | if (!oldcard) | 378 | if (!oldcard) |
379 | mmc_remove_card(card); | 379 | mmc_remove_card(card); |
380 | err: | 380 | err: |
381 | 381 | ||
382 | return MMC_ERR_FAILED; | 382 | return -EIO; |
383 | } | 383 | } |
384 | 384 | ||
385 | /* | 385 | /* |
@@ -413,7 +413,7 @@ static void mmc_detect(struct mmc_host *host) | |||
413 | 413 | ||
414 | mmc_release_host(host); | 414 | mmc_release_host(host); |
415 | 415 | ||
416 | if (err != MMC_ERR_NONE) { | 416 | if (err) { |
417 | mmc_remove(host); | 417 | mmc_remove(host); |
418 | 418 | ||
419 | mmc_claim_host(host); | 419 | mmc_claim_host(host); |
@@ -502,7 +502,7 @@ static void mmc_resume(struct mmc_host *host) | |||
502 | err = mmc_init_card(host, host->ocr, host->card); | 502 | err = mmc_init_card(host, host->ocr, host->card); |
503 | mmc_release_host(host); | 503 | mmc_release_host(host); |
504 | 504 | ||
505 | if (err != MMC_ERR_NONE) { | 505 | if (err) { |
506 | mmc_remove(host); | 506 | mmc_remove(host); |
507 | 507 | ||
508 | mmc_claim_host(host); | 508 | mmc_claim_host(host); |
@@ -565,7 +565,7 @@ int mmc_attach_mmc(struct mmc_host *host, u32 ocr) | |||
565 | * Detect and init the card. | 565 | * Detect and init the card. |
566 | */ | 566 | */ |
567 | err = mmc_init_card(host, host->ocr, NULL); | 567 | err = mmc_init_card(host, host->ocr, NULL); |
568 | if (err != MMC_ERR_NONE) | 568 | if (err) |
569 | goto err; | 569 | goto err; |
570 | 570 | ||
571 | mmc_release_host(host); | 571 | mmc_release_host(host); |
diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c index 913e75f00843..15cd575effaa 100644 --- a/drivers/mmc/core/mmc_ops.c +++ b/drivers/mmc/core/mmc_ops.c | |||
@@ -40,10 +40,10 @@ static int _mmc_select_card(struct mmc_host *host, struct mmc_card *card) | |||
40 | } | 40 | } |
41 | 41 | ||
42 | err = mmc_wait_for_cmd(host, &cmd, MMC_CMD_RETRIES); | 42 | err = mmc_wait_for_cmd(host, &cmd, MMC_CMD_RETRIES); |
43 | if (err != MMC_ERR_NONE) | 43 | if (err) |
44 | return err; | 44 | return err; |
45 | 45 | ||
46 | return MMC_ERR_NONE; | 46 | return 0; |
47 | } | 47 | } |
48 | 48 | ||
49 | int mmc_select_card(struct mmc_card *card) | 49 | int mmc_select_card(struct mmc_card *card) |
@@ -99,13 +99,13 @@ int mmc_send_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr) | |||
99 | 99 | ||
100 | for (i = 100; i; i--) { | 100 | for (i = 100; i; i--) { |
101 | err = mmc_wait_for_cmd(host, &cmd, 0); | 101 | err = mmc_wait_for_cmd(host, &cmd, 0); |
102 | if (err != MMC_ERR_NONE) | 102 | if (err) |
103 | break; | 103 | break; |
104 | 104 | ||
105 | if (cmd.resp[0] & MMC_CARD_BUSY || ocr == 0) | 105 | if (cmd.resp[0] & MMC_CARD_BUSY || ocr == 0) |
106 | break; | 106 | break; |
107 | 107 | ||
108 | err = MMC_ERR_TIMEOUT; | 108 | err = -ETIMEDOUT; |
109 | 109 | ||
110 | mmc_delay(10); | 110 | mmc_delay(10); |
111 | } | 111 | } |
@@ -131,12 +131,12 @@ int mmc_all_send_cid(struct mmc_host *host, u32 *cid) | |||
131 | cmd.flags = MMC_RSP_R2 | MMC_CMD_BCR; | 131 | cmd.flags = MMC_RSP_R2 | MMC_CMD_BCR; |
132 | 132 | ||
133 | err = mmc_wait_for_cmd(host, &cmd, MMC_CMD_RETRIES); | 133 | err = mmc_wait_for_cmd(host, &cmd, MMC_CMD_RETRIES); |
134 | if (err != MMC_ERR_NONE) | 134 | if (err) |
135 | return err; | 135 | return err; |
136 | 136 | ||
137 | memcpy(cid, cmd.resp, sizeof(u32) * 4); | 137 | memcpy(cid, cmd.resp, sizeof(u32) * 4); |
138 | 138 | ||
139 | return MMC_ERR_NONE; | 139 | return 0; |
140 | } | 140 | } |
141 | 141 | ||
142 | int mmc_set_relative_addr(struct mmc_card *card) | 142 | int mmc_set_relative_addr(struct mmc_card *card) |
@@ -154,10 +154,10 @@ int mmc_set_relative_addr(struct mmc_card *card) | |||
154 | cmd.flags = MMC_RSP_R1 | MMC_CMD_AC; | 154 | cmd.flags = MMC_RSP_R1 | MMC_CMD_AC; |
155 | 155 | ||
156 | err = mmc_wait_for_cmd(card->host, &cmd, MMC_CMD_RETRIES); | 156 | err = mmc_wait_for_cmd(card->host, &cmd, MMC_CMD_RETRIES); |
157 | if (err != MMC_ERR_NONE) | 157 | if (err) |
158 | return err; | 158 | return err; |
159 | 159 | ||
160 | return MMC_ERR_NONE; | 160 | return 0; |
161 | } | 161 | } |
162 | 162 | ||
163 | int mmc_send_csd(struct mmc_card *card, u32 *csd) | 163 | int mmc_send_csd(struct mmc_card *card, u32 *csd) |
@@ -176,12 +176,12 @@ int mmc_send_csd(struct mmc_card *card, u32 *csd) | |||
176 | cmd.flags = MMC_RSP_R2 | MMC_CMD_AC; | 176 | cmd.flags = MMC_RSP_R2 | MMC_CMD_AC; |
177 | 177 | ||
178 | err = mmc_wait_for_cmd(card->host, &cmd, MMC_CMD_RETRIES); | 178 | err = mmc_wait_for_cmd(card->host, &cmd, MMC_CMD_RETRIES); |
179 | if (err != MMC_ERR_NONE) | 179 | if (err) |
180 | return err; | 180 | return err; |
181 | 181 | ||
182 | memcpy(csd, cmd.resp, sizeof(u32) * 4); | 182 | memcpy(csd, cmd.resp, sizeof(u32) * 4); |
183 | 183 | ||
184 | return MMC_ERR_NONE; | 184 | return 0; |
185 | } | 185 | } |
186 | 186 | ||
187 | int mmc_send_ext_csd(struct mmc_card *card, u8 *ext_csd) | 187 | int mmc_send_ext_csd(struct mmc_card *card, u8 *ext_csd) |
@@ -218,12 +218,12 @@ int mmc_send_ext_csd(struct mmc_card *card, u8 *ext_csd) | |||
218 | 218 | ||
219 | mmc_wait_for_req(card->host, &mrq); | 219 | mmc_wait_for_req(card->host, &mrq); |
220 | 220 | ||
221 | if (cmd.error != MMC_ERR_NONE) | 221 | if (cmd.error) |
222 | return cmd.error; | 222 | return cmd.error; |
223 | if (data.error != MMC_ERR_NONE) | 223 | if (data.error) |
224 | return data.error; | 224 | return data.error; |
225 | 225 | ||
226 | return MMC_ERR_NONE; | 226 | return 0; |
227 | } | 227 | } |
228 | 228 | ||
229 | int mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value) | 229 | int mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value) |
@@ -244,10 +244,10 @@ int mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value) | |||
244 | cmd.flags = MMC_RSP_R1B | MMC_CMD_AC; | 244 | cmd.flags = MMC_RSP_R1B | MMC_CMD_AC; |
245 | 245 | ||
246 | err = mmc_wait_for_cmd(card->host, &cmd, MMC_CMD_RETRIES); | 246 | err = mmc_wait_for_cmd(card->host, &cmd, MMC_CMD_RETRIES); |
247 | if (err != MMC_ERR_NONE) | 247 | if (err) |
248 | return err; | 248 | return err; |
249 | 249 | ||
250 | return MMC_ERR_NONE; | 250 | return 0; |
251 | } | 251 | } |
252 | 252 | ||
253 | int mmc_send_status(struct mmc_card *card, u32 *status) | 253 | int mmc_send_status(struct mmc_card *card, u32 *status) |
@@ -265,12 +265,12 @@ int mmc_send_status(struct mmc_card *card, u32 *status) | |||
265 | cmd.flags = MMC_RSP_R1 | MMC_CMD_AC; | 265 | cmd.flags = MMC_RSP_R1 | MMC_CMD_AC; |
266 | 266 | ||
267 | err = mmc_wait_for_cmd(card->host, &cmd, MMC_CMD_RETRIES); | 267 | err = mmc_wait_for_cmd(card->host, &cmd, MMC_CMD_RETRIES); |
268 | if (err != MMC_ERR_NONE) | 268 | if (err) |
269 | return err; | 269 | return err; |
270 | 270 | ||
271 | if (status) | 271 | if (status) |
272 | *status = cmd.resp[0]; | 272 | *status = cmd.resp[0]; |
273 | 273 | ||
274 | return MMC_ERR_NONE; | 274 | return 0; |
275 | } | 275 | } |
276 | 276 | ||
diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c index 1edc62b1e5c6..00895c99d9bb 100644 --- a/drivers/mmc/core/sd.c +++ b/drivers/mmc/core/sd.c | |||
@@ -193,30 +193,30 @@ static int mmc_read_switch(struct mmc_card *card) | |||
193 | u8 *status; | 193 | u8 *status; |
194 | 194 | ||
195 | if (card->scr.sda_vsn < SCR_SPEC_VER_1) | 195 | if (card->scr.sda_vsn < SCR_SPEC_VER_1) |
196 | return MMC_ERR_NONE; | 196 | return 0; |
197 | 197 | ||
198 | if (!(card->csd.cmdclass & CCC_SWITCH)) { | 198 | if (!(card->csd.cmdclass & CCC_SWITCH)) { |
199 | printk(KERN_WARNING "%s: card lacks mandatory switch " | 199 | printk(KERN_WARNING "%s: card lacks mandatory switch " |
200 | "function, performance might suffer.\n", | 200 | "function, performance might suffer.\n", |
201 | mmc_hostname(card->host)); | 201 | mmc_hostname(card->host)); |
202 | return MMC_ERR_NONE; | 202 | return 0; |
203 | } | 203 | } |
204 | 204 | ||
205 | err = MMC_ERR_FAILED; | 205 | err = -EIO; |
206 | 206 | ||
207 | status = kmalloc(64, GFP_KERNEL); | 207 | status = kmalloc(64, GFP_KERNEL); |
208 | if (!status) { | 208 | if (!status) { |
209 | printk(KERN_ERR "%s: could not allocate a buffer for " | 209 | printk(KERN_ERR "%s: could not allocate a buffer for " |
210 | "switch capabilities.\n", mmc_hostname(card->host)); | 210 | "switch capabilities.\n", mmc_hostname(card->host)); |
211 | return err; | 211 | return -ENOMEM; |
212 | } | 212 | } |
213 | 213 | ||
214 | err = mmc_sd_switch(card, 0, 0, 1, status); | 214 | err = mmc_sd_switch(card, 0, 0, 1, status); |
215 | if (err != MMC_ERR_NONE) { | 215 | if (err) { |
216 | printk(KERN_WARNING "%s: problem reading switch " | 216 | printk(KERN_WARNING "%s: problem reading switch " |
217 | "capabilities, performance might suffer.\n", | 217 | "capabilities, performance might suffer.\n", |
218 | mmc_hostname(card->host)); | 218 | mmc_hostname(card->host)); |
219 | err = MMC_ERR_NONE; | 219 | err = 0; |
220 | goto out; | 220 | goto out; |
221 | } | 221 | } |
222 | 222 | ||
@@ -238,28 +238,28 @@ static int mmc_switch_hs(struct mmc_card *card) | |||
238 | u8 *status; | 238 | u8 *status; |
239 | 239 | ||
240 | if (card->scr.sda_vsn < SCR_SPEC_VER_1) | 240 | if (card->scr.sda_vsn < SCR_SPEC_VER_1) |
241 | return MMC_ERR_NONE; | 241 | return 0; |
242 | 242 | ||
243 | if (!(card->csd.cmdclass & CCC_SWITCH)) | 243 | if (!(card->csd.cmdclass & CCC_SWITCH)) |
244 | return MMC_ERR_NONE; | 244 | return 0; |
245 | 245 | ||
246 | if (!(card->host->caps & MMC_CAP_SD_HIGHSPEED)) | 246 | if (!(card->host->caps & MMC_CAP_SD_HIGHSPEED)) |
247 | return MMC_ERR_NONE; | 247 | return 0; |
248 | 248 | ||
249 | if (card->sw_caps.hs_max_dtr == 0) | 249 | if (card->sw_caps.hs_max_dtr == 0) |
250 | return MMC_ERR_NONE; | 250 | return 0; |
251 | 251 | ||
252 | err = MMC_ERR_FAILED; | 252 | err = -EIO; |
253 | 253 | ||
254 | status = kmalloc(64, GFP_KERNEL); | 254 | status = kmalloc(64, GFP_KERNEL); |
255 | if (!status) { | 255 | if (!status) { |
256 | printk(KERN_ERR "%s: could not allocate a buffer for " | 256 | printk(KERN_ERR "%s: could not allocate a buffer for " |
257 | "switch capabilities.\n", mmc_hostname(card->host)); | 257 | "switch capabilities.\n", mmc_hostname(card->host)); |
258 | return err; | 258 | return -ENOMEM; |
259 | } | 259 | } |
260 | 260 | ||
261 | err = mmc_sd_switch(card, 1, 0, 1, status); | 261 | err = mmc_sd_switch(card, 1, 0, 1, status); |
262 | if (err != MMC_ERR_NONE) | 262 | if (err) |
263 | goto out; | 263 | goto out; |
264 | 264 | ||
265 | if ((status[16] & 0xF) != 1) { | 265 | if ((status[16] & 0xF) != 1) { |
@@ -309,18 +309,18 @@ static int mmc_sd_init_card(struct mmc_host *host, u32 ocr, | |||
309 | * block-addressed SDHC cards. | 309 | * block-addressed SDHC cards. |
310 | */ | 310 | */ |
311 | err = mmc_send_if_cond(host, ocr); | 311 | err = mmc_send_if_cond(host, ocr); |
312 | if (err == MMC_ERR_NONE) | 312 | if (!err) |
313 | ocr |= 1 << 30; | 313 | ocr |= 1 << 30; |
314 | 314 | ||
315 | err = mmc_send_app_op_cond(host, ocr, NULL); | 315 | err = mmc_send_app_op_cond(host, ocr, NULL); |
316 | if (err != MMC_ERR_NONE) | 316 | if (err) |
317 | goto err; | 317 | goto err; |
318 | 318 | ||
319 | /* | 319 | /* |
320 | * Fetch CID from card. | 320 | * Fetch CID from card. |
321 | */ | 321 | */ |
322 | err = mmc_all_send_cid(host, cid); | 322 | err = mmc_all_send_cid(host, cid); |
323 | if (err != MMC_ERR_NONE) | 323 | if (err) |
324 | goto err; | 324 | goto err; |
325 | 325 | ||
326 | if (oldcard) { | 326 | if (oldcard) { |
@@ -344,7 +344,7 @@ static int mmc_sd_init_card(struct mmc_host *host, u32 ocr, | |||
344 | * Set card RCA. | 344 | * Set card RCA. |
345 | */ | 345 | */ |
346 | err = mmc_send_relative_addr(host, &card->rca); | 346 | err = mmc_send_relative_addr(host, &card->rca); |
347 | if (err != MMC_ERR_NONE) | 347 | if (err) |
348 | goto free_card; | 348 | goto free_card; |
349 | 349 | ||
350 | mmc_set_bus_mode(host, MMC_BUSMODE_PUSHPULL); | 350 | mmc_set_bus_mode(host, MMC_BUSMODE_PUSHPULL); |
@@ -354,7 +354,7 @@ static int mmc_sd_init_card(struct mmc_host *host, u32 ocr, | |||
354 | * Fetch CSD from card. | 354 | * Fetch CSD from card. |
355 | */ | 355 | */ |
356 | err = mmc_send_csd(card, card->raw_csd); | 356 | err = mmc_send_csd(card, card->raw_csd); |
357 | if (err != MMC_ERR_NONE) | 357 | if (err) |
358 | goto free_card; | 358 | goto free_card; |
359 | 359 | ||
360 | err = mmc_decode_csd(card); | 360 | err = mmc_decode_csd(card); |
@@ -368,7 +368,7 @@ static int mmc_sd_init_card(struct mmc_host *host, u32 ocr, | |||
368 | * Select card, as all following commands rely on that. | 368 | * Select card, as all following commands rely on that. |
369 | */ | 369 | */ |
370 | err = mmc_select_card(card); | 370 | err = mmc_select_card(card); |
371 | if (err != MMC_ERR_NONE) | 371 | if (err) |
372 | goto free_card; | 372 | goto free_card; |
373 | 373 | ||
374 | if (!oldcard) { | 374 | if (!oldcard) { |
@@ -376,7 +376,7 @@ static int mmc_sd_init_card(struct mmc_host *host, u32 ocr, | |||
376 | * Fetch SCR from card. | 376 | * Fetch SCR from card. |
377 | */ | 377 | */ |
378 | err = mmc_app_send_scr(card, card->raw_scr); | 378 | err = mmc_app_send_scr(card, card->raw_scr); |
379 | if (err != MMC_ERR_NONE) | 379 | if (err) |
380 | goto free_card; | 380 | goto free_card; |
381 | 381 | ||
382 | err = mmc_decode_scr(card); | 382 | err = mmc_decode_scr(card); |
@@ -387,7 +387,7 @@ static int mmc_sd_init_card(struct mmc_host *host, u32 ocr, | |||
387 | * Fetch switch information from card. | 387 | * Fetch switch information from card. |
388 | */ | 388 | */ |
389 | err = mmc_read_switch(card); | 389 | err = mmc_read_switch(card); |
390 | if (err != MMC_ERR_NONE) | 390 | if (err) |
391 | goto free_card; | 391 | goto free_card; |
392 | } | 392 | } |
393 | 393 | ||
@@ -395,7 +395,7 @@ static int mmc_sd_init_card(struct mmc_host *host, u32 ocr, | |||
395 | * Attempt to change to high-speed (if supported) | 395 | * Attempt to change to high-speed (if supported) |
396 | */ | 396 | */ |
397 | err = mmc_switch_hs(card); | 397 | err = mmc_switch_hs(card); |
398 | if (err != MMC_ERR_NONE) | 398 | if (err) |
399 | goto free_card; | 399 | goto free_card; |
400 | 400 | ||
401 | /* | 401 | /* |
@@ -418,7 +418,7 @@ static int mmc_sd_init_card(struct mmc_host *host, u32 ocr, | |||
418 | if ((host->caps & MMC_CAP_4_BIT_DATA) && | 418 | if ((host->caps & MMC_CAP_4_BIT_DATA) && |
419 | (card->scr.bus_widths & SD_SCR_BUS_WIDTH_4)) { | 419 | (card->scr.bus_widths & SD_SCR_BUS_WIDTH_4)) { |
420 | err = mmc_app_set_bus_width(card, MMC_BUS_WIDTH_4); | 420 | err = mmc_app_set_bus_width(card, MMC_BUS_WIDTH_4); |
421 | if (err != MMC_ERR_NONE) | 421 | if (err) |
422 | goto free_card; | 422 | goto free_card; |
423 | 423 | ||
424 | mmc_set_bus_width(host, MMC_BUS_WIDTH_4); | 424 | mmc_set_bus_width(host, MMC_BUS_WIDTH_4); |
@@ -442,14 +442,14 @@ static int mmc_sd_init_card(struct mmc_host *host, u32 ocr, | |||
442 | if (!oldcard) | 442 | if (!oldcard) |
443 | host->card = card; | 443 | host->card = card; |
444 | 444 | ||
445 | return MMC_ERR_NONE; | 445 | return 0; |
446 | 446 | ||
447 | free_card: | 447 | free_card: |
448 | if (!oldcard) | 448 | if (!oldcard) |
449 | mmc_remove_card(card); | 449 | mmc_remove_card(card); |
450 | err: | 450 | err: |
451 | 451 | ||
452 | return MMC_ERR_FAILED; | 452 | return -EIO; |
453 | } | 453 | } |
454 | 454 | ||
455 | /* | 455 | /* |
@@ -483,7 +483,7 @@ static void mmc_sd_detect(struct mmc_host *host) | |||
483 | 483 | ||
484 | mmc_release_host(host); | 484 | mmc_release_host(host); |
485 | 485 | ||
486 | if (err != MMC_ERR_NONE) { | 486 | if (err) { |
487 | mmc_sd_remove(host); | 487 | mmc_sd_remove(host); |
488 | 488 | ||
489 | mmc_claim_host(host); | 489 | mmc_claim_host(host); |
@@ -574,7 +574,7 @@ static void mmc_sd_resume(struct mmc_host *host) | |||
574 | err = mmc_sd_init_card(host, host->ocr, host->card); | 574 | err = mmc_sd_init_card(host, host->ocr, host->card); |
575 | mmc_release_host(host); | 575 | mmc_release_host(host); |
576 | 576 | ||
577 | if (err != MMC_ERR_NONE) { | 577 | if (err) { |
578 | mmc_sd_remove(host); | 578 | mmc_sd_remove(host); |
579 | 579 | ||
580 | mmc_claim_host(host); | 580 | mmc_claim_host(host); |
@@ -644,7 +644,7 @@ int mmc_attach_sd(struct mmc_host *host, u32 ocr) | |||
644 | * Detect and init the card. | 644 | * Detect and init the card. |
645 | */ | 645 | */ |
646 | err = mmc_sd_init_card(host, host->ocr, NULL); | 646 | err = mmc_sd_init_card(host, host->ocr, NULL); |
647 | if (err != MMC_ERR_NONE) | 647 | if (err) |
648 | goto err; | 648 | goto err; |
649 | 649 | ||
650 | mmc_release_host(host); | 650 | mmc_release_host(host); |
diff --git a/drivers/mmc/core/sd_ops.c b/drivers/mmc/core/sd_ops.c index 342f340ebc25..b4d43bd0fedd 100644 --- a/drivers/mmc/core/sd_ops.c +++ b/drivers/mmc/core/sd_ops.c | |||
@@ -40,14 +40,14 @@ static int mmc_app_cmd(struct mmc_host *host, struct mmc_card *card) | |||
40 | } | 40 | } |
41 | 41 | ||
42 | err = mmc_wait_for_cmd(host, &cmd, 0); | 42 | err = mmc_wait_for_cmd(host, &cmd, 0); |
43 | if (err != MMC_ERR_NONE) | 43 | if (err) |
44 | return err; | 44 | return err; |
45 | 45 | ||
46 | /* Check that card supported application commands */ | 46 | /* Check that card supported application commands */ |
47 | if (!(cmd.resp[0] & R1_APP_CMD)) | 47 | if (!(cmd.resp[0] & R1_APP_CMD)) |
48 | return MMC_ERR_FAILED; | 48 | return -EOPNOTSUPP; |
49 | 49 | ||
50 | return MMC_ERR_NONE; | 50 | return 0; |
51 | } | 51 | } |
52 | 52 | ||
53 | /** | 53 | /** |
@@ -73,7 +73,7 @@ int mmc_wait_for_app_cmd(struct mmc_host *host, struct mmc_card *card, | |||
73 | BUG_ON(!cmd); | 73 | BUG_ON(!cmd); |
74 | BUG_ON(retries < 0); | 74 | BUG_ON(retries < 0); |
75 | 75 | ||
76 | err = MMC_ERR_INVALID; | 76 | err = -EIO; |
77 | 77 | ||
78 | /* | 78 | /* |
79 | * We have to resend MMC_APP_CMD for each attempt so | 79 | * We have to resend MMC_APP_CMD for each attempt so |
@@ -83,7 +83,7 @@ int mmc_wait_for_app_cmd(struct mmc_host *host, struct mmc_card *card, | |||
83 | memset(&mrq, 0, sizeof(struct mmc_request)); | 83 | memset(&mrq, 0, sizeof(struct mmc_request)); |
84 | 84 | ||
85 | err = mmc_app_cmd(host, card); | 85 | err = mmc_app_cmd(host, card); |
86 | if (err != MMC_ERR_NONE) | 86 | if (err) |
87 | continue; | 87 | continue; |
88 | 88 | ||
89 | memset(&mrq, 0, sizeof(struct mmc_request)); | 89 | memset(&mrq, 0, sizeof(struct mmc_request)); |
@@ -97,7 +97,7 @@ int mmc_wait_for_app_cmd(struct mmc_host *host, struct mmc_card *card, | |||
97 | mmc_wait_for_req(host, &mrq); | 97 | mmc_wait_for_req(host, &mrq); |
98 | 98 | ||
99 | err = cmd->error; | 99 | err = cmd->error; |
100 | if (cmd->error == MMC_ERR_NONE) | 100 | if (!cmd->error) |
101 | break; | 101 | break; |
102 | } | 102 | } |
103 | 103 | ||
@@ -127,14 +127,14 @@ int mmc_app_set_bus_width(struct mmc_card *card, int width) | |||
127 | cmd.arg = SD_BUS_WIDTH_4; | 127 | cmd.arg = SD_BUS_WIDTH_4; |
128 | break; | 128 | break; |
129 | default: | 129 | default: |
130 | return MMC_ERR_INVALID; | 130 | return -EINVAL; |
131 | } | 131 | } |
132 | 132 | ||
133 | err = mmc_wait_for_app_cmd(card->host, card, &cmd, MMC_CMD_RETRIES); | 133 | err = mmc_wait_for_app_cmd(card->host, card, &cmd, MMC_CMD_RETRIES); |
134 | if (err != MMC_ERR_NONE) | 134 | if (err) |
135 | return err; | 135 | return err; |
136 | 136 | ||
137 | return MMC_ERR_NONE; | 137 | return 0; |
138 | } | 138 | } |
139 | 139 | ||
140 | int mmc_send_app_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr) | 140 | int mmc_send_app_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr) |
@@ -152,13 +152,13 @@ int mmc_send_app_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr) | |||
152 | 152 | ||
153 | for (i = 100; i; i--) { | 153 | for (i = 100; i; i--) { |
154 | err = mmc_wait_for_app_cmd(host, NULL, &cmd, MMC_CMD_RETRIES); | 154 | err = mmc_wait_for_app_cmd(host, NULL, &cmd, MMC_CMD_RETRIES); |
155 | if (err != MMC_ERR_NONE) | 155 | if (err) |
156 | break; | 156 | break; |
157 | 157 | ||
158 | if (cmd.resp[0] & MMC_CARD_BUSY || ocr == 0) | 158 | if (cmd.resp[0] & MMC_CARD_BUSY || ocr == 0) |
159 | break; | 159 | break; |
160 | 160 | ||
161 | err = MMC_ERR_TIMEOUT; | 161 | err = -ETIMEDOUT; |
162 | 162 | ||
163 | mmc_delay(10); | 163 | mmc_delay(10); |
164 | } | 164 | } |
@@ -185,13 +185,13 @@ int mmc_send_if_cond(struct mmc_host *host, u32 ocr) | |||
185 | cmd.flags = MMC_RSP_R7 | MMC_CMD_BCR; | 185 | cmd.flags = MMC_RSP_R7 | MMC_CMD_BCR; |
186 | 186 | ||
187 | err = mmc_wait_for_cmd(host, &cmd, 0); | 187 | err = mmc_wait_for_cmd(host, &cmd, 0); |
188 | if (err != MMC_ERR_NONE) | 188 | if (err) |
189 | return err; | 189 | return err; |
190 | 190 | ||
191 | if ((cmd.resp[0] & 0xFF) != test_pattern) | 191 | if ((cmd.resp[0] & 0xFF) != test_pattern) |
192 | return MMC_ERR_FAILED; | 192 | return -EIO; |
193 | 193 | ||
194 | return MMC_ERR_NONE; | 194 | return 0; |
195 | } | 195 | } |
196 | 196 | ||
197 | int mmc_send_relative_addr(struct mmc_host *host, unsigned int *rca) | 197 | int mmc_send_relative_addr(struct mmc_host *host, unsigned int *rca) |
@@ -209,12 +209,12 @@ int mmc_send_relative_addr(struct mmc_host *host, unsigned int *rca) | |||
209 | cmd.flags = MMC_RSP_R6 | MMC_CMD_BCR; | 209 | cmd.flags = MMC_RSP_R6 | MMC_CMD_BCR; |
210 | 210 | ||
211 | err = mmc_wait_for_cmd(host, &cmd, MMC_CMD_RETRIES); | 211 | err = mmc_wait_for_cmd(host, &cmd, MMC_CMD_RETRIES); |
212 | if (err != MMC_ERR_NONE) | 212 | if (err) |
213 | return err; | 213 | return err; |
214 | 214 | ||
215 | *rca = cmd.resp[0] >> 16; | 215 | *rca = cmd.resp[0] >> 16; |
216 | 216 | ||
217 | return MMC_ERR_NONE; | 217 | return 0; |
218 | } | 218 | } |
219 | 219 | ||
220 | int mmc_app_send_scr(struct mmc_card *card, u32 *scr) | 220 | int mmc_app_send_scr(struct mmc_card *card, u32 *scr) |
@@ -230,7 +230,7 @@ int mmc_app_send_scr(struct mmc_card *card, u32 *scr) | |||
230 | BUG_ON(!scr); | 230 | BUG_ON(!scr); |
231 | 231 | ||
232 | err = mmc_app_cmd(card->host, card); | 232 | err = mmc_app_cmd(card->host, card); |
233 | if (err != MMC_ERR_NONE) | 233 | if (err) |
234 | return err; | 234 | return err; |
235 | 235 | ||
236 | memset(&mrq, 0, sizeof(struct mmc_request)); | 236 | memset(&mrq, 0, sizeof(struct mmc_request)); |
@@ -256,15 +256,15 @@ int mmc_app_send_scr(struct mmc_card *card, u32 *scr) | |||
256 | 256 | ||
257 | mmc_wait_for_req(card->host, &mrq); | 257 | mmc_wait_for_req(card->host, &mrq); |
258 | 258 | ||
259 | if (cmd.error != MMC_ERR_NONE) | 259 | if (cmd.error) |
260 | return cmd.error; | 260 | return cmd.error; |
261 | if (data.error != MMC_ERR_NONE) | 261 | if (data.error) |
262 | return data.error; | 262 | return data.error; |
263 | 263 | ||
264 | scr[0] = ntohl(scr[0]); | 264 | scr[0] = ntohl(scr[0]); |
265 | scr[1] = ntohl(scr[1]); | 265 | scr[1] = ntohl(scr[1]); |
266 | 266 | ||
267 | return MMC_ERR_NONE; | 267 | return 0; |
268 | } | 268 | } |
269 | 269 | ||
270 | int mmc_sd_switch(struct mmc_card *card, int mode, int group, | 270 | int mmc_sd_switch(struct mmc_card *card, int mode, int group, |
@@ -306,11 +306,11 @@ int mmc_sd_switch(struct mmc_card *card, int mode, int group, | |||
306 | 306 | ||
307 | mmc_wait_for_req(card->host, &mrq); | 307 | mmc_wait_for_req(card->host, &mrq); |
308 | 308 | ||
309 | if (cmd.error != MMC_ERR_NONE) | 309 | if (cmd.error) |
310 | return cmd.error; | 310 | return cmd.error; |
311 | if (data.error != MMC_ERR_NONE) | 311 | if (data.error) |
312 | return data.error; | 312 | return data.error; |
313 | 313 | ||
314 | return MMC_ERR_NONE; | 314 | return 0; |
315 | } | 315 | } |
316 | 316 | ||