.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * linux/drivers/mmc/core/sdio_io.c |
---|
3 | 4 | * |
---|
4 | 5 | * Copyright 2007-2008 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/export.h> |
---|
| 9 | +#include <linux/kernel.h> |
---|
13 | 10 | #include <linux/mmc/host.h> |
---|
14 | 11 | #include <linux/mmc/card.h> |
---|
15 | 12 | #include <linux/mmc/sdio.h> |
---|
.. | .. |
---|
136 | 133 | |
---|
137 | 134 | err: |
---|
138 | 135 | pr_debug("SDIO: Failed to disable device %s\n", sdio_func_id(func)); |
---|
139 | | - return -EIO; |
---|
| 136 | + return ret; |
---|
140 | 137 | } |
---|
141 | 138 | EXPORT_SYMBOL_GPL(sdio_disable_func); |
---|
142 | 139 | |
---|
.. | .. |
---|
204 | 201 | return min(mval, 512u); /* maximum size for byte mode */ |
---|
205 | 202 | } |
---|
206 | 203 | |
---|
| 204 | +/* |
---|
| 205 | + * This is legacy code, which needs to be re-worked some day. Basically we need |
---|
| 206 | + * to take into account the properties of the host, as to enable the SDIO func |
---|
| 207 | + * driver layer to allocate optimal buffers. |
---|
| 208 | + */ |
---|
| 209 | +static inline unsigned int _sdio_align_size(unsigned int sz) |
---|
| 210 | +{ |
---|
| 211 | + /* |
---|
| 212 | + * FIXME: We don't have a system for the controller to tell |
---|
| 213 | + * the core about its problems yet, so for now we just 32-bit |
---|
| 214 | + * align the size. |
---|
| 215 | + */ |
---|
| 216 | + return ALIGN(sz, 4); |
---|
| 217 | +} |
---|
| 218 | + |
---|
207 | 219 | /** |
---|
208 | 220 | * sdio_align_size - pads a transfer size to a more optimal value |
---|
209 | 221 | * @func: SDIO function |
---|
.. | .. |
---|
231 | 243 | * wants to increase the size up to a point where it |
---|
232 | 244 | * might need more than one block. |
---|
233 | 245 | */ |
---|
234 | | - sz = mmc_align_data_size(func->card, sz); |
---|
| 246 | + sz = _sdio_align_size(sz); |
---|
235 | 247 | |
---|
236 | 248 | /* |
---|
237 | 249 | * If we can still do this with just a byte transfer, then |
---|
.. | .. |
---|
253 | 265 | */ |
---|
254 | 266 | blk_sz = ((sz + func->cur_blksize - 1) / |
---|
255 | 267 | func->cur_blksize) * func->cur_blksize; |
---|
256 | | - blk_sz = mmc_align_data_size(func->card, blk_sz); |
---|
| 268 | + blk_sz = _sdio_align_size(blk_sz); |
---|
257 | 269 | |
---|
258 | 270 | /* |
---|
259 | 271 | * This value is only good if it is still just |
---|
.. | .. |
---|
266 | 278 | * We failed to do one request, but at least try to |
---|
267 | 279 | * pad the remainder properly. |
---|
268 | 280 | */ |
---|
269 | | - byte_sz = mmc_align_data_size(func->card, |
---|
270 | | - sz % func->cur_blksize); |
---|
| 281 | + byte_sz = _sdio_align_size(sz % func->cur_blksize); |
---|
271 | 282 | if (byte_sz <= sdio_max_byte_size(func)) { |
---|
272 | 283 | blk_sz = sz / func->cur_blksize; |
---|
273 | 284 | return blk_sz * func->cur_blksize + byte_sz; |
---|
.. | .. |
---|
277 | 288 | * We need multiple requests, so first check that the |
---|
278 | 289 | * controller can handle the chunk size; |
---|
279 | 290 | */ |
---|
280 | | - chunk_sz = mmc_align_data_size(func->card, |
---|
281 | | - sdio_max_byte_size(func)); |
---|
| 291 | + chunk_sz = _sdio_align_size(sdio_max_byte_size(func)); |
---|
282 | 292 | if (chunk_sz == sdio_max_byte_size(func)) { |
---|
283 | 293 | /* |
---|
284 | 294 | * Fix up the size of the remainder (if any) |
---|
285 | 295 | */ |
---|
286 | 296 | byte_sz = orig_sz % chunk_sz; |
---|
287 | 297 | if (byte_sz) { |
---|
288 | | - byte_sz = mmc_align_data_size(func->card, |
---|
289 | | - byte_sz); |
---|
| 298 | + byte_sz = _sdio_align_size(byte_sz); |
---|
290 | 299 | } |
---|
291 | 300 | |
---|
292 | 301 | return (orig_sz / chunk_sz) * chunk_sz + byte_sz; |
---|
.. | .. |
---|
700 | 709 | /** |
---|
701 | 710 | * sdio_set_host_pm_flags - set wanted host power management capabilities |
---|
702 | 711 | * @func: SDIO function attached to host |
---|
| 712 | + * @flags: Power Management flags to set |
---|
703 | 713 | * |
---|
704 | 714 | * Set a capability bitmask corresponding to wanted host controller |
---|
705 | 715 | * power management features for the upcoming suspend state. |
---|