hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/mmc/core/sdio_io.c
....@@ -1,15 +1,12 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * linux/drivers/mmc/core/sdio_io.c
34 *
45 * 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.
106 */
117
128 #include <linux/export.h>
9
+#include <linux/kernel.h>
1310 #include <linux/mmc/host.h>
1411 #include <linux/mmc/card.h>
1512 #include <linux/mmc/sdio.h>
....@@ -136,7 +133,7 @@
136133
137134 err:
138135 pr_debug("SDIO: Failed to disable device %s\n", sdio_func_id(func));
139
- return -EIO;
136
+ return ret;
140137 }
141138 EXPORT_SYMBOL_GPL(sdio_disable_func);
142139
....@@ -204,6 +201,21 @@
204201 return min(mval, 512u); /* maximum size for byte mode */
205202 }
206203
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
+
207219 /**
208220 * sdio_align_size - pads a transfer size to a more optimal value
209221 * @func: SDIO function
....@@ -231,7 +243,7 @@
231243 * wants to increase the size up to a point where it
232244 * might need more than one block.
233245 */
234
- sz = mmc_align_data_size(func->card, sz);
246
+ sz = _sdio_align_size(sz);
235247
236248 /*
237249 * If we can still do this with just a byte transfer, then
....@@ -253,7 +265,7 @@
253265 */
254266 blk_sz = ((sz + func->cur_blksize - 1) /
255267 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);
257269
258270 /*
259271 * This value is only good if it is still just
....@@ -266,8 +278,7 @@
266278 * We failed to do one request, but at least try to
267279 * pad the remainder properly.
268280 */
269
- byte_sz = mmc_align_data_size(func->card,
270
- sz % func->cur_blksize);
281
+ byte_sz = _sdio_align_size(sz % func->cur_blksize);
271282 if (byte_sz <= sdio_max_byte_size(func)) {
272283 blk_sz = sz / func->cur_blksize;
273284 return blk_sz * func->cur_blksize + byte_sz;
....@@ -277,16 +288,14 @@
277288 * We need multiple requests, so first check that the
278289 * controller can handle the chunk size;
279290 */
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));
282292 if (chunk_sz == sdio_max_byte_size(func)) {
283293 /*
284294 * Fix up the size of the remainder (if any)
285295 */
286296 byte_sz = orig_sz % chunk_sz;
287297 if (byte_sz) {
288
- byte_sz = mmc_align_data_size(func->card,
289
- byte_sz);
298
+ byte_sz = _sdio_align_size(byte_sz);
290299 }
291300
292301 return (orig_sz / chunk_sz) * chunk_sz + byte_sz;
....@@ -700,6 +709,7 @@
700709 /**
701710 * sdio_set_host_pm_flags - set wanted host power management capabilities
702711 * @func: SDIO function attached to host
712
+ * @flags: Power Management flags to set
703713 *
704714 * Set a capability bitmask corresponding to wanted host controller
705715 * power management features for the upcoming suspend state.