转载请声明原创:http://jinglexy.cublog.cn
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;
}
阅读(1866) | 评论(2) | 转发(0) |