summaryrefslogtreecommitdiff
path: root/drivers/staging
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/staging')
-rw-r--r--drivers/staging/android/sync.c18
-rw-r--r--drivers/staging/iio/adc/palmas_gpadc.c20
-rw-r--r--drivers/staging/iio/light/Kconfig5
-rw-r--r--drivers/staging/iio/light/cm3217.c14
-rw-r--r--drivers/staging/iio/light/iqs253.c4
-rw-r--r--drivers/staging/iio/light/jsa1127.c32
-rw-r--r--drivers/staging/iio/light/ltr558als.c44
-rw-r--r--drivers/staging/iio/meter/ina230.c63
8 files changed, 131 insertions, 69 deletions
diff --git a/drivers/staging/android/sync.c b/drivers/staging/android/sync.c
index 6a839fc6896e..f0df89ec9b35 100644
--- a/drivers/staging/android/sync.c
+++ b/drivers/staging/android/sync.c
@@ -34,6 +34,7 @@
static void sync_fence_signal_pt(struct sync_pt *pt);
static int _sync_pt_has_signaled(struct sync_pt *pt);
static void sync_fence_free(struct kref *kref);
+static void sync_fence_dump(struct sync_fence *fence);
static void sync_dump(void);
static LIST_HEAD(sync_timeline_list_head);
@@ -613,6 +614,7 @@ int sync_fence_wait(struct sync_fence *fence, long timeout)
if (fence->status < 0) {
pr_info("fence error %d on [%p]\n", fence->status, fence);
+ sync_fence_dump(fence);
sync_dump();
return fence->status;
}
@@ -621,6 +623,7 @@ int sync_fence_wait(struct sync_fence *fence, long timeout)
if (timeout > 0) {
pr_info("fence timeout on [%p] after %dms\n", fence,
jiffies_to_msecs(timeout));
+ sync_fence_dump(fence);
sync_dump();
}
return -ETIME;
@@ -842,6 +845,21 @@ static long sync_fence_ioctl(struct file *file, unsigned int cmd,
}
}
+static void sync_fence_dump(struct sync_fence *fence)
+{
+ struct sync_pt *pt;
+ char val[32];
+
+ list_for_each_entry(pt, &fence->pt_list_head, pt_list) {
+ val[0] = '\0';
+ if (pt->parent->ops->pt_value_str)
+ pt->parent->ops->pt_value_str(pt, val, sizeof(val));
+
+ pr_info("name=%s, value=%s\n", pt->parent->name, val);
+ }
+
+}
+
#ifdef CONFIG_DEBUG_FS
static const char *sync_status_str(int status)
{
diff --git a/drivers/staging/iio/adc/palmas_gpadc.c b/drivers/staging/iio/adc/palmas_gpadc.c
index b6f030c39f09..dc2e03fd2a48 100644
--- a/drivers/staging/iio/adc/palmas_gpadc.c
+++ b/drivers/staging/iio/adc/palmas_gpadc.c
@@ -37,6 +37,7 @@
#include <linux/iio/iio.h>
#include <linux/iio/machine.h>
#include <linux/iio/driver.h>
+#include <linux/mutex.h>
#define MOD_NAME "palmas-gpadc"
#define ADC_CONVERTION_TIMEOUT (msecs_to_jiffies(5000))
@@ -103,6 +104,8 @@ struct palmas_gpadc {
int auto_conversion_period;
struct dentry *dentry;
+ bool is_shutdown;
+ struct mutex lock;
};
/*
@@ -550,7 +553,7 @@ static int palmas_gpadc_start_convertion(struct palmas_gpadc *adc, int adc_chan)
ret = (val & 0xFFF);
if (ret == 0) {
ret = palmas_gpadc_check_status(adc);
- if (ret == 0)
+ if (ret < 0)
ret = -EAGAIN;
}
@@ -586,8 +589,13 @@ static int palmas_gpadc_read_raw(struct iio_dev *indio_dev,
if (adc_chan > PALMAS_ADC_CH_MAX)
return -EINVAL;
- mutex_lock(&indio_dev->mlock);
+ mutex_lock(&adc->lock);
+ if (adc->is_shutdown) {
+ mutex_unlock(&adc->lock);
+ return -EINVAL;
+ }
+ mutex_lock(&indio_dev->mlock);
switch (mask) {
case IIO_CHAN_INFO_RAW:
case IIO_CHAN_INFO_PROCESSED:
@@ -664,11 +672,13 @@ static int palmas_gpadc_read_raw(struct iio_dev *indio_dev,
}
mutex_unlock(&indio_dev->mlock);
+ mutex_unlock(&adc->lock);
return ret;
out:
palmas_gpadc_read_done(adc, adc_chan);
mutex_unlock(&indio_dev->mlock);
+ mutex_unlock(&adc->lock);
return ret;
}
@@ -1055,6 +1065,9 @@ static int palmas_gpadc_probe(struct platform_device *pdev)
init_completion(&adc->conv_completion);
dev_set_drvdata(&pdev->dev, iodev);
+ adc->is_shutdown = false;
+ mutex_init(&adc->lock);
+
adc->auto_conversion_period = gpadc_pdata->auto_conversion_period_ms;
adc->irq = palmas_irq_get_virq(adc->palmas, PALMAS_GPADC_EOC_SW_IRQ);
ret = request_threaded_irq(adc->irq, NULL,
@@ -1207,8 +1220,11 @@ static void palmas_gpadc_shutdown(struct platform_device *pdev)
struct iio_dev *iodev = dev_get_drvdata(&pdev->dev);
struct palmas_gpadc *adc = iio_priv(iodev);
+ mutex_lock(&adc->lock);
+ adc->is_shutdown = true;
if (adc->auto_conv0_enable || adc->auto_conv1_enable)
palmas_gpadc_auto_conv_reset(adc);
+ mutex_unlock(&adc->lock);
}
#ifdef CONFIG_PM_SLEEP
diff --git a/drivers/staging/iio/light/Kconfig b/drivers/staging/iio/light/Kconfig
index 49d0b146450e..3630c68dee51 100644
--- a/drivers/staging/iio/light/Kconfig
+++ b/drivers/staging/iio/light/Kconfig
@@ -98,9 +98,14 @@ config SENSORS_TCS3772
config SENSORS_CM3217
tristate "CM3217 Ambient light sensor"
depends on I2C
+ select LS_OF
+ select LS_SYSFS
default n
help
Say Y here to enable the CM3217 Ambient Light Sensor.
+ This driver will provide the measurements of ambient light intensity
+ in its own units.
+ Data from sensor is accessible via sysfs.
config LS_OF
tristate "Device Tree parsing for Light sensor specification details"
diff --git a/drivers/staging/iio/light/cm3217.c b/drivers/staging/iio/light/cm3217.c
index e5cc8e7f7223..a955bb255d7e 100644
--- a/drivers/staging/iio/light/cm3217.c
+++ b/drivers/staging/iio/light/cm3217.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013, NVIDIA CORPORATION. All rights reserved.
+/* Copyright (c) 2013-2014, NVIDIA CORPORATION. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
@@ -19,6 +19,8 @@
#include <linux/regulator/consumer.h>
#include <linux/iio/iio.h>
#include <linux/iio/sysfs.h>
+#include <linux/iio/light/ls_sysfs.h>
+#include <linux/iio/light/ls_dt.h>
/* IT = Integration Time. The amount of time the photons hit the sensor.
* STEP = the value from HW which is the photon count during IT.
@@ -445,6 +447,7 @@ static int cm3217_probe(struct i2c_client *client,
{
struct cm3217_inf *inf;
struct iio_dev *indio_dev;
+ struct lightsensor_spec *ls_spec;
int err;
indio_dev = iio_device_alloc(sizeof(*inf));
@@ -455,6 +458,15 @@ static int cm3217_probe(struct i2c_client *client,
inf = iio_priv(indio_dev);
+ ls_spec = of_get_ls_spec(&client->dev);
+ if (!ls_spec) {
+ dev_warn(&client->dev,
+ "devname:%s func:%s line:%d invalid meta data, use default\n",
+ id->name, __func__, __LINE__);
+ } else {
+ fill_ls_attrs(ls_spec, cm3217_attrs);
+ }
+
inf->wq = create_singlethread_workqueue(CM3217_NAME);
if (!inf->wq) {
dev_err(&client->dev, "%s workqueue err\n", __func__);
diff --git a/drivers/staging/iio/light/iqs253.c b/drivers/staging/iio/light/iqs253.c
index 035d3fe79d9a..76b264a66de6 100644
--- a/drivers/staging/iio/light/iqs253.c
+++ b/drivers/staging/iio/light/iqs253.c
@@ -151,7 +151,7 @@ static void iqs253_i2c_hand_shake(struct iqs253_chip *iqs253_chip)
int retry_count = 10;
do {
gpio_direction_output(iqs253_chip->rdy_gpio, 0);
- mdelay(10);
+ usleep_range(10 * 1000, 10 * 1000);
/* put to tristate */
gpio_direction_input(iqs253_chip->rdy_gpio);
} while (gpio_get_value(iqs253_chip->rdy_gpio) && retry_count--);
@@ -206,8 +206,8 @@ static int iqs253_set(struct iqs253_chip *iqs253_chip, int mode)
/* wait for ATI to finish */
do {
+ usleep_range(10 * 1000, 10 * 1000);
ret = iqs253_i2c_read_byte(iqs253_chip, SYSFLAGS);
- mdelay(10);
} while (ret & ATI_IN_PROGRESS);
iqs253_chip->mode = mode;
diff --git a/drivers/staging/iio/light/jsa1127.c b/drivers/staging/iio/light/jsa1127.c
index a8678ea5ed30..4141f7f55363 100644
--- a/drivers/staging/iio/light/jsa1127.c
+++ b/drivers/staging/iio/light/jsa1127.c
@@ -519,6 +519,16 @@ static int jsa1127_probe(struct i2c_client *client,
i2c_set_clientdata(client, indio_dev);
chip->client = client;
+ chip->regulator = devm_regulator_get(&client->dev, "vdd");
+ if (IS_ERR(chip->regulator)) {
+ dev_info(&client->dev,
+ "idname:%s func:%s line:%d regulator not found.\n"
+ "Assuming regulator is not needed\n",
+ id->name, __func__, __LINE__);
+ chip->regulator = NULL;
+ goto finish;
+ }
+
indio_dev->info = &jsa1127_iio_info;
indio_dev->channels = jsa1127_channels;
indio_dev->num_channels = 1;
@@ -537,16 +547,6 @@ static int jsa1127_probe(struct i2c_client *client,
WQ_NON_REENTRANT | WQ_UNBOUND, 1);
INIT_DELAYED_WORK(&chip->dw, jsa1127_work_func);
- chip->regulator = devm_regulator_get(&client->dev, "vdd");
- if (IS_ERR(chip->regulator)) {
- dev_info(&client->dev,
- "idname:%s func:%s line:%d regulator not found.\n"
- "Assuming regulator is not needed\n",
- id->name, __func__, __LINE__);
- chip->regulator = NULL;
- goto finish;
- }
-
if (regulator_is_enabled(chip->regulator))
jsa1127_send_cmd_locked(chip, JSA1127_CMD_STANDBY);
if (ret)
@@ -567,14 +567,13 @@ free_iio_dev:
return ret;
}
-/* no need for any additional shutdown flag as
- * by now workqueue will not schedule */
-static void jsa1127_shutdown(struct i2c_client *client)
+static int jsa1127_remove(struct i2c_client *client)
{
struct iio_dev *indio_dev = i2c_get_clientdata(client);
struct jsa1127_chip *chip = iio_priv(indio_dev);
int ret;
+ iio_device_unregister(indio_dev);
destroy_workqueue(chip->wq);
if (chip->regulator && (chip->als_state != CHIP_POWER_OFF))
regulator_disable(chip->regulator);
@@ -582,13 +581,7 @@ static void jsa1127_shutdown(struct i2c_client *client)
if (!chip->regulator || regulator_is_enabled(chip->regulator))
ret = jsa1127_send_cmd_locked(chip, JSA1127_CMD_STANDBY);
- iio_device_unregister(indio_dev);
iio_device_free(indio_dev);
-}
-
-static int jsa1127_remove(struct i2c_client *client)
-{
- jsa1127_shutdown(client);
return 0;
}
#undef SEND
@@ -616,7 +609,6 @@ static struct i2c_driver jsa1127_driver = {
.id_table = jsa1127_id,
.probe = jsa1127_probe,
.remove = jsa1127_remove,
- .shutdown = jsa1127_shutdown,
};
module_i2c_driver(jsa1127_driver);
diff --git a/drivers/staging/iio/light/ltr558als.c b/drivers/staging/iio/light/ltr558als.c
index f5146123f284..e4983dbd46b6 100644
--- a/drivers/staging/iio/light/ltr558als.c
+++ b/drivers/staging/iio/light/ltr558als.c
@@ -872,48 +872,6 @@ static int ltr558_remove(struct i2c_client *client)
return 0;
}
-
-static int ltr558_suspend(struct i2c_client *client, pm_message_t mesg)
-{
- struct iio_dev *indio_dev = i2c_get_clientdata(client);
- struct ltr558_chip *chip = iio_priv(indio_dev);
- int ret;
-
- if (chip->is_als_enable == 1)
- chip->als_enabled_before_suspend = 1;
- if (chip->is_prox_enable == 1)
- chip->prox_enabled_before_suspend = 1;
-
- ret = ltr558_ps_disable(client);
- if (ret == 0)
- ret = ltr558_als_disable(client);
-
- return ret;
-}
-
-
-static int ltr558_resume(struct i2c_client *client)
-{
- struct iio_dev *indio_dev = i2c_get_clientdata(client);
- struct ltr558_chip *chip = iio_priv(indio_dev);
- int error = 0;
-
- mdelay(PON_DELAY);
-
- if (chip->prox_enabled_before_suspend == 1) {
- error = ltr558_ps_enable(client, chip->ps_gainrange);
- if (error < 0)
- goto out;
- }
-
- if (chip->als_enabled_before_suspend == 1) {
- error = ltr558_als_enable(client, chip->als_gainrange);
- }
-out:
- return error;
-}
-
-
static const struct i2c_device_id ltr558_id[] = {
{ DEVICE_NAME, 0 },
{}
@@ -937,8 +895,6 @@ static struct i2c_driver ltr558_driver = {
.name = DEVICE_NAME,
.of_match_table = of_match_ptr(ltr558_of_match),
},
- .suspend = ltr558_suspend,
- .resume = ltr558_resume,
};
diff --git a/drivers/staging/iio/meter/ina230.c b/drivers/staging/iio/meter/ina230.c
index 20e26f155db6..d37ad274f626 100644
--- a/drivers/staging/iio/meter/ina230.c
+++ b/drivers/staging/iio/meter/ina230.c
@@ -74,6 +74,7 @@ enum {
CHANNEL_NAME = 0,
CURRENT_THRESHOLD,
ALERT_FLAG,
+ VBUS_VOLTAGE_CURRENT,
};
struct ina230_platform_data {
@@ -480,6 +481,53 @@ static int ina230_get_shunt_power(struct ina230_chip *chip, int *power_mw)
return 0;
}
+static int ina230_get_vbus_voltage_current(struct ina230_chip *chip,
+ int *current_ma, int *voltage_mv)
+{
+ int ret = 0, val;
+ int ma;
+
+ mutex_lock(&chip->mutex);
+ /* ensure that triggered mode will be used */
+ chip->running = 0;
+ ret = ina230_ensure_enabled_start(chip);
+ if (ret < 0)
+ goto out;
+
+ ret = __locked_wait_for_conversion(chip);
+ if (ret)
+ goto out;
+
+ val = i2c_smbus_read_word_data(chip->client, INA230_VOLTAGE);
+ if (val < 0) {
+ ret = val;
+ goto out;
+ }
+ *voltage_mv = busv_register_to_mv(be16_to_cpu(val));
+
+ if (chip->pdata->resistor) {
+ val = i2c_smbus_read_word_data(chip->client, INA230_SHUNT);
+ if (val < 0) {
+ ret = val;
+ goto out;
+ }
+ ma = shuntv_register_to_uv((s16)be16_to_cpu(val));
+ ma = DIV_ROUND_CLOSEST(ma, chip->pdata->resistor);
+ if (chip->pdata->shunt_polarity_inverted)
+ ma *= -1;
+ *current_ma = ma;
+ } else {
+ *current_ma = 0;
+ }
+out:
+ /* restart continuous current monitoring, if enabled */
+ if (chip->pdata->current_threshold)
+ __locked_ina230_evaluate_state(chip);
+ mutex_unlock(&chip->mutex);
+ return ret;
+}
+
+
static int ina230_set_current_threshold(struct ina230_chip *chip,
int current_ma)
{
@@ -603,6 +651,9 @@ static ssize_t ina230_show_channel(struct device *dev,
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ina230_chip *chip = iio_priv(indio_dev);
struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
+ int current_ma = 0;
+ int voltage_mv = 0;
+ int ret;
switch (this_attr->address) {
case CHANNEL_NAME:
@@ -614,6 +665,13 @@ static ssize_t ina230_show_channel(struct device *dev,
case ALERT_FLAG:
return ina230_show_alert_flag(chip, buf);
+ case VBUS_VOLTAGE_CURRENT:
+ ret = ina230_get_vbus_voltage_current(chip, &current_ma,
+ &voltage_mv);
+ if (!ret)
+ return sprintf(buf, "%d %d\n", voltage_mv, current_ma);
+ return ret;
+
default:
break;
}
@@ -653,11 +711,16 @@ static IIO_DEVICE_ATTR(current_threshold, S_IRUGO | S_IWUSR,
static IIO_DEVICE_ATTR(alert_flag, S_IRUGO,
ina230_show_channel, NULL, ALERT_FLAG);
+static IIO_DEVICE_ATTR(ui_input, S_IRUSR|S_IRGRP,
+ ina230_show_channel, NULL,
+ VBUS_VOLTAGE_CURRENT);
+
static struct attribute *ina230_attributes[] = {
&iio_dev_attr_rail_name.dev_attr.attr,
&iio_dev_attr_current_threshold.dev_attr.attr,
&iio_dev_attr_alert_flag.dev_attr.attr,
+ &iio_dev_attr_ui_input.dev_attr.attr,
NULL,
};