int bma250_set_fast_calibration_x(struct i2c_client *client,unsigned char target)
{
	signed char tmp;
	unsigned char timeout = 0;

	bma250_set_offset_target_x(client,target);

	bma250_set_cal_trigger(client,1);

	do {
		msleep(4);
		tmp = bma250_get_cal_ready(client);

		//printk(KERN_INFO "wait 2ms and got cal ready flag is %d\n",tmp);
		timeout++;
		if(timeout==100) {
			printk(KERN_INFO "get fast calibration ready error\n");
			return -EINVAL;
		};

	}while(tmp==0);

	printk(KERN_INFO "x axis fast calibration finished\n");
	return 0;
}
static ssize_t bma250_fast_calibration_x_store(struct device *dev,
		struct device_attribute *attr,
		const char *buf, size_t count)
{
	unsigned long data;
	signed char tmp;
	unsigned int timeout = 0;
	int error;
	struct i2c_client *client = to_i2c_client(dev);
	struct bma250_data *bma250 = i2c_get_clientdata(client);

	error = strict_strtoul(buf, 10, &data);
	if (error)
		return error;

	if (bma250_set_offset_target_x(bma250->bma250_client,
				(unsigned char)data) < 0)
		return -EINVAL;

	if (bma250_set_cal_trigger(bma250->bma250_client, 1) < 0)
		return -EINVAL;

	do {
		mdelay(2);
		bma250_get_cal_ready(bma250->bma250_client, &tmp);

		printk(KERN_INFO "wait 2ms and got cal ready flag is %d\n",
				tmp);
		timeout++;
		if (timeout == 1000) {
			printk(KERN_INFO "get fast calibration ready error\n");
			return -EINVAL;
		};

	} while (tmp == 0);

	printk(KERN_INFO "x axis fast calibration finished\n");
	return count;
}
static ssize_t bma250_fast_calibration_x_store(struct device *dev,
		struct device_attribute *attr,
		const char *buf, size_t count)
{
	unsigned long data;
	signed char tmp;
	unsigned int timeout = 0;
	int error;
	struct i2c_client *client = to_i2c_client(dev);
	struct bma250_data *bma250 = i2c_get_clientdata(client);
	struct bma250acc acc_cal;
	struct bma250acc acc_cal_pre; 

	error = strict_strtoul(buf, 10, &data);
	if (error)
		return error;
	
	bma250_read_accel_xyz(bma250->bma250_client, &acc_cal_pre);
	mdelay(50);

	if (bma250_set_offset_target_x(bma250->bma250_client,
				(unsigned char)data) < 0)
		{		
 		return -EINVAL;
		}

	if (bma250_set_cal_trigger(bma250->bma250_client, 1) < 0)
		{
 		return -EINVAL;
		}

	atomic_set(&bma250->fast_calib_x_rslt, 0);

	do {
		mdelay(2);
		bma250_get_cal_ready(bma250->bma250_client, &tmp);

		bma250_read_accel_xyz(bma250->bma250_client, &acc_cal);

		if( (tmp == 0)	&&
			((abs(acc_cal.x - acc_cal_pre.x) > BMA250_SHAKING_DETECT_THRESHOLD)
				|| (abs((acc_cal.y - acc_cal_pre.y)) > BMA250_SHAKING_DETECT_THRESHOLD)
				|| (abs((acc_cal.z - acc_cal_pre.z)) > BMA250_SHAKING_DETECT_THRESHOLD))
		  )
		{			
			return count;
		}
		else
		{
			acc_cal_pre.x = acc_cal.x;
			acc_cal_pre.y = acc_cal.y;
			acc_cal_pre.z = acc_cal.z;
		}


		printk(KERN_INFO "wait 2ms and got cal ready flag is %d\n",
				tmp);
		timeout++;
		if (timeout == 1000) {
			printk(KERN_INFO "get fast calibration ready error\n");
			return -EINVAL;
		};

	} while (tmp == 0);

	atomic_set(&bma250->fast_calib_x_rslt, 1);

	printk(KERN_INFO "x axis fast calibration finished\n");
	return count;
}