static void bma255_set_enable(struct bma255_p *data, int enable) { int pre_enable = atomic_read(&data->enable); pr_info("\n bma255 sysfs set_enable sensor enable %d", enable); if (enable) { if (pre_enable == OFF) { bma255_open_calibration(data); bma255_set_mode(data->client, BMA255_MODE_NORMAL); schedule_delayed_work(&data->work, msecs_to_jiffies(atomic_read(&data->delay))); atomic_set(&data->enable, ON); //pr_info("bma255 enable =%d",data->enable); } } else { if (pre_enable == ON) { if (data->recog_flag == ON) bma255_set_mode(data->client, BMA255_MODE_LOWPOWER1); else bma255_set_mode(data->client, BMA255_MODE_SUSPEND); cancel_delayed_work_sync(&data->work); atomic_set(&data->enable, OFF); } } }
static ssize_t bma255_calibration_show(struct device *dev, struct device_attribute *attr, char *buf) { int ret; struct bma255_p *data = dev_get_drvdata(dev); ret = bma255_open_calibration(data); if (ret < 0) pr_err("[SENSOR]: %s - calibration open failed(%d)\n", __func__, ret); pr_info("[SENSOR]: %s - cal data %d %d %d - ret : %d\n", __func__, data->caldata.x, data->caldata.y, data->caldata.z, ret); return snprintf(buf, PAGE_SIZE, "%d %d %d %d\n", ret, data->caldata.x, data->caldata.y, data->caldata.z); }
static void bma255_set_enable(struct bma255_p *data, int enable) { int pre_enable = atomic_read(&data->enable); if (enable) { if (pre_enable == OFF) { bma255_open_calibration(data); bma255_set_mode(data, BMA255_MODE_NORMAL); schedule_delayed_work(&data->work, msecs_to_jiffies(atomic_read(&data->delay))); atomic_set(&data->enable, ON); } } else { if (pre_enable == ON) { if (data->recog_flag == ON) bma255_set_mode(data, BMA255_MODE_NORMAL); else bma255_set_mode(data, BMA255_MODE_SUSPEND); cancel_delayed_work_sync(&data->work); atomic_set(&data->enable, OFF); } } }