static ssize_t __efuse_write(const char *buf, size_t count, loff_t *ppos ) { unsigned pos = *ppos; loff_t *readppos = ppos; unsigned char *pc; char efuse_data[EFUSE_USERIDF_BYTES],null_data[EFUSE_USERIDF_BYTES]; if (pos >= EFUSE_BYTES) return 0; /* Past EOF */ if (count > EFUSE_BYTES - pos) count = EFUSE_BYTES - pos; if (count > EFUSE_BYTES) return -EFAULT; __efuse_read(efuse_data, count, readppos); memset(null_data,0,count); if(strncmp(efuse_data,null_data,count) != 0){ printk(" Data had written ,the block is not clean!!!\n"); return -EFAULT; } for (pc = buf; count--; ++pos, ++pc) __efuse_write_byte(pos, *pc); *ppos = pos; return (const char *)pc - buf; }
static u32 efuse_read(int blk_index) { u32 val; pr_debug("efuse read %d\n", blk_index); efuse_lock(); __efuse_power_on(); val = __efuse_read(blk_index); __efuse_power_off(); efuse_unlock(); return val; }
/* Sysfs Files */ int get_zt_mac(char *buf) { char buf_mac[6] = {0}; loff_t ppos = MAC_POS; __efuse_read(buf_mac, sizeof(buf_mac), &ppos); printk("get_zt_mac %x:%x:%x:%x:%x:%0x\n", buf_mac[0],buf_mac[1],buf_mac[2],buf_mac[3],buf_mac[4],buf_mac[5]); //memset(buf,buf_mac,sizeof(buf_mac)); buf[0] = buf_mac[0]; buf[1] = buf_mac[1]; buf[2] = buf_mac[2]; buf[3] = buf_mac[3]; buf[4] = buf_mac[4]; buf[5] = buf_mac[5]; //printk("get_zt_mac 2 %x:%x:%x:%x:%x:%0x\n", // buf[0],buf[1],buf[2],buf[3],buf[4],buf[5]); return 1; }