static ssize_t sirf_write_proc(struct file *filp,
		const char *buff, size_t len, loff_t *off)
{
	char messages[256];
	int flag, ret;
	char buffer[7];

	if (len > 256)
		len = 256;

	if (copy_from_user(messages, buff, len))
		return -EFAULT;

	if (strncmp(messages, "off", 3) == 0) {
		strcpy(sirf_status, "off");
		gps_power_off();
	} else if (strncmp(messages, "on", 2) == 0) {
		strcpy(sirf_status, "on");
		gps_power_on();
	} else if (strncmp(messages, "reset", 5) == 0) {
		strcpy(sirf_status, messages);
		ret = sscanf(messages, "%s %d", buffer, &flag);
		if (ret == 2)
			gps_reset(flag);
	} else if (strncmp(messages, "sirfon", 5) == 0) {
		strcpy(sirf_status, messages);
		ret = sscanf(messages, "%s %d", buffer, &flag);
		if (ret == 2)
			gps_on_off(flag);
	} else {
		printk("usage: echo {on/off} > /proc/driver/sirf\n");
	}

	return len;
}
static void create_sirf_proc_file(void)
{
	struct proc_dir_entry *sirf_proc_file =
		create_proc_entry("driver/sirf", 0777, NULL);

	if (sirf_proc_file) {
		sirf_proc_file->read_proc = sirf_read_proc;
		sirf_proc_file->write_proc = (write_proc_t  *)sirf_write_proc;
	} else
		printk(KERN_INFO "proc file create failed!\n");
      gps_sirf_gpio_init();
      gps_power_on();
}
static ssize_t sirf_write_proc(struct file *filp,
		const char *buff, size_t len, loff_t *off)
{
	char messages[256];
	int flag, ret;
	char buffer[7];

	if (len > 255)
		len = 255;

	memset(messages, 0, sizeof(messages));
	
	if (!buff || copy_from_user(messages, buff, len))
		return -EFAULT;

	if (strlen(messages) > (SIRF_STATUS_LEN - 1)) {
		pr_warning("[ERROR] messages too long! (%d) %s\n",
			strlen(messages), messages);
		return -EFAULT;
	}

	if (strncmp(messages, "off", 3) == 0) {
		strcpy(sirf_status, "off");
		gps_power_off();
	} else if (strncmp(messages, "on", 2) == 0) {
		strcpy(sirf_status, "on");
		gps_power_on();
	} else if (strncmp(messages, "reset", 5) == 0) {
		strcpy(sirf_status, messages);
		ret = sscanf(messages, "%s %d", buffer, &flag);
		if (ret == 2){
			gps_reset(flag);
		}
	} else if (strncmp(messages, "sirfon", 6) == 0) {
		strcpy(sirf_status, messages);
		ret = sscanf(messages, "%s %d", buffer, &flag);
		if (ret == 2){
			gps_on_off(flag);
		}
	} else
		pr_info("usage: echo {on/off} > /proc/driver/sirf\n");

	return len;
}
static ssize_t gps_ctrl(struct device *dev,
			struct device_attribute *attr,
			const char *buf, size_t count)
{
	static char msg[256];
	int flag, ret;


	struct mmp_gps_info *info = dev_get_drvdata(dev);

	count = (count > 255) ? 255 : count;
	memset(msg, 0, count);

	sscanf(buf, "%s", info->chip_status);
	if (!strncmp(buf, "off", 3)) {
		strncpy(info->chip_status, "off", 4);
		gps_power_off(info);
	} else if (!strncmp(buf, "on", 2)) {
		strncpy(info->chip_status, "on", 3);
		gps_power_on(info);
	} else if (!strncmp(buf, "reset", 5)) {
		strncpy(info->chip_status, "reset", 6);
		ret = sscanf(buf, "%s %d", msg, &flag);
		if (ret == 2)
			gps_reset(info, flag);
	} else if (!strncmp(buf, "wakeup", 6)) {
		strncpy(info->chip_status, "wakeup", 7);
		ret = sscanf(buf, "%s %d", msg, &flag);
		if (ret == 2)
			gps_on_off(info, flag);
	} else if (!strncmp(buf, "eclk", 4)) {
		strncpy(info->chip_status, "eclk", 5);
		ret = sscanf(buf, "%s %d", msg, &flag);
		if (ret == 2)
			gps_eclk_ctrl(info, flag);
	} else
		dev_info(info->dev, "usage wrong\n");

	return count;
}