From 2489007e7d740ccbc3e0a202914e243ad5178787 Mon Sep 17 00:00:00 2001 From: codeworkx Date: Sat, 22 Sep 2012 09:48:20 +0200 Subject: merge opensource jb u5 Change-Id: I1aaec157aa196f3448eff8636134fce89a814cf2 --- drivers/sensor/cm3663.c | 113 ++---------------------------------------------- 1 file changed, 3 insertions(+), 110 deletions(-) (limited to 'drivers/sensor/cm3663.c') diff --git a/drivers/sensor/cm3663.c b/drivers/sensor/cm3663.c index c2228fb..25bf4ba 100644 --- a/drivers/sensor/cm3663.c +++ b/drivers/sensor/cm3663.c @@ -30,9 +30,6 @@ #include #include #include -#if defined(CONFIG_MACH_S2PLUS) -#include -#endif #define PROX_READ_NUM 40 @@ -151,23 +148,19 @@ int cm3663_i2c_write(struct cm3663_data *cm3663, u8 addr, u8 val) static void cm3663_light_enable(struct cm3663_data *cm3663) { u8 tmp; -#if defined(CONFIG_MACH_S2PLUS) - printk(KERN_INFO "[%s]\n", __func__); -#endif + int64_t temp_time = 0; cm3663_i2c_read(cm3663, REGS_ARA, &tmp); cm3663_i2c_read(cm3663, REGS_ARA, &tmp); cm3663_i2c_read(cm3663, REGS_ARA, &tmp); cm3663_i2c_write(cm3663, REGS_INIT, reg_defaults[3]); cm3663_i2c_write(cm3663, REGS_ALS_CMD, reg_defaults[1]); - hrtimer_start(&cm3663->light_timer, cm3663->light_poll_delay, + temp_time = ktime_to_ns(cm3663->light_poll_delay) + 100000000; + hrtimer_start(&cm3663->light_timer, ns_to_ktime(temp_time), HRTIMER_MODE_REL); } static void cm3663_light_disable(struct cm3663_data *cm3663) { -#if defined(CONFIG_MACH_S2PLUS) - printk(KERN_INFO "[%s]\n", __func__); -#endif cm3663_i2c_write(cm3663, REGS_ALS_CMD, 0x01); hrtimer_cancel(&cm3663->light_timer); cancel_work_sync(&cm3663->work_light); @@ -338,9 +331,6 @@ static ssize_t proximity_enable_store(struct device *dev, struct cm3663_data *cm3663 = dev_get_drvdata(dev); bool new_value; u8 tmp; -#if defined(CONFIG_MACH_S2PLUS) - u8 val = 1; -#endif if (sysfs_streq(buf, "1")) new_value = true; @@ -362,25 +352,6 @@ static ssize_t proximity_enable_store(struct device *dev, cm3663_i2c_write(cm3663, REGS_PS_THD, reg_defaults[7]); cm3663_i2c_write(cm3663, REGS_PS_CMD, reg_defaults[5]); -#if defined(CONFIG_MACH_S2PLUS) - /* report the first value */ - val = gpio_get_value(cm3663->i2c_client->irq); - if (val < 0) { - pr_err("%s: gpio_get_value error %d\n", __func__, val); - return IRQ_HANDLED; - } - - cm3663_i2c_read(cm3663, REGS_PS_DATA, &tmp); - printk(KERN_INFO "%s: proximity value = %d, val = %d\n", - __func__, tmp, val); - - /* 0 is close, 1 is far */ - input_report_abs(cm3663->proximity_input_dev, - ABS_DISTANCE, val); - input_sync(cm3663->proximity_input_dev); - wake_lock_timeout(&cm3663->prx_wake_lock, 3*HZ); -#endif - enable_irq(cm3663->irq); enable_irq_wake(cm3663->irq); } else if (!new_value && (cm3663->power_state & PROXIMITY_ENABLED)) { @@ -440,21 +411,12 @@ static ssize_t proximity_avg_store(struct device *dev, return size; } -#if defined(CONFIG_MACH_S2PLUS) -static DEVICE_ATTR(prox_avg, 0644, - proximity_avg_show, proximity_avg_store); -static DEVICE_ATTR(state, 0644, proximity_state_show, NULL); - -static DEVICE_ATTR(lux, 0644, lightsensor_file_state_show, - NULL); -#else static DEVICE_ATTR(proximity_avg, 0644, proximity_avg_show, proximity_avg_store); static DEVICE_ATTR(proximity_state, 0644, proximity_state_show, NULL); static DEVICE_ATTR(lightsensor_file_state, 0644, lightsensor_file_state_show, NULL); -#endif static DEVICE_ATTR(poll_delay, S_IRUGO | S_IWUSR | S_IWGRP, poll_delay_show, poll_delay_store); @@ -488,19 +450,13 @@ static struct attribute_group proximity_attribute_group = { static void cm3663_work_func_light(struct work_struct *work) { - int i; int als; struct cm3663_data *cm3663 = container_of(work, struct cm3663_data, work_light); als = lightsensor_get_alsvalue(cm3663); -#if defined(CONFIG_MACH_S2PLUS) - input_report_rel(cm3663->light_input_dev, - REL_MISC, als + 1); -#else input_report_abs(cm3663->light_input_dev, ABS_MISC, als + 1); -#endif input_sync(cm3663->light_input_dev); } @@ -716,12 +672,8 @@ static int cm3663_i2c_probe(struct i2c_client *client, } input_set_drvdata(input_dev, cm3663); input_dev->name = "light_sensor"; -#if defined(CONFIG_MACH_S2PLUS) - input_set_capability(input_dev, EV_REL, REL_MISC); -#else input_set_capability(input_dev, EV_ABS, ABS_MISC); input_set_abs_params(input_dev, ABS_MISC, 0, 1, 0, 0); -#endif ret = input_register_device(input_dev); if (ret < 0) { @@ -737,43 +689,6 @@ static int cm3663_i2c_probe(struct i2c_client *client, goto err_sysfs_create_group_light; } -#if defined(CONFIG_MACH_S2PLUS) - /* set sysfs for proximity sensor */ - cm3663->proximity_dev = sensors_classdev_register("proximity_sensor"); - if (IS_ERR(cm3663->proximity_dev)) { - pr_err("%s: could not create proximity_dev\n", __func__); - goto err_proximity_classdev_create; - } - - if (device_create_file(cm3663->proximity_dev, - &dev_attr_state) < 0) { - pr_err("%s: could not create device file(%s)!\n", __func__, - dev_attr_state.attr.name); - goto err_proximity_device_create_file1; - } - - if (device_create_file(cm3663->proximity_dev, - &dev_attr_prox_avg) < 0) { - pr_err("%s: could not create device file(%s)!\n", __func__, - dev_attr_prox_avg.attr.name); - goto err_proximity_device_create_file2; - } - dev_set_drvdata(cm3663->proximity_dev, cm3663); - - /* set sysfs for light sensor */ - cm3663->switch_cmd_dev = sensors_classdev_register("light_sensor"); - if (IS_ERR(cm3663->switch_cmd_dev)) { - pr_err("%s: could not create switch_cmd_dev\n", __func__); - goto err_light_classdev_create; - } - if (device_create_file(cm3663->switch_cmd_dev, - &dev_attr_lux) < 0) { - pr_err("%s: could not create device file(%s)!\n", __func__, - dev_attr_lux.attr.name); - goto err_light_device_create_file; - } - dev_set_drvdata(cm3663->switch_cmd_dev, cm3663); -#else /* set sysfs for proximity sensor */ cm3663->proximity_class = class_create(THIS_MODULE, "proximity"); if (IS_ERR(cm3663->proximity_class)) { @@ -824,22 +739,10 @@ static int cm3663_i2c_probe(struct i2c_client *client, goto err_light_device_create_file; } dev_set_drvdata(cm3663->switch_cmd_dev, cm3663); -#endif goto done; /* error, unwind it all */ -#if defined(CONFIG_MACH_S2PLUS) -err_light_device_create_file: - sensors_classdev_unregister(cm3663->switch_cmd_dev); -err_light_classdev_create: - device_remove_file(cm3663->proximity_dev, &dev_attr_prox_avg); -err_proximity_device_create_file2: - device_remove_file(cm3663->proximity_dev, &dev_attr_state); -err_proximity_device_create_file1: - sensors_classdev_unregister(cm3663->proximity_dev); -err_proximity_classdev_create: -#else err_light_device_create_file: device_destroy(cm3663->lightsensor_class, 0); err_light_device_create: @@ -853,7 +756,6 @@ err_proximity_device_create_file1: err_proximity_device_create: class_destroy(cm3663->proximity_class); err_proximity_class_create: -#endif sysfs_remove_group(&input_dev->dev.kobj, &light_attribute_group); err_sysfs_create_group_light: @@ -910,14 +812,6 @@ static int cm3663_i2c_remove(struct i2c_client *client) { struct cm3663_data *cm3663 = i2c_get_clientdata(client); -#if defined(CONFIG_MACH_S2PLUS) - device_remove_file(cm3663->switch_cmd_dev, - &dev_attr_lux); - sensors_classdev_unregister(cm3663->switch_cmd_dev); - device_remove_file(cm3663->proximity_dev, &dev_attr_prox_avg); - device_remove_file(cm3663->proximity_dev, &dev_attr_state); - sensors_classdev_unregister(cm3663->proximity_dev); -#else device_remove_file(cm3663->proximity_dev, &dev_attr_proximity_avg); device_remove_file(cm3663->switch_cmd_dev, @@ -928,7 +822,6 @@ static int cm3663_i2c_remove(struct i2c_client *client) device_remove_file(cm3663->proximity_dev, &dev_attr_proximity_state); device_destroy(cm3663->proximity_class, 0); class_destroy(cm3663->proximity_class); -#endif sysfs_remove_group(&cm3663->light_input_dev->dev.kobj, &light_attribute_group); input_unregister_device(cm3663->light_input_dev); -- cgit v1.1