void bma220_set_offset_xyz(struct i2c_client *client,signed char x_offset, signed char y_offset,signed char z_offset) { signed char data[3]; bma220_set_cal_manual(client,1); data[0] = BMA220_SET_BITSLICE(0, BMA220_ACC_X, x_offset); data[1] = BMA220_SET_BITSLICE(0, BMA220_ACC_X, y_offset); data[2] = BMA220_SET_BITSLICE(0, BMA220_ACC_X, z_offset); sensor_dbg_d("bma220_set_offset_xyz %d, %d, %d %d, %d, %d \n", x_offset,y_offset,z_offset,data[0],data[1],data[2]); printk("bma220_set_offset_xyz %d, %d, %d %d, %d, %d \n", x_offset,y_offset,z_offset,data[0],data[1],data[2]); SENSOR_SEND_CMD(client,BMA220_OFFSET_X__REG,data[0]); SENSOR_SEND_CMD(client,BMA220_OFFSET_Y__REG,data[1]); SENSOR_SEND_CMD(client,BMA220_OFFSET_Z__REG,data[2]); bma220_set_cal_manual(client,0); }
/* ioctl command for BMA accel device file */ static int bma_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) { int err = 0; unsigned char data[6]; /* check cmd */ if(_IOC_TYPE(cmd) != BMA220_IOC_MAGIC) { #ifdef BMA_DEBUG printk("cmd magic type error\n"); #endif return -ENOTTY; } if(_IOC_NR(cmd) > BMA220_IOC_MAXNR) { #ifdef BMA_DEBUG printk("cmd number error\n"); #endif return -ENOTTY; } if(_IOC_DIR(cmd) & _IOC_READ) err = !access_ok(VERIFY_WRITE,(void __user*)arg, _IOC_SIZE(cmd)); else if(_IOC_DIR(cmd) & _IOC_WRITE) err = !access_ok(VERIFY_READ, (void __user*)arg, _IOC_SIZE(cmd)); if(err) { #ifdef BMA_DEBUG printk("cmd access_ok error\n"); #endif return -EFAULT; } /* check bam120_client */ if( bma_client == NULL) { #ifdef BMA_DEBUG printk("I2C driver not install\n"); #endif return -EFAULT; } /* cmd mapping */ switch(cmd) { case BMA220_SOFT_RESET: err = bma220_soft_reset(); return err; case BMA220_SET_SUSPEND: err = bma220_set_suspend(); return err; case BMA220_SET_OFFSET_TARGET_X: if(copy_from_user(data,(unsigned char*)arg,1)!=0) { #ifdef BMA_DEBUG printk("copy_from_user error\n"); #endif return -EFAULT; } err = bma220_set_offset_target_x(*data); return err; case BMA220_SET_OFFSET_TARGET_Y: if(copy_from_user(data,(unsigned char*)arg,1)!=0) { #ifdef BMA_DEBUG printk("copy_from_user error\n"); #endif return -EFAULT; } err = bma220_set_offset_target_y(*data); return err; case BMA220_SET_OFFSET_TARGET_Z: if(copy_from_user(data,(unsigned char*)arg,1)!=0) { #ifdef BMA_DEBUG printk("copy_from_user error\n"); #endif return -EFAULT; } err = bma220_set_offset_target_z(*data); return err; case BMA220_SET_RANGE: if(copy_from_user(data,(unsigned char*)arg,1)!=0) { #ifdef BMA_DEBUG printk("copy_from_user error\n"); #endif return -EFAULT; } err = bma220_set_range(*data); return err; case BMA220_GET_RANGE: err = bma220_get_range(data); if(copy_to_user((unsigned char*)arg,data,1)!=0) { #ifdef BMA_DEBUG printk("copy_to_user error\n"); #endif return -EFAULT; } return err; case BMA220_SET_MODE: if(copy_from_user(data,(unsigned char*)arg,1)!=0) { #ifdef BMA_DEBUG printk("copy_from_user error\n"); #endif return -EFAULT; } err = bma220_set_mode(*data); return err; case BMA220_GET_MODE: err = bma220_get_mode(data); if(copy_to_user((unsigned char*)arg,data,1)!=0) { #ifdef BMA_DEBUG printk("copy_to_user error\n"); #endif return -EFAULT; } return err; case BMA220_SET_BANDWIDTH: if(copy_from_user(data,(unsigned char*)arg,1)!=0) { #ifdef BMA_DEBUG printk("copy_from_user error\n"); #endif return -EFAULT; } err = bma220_set_bandwidth(*data); return err; case BMA220_GET_BANDWIDTH: err = bma220_get_bandwidth(data); if(copy_to_user((unsigned char*)arg,data,1)!=0) { #ifdef BMA_DEBUG printk("copy_to_user error\n"); #endif return -EFAULT; } return err; case BMA220_SET_LOW_TH: if(copy_from_user(data,(unsigned char*)arg,1)!=0) { #ifdef BMA_DEBUG printk("copy_from_user error\n"); #endif return -EFAULT; } err = bma220_set_low_th(*data); return err; case BMA220_SET_LOW_DUR: if(copy_from_user(data,(unsigned char*)arg,1)!=0) { #ifdef BMA_DEBUG printk("copy_from_user error\n"); #endif return -EFAULT; } err = bma220_set_low_dur(*data); return err; case BMA220_SET_HIGH_TH: if(copy_from_user(data,(unsigned char*)arg,1)!=0) { #ifdef BMA_DEBUG printk("copy_from_user error\n"); #endif return -EFAULT; } err = bma220_set_high_th(*data); return err; case BMA220_SET_HIGH_DUR: if(copy_from_user(data,(unsigned char*)arg,1)!=0) { #ifdef BMA_DEBUG printk("copy_from_user error\n"); #endif return -EFAULT; } err = bma220_set_high_dur(*data); return err; case BMA220_RESET_INTERRUPT: err = bma220_reset_int(); return err; case BMA220_READ_ACCEL_X: err = bma220_read_accel_x((signed char*)data); if(copy_to_user((signed char*)arg,(signed char*)data,1)!=0) { #ifdef BMA_DEBUG printk("copy_to_user error\n"); #endif return -EFAULT; } return err; case BMA220_READ_ACCEL_Y: err = bma220_read_accel_y((signed char*)data); if(copy_to_user((signed char*)arg,(signed char*)data,1)!=0) { #ifdef BMA_DEBUG printk("copy_to_user error\n"); #endif return -EFAULT; } return err; case BMA220_READ_ACCEL_Z: err = bma220_read_accel_z((signed char*)data); if(copy_to_user((signed char*)arg,(signed char*)data,1)!=0) { #ifdef BMA_DEBUG printk("copy_to_user error\n"); #endif return -EFAULT; } return err; case BMA220_SET_EN_LOW: if(copy_from_user(data,(unsigned char*)arg,1)!=0) { #ifdef BMA_DEBUG printk("copy_from_user error\n"); #endif return -EFAULT; } err = bma220_set_en_low(*data); return err; case BMA220_SET_EN_HIGH_XYZ: if(copy_from_user(data,(unsigned char*)arg,1)!=0) { #ifdef BMA_DEBUG printk("copy_from_user error\n"); #endif return -EFAULT; } err = bma220_set_en_high_xyz(*data); return err; case BMA220_SET_LATCH_INT: if(copy_from_user(data,(unsigned char*)arg,1)!=0) { #ifdef BMA_DEBUG printk("copy_from_user error\n"); #endif return -EFAULT; } err = bma220_set_latch_int(*data); return err; case BMA220_SET_LOW_HY: if(copy_from_user(data,(unsigned char*)arg,1)!=0) { #ifdef BMA_DEBUG printk("copy_from_user error\n"); #endif return -EFAULT; } err = bma220_set_low_hy(*data); return err; case BMA220_SET_HIGH_HY: if(copy_from_user(data,(unsigned char*)arg,1)!=0) { #ifdef BMA_DEBUG printk("copy_from_user error\n"); #endif return -EFAULT; } err = bma220_set_high_hy(*data); return err; case BMA220_READ_ACCEL_XYZ: if(sensor_type == BMA220) { err = bma220_read_accel_xyz((bma220acc_t*)data); if(copy_to_user((bma220acc_t*)arg,(bma220acc_t*)data,3)!=0) { #ifdef BMA_DEBUG printk("copy_to error\n"); #endif return -EFAULT; } }else if(sensor_type == BMA023) { err = bma023_read_accel_xyz((bma023acc_t*)data); //printk("[%s] read accel x = %d, y = %d, z = %d\n", __func__, ((bma023acc_t*)data)->x, ((bma023acc_t*)data)->y, ((bma023acc_t*)data)->z); if(copy_to_user((bma023acc_t*)arg,(bma023acc_t*)data,3*sizeof(short))!=0) { #ifdef BMA_DEBUG printk("copy_to error\n"); #endif return -EFAULT; } } return err; case BMA220_GET_OFFSET_XYZ: err = bma220_get_offset_xyz((bma220acc_t*)data); if(copy_to_user((bma220acc_t*)arg,(bma220acc_t*)data,3)!=0) { #ifdef BMA_DEBUG printk("copy_to error\n"); #endif return -EFAULT; } return err; case BMA220_SET_OFFSET_XYZ: if(copy_from_user((bma220acc_t*)data,(bma220acc_t*)arg,3)!=0) { #ifdef BMA_DEBUG printk("copy_from_user error\n"); #endif return -EFAULT; } err = bma220_set_offset_xyz(*(bma220acc_t *)data); return err; case BMA220_SET_SLEEP_EN: if(copy_from_user(data,(unsigned char*)arg,1)!=0) { #ifdef BMA_DEBUG printk("copy_from_user error\n"); #endif return -EFAULT; } err = bma220_set_sleep_en(*data); return err; case BMA220_SET_SC_FILT_CONFIG: if(copy_from_user(data,(unsigned char*)arg,1)!=0) { #ifdef BMA_DEBUG printk("copy_from_user error\n"); #endif return -EFAULT; } err = bma220_set_sc_filt_config(*data); return err; case BMA220_SET_SERIAL_HIGH_BW: if(copy_from_user(data,(unsigned char*)arg,1)!=0) { #ifdef BMA_DEBUG printk("copy_from_user error\n"); #endif return -EFAULT; } err = bma220_set_serial_high_bw(*data); return err; case BMA220_SET_EN_ORIENT: if(copy_from_user(data,(unsigned char*)arg,1)!=0) { #ifdef BMA_DEBUG printk("copy_from_user error\n"); #endif return -EFAULT; } err = bma220_set_en_orient(*data); return err; case BMA220_SET_ORIENT_EX: if(copy_from_user(data,(unsigned char*)arg,1)!=0) { #ifdef BMA_DEBUG printk("copy_from_user error\n"); #endif return -EFAULT; } err = bma220_set_orient_ex(*data); return err; case BMA220_SET_ORIENT_BLOCKING: if(copy_from_user(data,(unsigned char*)arg,1)!=0) { #ifdef BMA_DEBUG printk("copy_from_user error\n"); #endif return -EFAULT; } err = bma220_set_orient_blocking(*data); return err; case BMA220_SET_EN_TT_XYZ: if(copy_from_user(data,(unsigned char*)arg,1)!=0) { #ifdef BMA_DEBUG printk("copy_from_user error\n"); #endif return -EFAULT; } err = bma220_set_en_tt_xyz(*data); return err; case BMA220_SET_TT_TH: if(copy_from_user(data,(unsigned char*)arg,1)!=0) { #ifdef BMA_DEBUG printk("copy_from_user error\n"); #endif return -EFAULT; } err = bma220_set_tt_th(*data); return err; case BMA220_SET_TT_DUR: if(copy_from_user(data,(unsigned char*)arg,1)!=0) { #ifdef BMA_DEBUG printk("copy_from_user error\n"); #endif return -EFAULT; } err = bma220_set_tt_dur(*data); return err; case BMA220_SET_TT_FILT: if(copy_from_user(data,(unsigned char*)arg,1)!=0) { #ifdef BMA_DEBUG printk("copy_from_user error\n"); #endif return -EFAULT; } err = bma220_set_tt_filt(*data); return err; case BMA220_SET_EN_SLOPE_XYZ: if(copy_from_user(data,(unsigned char*)arg,1)!=0) { #ifdef BMA_DEBUG printk("copy_from_user error\n"); #endif return -EFAULT; } err = bma220_set_en_slope_xyz(*data); return err; case BMA220_SET_EN_DATA: if(copy_from_user(data,(unsigned char*)arg,1)!=0) { #ifdef BMA_DEBUG printk("copy_from_user error\n"); #endif return -EFAULT; } err = bma220_set_en_data(*data); return err; case BMA220_SET_SLOPE_TH: if(copy_from_user(data,(unsigned char*)arg,1)!=0) { #ifdef BMA_DEBUG printk("copy_from_user error\n"); #endif return -EFAULT; } err = bma220_set_slope_th(*data); return err; case BMA220_SET_SLOPE_DUR: if(copy_from_user(data,(unsigned char*)arg,1)!=0) { #ifdef BMA_DEBUG printk("copy_from_user error\n"); #endif return -EFAULT; } err = bma220_set_slope_dur(*data); return err; case BMA220_SET_SLOPE_FILT: if(copy_from_user(data,(unsigned char*)arg,1)!=0) { #ifdef BMA_DEBUG printk("copy_from_user error\n"); #endif return -EFAULT; } err = bma220_set_slope_filt(*data); return err; case BMA220_SET_CAL_TRIGGER: if(copy_from_user(data,(unsigned char*)arg,1)!=0) { #ifdef BMA_DEBUG printk("copy_from_user error\n"); #endif return -EFAULT; } err = bma220_set_cal_trigger(*data); return err; case BMA220_SET_HP_XYZ_EN: if(copy_from_user(data,(unsigned char*)arg,1)!=0) { #ifdef BMA_DEBUG printk("copy_from_user error\n"); #endif return -EFAULT; } err = bma220_set_hp_xyz_en(*data); return err; case BMA220_SET_SLEEP_DUR: if(copy_from_user(data,(unsigned char*)arg,1)!=0) { #ifdef BMA_DEBUG printk("copy_from_user error\n"); #endif return -EFAULT; } err = bma220_set_sleep_dur(*data); return err; case BMA220_SET_OFFSET_RESET: if(copy_from_user(data,(unsigned char*)arg,1)!=0) { #ifdef BMA_DEBUG printk("copy_from_user error\n"); #endif return -EFAULT; } err = bma220_set_offset_reset(*data); return err; case BMA220_SET_CUT_OFF_SPEED: if(copy_from_user(data,(unsigned char*)arg,1)!=0) { #ifdef BMA_DEBUG printk("copy_from_user error\n"); #endif return -EFAULT; } err = bma220_set_cut_off_speed(*data); return err; case BMA220_SET_CAL_MANUAL: if(copy_from_user(data,(unsigned char*)arg,1)!=0) { #ifdef BMA_DEBUG printk("copy_from_user error\n"); #endif return -EFAULT; } err = bma220_set_cal_manual(*data); return err; case BMA220_SET_SBIST: if(copy_from_user(data,(unsigned char*)arg,1)!=0) { #ifdef BMA_DEBUG printk("copy_from_user error\n"); #endif return -EFAULT; } err = bma220_set_sbist(*data); return err; case BMA220_SET_INTERRUPT_REGISTER: if(copy_from_user(data,(unsigned char*)arg,1)!=0) { #ifdef BMA_DEBUG printk("copy_from_user error\n"); #endif return -EFAULT; } err = bma220_set_interrupt_register(*data); return err; case BMA220_SET_DIRECTION_INTERRUPT_REGISTER: if(copy_from_user(data,(unsigned char*)arg,1)!=0) { #ifdef BMA_DEBUG printk("copy_from_user error\n"); #endif return -EFAULT; } err = bma220_set_direction_interrupt_register(*data); return err; case BMA220_GET_DIRECTION_STATUS_REGISTER: err = bma220_get_direction_status_register(data); if(copy_to_user((unsigned char*)arg,data,1)!=0) { #ifdef BMA_DEBUG printk("copy_to_user error\n"); #endif return -EFAULT; } return err; case BMA220_GET_INTERRUPT_STATUS_REGISTER: err = bma220_get_interrupt_status_register(data); if(copy_to_user((unsigned char*)arg,data,1)!=0) { #ifdef BMA_DEBUG printk("copy_to_user error\n"); #endif return -EFAULT; } return err; case BMA220_GET_ORIENTATION: err = bma220_get_orientation(data); if(copy_to_user((unsigned char*)arg,data,1)!=0) { #ifdef BMA_DEBUG printk("copy_to_user error\n"); #endif return -EFAULT; } return err; case BMA220_GET_ORIENT_INT: err = bma220_get_orient_int(data); if(copy_to_user((unsigned char*)arg,data,1)!=0) { #ifdef BMA_DEBUG printk("copy_to_user error\n"); #endif return -EFAULT; } return err; case BMA220_GET_CHIP_ID: err = bma220_get_chip_id(data); if(copy_to_user((unsigned char*)arg,data,1)!=0) { #ifdef BMA_DEBUG printk("copy_to_user error\n"); #endif return -EFAULT; } return err; case BMA220_GET_SC_FILT_CONFIG: err = bma220_get_sc_filt_config(data); if(copy_to_user((unsigned char*)arg,data,1)!=0) { #ifdef BMA_DEBUG printk("copy_to_user error\n"); #endif return -EFAULT; } return err; case BMA220_GET_SLEEP_EN: err = bma220_get_sleep_en(data); if(copy_to_user((unsigned char*)arg,data,1)!=0) { #ifdef BMA_DEBUG printk("copy_to_user error\n"); #endif return -EFAULT; } return err; case BMA220_GET_SERIAL_HIGH_BW: err = bma220_get_serial_high_bw(data); if(copy_to_user((unsigned char*)arg,data,1)!=0) { #ifdef BMA_DEBUG printk("copy_to_user error\n"); #endif return -EFAULT; } return err; case BMA220_GET_LATCH_INT: err = bma220_get_latch_int(data); if(copy_to_user((unsigned char*)arg,data,1)!=0) { #ifdef BMA_DEBUG printk("copy_to_user error\n"); #endif return -EFAULT; } return err; case BMA220_GET_EN_DATA: err = bma220_get_en_data(data); if(copy_to_user((unsigned char*)arg,data,1)!=0) { #ifdef BMA_DEBUG printk("copy_to_user error\n"); #endif return -EFAULT; } return err; case BMA220_GET_EN_HIGH_XYZ: err = bma220_get_en_high_xyz(data); if(copy_to_user((unsigned char*)arg,data,1)!=0) { #ifdef BMA_DEBUG printk("copy_to_user error\n"); #endif return -EFAULT; } return err; case BMA220_GET_HIGH_TH: err = bma220_get_high_th(data); if(copy_to_user((unsigned char*)arg,data,1)!=0) { #ifdef BMA_DEBUG printk("copy_to_user error\n"); #endif return -EFAULT; } return err; case BMA220_GET_HIGH_HY: err = bma220_get_high_hy(data); if(copy_to_user((unsigned char*)arg,data,1)!=0) { #ifdef BMA_DEBUG printk("copy_to_user error\n"); #endif return -EFAULT; } return err; case BMA220_GET_HIGH_DUR: err = bma220_get_high_g_dur(data); if(copy_to_user((unsigned char*)arg,data,1)!=0) { #ifdef BMA_DEBUG printk("copy_to_user error\n"); #endif return -EFAULT; } return err; case BMA220_GET_EN_LOW: err = bma220_get_en_low(data); if(copy_to_user((unsigned char*)arg,data,1)!=0) { #ifdef BMA_DEBUG printk("copy_to_user error\n"); #endif return -EFAULT; } return err; case BMA220_GET_LOW_TH: err = bma220_get_low_th(data); if(copy_to_user((unsigned char*)arg,data,1)!=0) { #ifdef BMA_DEBUG printk("copy_to_user error\n"); #endif return -EFAULT; } return err; case BMA220_GET_LOW_HY: err = bma220_get_low_hy(data); if(copy_to_user((unsigned char*)arg,data,1)!=0) { #ifdef BMA_DEBUG printk("copy_to_user error\n"); #endif return -EFAULT; } return err; case BMA220_GET_LOW_DUR: err = bma220_get_low_g_dur(data); if(copy_to_user((unsigned char*)arg,data,1)!=0) { #ifdef BMA_DEBUG printk("copy_to_user error\n"); #endif return -EFAULT; } return err; case BMA220_GET_EN_ORIENT: err = bma220_get_en_orient(data); if(copy_to_user((unsigned char*)arg,data,1)!=0) { #ifdef BMA_DEBUG printk("copy_to_user error\n"); #endif return -EFAULT; } return err; case BMA220_GET_ORIENT_EX: err = bma220_get_orient_ex(data); if(copy_to_user((unsigned char*)arg,data,1)!=0) { #ifdef BMA_DEBUG printk("copy_to_user error\n"); #endif return -EFAULT; } return err; case BMA220_GET_ORIENT_BLOCKING: err = bma220_get_orient_blocking(data); if(copy_to_user((unsigned char*)arg,data,1)!=0) { #ifdef BMA_DEBUG printk("copy_to_user error\n"); #endif return -EFAULT; } return err; case BMA220_GET_EN_TT_XYZ: err = bma220_get_en_tt_xyz(data); if(copy_to_user((unsigned char*)arg,data,1)!=0) { #ifdef BMA_DEBUG printk("copy_to_user error\n"); #endif return -EFAULT; } return err; case BMA220_GET_TT_TH: err = bma220_get_tt_th(data); if(copy_to_user((unsigned char*)arg,data,1)!=0) { #ifdef BMA_DEBUG printk("copy_to_user error\n"); #endif return -EFAULT; } return err; case BMA220_GET_TT_DUR: err = bma220_get_tt_dur(data); if(copy_to_user((unsigned char*)arg,data,1)!=0) { #ifdef BMA_DEBUG printk("copy_to_user error\n"); #endif return -EFAULT; } return err; case BMA220_GET_TT_FILT: err = bma220_get_tt_filt(data); if(copy_to_user((unsigned char*)arg,data,1)!=0) { #ifdef BMA_DEBUG printk("copy_to_user error\n"); #endif return -EFAULT; } return err; case BMA220_SET_TT_SAMP: if(copy_from_user(data,(unsigned char*)arg,1)!=0) { #ifdef BMA_DEBUG printk("copy_from_user error\n"); #endif return -EFAULT; } err = bma220_set_tt_samp(*data); return err; case BMA220_SET_TIP_EN: if(copy_from_user(data,(unsigned char*)arg,1)!=0) { #ifdef BMA_DEBUG printk("copy_from_user error\n"); #endif return -EFAULT; } err = bma220_set_tip_en(*data); return err; case BMA220_GET_TT_SAMP: err = bma220_get_tt_samp(data); if(copy_to_user((unsigned char*)arg,data,1)!=0) { #ifdef BMA_DEBUG printk("copy_to_user error\n"); #endif return -EFAULT; } return err; case BMA220_GET_TIP_EN: err = bma220_get_tip_en(data); if(copy_to_user((unsigned char*)arg,data,1)!=0) { #ifdef BMA_DEBUG printk("copy_to_user error\n"); #endif return -EFAULT; } return err; case BMA220_GET_EN_SLOPE_XYZ: err = bma220_get_en_slope_xyz(data); if(copy_to_user((unsigned char*)arg,data,1)!=0) { #ifdef BMA_DEBUG printk("copy_to_user error\n"); #endif return -EFAULT; } return err; case BMA220_GET_SLOPE_TH: err = bma220_get_slope_th(data); if(copy_to_user((unsigned char*)arg,data,1)!=0) { #ifdef BMA_DEBUG printk("copy_to_user error\n"); #endif return -EFAULT; } return err; case BMA220_GET_SLOPE_DUR: err = bma220_get_slope_dur(data); if(copy_to_user((unsigned char*)arg,data,1)!=0) { #ifdef BMA_DEBUG printk("copy_to_user error\n"); #endif return -EFAULT; } return err; case BMA220_GET_SLOPE_FILT: err = bma220_get_slope_filt(data); if(copy_to_user((unsigned char*)arg,data,1)!=0) { #ifdef BMA_DEBUG printk("copy_to_user error\n"); #endif return -EFAULT; } return err; case BMA220_GET_HP_XYZ_EN: err = bma220_get_hp_xyz_en(data); if(copy_to_user((unsigned char*)arg,data,1)!=0) { #ifdef BMA_DEBUG printk("copy_to_user error\n"); #endif return -EFAULT; } return err; case BMA220_GET_OFFSET_TARGET_X: err = bma220_get_offset_target_x(data); if(copy_to_user((unsigned char*)arg,data,1)!=0) { #ifdef BMA_DEBUG printk("copy_to_user error\n"); #endif return -EFAULT; } return err; case BMA220_GET_OFFSET_TARGET_Y: err = bma220_get_offset_target_y(data); if(copy_to_user((unsigned char*)arg,data,1)!=0) { #ifdef BMA_DEBUG printk("copy_to_user error\n"); #endif return -EFAULT; } return err; case BMA220_GET_OFFSET_TARGET_Z: err = bma220_get_offset_target_z(data); if(copy_to_user((unsigned char*)arg,data,1)!=0) { #ifdef BMA_DEBUG printk("copy_to_user error\n"); #endif return -EFAULT; } return err; case BMA220_GET_CUT_OFF_SPEED: err = bma220_get_cut_off_speed(data); if(copy_to_user((unsigned char*)arg,data,1)!=0) { #ifdef BMA_DEBUG printk("copy_to_user error\n"); #endif return -EFAULT; } return err; case BMA220_GET_CAL_MANUAL: err = bma220_get_cal_manual(data); if(copy_to_user((unsigned char*)arg,data,1)!=0) { #ifdef BMA_DEBUG printk("copy_to_user error\n"); #endif return -EFAULT; } return err; case BMA220_GET_CAL_RDY: err = bma220_get_cal_rdy(data); if(copy_to_user((unsigned char*)arg,data,1)!=0) { #ifdef BMA_DEBUG printk("copy_to_user error\n"); #endif return -EFAULT; } return err; case BMA220_GET_SLEEP_DUR: err = bma220_get_sleep_dur(data); if(copy_to_user((unsigned char*)arg,data,1)!=0) { #ifdef BMA_DEBUG printk("copy_to_user error\n"); #endif return -EFAULT; } return err; case BMA220_GET_SENSOR_TYPE: printk("[%s] Get Sensor Type = %d\n", __func__, sensor_type); if(copy_to_user((char*)arg,&sensor_type,1)!=0) { #ifdef BMA_DEBUG printk("copy_to_user error\n"); #endif return -EFAULT; } return err; default: return 0; } }