//20120730 +++++Emily add for firmware upgrade

#include <linux/fs.h>

#include <linux/file.h>

#include <linux/types.h>

#include <linux/unistd.h>

#include <asm/uaccess.h>

#define MY_FILE "/tmp/flashStatus"

unsigned int flashStatus=0;

//20120730 -----Emily add for firmware upgrade

struct file *filp = NULL;

char buf[8]="";

mm_segment_t old_fs; //Emily

if(filp == NULL)

filp = filp_open(MY_FILE, O_RDWR | O_CREAT, 0644);

if (IS_ERR(filp)) {

printk("spi_flash.c error occured while opening file %s, exiting...\n", MY_FILE);

}

old_fs = get_fs();

set_fs(KERNEL_DS);

flashStatus=3;

sprintf(buf, "%x", flashStatus);

if (!IS_ERR(filp)) {

filp->f_op->write(filp, (char *)buf, sizeof(buf), &filp->f_pos);

}

flashStatus=1;

sprintf(buf, "%x", flashStatus);

if (!IS_ERR(filp)) {

filp->f_op->llseek(filp,0,0); // 把指標移到檔案開始,再寫值

filp->f_op->write(filp, (char *)buf, sizeof(buf), &filp->f_pos);

}

set_fs(old_fs);

if(filp != NULL)

filp_close(filp, NULL);

文章標籤
創作者介紹
創作者 Yisin 的頭像
Yisin

欣情巧克力

Yisin 發表在 痞客邦 留言(0) 人氣()