Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

sdio: add sdio_f0_readb() and sdio_f0_writeb()

Add sdio_f0_readb() and sdio_f0_writeb() functions to reading and
writing function 0 registers. Writes outside the vendor specific CCCR
registers (0xF0 - 0xFF) are not permitted.

Signed-off-by: David Vrabel <david.vrabel@csr.com>
Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>

authored by

David Vrabel and committed by
Pierre Ossman
7806cdb4 d84075c8

+69
+64
drivers/mmc/core/sdio_io.c
··· 482 482 } 483 483 EXPORT_SYMBOL_GPL(sdio_writel); 484 484 485 + /** 486 + * sdio_f0_readb - read a single byte from SDIO function 0 487 + * @func: an SDIO function of the card 488 + * @addr: address to read 489 + * @err_ret: optional status value from transfer 490 + * 491 + * Reads a single byte from the address space of SDIO function 0. 492 + * If there is a problem reading the address, 0xff is returned 493 + * and @err_ret will contain the error code. 494 + */ 495 + unsigned char sdio_f0_readb(struct sdio_func *func, unsigned int addr, 496 + int *err_ret) 497 + { 498 + int ret; 499 + unsigned char val; 500 + 501 + BUG_ON(!func); 502 + 503 + if (err_ret) 504 + *err_ret = 0; 505 + 506 + ret = mmc_io_rw_direct(func->card, 0, 0, addr, 0, &val); 507 + if (ret) { 508 + if (err_ret) 509 + *err_ret = ret; 510 + return 0xFF; 511 + } 512 + 513 + return val; 514 + } 515 + EXPORT_SYMBOL_GPL(sdio_f0_readb); 516 + 517 + /** 518 + * sdio_f0_writeb - write a single byte to SDIO function 0 519 + * @func: an SDIO function of the card 520 + * @b: byte to write 521 + * @addr: address to write to 522 + * @err_ret: optional status value from transfer 523 + * 524 + * Writes a single byte to the address space of SDIO function 0. 525 + * @err_ret will contain the status of the actual transfer. 526 + * 527 + * Only writes to the vendor specific CCCR registers (0xF0 - 528 + * 0xFF) are permiited; @err_ret will be set to -EINVAL for * 529 + * writes outside this range. 530 + */ 531 + void sdio_f0_writeb(struct sdio_func *func, unsigned char b, unsigned int addr, 532 + int *err_ret) 533 + { 534 + int ret; 535 + 536 + BUG_ON(!func); 537 + 538 + if (addr < 0xF0 || addr > 0xFF) { 539 + if (err_ret) 540 + *err_ret = -EINVAL; 541 + return; 542 + } 543 + 544 + ret = mmc_io_rw_direct(func->card, 1, 0, addr, b, NULL); 545 + if (err_ret) 546 + *err_ret = ret; 547 + } 548 + EXPORT_SYMBOL_GPL(sdio_f0_writeb);
+5
include/linux/mmc/sdio_func.h
··· 141 141 extern int sdio_writesb(struct sdio_func *func, unsigned int addr, 142 142 void *src, int count); 143 143 144 + extern unsigned char sdio_f0_readb(struct sdio_func *func, 145 + unsigned int addr, int *err_ret); 146 + extern void sdio_f0_writeb(struct sdio_func *func, unsigned char b, 147 + unsigned int addr, int *err_ret); 148 + 144 149 #endif 145 150