Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=7806cdb40fd562e5dcc07321579b62a5dc7cd95c
Commit:     7806cdb40fd562e5dcc07321579b62a5dc7cd95c
Parent:     d84075c8aed771d47d7ac6e96b098559da361c25
Author:     David Vrabel <[EMAIL PROTECTED]>
AuthorDate: Fri Aug 10 13:29:46 2007 +0100
Committer:  Pierre Ossman <[EMAIL PROTECTED]>
CommitDate: Sun Sep 23 21:24:27 2007 +0200

    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 <[EMAIL PROTECTED]>
    Signed-off-by: Pierre Ossman <[EMAIL PROTECTED]>
---
 drivers/mmc/core/sdio_io.c    |   64 +++++++++++++++++++++++++++++++++++++++++
 include/linux/mmc/sdio_func.h |    5 +++
 2 files changed, 69 insertions(+), 0 deletions(-)

diff --git a/drivers/mmc/core/sdio_io.c b/drivers/mmc/core/sdio_io.c
index 34b085d..625b92c 100644
--- a/drivers/mmc/core/sdio_io.c
+++ b/drivers/mmc/core/sdio_io.c
@@ -482,3 +482,67 @@ void sdio_writel(struct sdio_func *func, unsigned long b, 
unsigned int addr,
 }
 EXPORT_SYMBOL_GPL(sdio_writel);
 
+/**
+ *     sdio_f0_readb - read a single byte from SDIO function 0
+ *     @func: an SDIO function of the card
+ *     @addr: address to read
+ *     @err_ret: optional status value from transfer
+ *
+ *     Reads a single byte from the address space of SDIO function 0.
+ *     If there is a problem reading the address, 0xff is returned
+ *     and @err_ret will contain the error code.
+ */
+unsigned char sdio_f0_readb(struct sdio_func *func, unsigned int addr,
+       int *err_ret)
+{
+       int ret;
+       unsigned char val;
+
+       BUG_ON(!func);
+
+       if (err_ret)
+               *err_ret = 0;
+
+       ret = mmc_io_rw_direct(func->card, 0, 0, addr, 0, &val);
+       if (ret) {
+               if (err_ret)
+                       *err_ret = ret;
+               return 0xFF;
+       }
+
+       return val;
+}
+EXPORT_SYMBOL_GPL(sdio_f0_readb);
+
+/**
+ *     sdio_f0_writeb - write a single byte to SDIO function 0
+ *     @func: an SDIO function of the card
+ *     @b: byte to write
+ *     @addr: address to write to
+ *     @err_ret: optional status value from transfer
+ *
+ *     Writes a single byte to the address space of SDIO function 0.
+ *     @err_ret will contain the status of the actual transfer.
+ *
+ *     Only writes to the vendor specific CCCR registers (0xF0 -
+ *     0xFF) are permiited; @err_ret will be set to -EINVAL for *
+ *     writes outside this range.
+ */
+void sdio_f0_writeb(struct sdio_func *func, unsigned char b, unsigned int addr,
+       int *err_ret)
+{
+       int ret;
+
+       BUG_ON(!func);
+
+       if (addr < 0xF0 || addr > 0xFF) {
+               if (err_ret)
+                       *err_ret = -EINVAL;
+               return;
+       }
+
+       ret = mmc_io_rw_direct(func->card, 1, 0, addr, b, NULL);
+       if (err_ret)
+               *err_ret = ret;
+}
+EXPORT_SYMBOL_GPL(sdio_f0_writeb);
diff --git a/include/linux/mmc/sdio_func.h b/include/linux/mmc/sdio_func.h
index f057579..da6a96c 100644
--- a/include/linux/mmc/sdio_func.h
+++ b/include/linux/mmc/sdio_func.h
@@ -141,5 +141,10 @@ extern int sdio_memcpy_toio(struct sdio_func *func, 
unsigned int addr,
 extern int sdio_writesb(struct sdio_func *func, unsigned int addr,
        void *src, int count);
 
+extern unsigned char sdio_f0_readb(struct sdio_func *func,
+       unsigned int addr, int *err_ret);
+extern void sdio_f0_writeb(struct sdio_func *func, unsigned char b,
+       unsigned int addr, int *err_ret);
+
 #endif
 
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to