Skip to content

Commit eae343c

Browse files
committed
mmc: core: Convert mmc_align_data_size() into an SDIO specific function
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 <[email protected]> Reviewed-by: Avri Altman <[email protected]>
1 parent 9d2d243 commit eae343c

File tree

3 files changed

+21
-36
lines changed

3 files changed

+21
-36
lines changed

drivers/mmc/core/core.c

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -757,33 +757,6 @@ void mmc_set_data_timeout(struct mmc_data *data, const struct mmc_card *card)
757757
}
758758
EXPORT_SYMBOL(mmc_set_data_timeout);
759759

760-
/**
761-
* mmc_align_data_size - pads a transfer size to a more optimal value
762-
* @card: the MMC card associated with the data transfer
763-
* @sz: original transfer size
764-
*
765-
* Pads the original data size with a number of extra bytes in
766-
* order to avoid controller bugs and/or performance hits
767-
* (e.g. some controllers revert to PIO for certain sizes).
768-
*
769-
* Returns the improved size, which might be unmodified.
770-
*
771-
* Note that this function is only relevant when issuing a
772-
* single scatter gather entry.
773-
*/
774-
unsigned int mmc_align_data_size(struct mmc_card *card, unsigned int sz)
775-
{
776-
/*
777-
* FIXME: We don't have a system for the controller to tell
778-
* the core about its problems yet, so for now we just 32-bit
779-
* align the size.
780-
*/
781-
sz = ((sz + 3) / 4) * 4;
782-
783-
return sz;
784-
}
785-
EXPORT_SYMBOL(mmc_align_data_size);
786-
787760
/*
788761
* Allow claiming an already claimed host if the context is the same or there is
789762
* no context but the task is the same.

drivers/mmc/core/sdio_io.c

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
*/
1111

1212
#include <linux/export.h>
13+
#include <linux/kernel.h>
1314
#include <linux/mmc/host.h>
1415
#include <linux/mmc/card.h>
1516
#include <linux/mmc/sdio.h>
@@ -203,6 +204,21 @@ static inline unsigned int sdio_max_byte_size(struct sdio_func *func)
203204
return min(mval, 512u); /* maximum size for byte mode */
204205
}
205206

207+
/*
208+
* This is legacy code, which needs to be re-worked some day. Basically we need
209+
* to take into account the properties of the host, as to enable the SDIO func
210+
* driver layer to allocate optimal buffers.
211+
*/
212+
static inline unsigned int _sdio_align_size(unsigned int sz)
213+
{
214+
/*
215+
* FIXME: We don't have a system for the controller to tell
216+
* the core about its problems yet, so for now we just 32-bit
217+
* align the size.
218+
*/
219+
return ALIGN(sz, 4);
220+
}
221+
206222
/**
207223
* sdio_align_size - pads a transfer size to a more optimal value
208224
* @func: SDIO function
@@ -230,7 +246,7 @@ unsigned int sdio_align_size(struct sdio_func *func, unsigned int sz)
230246
* wants to increase the size up to a point where it
231247
* might need more than one block.
232248
*/
233-
sz = mmc_align_data_size(func->card, sz);
249+
sz = _sdio_align_size(sz);
234250

235251
/*
236252
* 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)
252268
*/
253269
blk_sz = ((sz + func->cur_blksize - 1) /
254270
func->cur_blksize) * func->cur_blksize;
255-
blk_sz = mmc_align_data_size(func->card, blk_sz);
271+
blk_sz = _sdio_align_size(blk_sz);
256272

257273
/*
258274
* 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)
265281
* We failed to do one request, but at least try to
266282
* pad the remainder properly.
267283
*/
268-
byte_sz = mmc_align_data_size(func->card,
269-
sz % func->cur_blksize);
284+
byte_sz = _sdio_align_size(sz % func->cur_blksize);
270285
if (byte_sz <= sdio_max_byte_size(func)) {
271286
blk_sz = sz / func->cur_blksize;
272287
return blk_sz * func->cur_blksize + byte_sz;
@@ -276,16 +291,14 @@ unsigned int sdio_align_size(struct sdio_func *func, unsigned int sz)
276291
* We need multiple requests, so first check that the
277292
* controller can handle the chunk size;
278293
*/
279-
chunk_sz = mmc_align_data_size(func->card,
280-
sdio_max_byte_size(func));
294+
chunk_sz = _sdio_align_size(sdio_max_byte_size(func));
281295
if (chunk_sz == sdio_max_byte_size(func)) {
282296
/*
283297
* Fix up the size of the remainder (if any)
284298
*/
285299
byte_sz = orig_sz % chunk_sz;
286300
if (byte_sz) {
287-
byte_sz = mmc_align_data_size(func->card,
288-
byte_sz);
301+
byte_sz = _sdio_align_size(byte_sz);
289302
}
290303

291304
return (orig_sz / chunk_sz) * chunk_sz + byte_sz;

drivers/mmc/core/sdio_ops.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ int mmc_io_rw_direct(struct mmc_card *card, int write, unsigned fn,
2525
int mmc_io_rw_extended(struct mmc_card *card, int write, unsigned fn,
2626
unsigned addr, int incr_addr, u8 *buf, unsigned blocks, unsigned blksz);
2727
int sdio_reset(struct mmc_host *host);
28-
unsigned int mmc_align_data_size(struct mmc_card *card, unsigned int sz);
2928
void sdio_irq_work(struct work_struct *work);
3029

3130
static inline bool sdio_is_io_busy(u32 opcode, u32 arg)

0 commit comments

Comments
 (0)