Posted on 2008-05-04 21:21
天衣有缝 阅读(1171)
评论(0) 编辑 收藏 引用 所属分类:
program
转载请声明原创:http://www.cppblog.com/jinglexy
MSN: jinglexy at yahoo dot com dot cn
it's simple, we just use the vfs func:
char *fw_read_helper(u32* len)
{
int ret;
int fd1;
char *p = NULL;
mm_segment_t fs;
fs = get_fs();
set_fs(KERNEL_DS);
if(NULL == (p = kmalloc(FW_SIZE_HELPER, GFP_KERNEL))) {
dpline();
return NULL;
}
fd1 = sys_open("/helper_gspi.bin", O_RDONLY, S_IRWXU);
if(fd1 < 0) {
kfree(p);
dpline();
printk("fd is %d\n", fd1);
return NULL;
}
ret = sys_read(fd1, p, FW_SIZE_HELPER);
if(ret <= 0) {
kfree(p);
sys_close(fd1);
dpline();
return NULL;
}
sys_close(fd1);
set_fs(fs);
*len = ret;
return p;
*len = sizeof(helperimage);
return helperimage;
}