]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
mmc: core: Convert mmc_align_data_size() into an SDIO specific function
authorUlf Hansson <ulf.hansson@linaro.org>
Wed, 13 Feb 2019 19:03:30 +0000 (20:03 +0100)
committerUlf Hansson <ulf.hansson@linaro.org>
Mon, 25 Feb 2019 16:20:21 +0000 (17:20 +0100)
The only user of mmc_align_data_size() is sdio_align_size(), which is
called from SDIO func drivers to let them distinguish, how to optimally
allocate data buffers.

Let's move mmc_align_data_size() close to the SDIO code as to make it
static, rename it to _sdio_align_size() and simplify its definition, all
with the purpose of clarifying that this is SDIO specific.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Reviewed-by: Avri Altman <avri.altman@wdc.com>
drivers/mmc/core/core.c
drivers/mmc/core/sdio_io.c
drivers/mmc/core/sdio_ops.h

index 659eb32c0246ce5641ec51f43e32ecef816d68e0..b45aaa9041078a55d69f910efc4fa64e7d64a03f 100644 (file)
@@ -757,33 +757,6 @@ void mmc_set_data_timeout(struct mmc_data *data, const struct mmc_card *card)
 }
 EXPORT_SYMBOL(mmc_set_data_timeout);
 
-/**
- *     mmc_align_data_size - pads a transfer size to a more optimal value
- *     @card: the MMC card associated with the data transfer
- *     @sz: original transfer size
- *
- *     Pads the original data size with a number of extra bytes in
- *     order to avoid controller bugs and/or performance hits
- *     (e.g. some controllers revert to PIO for certain sizes).
- *
- *     Returns the improved size, which might be unmodified.
- *
- *     Note that this function is only relevant when issuing a
- *     single scatter gather entry.
- */
-unsigned int mmc_align_data_size(struct mmc_card *card, unsigned int sz)
-{
-       /*
-        * FIXME: We don't have a system for the controller to tell
-        * the core about its problems yet, so for now we just 32-bit
-        * align the size.
-        */
-       sz = ((sz + 3) / 4) * 4;
-
-       return sz;
-}
-EXPORT_SYMBOL(mmc_align_data_size);
-
 /*
  * Allow claiming an already claimed host if the context is the same or there is
  * no context but the task is the same.
index d40744bbafa9a95e7a36bd8efb980ac9a78c2f1e..3f67fbbe0d754c7fe24b68cc3d1eac40a354094e 100644 (file)
@@ -10,6 +10,7 @@
  */
 
 #include <linux/export.h>
+#include <linux/kernel.h>
 #include <linux/mmc/host.h>
 #include <linux/mmc/card.h>
 #include <linux/mmc/sdio.h>
@@ -203,6 +204,21 @@ static inline unsigned int sdio_max_byte_size(struct sdio_func *func)
        return min(mval, 512u); /* maximum size for byte mode */
 }
 
+/*
+ * This is legacy code, which needs to be re-worked some day. Basically we need
+ * to take into account the properties of the host, as to enable the SDIO func
+ * driver layer to allocate optimal buffers.
+ */
+static inline unsigned int _sdio_align_size(unsigned int sz)
+{
+       /*
+        * FIXME: We don't have a system for the controller to tell
+        * the core about its problems yet, so for now we just 32-bit
+        * align the size.
+        */
+       return ALIGN(sz, 4);
+}
+
 /**
  *     sdio_align_size - pads a transfer size to a more optimal value
  *     @func: SDIO function
@@ -230,7 +246,7 @@ unsigned int sdio_align_size(struct sdio_func *func, unsigned int sz)
         * wants to increase the size up to a point where it
         * might need more than one block.
         */
-       sz = mmc_align_data_size(func->card, sz);
+       sz = _sdio_align_size(sz);
 
        /*
         * If we can still do this with just a byte transfer, then
@@ -252,7 +268,7 @@ unsigned int sdio_align_size(struct sdio_func *func, unsigned int sz)
                 */
                blk_sz = ((sz + func->cur_blksize - 1) /
                        func->cur_blksize) * func->cur_blksize;
-               blk_sz = mmc_align_data_size(func->card, blk_sz);
+               blk_sz = _sdio_align_size(blk_sz);
 
                /*
                 * This value is only good if it is still just
@@ -265,8 +281,7 @@ unsigned int sdio_align_size(struct sdio_func *func, unsigned int sz)
                 * We failed to do one request, but at least try to
                 * pad the remainder properly.
                 */
-               byte_sz = mmc_align_data_size(func->card,
-                               sz % func->cur_blksize);
+               byte_sz = _sdio_align_size(sz % func->cur_blksize);
                if (byte_sz <= sdio_max_byte_size(func)) {
                        blk_sz = sz / func->cur_blksize;
                        return blk_sz * func->cur_blksize + byte_sz;
@@ -276,16 +291,14 @@ unsigned int sdio_align_size(struct sdio_func *func, unsigned int sz)
                 * We need multiple requests, so first check that the
                 * controller can handle the chunk size;
                 */
-               chunk_sz = mmc_align_data_size(func->card,
-                               sdio_max_byte_size(func));
+               chunk_sz = _sdio_align_size(sdio_max_byte_size(func));
                if (chunk_sz == sdio_max_byte_size(func)) {
                        /*
                         * Fix up the size of the remainder (if any)
                         */
                        byte_sz = orig_sz % chunk_sz;
                        if (byte_sz) {
-                               byte_sz = mmc_align_data_size(func->card,
-                                               byte_sz);
+                               byte_sz = _sdio_align_size(byte_sz);
                        }
 
                        return (orig_sz / chunk_sz) * chunk_sz + byte_sz;
index 96945cafbf0be3b3175b2ae8f9f38bb6e9a3509f..1f6d0447ea0f9475f97715f1c9232359b4c64207 100644 (file)
@@ -25,7 +25,6 @@ int mmc_io_rw_direct(struct mmc_card *card, int write, unsigned fn,
 int mmc_io_rw_extended(struct mmc_card *card, int write, unsigned fn,
        unsigned addr, int incr_addr, u8 *buf, unsigned blocks, unsigned blksz);
 int sdio_reset(struct mmc_host *host);
-unsigned int mmc_align_data_size(struct mmc_card *card, unsigned int sz);
 void sdio_irq_work(struct work_struct *work);
 
 static inline bool sdio_is_io_busy(u32 opcode, u32 arg)