static void sensor_set_enable(struct device *dev, int enable) { struct input_dev *inputdev = to_input_dev(dev); struct sensor_data *sensordata = input_get_drvdata(inputdev); int delay = atomic_read(&sensordata->delay); dbg_func_in(); mutex_lock(&sensordata->enable_mutex); if (enable) { /* enable if state will be changed */ if (!atomic_cmpxchg(&sensordata->enable, 0, 1)) { sensordata->status = apds9900_control_enable(APDS9900_TYPE_PROXIMITY, true) ? 0 : 1; if(sensordata->status) { schedule_delayed_work(&sensordata->work, delay_to_jiffies(delay) + 1); } } } else { /* disable if state will be changed */ if (atomic_cmpxchg(&sensordata->enable, 1, 0) && sensordata->status) { if(sensordata->status) { cancel_delayed_work_sync(&sensordata->work); sensordata->status = apds9900_control_enable(APDS9900_TYPE_PROXIMITY, false) ? 0 : 1; } } } atomic_set(&sensordata->enable, enable); mutex_unlock(&sensordata->enable_mutex); dbg_func_out(); }
static int yas_acc_set_enable(struct yas_acc_driver *driver, int enable) { struct yas_acc_private_data *data = yas_acc_get_data(); int delay = driver->get_delay(); dbg_func_in(); dbg("%s : enable=%d, delay=%d\n", __func__, enable, delay); #ifndef PANTECH_AVOID_DEADLOCK if (yas_acc_ischg_enable(driver, enable)) { #endif if (enable) { driver->set_enable(enable); schedule_delayed_work(&data->work, delay_to_jiffies(delay) + 1); dbg("%s : schedule_delayed_work(&data->work, %d)\n", __func__, delay); } else { cancel_delayed_work_sync(&data->work); dbg("%s : cancel_delayed_work_sync\n", __func__); driver->set_enable(enable); } #ifndef PANTECH_AVOID_DEADLOCK } #endif dbg_func_out(); return 0; }
static int yas_acc_resume(struct i2c_client *client) { struct yas_acc_private_data *data = i2c_get_clientdata(client); struct yas_acc_driver *driver = data->driver; int delay; mutex_lock(&data->data_mutex); #ifdef WILLOW_SENSOR_REGULATOR_CONTROL regulator_enable(data->regulator); #endif if (data->suspend == 1) { if (data->suspend_enable) { delay = yas_acc_get_delay(driver); schedule_delayed_work(&data->work, delay_to_jiffies(delay) + 1); yas_acc_set_enable(driver, 1); } } data->suspend = 0; mutex_unlock(&data->data_mutex); return 0; }
static void yas_acc_work_func(struct work_struct *work) { struct yas_acc_private_data *data = container_of((struct delayed_work *)work, struct yas_acc_private_data, work); struct yas_acc_data accel, last; unsigned long delay = delay_to_jiffies(yas_acc_get_delay(data->driver)); static int cnt = 0; accel.xyz.v[0] = accel.xyz.v[1] = accel.xyz.v[2] = 0; yas_acc_measure(data->driver, &accel); mutex_lock(&data->data_mutex); last = data->last; mutex_unlock(&data->data_mutex); input_report_abs(data->input, ABS_X, accel.xyz.v[0]); input_report_abs(data->input, ABS_Y, accel.xyz.v[1]); input_report_abs(data->input, ABS_Z, accel.xyz.v[2]); if (last.xyz.v[0] == accel.xyz.v[0] && last.xyz.v[1] == accel.xyz.v[1] && last.xyz.v[2] == accel.xyz.v[2]) { input_report_abs(data->input, ABS_RUDDER, cnt++); } input_sync(data->input); mutex_lock(&data->data_mutex); data->last = accel; mutex_unlock(&data->data_mutex); schedule_delayed_work(&data->work, delay); }
static int yas_acc_resume(struct i2c_client *client) { struct yas_acc_private_data *data = i2c_get_clientdata(client); struct yas_acc_driver *driver = data->driver; int delay; dbg_func_in(); #ifdef POWER_ON_OFF geomagnetic_set_power(1); #endif #ifndef PANTECH_AVOID_DEADLOCK mutex_lock(&data->data_mutex); #endif dbg("%s : data->suspend = %d / data->suspend_enable = %d / delay = %d\n", __func__, data->suspend, yas_acc_get_enable(driver), yas_acc_get_delay(driver)); if (data->suspend == 1) { if (data->suspend_enable) { delay = yas_acc_get_delay(driver); #ifndef PANTECH_AVOID_DEADLOCK schedule_delayed_work(&data->work, delay_to_jiffies(delay) + 1); #endif yas_acc_set_enable(driver, 1); } } data->suspend = 0; #ifndef PANTECH_AVOID_DEADLOCK mutex_unlock(&data->data_mutex); #endif dbg_func_out(); return 0; }
static void bma023_set_delay(struct device *dev, int delay) { struct bma023_data *bma023 = dev_get_drvdata(dev); int i; u8 odr; /* determine optimum ODR */ for (i = 1; (i < ARRAY_SIZE(bma023_odr_table)) && (actual_delay(delay) >= bma023_odr_table[i].delay); i++) ; odr = bma023_odr_table[i-1].odr; atomic_set(&bma023->delay, delay); mutex_lock(&bma023->enable_mutex); if (bma023_get_enable(dev)) { cancel_delayed_work_sync(&bma023->work); bma023_update_bits(bma023, BMA023_BANDWIDTH, odr); schedule_delayed_work(&bma023->work, delay_to_jiffies(delay) + 1); } else { bma023_power_up(bma023); bma023_update_bits(bma023, BMA023_BANDWIDTH, odr); bma023_power_down(bma023); } mutex_unlock(&bma023->enable_mutex); }
static void sensor_work_func(struct work_struct *work) { struct sensor_data *sensordata = container_of((struct delayed_work *)work, struct sensor_data, work); axes_t val; unsigned long delay; dbg_func_in(); if(input_pdev == NULL) { cancel_delayed_work_sync(&sensordata->work); } else { sensor_measure(sensordata, &val); #if AT1_BDVER_GE(AT1_WS20) //hhs veeapp read function add 20110316 val_backup.x = val.x; val_backup.y = val.y; val_backup.z = val.z; #endif input_report_abs(input_pdev, ABS_X, (int)val.x); input_report_abs(input_pdev, ABS_Y, (int)val.y); input_report_abs(input_pdev, ABS_Z, (int)val.z); input_sync(input_pdev); mutex_lock(&sensordata->data_mutex); sensordata->lastval = val; mutex_unlock(&sensordata->data_mutex); delay = delay_to_jiffies(atomic_read(&sensordata->delay)); schedule_delayed_work(&sensordata->work, delay); } dbg_func_out(); }
static void sensor_set_enable(struct device *dev, int enable) { struct input_dev *inputdev = to_input_dev(dev); struct sensor_data *sensordata = input_get_drvdata(inputdev); int delay = atomic_read(&sensordata->delay); dbg_func_in(); mutex_lock(&sensordata->enable_mutex); if (enable) { /* enable if state will be changed */ if (!atomic_cmpxchg(&sensordata->enable, 0, 1)) { l3g4200d_control_enable(1); schedule_delayed_work(&sensordata->work, delay_to_jiffies(delay) + 1); } } else { /* disable if state will be changed */ if (atomic_cmpxchg(&sensordata->enable, 1, 0)) { cancel_delayed_work_sync(&sensordata->work); l3g4200d_control_enable(0); } } atomic_set(&sensordata->enable, enable); mutex_unlock(&sensordata->enable_mutex); dbg_func_out(); }
static void sensor_work_func(struct work_struct *work) { struct sensor_data *sensordata = container_of((struct delayed_work *)work, struct sensor_data, work); axes_t val; unsigned long delay; dbg_func_in(); if(input_pdev == NULL) { cancel_delayed_work_sync(&sensordata->work); } else { sensor_measure(sensordata, &val); input_report_abs(input_pdev, ABS_X, (int)val.x); input_report_abs(input_pdev, ABS_Y, (int)val.y); input_report_abs(input_pdev, ABS_Z, (int)val.z); input_sync(input_pdev); mutex_lock(&sensordata->data_mutex); sensordata->lastval = val; mutex_unlock(&sensordata->data_mutex); delay = delay_to_jiffies(atomic_read(&sensordata->delay)); schedule_delayed_work(&sensordata->work, delay); } dbg_func_out(); }
static void adxl345_set_delay(struct device *dev, int delay) { struct i2c_client *client = to_i2c_client(dev); struct adxl345_data *adxl345 = i2c_get_clientdata(client); u8 odr; int i; /* determine optimum ODR */ for (i = 1; (i < ARRAY_SIZE(adxl345_odr_table)) && (actual_delay(delay) >= adxl345_odr_table[i].delay); i++) ; odr = adxl345_odr_table[i-1].odr; atomic_set(&adxl345->delay, delay); mutex_lock(&adxl345->enable_mutex); if (adxl345_get_enable(dev)) { cancel_delayed_work_sync(&adxl345->work); adxl345_update_bits(adxl345, ADXL345_BANDWIDTH, odr); schedule_delayed_work(&adxl345->work, delay_to_jiffies(delay) + 1); } else { adxl345_power_up(adxl345); adxl345_update_bits(adxl345, ADXL345_BANDWIDTH, odr); adxl345_power_down(adxl345); } mutex_unlock(&adxl345->enable_mutex); }
static int isl29023_probe(struct i2c_client *client, const struct i2c_device_id *id) { int res; int err; int mode_check; struct isl29023_data *isl29023; pr_info("isl29023 probe begin...\n"); isl29023 = kzalloc(sizeof(struct isl29023_data), GFP_KERNEL); if (!isl29023) { return -EINVAL; } err = isl29023_input_init(isl29023); if (err < 0) { goto err_exit; } err = sysfs_create_group(&client->dev.kobj, &m_isl_gr); if (err < 0) { goto err_exit; } res = isl_set_default_config(client); if (res < 0) { pr_warn("isl29023: set default config failed!!\n"); is_device = 0; goto err_exit; } i2c_set_clientdata(client, isl29023); isl29023->client = client; /* setup driver interfaces */ INIT_DELAYED_WORK(&isl29023->work, isl29023_work_func); last_mod = 0; mode_check = isl_set_mod(client, ISL_MOD_ALS_CONT); if (mode_check) schedule_delayed_work(&isl29023->work, delay_to_jiffies(1000) + 1); else cancel_delayed_work_sync(&isl29023->work); #if DEBUG dev_dbg(&client->dev, "isl29023 probe succeed!\n"); #endif return res; err_exit: kfree(isl29023); return -EINVAL; }
static void isl29023_work_func(struct work_struct *work) { int last_data; struct isl29023_data *isl29023 = container_of((struct delayed_work *)work,struct isl29023_data, work); last_data = isl29023_measure(isl29023); isl29023_value_report(isl29023->input,last_data); isl29023->last = last_data; schedule_delayed_work(&isl29023->work, delay_to_jiffies(1000) + 1); }
static int yas_acc_set_delay(struct yas_acc_driver *driver, int delay) { struct yas_acc_private_data *data = yas_acc_get_data(); if (driver->get_enable()) { cancel_delayed_work_sync(&data->work); driver->set_delay(actual_delay(delay)); schedule_delayed_work(&data->work, delay_to_jiffies(delay) + 1); } else { driver->set_delay(actual_delay(delay)); } return 0; }
static int yas_acc_set_enable(struct yas_acc_driver *driver, int enable) { struct yas_acc_private_data *data = yas_acc_get_data(); int delay = driver->get_delay(); if (yas_acc_ischg_enable(driver, enable)) { if (enable) { driver->set_enable(enable); schedule_delayed_work(&data->work, delay_to_jiffies(delay) + 1); } else { cancel_delayed_work_sync(&data->work); driver->set_enable(enable); } } return 0; }
static void bma023_work_func(struct work_struct *work) { struct bma023_data *bma023 = container_of((struct delayed_work *)work, struct bma023_data, work); struct acceleration accel; unsigned long delay = delay_to_jiffies(atomic_read(&bma023->delay)); bma023_measure(bma023, &accel); input_report_rel(bma023->input, REL_X, accel.x); input_report_rel(bma023->input, REL_Y, accel.y); input_report_rel(bma023->input, REL_Z, accel.z); input_sync(bma023->input); schedule_delayed_work(&bma023->work, delay); }
static void bh1780_work_func(struct work_struct *work) { struct bh1780_data *bh1780 = container_of((struct delayed_work *)work, struct bh1780_data, work); unsigned long delay = delay_to_jiffies(atomic_read(&bh1780->delay)); bh1780_measure(bh1780); input_report_abs(bh1780->input, ABS_X, bh1780->light_data); input_sync(bh1780->input); mutex_lock(&bh1780->data_mutex); bh1780->light_data_last = bh1780->light_data; mutex_unlock(&bh1780->data_mutex); schedule_delayed_work(&bh1780->work, delay); }
static void bh1780_set_delay(struct device *dev, int delay) { struct i2c_client *client = to_i2c_client(dev); struct bh1780_data *bh1780 = i2c_get_clientdata(client); mutex_lock(&bh1780->enable_mutex); atomic_set(&bh1780->delay, delay); if (bh1780_get_enable(dev)) { cancel_delayed_work_sync(&bh1780->work); schedule_delayed_work(&bh1780->work, delay_to_jiffies(delay) + 1); } mutex_unlock(&bh1780->enable_mutex); }
static int yas_acc_set_delay(struct yas_acc_driver *driver, int delay) { #ifdef PANTECH_AVOID_DEADLOCK driver->set_delay(actual_delay(delay)); #else struct yas_acc_private_data *data = yas_acc_get_data(); if (driver->get_enable()) { cancel_delayed_work_sync(&data->work); driver->set_delay(actual_delay(delay)); schedule_delayed_work(&data->work, delay_to_jiffies(delay) + 1); } else { driver->set_delay(actual_delay(delay)); } #endif return 0; }
static ssize_t isl_enable_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct isl29023_data *isl29023 = dev_get_drvdata(dev); int ret_val; unsigned long val; if (strict_strtoul(buf, 10, &val)) return -EINVAL; //printk("[LIGHT]isl_enable_store val = %ld \n",val); if(!is_device) { printk("[LIGHT] NO DEVICE is_device = %d \n",is_device); return; } if(val == 1) val = 5; //ISL_MOD_ALS_CONT mutex_lock(&mutex); ret_val = isl_set_mod(isl29023->client, val); mutex_unlock(&mutex); if (ret_val < 0) return ret_val; if(val){ schedule_delayed_work(&isl29023->work, delay_to_jiffies(3000) + 1); #ifdef FEATURE_BACKLIGHT_ONOFF_LOG printk("[LIGHT] Power-Up \n"); #endif } else{ cancel_delayed_work_sync(&isl29023->work); #ifdef FEATURE_BACKLIGHT_ONOFF_LOG printk("[LIGHT] Power-Down \n"); #endif } return count; }
static void adxl345_work_func(struct work_struct *work) { struct adxl345_data *adxl345 = container_of((struct delayed_work *)work, struct adxl345_data, work); struct acceleration accel; unsigned long delay = delay_to_jiffies(atomic_read(&adxl345->delay)); adxl345_measure(adxl345, &accel); input_report_abs(adxl345->input, ABS_X, accel.x); input_report_abs(adxl345->input, ABS_Y, accel.y); input_report_abs(adxl345->input, ABS_Z, accel.z); input_sync(adxl345->input); mutex_lock(&adxl345->data_mutex); adxl345->last = accel; mutex_unlock(&adxl345->data_mutex); schedule_delayed_work(&adxl345->work, delay); }
static void yas_acc_work_func(struct work_struct *work) { struct yas_acc_private_data *data = container_of((struct delayed_work *)work, struct yas_acc_private_data, work); struct yas_acc_data accel, last; unsigned long delay = delay_to_jiffies(yas_acc_get_delay(data->driver)); static int cnt = 0; // dbg_func_in(); accel.xyz.v[0] = accel.xyz.v[1] = accel.xyz.v[2] = 0; yas_acc_measure(data->driver, &accel); #ifdef PANTECH_AVOID_DEADLOCK last = data->last; #else mutex_lock(&data->data_mutex); last = data->last; mutex_unlock(&data->data_mutex); #endif input_report_abs(data->input, ABS_X, accel.xyz.v[0]); input_report_abs(data->input, ABS_Y, accel.xyz.v[1]); input_report_abs(data->input, ABS_Z, accel.xyz.v[2]); if (last.xyz.v[0] == accel.xyz.v[0] && last.xyz.v[1] == accel.xyz.v[1] && last.xyz.v[2] == accel.xyz.v[2]) { input_report_abs(data->input, ABS_RUDDER, cnt++); } input_sync(data->input); #ifdef PANTECH_AVOID_DEADLOCK data->last = accel; #else mutex_lock(&data->data_mutex); data->last = accel; mutex_unlock(&data->data_mutex); #endif schedule_delayed_work(&data->work, delay); // dbg("%s : schedule_delayed_work(%d)\n", __func__ ,(int)delay); // dbg_func_out(); }
static int bh1780_resume(struct i2c_client *client) { struct bh1780_data *bh1780 = i2c_get_clientdata(client); int delay = atomic_read(&bh1780->delay); bh1780_power_up(bh1780); bh1780_set_delay(&client->dev, delay); mutex_lock(&bh1780->enable_mutex); if (bh1780_get_enable(&client->dev)) { bh1780_power_up(bh1780); schedule_delayed_work(&bh1780->work, delay_to_jiffies(delay) + 1); } mutex_unlock(&bh1780->enable_mutex); return 0; }
static void sensor_set_delay(struct device *dev, int delay) { struct input_dev *inputdev = to_input_dev(dev); struct sensor_data *sensordata = input_get_drvdata(inputdev); dbg_func_in(); atomic_set(&sensordata->delay, delay); mutex_lock(&sensordata->enable_mutex); if (sensor_get_enable(dev)) { cancel_delayed_work_sync(&sensordata->work); schedule_delayed_work(&sensordata->work, delay_to_jiffies(delay) + 1); } mutex_unlock(&sensordata->enable_mutex); dbg_func_out(); }
static int yas_acc_resume(struct i2c_client *client) { struct yas_acc_private_data *data = i2c_get_clientdata(client); struct yas_acc_driver *driver = data->driver; int delay; mutex_lock(&data->data_mutex); if (data->suspend == 1) { if (data->suspend_enable) { delay = yas_acc_get_delay(driver); schedule_delayed_work(&data->work, delay_to_jiffies(delay) + 1); yas_acc_set_enable(driver, 1); } } data->suspend = 0; mutex_unlock(&data->data_mutex); return 0; }
static void yas_acc_work_func(struct work_struct *work) { struct yas_acc_private_data *data = container_of((struct delayed_work *)work, struct yas_acc_private_data, work); struct yas_acc_data accel; unsigned long delay = delay_to_jiffies(yas_acc_get_delay(data->driver)); printk("[diony] yas_acc_work_func.\n"); accel.xyz.v[0] = accel.xyz.v[1] = accel.xyz.v[2] = 0; yas_acc_measure(data->driver, &accel); input_report_abs(data->input, ABS_X, accel.xyz.v[0]); input_report_abs(data->input, ABS_Y, accel.xyz.v[1]); input_report_abs(data->input, ABS_Z, accel.xyz.v[2]); input_sync(data->input); mutex_lock(&data->data_mutex); data->last = accel; mutex_unlock(&data->data_mutex); // schedule_delayed_work(&data->work, delay); }
static void bma023_set_enable(struct device *dev, int enable) { struct bma023_data *bma023 = dev_get_drvdata(dev); int delay = atomic_read(&bma023->delay); mutex_lock(&bma023->enable_mutex); if (enable) { /* enable if state will be changed */ if (!atomic_cmpxchg(&bma023->enable, 0, 1)) { bma023_power_up(bma023); schedule_delayed_work(&bma023->work, delay_to_jiffies(delay) + 1); } } else { /* disable if state will be changed */ if (atomic_cmpxchg(&bma023->enable, 1, 0)) { cancel_delayed_work_sync(&bma023->work); bma023_power_down(bma023); } } atomic_set(&bma023->enable, enable); mutex_unlock(&bma023->enable_mutex); }
void yas_acc_late_resume(struct early_suspend *h) { struct yas_acc_private_data *data = container_of(h, struct yas_acc_private_data, early_suspend); struct yas_acc_driver *driver = data->driver; int delay; #ifdef WILLOW_SENSOR_REGULATOR_CONTROL regulator_enable(data->regulator); #endif mutex_lock(&data->data_mutex); if (data->suspend == 1) { if (data->suspend_enable) { delay = yas_acc_get_delay(driver); schedule_delayed_work(&data->work, delay_to_jiffies(delay) + 1); yas_acc_set_enable(driver,1); } } data->suspend = 0; mutex_unlock(&data->data_mutex); }
static int adxl345_resume(struct i2c_client *client) { struct adxl345_data *adxl345 = i2c_get_clientdata(client); int delay = atomic_read(&adxl345->delay); adxl345_hw_init(adxl345); adxl345_set_delay(&client->dev, delay); mutex_lock(&adxl345->enable_mutex); if (adxl345_get_enable(&client->dev)) { adxl345_power_up(adxl345); schedule_delayed_work(&adxl345->work, delay_to_jiffies(delay) + 1); } #if DEBUG adxl345->suspend = 0; #endif mutex_unlock(&adxl345->enable_mutex); return 0; }
static void adxl345_set_enable(struct device *dev, int enable) { struct i2c_client *client = to_i2c_client(dev); struct adxl345_data *adxl345 = i2c_get_clientdata(client); int delay = atomic_read(&adxl345->delay); mutex_lock(&adxl345->enable_mutex); if (enable) { /* enable if state will be changed */ if (!atomic_cmpxchg(&adxl345->enable, 0, 1)) { adxl345_power_up(adxl345); schedule_delayed_work(&adxl345->work, delay_to_jiffies(delay) + 1); } } else { /* disable if state will be changed */ if (atomic_cmpxchg(&adxl345->enable, 1, 0)) { cancel_delayed_work_sync(&adxl345->work); adxl345_power_down(adxl345); } } atomic_set(&adxl345->enable, enable); mutex_unlock(&adxl345->enable_mutex); }
static int isl29023_probe(struct i2c_client *client, const struct i2c_device_id *id) { int res; int err; int mode_check; struct isl29023_data *isl29023; printk("[LIGHT] Isl29023 Probe \n"); isl29023 = kzalloc(sizeof(struct isl29023_data), GFP_KERNEL); if (!isl29023) { return -EINVAL; } //printk(KERN_INFO MODULE_NAME ": %s isl29023 probe call, ID= %s\n", __func__, id->name); #if 1 err = isl29023_input_init(isl29023); if (err < 0) { return -EINVAL; } err = sysfs_create_group(&isl29023->input->dev.kobj, &m_isl_gr); if (err < 0) { return -EINVAL; } #endif res = isl_set_default_config(client); if (res < 0) { //pr_warn("isl29023: set default config failed!!\n"); printk(KERN_INFO MODULE_NAME ": %s isl29023 set default config failed\n", __func__); is_device = 0; // return -EINVAL; } i2c_set_clientdata(client, isl29023); isl29023->client = client; /* setup driver interfaces */ INIT_DELAYED_WORK(&isl29023->work, isl29023_work_func); last_mod = 0; mode_check = isl_set_mod(client, ISL_MOD_ALS_CONT); if (mode_check) schedule_delayed_work(&isl29023->work, delay_to_jiffies(3000) + 1); else cancel_delayed_work_sync(&isl29023->work); #if 0 //Ĩ�� �ҷ����� ���� Ÿ ������ �������� ���� ���� �۾�. err = isl29023_input_init(isl29023); if (err < 0) { return -EINVAL; } err = sysfs_create_group(&isl29023->input->dev.kobj, &m_isl_gr); if (err < 0) { return -EINVAL; } #endif // pm_runtime_enable(&client->dev); #if DEBUG dev_dbg(&client->dev, "isl29023 probe succeed!\n"); #endif return res; }