예제 #1
0
 static ssize_t efuse_write( struct file *file, const char __user *buf,
     size_t count, loff_t *ppos )
 {
         unsigned char contents[EFUSE_BYTES];
         unsigned pos = *ppos;
         unsigned char *pc;

         if (pos >= EFUSE_BYTES)
                 return 0;       /* Past EOF */

         if (count > EFUSE_BYTES - pos)
                 count = EFUSE_BYTES - pos;
         if (count > EFUSE_BYTES)
                 return -EFAULT;

     printk( KERN_INFO "efuse_write: f_pos: %lld, ppos: %lld\n", file->f_pos, *ppos);

         if (copy_from_user(contents, buf, count))
                 return -EFAULT;

         for (pc = contents; count--; ++pos, ++pc)
                 __efuse_write_byte(pos, *pc);

         *ppos = pos;

         return pc - contents;
 }
예제 #2
0
 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;
 }
예제 #3
0
int efuse_write(char *buf, unsigned count, unsigned *ppos, int from)
{
	unsigned pos = *ppos;
	const char *pc;
	unsigned long contents[EFUSE_DWORDS];
	
	if (pos >= EFUSE_BYTES)
		return 0;	/* Past EOF */
	if (count > EFUSE_BYTES - pos)
		count = EFUSE_BYTES - pos;
	if (count > EFUSE_BYTES)
		return -1;

	which=from;
	efuse_init();
	
	int i;	
	// checkout if have been written
	memset(contents, 0, EFUSE_DWORDS);
	pc = (char*)contents;
	efuse_read(pc, count, &pos, from);
	for(i=0; i<count; i++){
		if(pc[i] != 0)
			return -1;
	}
	
	pos = *ppos;
	for (pc = buf; count--; ++pos, ++pc)
		__efuse_write_byte(pos, *pc);
		
	*ppos = pos;
	
	return 0;	
}
예제 #4
0
static void efuse_write_byte(unsigned long addr, unsigned char data){
	efuse_init();
	unsigned int int_addr = addr;
	__efuse_write_byte(int_addr, (unsigned long)data);
}