rk: efuse: efuse_readregs return the number of bytes read when success
author黄涛 <huangtao@rock-chips.com>
Mon, 6 May 2013 05:07:23 +0000 (13:07 +0800)
committer黄涛 <huangtao@rock-chips.com>
Mon, 6 May 2013 05:07:23 +0000 (13:07 +0800)
arch/arm/plat-rk/efuse.c
arch/arm/plat-rk/include/plat/efuse.h

index a5ce5dbd91a2e77c42c8e87375195ec2dcf9fbc9..57c24df0897da013a81d0847e553531f84b2be2a 100644 (file)
 #define efuse_writel(val, offset)      writel_relaxed(val, RK30_EFUSE_BASE + offset)
 #endif
 
-int efuse_readregs(u32 addr, u32 length, u8 *pData)
+int efuse_readregs(u32 addr, u32 length, u8 *buf)
 {
-#ifdef efuse_readl
+#ifndef efuse_readl
+       return 0;
+#else
        unsigned long flags;
        static DEFINE_SPINLOCK(efuse_lock);
+       int ret = length;
 
        if (!length)
                return 0;
@@ -50,10 +53,10 @@ int efuse_readregs(u32 addr, u32 length, u8 *pData)
                udelay(2);
                efuse_writel(efuse_readl(REG_EFUSE_CTRL) | EFUSE_STROBE, REG_EFUSE_CTRL);
                udelay(2);
-               *pData = efuse_readl(REG_EFUSE_DOUT);
+               *buf = efuse_readl(REG_EFUSE_DOUT);
                efuse_writel(efuse_readl(REG_EFUSE_CTRL) & (~EFUSE_STROBE), REG_EFUSE_CTRL);
                udelay(2);
-               pData++;
+               buf++;
                addr++;
        } while(--length);
        udelay(2);
@@ -61,6 +64,6 @@ int efuse_readregs(u32 addr, u32 length, u8 *pData)
        udelay(1);
 
        spin_unlock_irqrestore(&efuse_lock, flags);
+       return ret;
 #endif
-       return 0;
 }
index 68f409b01bbaa243640b01a89c7b86aeb5e77442..44056f8467608b8c1c85e02622bdf0d84b446069 100644 (file)
@@ -3,6 +3,7 @@
 
 #include <asm/types.h>
 
-int efuse_readregs(u32 addr, u32 length, u8 *pData);
+/* On success, the number of bytes read is returned */
+int efuse_readregs(u32 addr, u32 length, u8 *buf);
 
 #endif