[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <3621e6eb47c287eeffaef7bf68521d0d1740a296.1371145891.git.andi@etezian.org>
Date: Thu, 13 Jun 2013 20:20:38 +0200
From: Andi Shyti <andi@...zian.org>
To: arnd@...db.de, gregkh@...uxfoundation.org
Cc: linux-kernel@...r.kernel.org, pc@...f.org, oatilla@...il.com,
andi@...zian.org
Subject: [PATCH 04/19] bh1770glc: Added raw lux output file for ALS to sysfs
From: Onur Atilla <oatilla@...il.com>
"lux0_raw" file gives the raw Ambient Light Sensor (ALS) value,
before adjusting it with the calibration coefficients, whereas
"lux0_input"returns the calibrated ALS value.
Signed-off-by: Onur Atilla <oatilla@...il.com>
Signed-off-by: Andi Shyti <andi@...zian.org>
---
drivers/misc/bh1770glc.c | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/drivers/misc/bh1770glc.c b/drivers/misc/bh1770glc.c
index 82c30e7..d8d6526 100644
--- a/drivers/misc/bh1770glc.c
+++ b/drivers/misc/bh1770glc.c
@@ -395,6 +395,12 @@ static int bh1770_lux_read_result(struct bh1770_chip *chip)
return bh1770_lux_raw_to_adjusted(chip, chip->lux_data_raw);
}
+static int bh1770_lux_read_raw_result(struct bh1770_chip *chip)
+{
+ bh1770_lux_get_result(chip);
+ return chip->lux_data_raw;
+}
+
/*
* Chip on / off functions are called while keeping mutex except probe
* or remove phase
@@ -725,6 +731,29 @@ static ssize_t bh1770_lux_result_show(struct device *dev,
return ret;
}
+static ssize_t bh1770_lux_raw_result_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct bh1770_chip *chip = dev_get_drvdata(dev);
+ ssize_t ret;
+ long timeout;
+
+ if (pm_runtime_suspended(dev))
+ return -EIO; /* Chip is not enabled at all */
+
+ timeout = wait_event_interruptible_timeout(chip->wait,
+ !chip->lux_wait_result,
+ msecs_to_jiffies(BH1770_TIMEOUT));
+ if (!timeout)
+ return -EIO;
+
+ mutex_lock(&chip->mutex);
+ ret = sprintf(buf, "%d\n", bh1770_lux_read_raw_result(chip));
+ mutex_unlock(&chip->mutex);
+
+ return ret;
+}
+
static ssize_t bh1770_lux_range_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
@@ -1184,6 +1213,7 @@ static DEVICE_ATTR(lux0_glass_factor, S_IRUGO, bh1770_lux_glass_factor_show,
NULL);
static DEVICE_ATTR(lux0_sensor_comp_factor, S_IRUGO, bh1770_lux_scf_show, NULL);
static DEVICE_ATTR(lux0_input, S_IRUGO, bh1770_lux_result_show, NULL);
+static DEVICE_ATTR(lux0_raw, S_IRUGO, bh1770_lux_raw_result_show, NULL);
static DEVICE_ATTR(lux0_sensor_range, S_IRUGO, bh1770_lux_range_show, NULL);
static DEVICE_ATTR(lux0_rate, S_IRUGO | S_IWUSR, bh1770_get_lux_rate,
bh1770_set_lux_rate);
@@ -1205,6 +1235,7 @@ static struct attribute *sysfs_attrs[] = {
&dev_attr_lux0_glass_factor.attr,
&dev_attr_lux0_sensor_comp_factor.attr,
&dev_attr_lux0_input.attr,
+ &dev_attr_lux0_raw.attr,
&dev_attr_lux0_sensor_range.attr,
&dev_attr_lux0_rate.attr,
&dev_attr_lux0_rate_avail.attr,
--
1.7.10.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists