| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * linux/drivers/mmc/sdio_ops.c |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * Copyright 2006-2007 Pierre Ossman |
|---|
| 5 | | - * |
|---|
| 6 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 7 | | - * it under the terms of the GNU General Public License as published by |
|---|
| 8 | | - * the Free Software Foundation; either version 2 of the License, or (at |
|---|
| 9 | | - * your option) any later version. |
|---|
| 10 | 6 | */ |
|---|
| 11 | 7 | |
|---|
| 12 | 8 | #include <linux/scatterlist.h> |
|---|
| .. | .. |
|---|
| 125 | 121 | struct sg_table sgtable; |
|---|
| 126 | 122 | unsigned int nents, left_size, i; |
|---|
| 127 | 123 | unsigned int seg_size = card->host->max_seg_size; |
|---|
| 124 | + int err; |
|---|
| 128 | 125 | |
|---|
| 129 | 126 | WARN_ON(blksz == 0); |
|---|
| 130 | 127 | |
|---|
| .. | .. |
|---|
| 174 | 171 | |
|---|
| 175 | 172 | mmc_set_data_timeout(&data, card); |
|---|
| 176 | 173 | |
|---|
| 174 | + mmc_pre_req(card->host, &mrq); |
|---|
| 175 | + |
|---|
| 177 | 176 | mmc_wait_for_req(card->host, &mrq); |
|---|
| 177 | + |
|---|
| 178 | + if (cmd.error) |
|---|
| 179 | + err = cmd.error; |
|---|
| 180 | + else if (data.error) |
|---|
| 181 | + err = data.error; |
|---|
| 182 | + else if (mmc_host_is_spi(card->host)) |
|---|
| 183 | + /* host driver already reported errors */ |
|---|
| 184 | + err = 0; |
|---|
| 185 | + else if (cmd.resp[0] & R5_ERROR) |
|---|
| 186 | + err = -EIO; |
|---|
| 187 | + else if (cmd.resp[0] & R5_FUNCTION_NUMBER) |
|---|
| 188 | + err = -EINVAL; |
|---|
| 189 | + else if (cmd.resp[0] & R5_OUT_OF_RANGE) |
|---|
| 190 | + err = -ERANGE; |
|---|
| 191 | + else |
|---|
| 192 | + err = 0; |
|---|
| 193 | + |
|---|
| 194 | + mmc_post_req(card->host, &mrq, err); |
|---|
| 178 | 195 | |
|---|
| 179 | 196 | if (nents > 1) |
|---|
| 180 | 197 | sg_free_table(&sgtable); |
|---|
| 181 | 198 | |
|---|
| 182 | | - if (cmd.error) |
|---|
| 183 | | - return cmd.error; |
|---|
| 184 | | - if (data.error) |
|---|
| 185 | | - return data.error; |
|---|
| 186 | | - |
|---|
| 187 | | - if (mmc_host_is_spi(card->host)) { |
|---|
| 188 | | - /* host driver already reported errors */ |
|---|
| 189 | | - } else { |
|---|
| 190 | | - if (cmd.resp[0] & R5_ERROR) |
|---|
| 191 | | - return -EIO; |
|---|
| 192 | | - if (cmd.resp[0] & R5_FUNCTION_NUMBER) |
|---|
| 193 | | - return -EINVAL; |
|---|
| 194 | | - if (cmd.resp[0] & R5_OUT_OF_RANGE) |
|---|
| 195 | | - return -ERANGE; |
|---|
| 196 | | - } |
|---|
| 197 | | - |
|---|
| 198 | | - return 0; |
|---|
| 199 | + return err; |
|---|
| 199 | 200 | } |
|---|
| 200 | 201 | |
|---|
| 201 | 202 | int sdio_reset(struct mmc_host *host) |
|---|