15
15
#include <linux/slab.h>
16
16
#include <linux/module.h>
17
17
#include <linux/bio.h>
18
- #include <linux/dma-direction.h>
19
18
#include <linux/crc7.h>
20
19
#include <linux/crc-itu-t.h>
21
20
#include <linux/scatterlist.h>
@@ -510,10 +509,7 @@ mmc_spi_command_send(struct mmc_spi_host *host,
510
509
* so we explicitly initialize it to all ones on RX paths.
511
510
*/
512
511
static void
513
- mmc_spi_setup_data_message (
514
- struct mmc_spi_host * host ,
515
- bool multiple ,
516
- enum dma_data_direction direction )
512
+ mmc_spi_setup_data_message (struct mmc_spi_host * host , bool multiple , bool write )
517
513
{
518
514
struct spi_transfer * t ;
519
515
struct scratch * scratch = host -> data ;
@@ -523,7 +519,7 @@ mmc_spi_setup_data_message(
523
519
/* for reads, readblock() skips 0xff bytes before finding
524
520
* the token; for writes, this transfer issues that token.
525
521
*/
526
- if (direction == DMA_TO_DEVICE ) {
522
+ if (write ) {
527
523
t = & host -> token ;
528
524
memset (t , 0 , sizeof (* t ));
529
525
t -> len = 1 ;
@@ -547,7 +543,7 @@ mmc_spi_setup_data_message(
547
543
t = & host -> crc ;
548
544
memset (t , 0 , sizeof (* t ));
549
545
t -> len = 2 ;
550
- if (direction == DMA_TO_DEVICE ) {
546
+ if (write ) {
551
547
/* the actual CRC may get written later */
552
548
t -> tx_buf = & scratch -> crc_val ;
553
549
} else {
@@ -570,10 +566,10 @@ mmc_spi_setup_data_message(
570
566
* the next token (next data block, or STOP_TRAN). We can try to
571
567
* minimize I/O ops by using a single read to collect end-of-busy.
572
568
*/
573
- if (multiple || direction == DMA_TO_DEVICE ) {
569
+ if (multiple || write ) {
574
570
t = & host -> early_status ;
575
571
memset (t , 0 , sizeof (* t ));
576
- t -> len = ( direction == DMA_TO_DEVICE ) ? sizeof (scratch -> status ) : 1 ;
572
+ t -> len = write ? sizeof (scratch -> status ) : 1 ;
577
573
t -> tx_buf = host -> ones ;
578
574
t -> rx_buf = scratch -> status ;
579
575
t -> cs_change = 1 ;
@@ -777,15 +773,15 @@ mmc_spi_data_do(struct mmc_spi_host *host, struct mmc_command *cmd,
777
773
{
778
774
struct spi_device * spi = host -> spi ;
779
775
struct spi_transfer * t ;
780
- enum dma_data_direction direction = mmc_get_dma_dir (data );
781
776
struct scatterlist * sg ;
782
777
unsigned n_sg ;
783
778
bool multiple = (data -> blocks > 1 );
784
- const char * write_or_read = (direction == DMA_TO_DEVICE ) ? "write" : "read" ;
779
+ bool write = (data -> flags & MMC_DATA_WRITE );
780
+ const char * write_or_read = write ? "write" : "read" ;
785
781
u32 clock_rate ;
786
782
unsigned long timeout ;
787
783
788
- mmc_spi_setup_data_message (host , multiple , direction );
784
+ mmc_spi_setup_data_message (host , multiple , write );
789
785
t = & host -> t ;
790
786
791
787
if (t -> speed_hz )
@@ -807,7 +803,7 @@ mmc_spi_data_do(struct mmc_spi_host *host, struct mmc_command *cmd,
807
803
808
804
/* allow pio too; we don't allow highmem */
809
805
kmap_addr = kmap (sg_page (sg ));
810
- if (direction == DMA_TO_DEVICE )
806
+ if (write )
811
807
t -> tx_buf = kmap_addr + sg -> offset ;
812
808
else
813
809
t -> rx_buf = kmap_addr + sg -> offset ;
@@ -818,7 +814,7 @@ mmc_spi_data_do(struct mmc_spi_host *host, struct mmc_command *cmd,
818
814
819
815
dev_dbg (& spi -> dev , " %s block, %d bytes\n" , write_or_read , t -> len );
820
816
821
- if (direction == DMA_TO_DEVICE )
817
+ if (write )
822
818
status = mmc_spi_writeblock (host , t , timeout );
823
819
else
824
820
status = mmc_spi_readblock (host , t , timeout );
@@ -833,7 +829,9 @@ mmc_spi_data_do(struct mmc_spi_host *host, struct mmc_command *cmd,
833
829
}
834
830
835
831
/* discard mappings */
836
- if (direction == DMA_FROM_DEVICE )
832
+ if (write )
833
+ /* nothing to do */ ;
834
+ else
837
835
flush_dcache_page (sg_page (sg ));
838
836
kunmap (sg_page (sg ));
839
837
@@ -850,7 +848,7 @@ mmc_spi_data_do(struct mmc_spi_host *host, struct mmc_command *cmd,
850
848
* that can affect the STOP_TRAN logic. Complete (and current)
851
849
* MMC specs should sort that out before Linux starts using CMD23.
852
850
*/
853
- if (direction == DMA_TO_DEVICE && multiple ) {
851
+ if (write && multiple ) {
854
852
struct scratch * scratch = host -> data ;
855
853
int tmp ;
856
854
const unsigned statlen = sizeof (scratch -> status );
0 commit comments