Commit eb3e6ae9 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

Merge tag 'iio-for-3.13c' of...

Merge tag 'iio-for-3.13c' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-next

Jonathan writes:

Third set of new functionality and cleanups for IIO in the 3.13 cycle.

Driver New Functionality
* MXS - new interrupt driven touch screen support for i.MX23/28. Old
  polled implementation dropped.

Driver Cleanups
* Some spi_sync boilerplate dropped by using spi_sync_transfer
* Some switching of drivers to the fractional type for scale reading.
  Moves the ugly calculation into one place.
* Fix the documentation for *_voltage_scale which is never been correct
  or as implemented in any driver.
* HID sensor hub and children : Open the sensor hub only when someone cares.
* hmc5843 - various minor
parents 5f1a1369 3658a71b
...@@ -79,7 +79,7 @@ Description: ...@@ -79,7 +79,7 @@ Description:
correspond to externally available input one of the named correspond to externally available input one of the named
versions may be used. The number must always be specified and versions may be used. The number must always be specified and
unique to allow association with event codes. Units after unique to allow association with event codes. Units after
application of scale and offset are microvolts. application of scale and offset are millivolts.
What: /sys/bus/iio/devices/iio:deviceX/in_voltageY-voltageZ_raw What: /sys/bus/iio/devices/iio:deviceX/in_voltageY-voltageZ_raw
KernelVersion: 2.6.35 KernelVersion: 2.6.35
...@@ -90,7 +90,7 @@ Description: ...@@ -90,7 +90,7 @@ Description:
physically equivalent inputs when non differential readings are physically equivalent inputs when non differential readings are
separately available. In differential only parts, then all that separately available. In differential only parts, then all that
is required is a consistent labeling. Units after application is required is a consistent labeling. Units after application
of scale and offset are microvolts. of scale and offset are millivolts.
What: /sys/bus/iio/devices/iio:deviceX/in_capacitanceY_raw What: /sys/bus/iio/devices/iio:deviceX/in_capacitanceY_raw
KernelVersion: 3.2 KernelVersion: 3.2
......
* Freescale i.MX28 LRADC device driver * Freescale i.MX28 LRADC device driver
Required properties: Required properties:
- compatible: Should be "fsl,imx28-lradc" - compatible: Should be "fsl,imx23-lradc" for i.MX23 SoC and "fsl,imx28-lradc"
for i.MX28 SoC
- reg: Address and length of the register set for the device - reg: Address and length of the register set for the device
- interrupts: Should contain the LRADC interrupts - interrupts: Should contain the LRADC interrupts
...@@ -9,13 +10,38 @@ Optional properties: ...@@ -9,13 +10,38 @@ Optional properties:
- fsl,lradc-touchscreen-wires: Number of wires used to connect the touchscreen - fsl,lradc-touchscreen-wires: Number of wires used to connect the touchscreen
to LRADC. Valid value is either 4 or 5. If this to LRADC. Valid value is either 4 or 5. If this
property is not present, then the touchscreen is property is not present, then the touchscreen is
disabled. disabled. 5 wires is valid for i.MX28 SoC only.
- fsl,ave-ctrl: number of samples per direction to calculate an average value.
Allowed value is 1 ... 31, default is 4
- fsl,ave-delay: delay between consecutive samples. Allowed value is
1 ... 2047. It is used if 'fsl,ave-ctrl' > 1, counts at
2 kHz and its default is 2 (= 1 ms)
- fsl,settling: delay between plate switch to next sample. Allowed value is
1 ... 2047. It counts at 2 kHz and its default is
10 (= 5 ms)
Examples: Example for i.MX23 SoC:
lradc@80050000 {
compatible = "fsl,imx23-lradc";
reg = <0x80050000 0x2000>;
interrupts = <36 37 38 39 40 41 42 43 44>;
status = "okay";
fsl,lradc-touchscreen-wires = <4>;
fsl,ave-ctrl = <4>;
fsl,ave-delay = <2>;
fsl,settling = <10>;
};
Example for i.MX28 SoC:
lradc@80050000 { lradc@80050000 {
compatible = "fsl,imx28-lradc"; compatible = "fsl,imx28-lradc";
reg = <0x80050000 0x2000>; reg = <0x80050000 0x2000>;
interrupts = <10 14 15 16 17 18 19 interrupts = <10 14 15 16 17 18 19 20 21 22 23 24 25>;
20 21 22 23 24 25>; status = "okay";
fsl,lradc-touchscreen-wires = <5>;
fsl,ave-ctrl = <4>;
fsl,ave-delay = <2>;
fsl,settling = <10>;
}; };
...@@ -430,6 +430,7 @@ lradc@80050000 { ...@@ -430,6 +430,7 @@ lradc@80050000 {
reg = <0x80050000 0x2000>; reg = <0x80050000 0x2000>;
interrupts = <36 37 38 39 40 41 42 43 44>; interrupts = <36 37 38 39 40 41 42 43 44>;
status = "disabled"; status = "disabled";
clocks = <&clks 26>;
}; };
spdif@80054000 { spdif@80054000 {
......
...@@ -183,6 +183,10 @@ saif1: saif@80046000 { ...@@ -183,6 +183,10 @@ saif1: saif@80046000 {
lradc@80050000 { lradc@80050000 {
status = "okay"; status = "okay";
fsl,lradc-touchscreen-wires = <4>;
fsl,ave-ctrl = <4>;
fsl,ave-delay = <2>;
fsl,settling = <10>;
}; };
i2c0: i2c@80058000 { i2c0: i2c@80058000 {
......
...@@ -902,6 +902,7 @@ lradc: lradc@80050000 { ...@@ -902,6 +902,7 @@ lradc: lradc@80050000 {
interrupts = <10 14 15 16 17 18 19 interrupts = <10 14 15 16 17 18 19
20 21 22 23 24 25>; 20 21 22 23 24 25>;
status = "disabled"; status = "disabled";
clocks = <&clks 41>;
}; };
spdif: spdif@80054000 { spdif: spdif@80054000 {
......
...@@ -465,6 +465,39 @@ static int sensor_hub_raw_event(struct hid_device *hdev, ...@@ -465,6 +465,39 @@ static int sensor_hub_raw_event(struct hid_device *hdev,
return 1; return 1;
} }
int sensor_hub_device_open(struct hid_sensor_hub_device *hsdev)
{
int ret = 0;
struct sensor_hub_data *data = hid_get_drvdata(hsdev->hdev);
mutex_lock(&data->mutex);
if (!hsdev->ref_cnt) {
ret = hid_hw_open(hsdev->hdev);
if (ret) {
hid_err(hsdev->hdev, "failed to open hid device\n");
mutex_unlock(&data->mutex);
return ret;
}
}
hsdev->ref_cnt++;
mutex_unlock(&data->mutex);
return ret;
}
EXPORT_SYMBOL_GPL(sensor_hub_device_open);
void sensor_hub_device_close(struct hid_sensor_hub_device *hsdev)
{
struct sensor_hub_data *data = hid_get_drvdata(hsdev->hdev);
mutex_lock(&data->mutex);
hsdev->ref_cnt--;
if (!hsdev->ref_cnt)
hid_hw_close(hsdev->hdev);
mutex_unlock(&data->mutex);
}
EXPORT_SYMBOL_GPL(sensor_hub_device_close);
static int sensor_hub_probe(struct hid_device *hdev, static int sensor_hub_probe(struct hid_device *hdev,
const struct hid_device_id *id) const struct hid_device_id *id)
{ {
...@@ -506,12 +539,6 @@ static int sensor_hub_probe(struct hid_device *hdev, ...@@ -506,12 +539,6 @@ static int sensor_hub_probe(struct hid_device *hdev,
hid_err(hdev, "hw start failed\n"); hid_err(hdev, "hw start failed\n");
return ret; return ret;
} }
ret = hid_hw_open(hdev);
if (ret) {
hid_err(hdev, "failed to open input interrupt pipe\n");
goto err_stop_hw;
}
INIT_LIST_HEAD(&sd->dyn_callback_list); INIT_LIST_HEAD(&sd->dyn_callback_list);
sd->hid_sensor_client_cnt = 0; sd->hid_sensor_client_cnt = 0;
report_enum = &hdev->report_enum[HID_INPUT_REPORT]; report_enum = &hdev->report_enum[HID_INPUT_REPORT];
...@@ -520,7 +547,7 @@ static int sensor_hub_probe(struct hid_device *hdev, ...@@ -520,7 +547,7 @@ static int sensor_hub_probe(struct hid_device *hdev,
if (dev_cnt > HID_MAX_PHY_DEVICES) { if (dev_cnt > HID_MAX_PHY_DEVICES) {
hid_err(hdev, "Invalid Physical device count\n"); hid_err(hdev, "Invalid Physical device count\n");
ret = -EINVAL; ret = -EINVAL;
goto err_close; goto err_stop_hw;
} }
sd->hid_sensor_hub_client_devs = kzalloc(dev_cnt * sd->hid_sensor_hub_client_devs = kzalloc(dev_cnt *
sizeof(struct mfd_cell), sizeof(struct mfd_cell),
...@@ -528,7 +555,7 @@ static int sensor_hub_probe(struct hid_device *hdev, ...@@ -528,7 +555,7 @@ static int sensor_hub_probe(struct hid_device *hdev,
if (sd->hid_sensor_hub_client_devs == NULL) { if (sd->hid_sensor_hub_client_devs == NULL) {
hid_err(hdev, "Failed to allocate memory for mfd cells\n"); hid_err(hdev, "Failed to allocate memory for mfd cells\n");
ret = -ENOMEM; ret = -ENOMEM;
goto err_close; goto err_stop_hw;
} }
list_for_each_entry(report, &report_enum->report_list, list) { list_for_each_entry(report, &report_enum->report_list, list) {
hid_dbg(hdev, "Report id:%x\n", report->id); hid_dbg(hdev, "Report id:%x\n", report->id);
...@@ -565,8 +592,6 @@ static int sensor_hub_probe(struct hid_device *hdev, ...@@ -565,8 +592,6 @@ static int sensor_hub_probe(struct hid_device *hdev,
for (i = 0; i < sd->hid_sensor_client_cnt ; ++i) for (i = 0; i < sd->hid_sensor_client_cnt ; ++i)
kfree(sd->hid_sensor_hub_client_devs[i].name); kfree(sd->hid_sensor_hub_client_devs[i].name);
kfree(sd->hid_sensor_hub_client_devs); kfree(sd->hid_sensor_hub_client_devs);
err_close:
hid_hw_close(hdev);
err_stop_hw: err_stop_hw:
hid_hw_stop(hdev); hid_hw_stop(hdev);
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
struct ad7266_state { struct ad7266_state {
struct spi_device *spi; struct spi_device *spi;
struct regulator *reg; struct regulator *reg;
unsigned long vref_uv; unsigned long vref_mv;
struct spi_transfer single_xfer[3]; struct spi_transfer single_xfer[3];
struct spi_message single_msg; struct spi_message single_msg;
...@@ -156,7 +156,7 @@ static int ad7266_read_raw(struct iio_dev *indio_dev, ...@@ -156,7 +156,7 @@ static int ad7266_read_raw(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan, int *val, int *val2, long m) struct iio_chan_spec const *chan, int *val, int *val2, long m)
{ {
struct ad7266_state *st = iio_priv(indio_dev); struct ad7266_state *st = iio_priv(indio_dev);
unsigned long scale_uv; unsigned long scale_mv;
int ret; int ret;
switch (m) { switch (m) {
...@@ -174,16 +174,15 @@ static int ad7266_read_raw(struct iio_dev *indio_dev, ...@@ -174,16 +174,15 @@ static int ad7266_read_raw(struct iio_dev *indio_dev,
return IIO_VAL_INT; return IIO_VAL_INT;
case IIO_CHAN_INFO_SCALE: case IIO_CHAN_INFO_SCALE:
scale_uv = (st->vref_uv * 100); scale_mv = st->vref_mv;
if (st->mode == AD7266_MODE_DIFF) if (st->mode == AD7266_MODE_DIFF)
scale_uv *= 2; scale_mv *= 2;
if (st->range == AD7266_RANGE_2VREF) if (st->range == AD7266_RANGE_2VREF)
scale_uv *= 2; scale_mv *= 2;
scale_uv >>= chan->scan_type.realbits; *val = scale_mv;
*val = scale_uv / 100000; *val2 = chan->scan_type.realbits;
*val2 = (scale_uv % 100000) * 10; return IIO_VAL_FRACTIONAL_LOG2;
return IIO_VAL_INT_PLUS_MICRO;
case IIO_CHAN_INFO_OFFSET: case IIO_CHAN_INFO_OFFSET:
if (st->range == AD7266_RANGE_2VREF && if (st->range == AD7266_RANGE_2VREF &&
st->mode != AD7266_MODE_DIFF) st->mode != AD7266_MODE_DIFF)
...@@ -414,10 +413,10 @@ static int ad7266_probe(struct spi_device *spi) ...@@ -414,10 +413,10 @@ static int ad7266_probe(struct spi_device *spi)
if (ret < 0) if (ret < 0)
goto error_disable_reg; goto error_disable_reg;
st->vref_uv = ret; st->vref_mv = ret / 1000;
} else { } else {
/* Use internal reference */ /* Use internal reference */
st->vref_uv = 2500000; st->vref_mv = 2500;
} }
if (pdata) { if (pdata) {
......
...@@ -127,10 +127,9 @@ static int ad7476_read_raw(struct iio_dev *indio_dev, ...@@ -127,10 +127,9 @@ static int ad7476_read_raw(struct iio_dev *indio_dev,
} else { } else {
scale_uv = st->chip_info->int_vref_uv; scale_uv = st->chip_info->int_vref_uv;
} }
scale_uv >>= chan->scan_type.realbits; *val = scale_uv / 1000;
*val = scale_uv / 1000; *val2 = chan->scan_type.realbits;
*val2 = (scale_uv % 1000) * 1000; return IIO_VAL_FRACTIONAL_LOG2;
return IIO_VAL_INT_PLUS_MICRO;
} }
return -EINVAL; return -EINVAL;
} }
......
...@@ -202,7 +202,6 @@ static int ad7791_read_raw(struct iio_dev *indio_dev, ...@@ -202,7 +202,6 @@ static int ad7791_read_raw(struct iio_dev *indio_dev,
{ {
struct ad7791_state *st = iio_priv(indio_dev); struct ad7791_state *st = iio_priv(indio_dev);
bool unipolar = !!(st->mode & AD7791_MODE_UNIPOLAR); bool unipolar = !!(st->mode & AD7791_MODE_UNIPOLAR);
unsigned long long scale_pv;
switch (info) { switch (info) {
case IIO_CHAN_INFO_RAW: case IIO_CHAN_INFO_RAW:
...@@ -220,23 +219,26 @@ static int ad7791_read_raw(struct iio_dev *indio_dev, ...@@ -220,23 +219,26 @@ static int ad7791_read_raw(struct iio_dev *indio_dev,
case IIO_CHAN_INFO_SCALE: case IIO_CHAN_INFO_SCALE:
/* The monitor channel uses an internal reference. */ /* The monitor channel uses an internal reference. */
if (chan->address == AD7791_CH_AVDD_MONITOR) { if (chan->address == AD7791_CH_AVDD_MONITOR) {
scale_pv = 5850000000000ULL; /*
* The signal is attenuated by a factor of 5 and
* compared against a 1.17V internal reference.
*/
*val = 1170 * 5;
} else { } else {
int voltage_uv; int voltage_uv;
voltage_uv = regulator_get_voltage(st->reg); voltage_uv = regulator_get_voltage(st->reg);
if (voltage_uv < 0) if (voltage_uv < 0)
return voltage_uv; return voltage_uv;
scale_pv = (unsigned long long)voltage_uv * 1000000;
*val = voltage_uv / 1000;
} }
if (unipolar) if (unipolar)
scale_pv >>= chan->scan_type.realbits; *val2 = chan->scan_type.realbits;
else else
scale_pv >>= chan->scan_type.realbits - 1; *val2 = chan->scan_type.realbits - 1;
*val2 = do_div(scale_pv, 1000000000);
*val = scale_pv;
return IIO_VAL_INT_PLUS_NANO; return IIO_VAL_FRACTIONAL_LOG2;
} }
return -EINVAL; return -EINVAL;
......
...@@ -366,9 +366,9 @@ static int at91_adc_read_raw(struct iio_dev *idev, ...@@ -366,9 +366,9 @@ static int at91_adc_read_raw(struct iio_dev *idev,
return IIO_VAL_INT; return IIO_VAL_INT;
case IIO_CHAN_INFO_SCALE: case IIO_CHAN_INFO_SCALE:
*val = (st->vref_mv * 1000) >> chan->scan_type.realbits; *val = st->vref_mv;
*val2 = 0; *val2 = chan->scan_type.realbits;
return IIO_VAL_INT_PLUS_MICRO; return IIO_VAL_FRACTIONAL_LOG2;
default: default:
break; break;
} }
......
...@@ -397,7 +397,6 @@ static int max1363_read_raw(struct iio_dev *indio_dev, ...@@ -397,7 +397,6 @@ static int max1363_read_raw(struct iio_dev *indio_dev,
{ {
struct max1363_state *st = iio_priv(indio_dev); struct max1363_state *st = iio_priv(indio_dev);
int ret; int ret;
unsigned long scale_uv;
switch (m) { switch (m) {
case IIO_CHAN_INFO_RAW: case IIO_CHAN_INFO_RAW:
...@@ -406,10 +405,9 @@ static int max1363_read_raw(struct iio_dev *indio_dev, ...@@ -406,10 +405,9 @@ static int max1363_read_raw(struct iio_dev *indio_dev,
return ret; return ret;
return IIO_VAL_INT; return IIO_VAL_INT;
case IIO_CHAN_INFO_SCALE: case IIO_CHAN_INFO_SCALE:
scale_uv = st->vref_uv >> st->chip_info->bits; *val = st->vref_uv / 1000;
*val = scale_uv / 1000; *val2 = st->chip_info->bits;
*val2 = (scale_uv % 1000) * 1000; return IIO_VAL_FRACTIONAL_LOG2;
return IIO_VAL_INT_PLUS_MICRO;
default: default:
return -EINVAL; return -EINVAL;
} }
......
...@@ -34,6 +34,12 @@ static int hid_sensor_data_rdy_trigger_set_state(struct iio_trigger *trig, ...@@ -34,6 +34,12 @@ static int hid_sensor_data_rdy_trigger_set_state(struct iio_trigger *trig,
struct hid_sensor_common *st = iio_trigger_get_drvdata(trig); struct hid_sensor_common *st = iio_trigger_get_drvdata(trig);
int state_val; int state_val;
if (state) {
if (sensor_hub_device_open(st->hsdev))
return -EIO;
} else
sensor_hub_device_close(st->hsdev);
state_val = state ? 1 : 0; state_val = state ? 1 : 0;
if (IS_ENABLED(CONFIG_HID_SENSOR_ENUM_BASE_QUIRKS)) if (IS_ENABLED(CONFIG_HID_SENSOR_ENUM_BASE_QUIRKS))
++state_val; ++state_val;
......
...@@ -239,10 +239,9 @@ static int ad5064_read_raw(struct iio_dev *indio_dev, ...@@ -239,10 +239,9 @@ static int ad5064_read_raw(struct iio_dev *indio_dev,
if (scale_uv < 0) if (scale_uv < 0)
return scale_uv; return scale_uv;
scale_uv = (scale_uv * 100) >> chan->scan_type.realbits; *val = scale_uv / 1000;
*val = scale_uv / 100000; *val2 = chan->scan_type.realbits;
*val2 = (scale_uv % 100000) * 10; return IIO_VAL_FRACTIONAL_LOG2;
return IIO_VAL_INT_PLUS_MICRO;
default: default:
break; break;
} }
......
...@@ -379,15 +379,14 @@ static int ad5360_read_raw(struct iio_dev *indio_dev, ...@@ -379,15 +379,14 @@ static int ad5360_read_raw(struct iio_dev *indio_dev,
*val = ret >> chan->scan_type.shift; *val = ret >> chan->scan_type.shift;
return IIO_VAL_INT; return IIO_VAL_INT;
case IIO_CHAN_INFO_SCALE: case IIO_CHAN_INFO_SCALE:
/* vout = 4 * vref * dac_code */ scale_uv = ad5360_get_channel_vref(st, chan->channel);
scale_uv = ad5360_get_channel_vref(st, chan->channel) * 4 * 100;
if (scale_uv < 0) if (scale_uv < 0)
return scale_uv; return scale_uv;
scale_uv >>= (chan->scan_type.realbits); /* vout = 4 * vref * dac_code */
*val = scale_uv / 100000; *val = scale_uv * 4 / 1000;
*val2 = (scale_uv % 100000) * 10; *val2 = chan->scan_type.realbits;
return IIO_VAL_INT_PLUS_MICRO; return IIO_VAL_FRACTIONAL_LOG2;
case IIO_CHAN_INFO_CALIBBIAS: case IIO_CHAN_INFO_CALIBBIAS:
ret = ad5360_read(indio_dev, AD5360_READBACK_OFFSET, ret = ad5360_read(indio_dev, AD5360_READBACK_OFFSET,
chan->address); chan->address);
......
...@@ -204,7 +204,6 @@ static int ad5380_read_raw(struct iio_dev *indio_dev, ...@@ -204,7 +204,6 @@ static int ad5380_read_raw(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan, int *val, int *val2, long info) struct iio_chan_spec const *chan, int *val, int *val2, long info)
{ {
struct ad5380_state *st = iio_priv(indio_dev); struct ad5380_state *st = iio_priv(indio_dev);
unsigned long scale_uv;
int ret; int ret;
switch (info) { switch (info) {
...@@ -225,10 +224,9 @@ static int ad5380_read_raw(struct iio_dev *indio_dev, ...@@ -225,10 +224,9 @@ static int ad5380_read_raw(struct iio_dev *indio_dev,
val -= (1 << chan->scan_type.realbits) / 2; val -= (1 << chan->scan_type.realbits) / 2;
return IIO_VAL_INT; return IIO_VAL_INT;
case IIO_CHAN_INFO_SCALE: case IIO_CHAN_INFO_SCALE:
scale_uv = ((2 * st->vref) >> chan->scan_type.realbits) * 100; *val = 2 * st->vref;
*val = scale_uv / 100000; *val2 = chan->scan_type.realbits;
*val2 = (scale_uv % 100000) * 10; return IIO_VAL_FRACTIONAL_LOG2;
return IIO_VAL_INT_PLUS_MICRO;
default: default:
break; break;
} }
...@@ -271,72 +269,72 @@ static const struct ad5380_chip_info ad5380_chip_info_tbl[] = { ...@@ -271,72 +269,72 @@ static const struct ad5380_chip_info ad5380_chip_info_tbl[] = {
[ID_AD5380_3] = { [ID_AD5380_3] = {
.channel_template = AD5380_CHANNEL(14), .channel_template = AD5380_CHANNEL(14),
.num_channels = 40, .num_channels = 40,
.int_vref = 1250000, .int_vref = 1250,
}, },
[ID_AD5380_5] = { [ID_AD5380_5] = {
.channel_template = AD5380_CHANNEL(14), .channel_template = AD5380_CHANNEL(14),
.num_channels = 40, .num_channels = 40,
.int_vref = 2500000, .int_vref = 2500,
}, },
[ID_AD5381_3] = { [ID_AD5381_3] = {
.channel_template = AD5380_CHANNEL(12), .channel_template = AD5380_CHANNEL(12),
.num_channels = 16, .num_channels = 16,
.int_vref = 1250000, .int_vref = 1250,
}, },
[ID_AD5381_5] = { [ID_AD5381_5] = {
.channel_template = AD5380_CHANNEL(12), .channel_template = AD5380_CHANNEL(12),
.num_channels = 16, .num_channels = 16,
.int_vref = 2500000, .int_vref = 2500,
}, },
[ID_AD5382_3] = { [ID_AD5382_3] = {
.channel_template = AD5380_CHANNEL(14), .channel_template = AD5380_CHANNEL(14),
.num_channels = 32, .num_channels = 32,
.int_vref = 1250000, .int_vref = 1250,
}, },
[ID_AD5382_5] = { [ID_AD5382_5] = {
.channel_template = AD5380_CHANNEL(14), .channel_template = AD5380_CHANNEL(14),
.num_channels = 32, .num_channels = 32,
.int_vref = 2500000, .int_vref = 2500,
}, },
[ID_AD5383_3] = { [ID_AD5383_3] = {
.channel_template = AD5380_CHANNEL(12), .channel_template = AD5380_CHANNEL(12),
.num_channels = 32, .num_channels = 32,
.int_vref = 1250000, .int_vref = 1250,
}, },
[ID_AD5383_5] = { [ID_AD5383_5] = {
.channel_template = AD5380_CHANNEL(12), .channel_template = AD5380_CHANNEL(12),
.num_channels = 32, .num_channels = 32,
.int_vref = 2500000, .int_vref = 2500,
}, },
[ID_AD5390_3] = { [ID_AD5390_3] = {
.channel_template = AD5380_CHANNEL(14), .channel_template = AD5380_CHANNEL(14),
.num_channels = 16, .num_channels = 16,
.int_vref = 1250000, .int_vref = 1250,
}, },
[ID_AD5390_5] = { [ID_AD5390_5] = {
.channel_template = AD5380_CHANNEL(14), .channel_template = AD5380_CHANNEL(14),
.num_channels = 16, .num_channels = 16,
.int_vref = 2500000, .int_vref = 2500,
}, },
[ID_AD5391_3] = { [ID_AD5391_3] = {
.channel_template = AD5380_CHANNEL(12), .channel_template = AD5380_CHANNEL(12),
.num_channels = 16, .num_channels = 16,
.int_vref = 1250000, .int_vref = 1250,
}, },
[ID_AD5391_5] = { [ID_AD5391_5] = {
.channel_template = AD5380_CHANNEL(12), .channel_template = AD5380_CHANNEL(12),
.num_channels = 16, .num_channels = 16,
.int_vref = 2500000, .int_vref = 2500,
}, },
[ID_AD5392_3] = { [ID_AD5392_3] = {
.channel_template = AD5380_CHANNEL(14), .channel_template = AD5380_CHANNEL(14),
.num_channels = 8, .num_channels = 8,
.int_vref = 1250000, .int_vref = 1250,
}, },
[ID_AD5392_5] = { [ID_AD5392_5] = {
.channel_template = AD5380_CHANNEL(14), .channel_template = AD5380_CHANNEL(14),
.num_channels = 8, .num_channels = 8,
.int_vref = 2500000, .int_vref = 2500,
}, },
}; };
...@@ -395,7 +393,7 @@ static int ad5380_probe(struct device *dev, struct regmap *regmap, ...@@ -395,7 +393,7 @@ static int ad5380_probe(struct device *dev, struct regmap *regmap,
return ret; return ret;
} }
if (st->chip_info->int_vref == 2500000) if (st->chip_info->int_vref == 2500)
ctrl |= AD5380_CTRL_INT_VREF_2V5; ctrl |= AD5380_CTRL_INT_VREF_2V5;
st->vref_reg = devm_regulator_get(dev, "vref"); st->vref_reg = devm_regulator_get(dev, "vref");
...@@ -411,7 +409,7 @@ static int ad5380_probe(struct device *dev, struct regmap *regmap, ...@@ -411,7 +409,7 @@ static int ad5380_probe(struct device *dev, struct regmap *regmap,
if (ret < 0) if (ret < 0)
goto error_disable_reg; goto error_disable_reg;
st->vref = ret; st->vref = ret / 1000;
} else { } else {
st->vref = st->chip_info->int_vref; st->vref = st->chip_info->int_vref;
ctrl |= AD5380_CTRL_INT_VREF_EN; ctrl |= AD5380_CTRL_INT_VREF_EN;
......
...@@ -281,18 +281,11 @@ static inline unsigned int ad5421_get_offset(struct ad5421_state *st) ...@@ -281,18 +281,11 @@ static inline unsigned int ad5421_get_offset(struct ad5421_state *st)
return (min * (1 << 16)) / (max - min); return (min * (1 << 16)) / (max - min);
} }
static inline unsigned int ad5421_get_scale(struct ad5421_state *st)
{
unsigned int min, max;
ad5421_get_current_min_max(st, &min, &max);
return ((max - min) * 1000) / (1 << 16);
}
static int ad5421_read_raw(struct iio_dev *indio_dev, static int ad5421_read_raw(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan, int *val, int *val2, long m) struct iio_chan_spec const *chan, int *val, int *val2, long m)
{ {
struct ad5421_state *st = iio_priv(indio_dev); struct ad5421_state *st = iio_priv(indio_dev);
unsigned int min, max;
int ret; int ret;
if (chan->type != IIO_CURRENT) if (chan->type != IIO_CURRENT)
...@@ -306,9 +299,10 @@ static int ad5421_read_raw(struct iio_dev *indio_dev, ...@@ -306,9 +299,10 @@ static int ad5421_read_raw(struct iio_dev *indio_dev,
*val = ret; *val = ret;
return IIO_VAL_INT; return IIO_VAL_INT;
case IIO_CHAN_INFO_SCALE: case IIO_CHAN_INFO_SCALE:
*val = 0; ad5421_get_current_min_max(st, &min, &max);
*val2 = ad5421_get_scale(st); *val = max - min;
return IIO_VAL_INT_PLUS_MICRO; *val2 = (1 << 16) * 1000;
return IIO_VAL_FRACTIONAL;
case IIO_CHAN_INFO_OFFSET: case IIO_CHAN_INFO_OFFSET:
*val = ad5421_get_offset(st); *val = ad5421_get_offset(st);
return IIO_VAL_INT; return IIO_VAL_INT;
......
...@@ -163,18 +163,15 @@ static int ad5446_read_raw(struct iio_dev *indio_dev, ...@@ -163,18 +163,15 @@ static int ad5446_read_raw(struct iio_dev *indio_dev,
long m) long m)
{ {
struct ad5446_state *st = iio_priv(indio_dev); struct ad5446_state *st = iio_priv(indio_dev);
unsigned long scale_uv;
switch (m) { switch (m) {
case IIO_CHAN_INFO_RAW: case IIO_CHAN_INFO_RAW:
*val = st->cached_val; *val = st->cached_val;
return IIO_VAL_INT; return IIO_VAL_INT;
case IIO_CHAN_INFO_SCALE: case IIO_CHAN_INFO_SCALE:
scale_uv = (st->vref_mv * 1000) >> chan->scan_type.realbits; *val = st->vref_mv;
*val = scale_uv / 1000; *val2 = chan->scan_type.realbits;
*val2 = (scale_uv % 1000) * 1000; return IIO_VAL_FRACTIONAL_LOG2;
return IIO_VAL_INT_PLUS_MICRO;
} }
return -EINVAL; return -EINVAL;
} }
......
...@@ -101,7 +101,6 @@ static int ad5449_read(struct iio_dev *indio_dev, unsigned int addr, ...@@ -101,7 +101,6 @@ static int ad5449_read(struct iio_dev *indio_dev, unsigned int addr,
{ {
struct ad5449 *st = iio_priv(indio_dev); struct ad5449 *st = iio_priv(indio_dev);
int ret; int ret;
struct spi_message msg;
struct spi_transfer t[] = { struct spi_transfer t[] = {
{ {
.tx_buf = &st->data[0], .tx_buf = &st->data[0],
...@@ -114,15 +113,11 @@ static int ad5449_read(struct iio_dev *indio_dev, unsigned int addr, ...@@ -114,15 +113,11 @@ static int ad5449_read(struct iio_dev *indio_dev, unsigned int addr,
}, },
}; };
spi_message_init(&msg);
spi_message_add_tail(&t[0], &msg);
spi_message_add_tail(&t[1], &msg);
mutex_lock(&indio_dev->mlock); mutex_lock(&indio_dev->mlock);
st->data[0] = cpu_to_be16(addr << 12); st->data[0] = cpu_to_be16(addr << 12);
st->data[1] = cpu_to_be16(AD5449_CMD_NOOP); st->data[1] = cpu_to_be16(AD5449_CMD_NOOP);
ret = spi_sync(st->spi, &msg); ret = spi_sync_transfer(st->spi, t, ARRAY_SIZE(t));
if (ret < 0) if (ret < 0)
goto out_unlock; goto out_unlock;
......
...@@ -100,7 +100,6 @@ static int ad5504_read_raw(struct iio_dev *indio_dev, ...@@ -100,7 +100,6 @@ static int ad5504_read_raw(struct iio_dev *indio_dev,
long m) long m)
{ {
struct ad5504_state *st = iio_priv(indio_dev); struct ad5504_state *st = iio_priv(indio_dev);
unsigned long scale_uv;
int ret; int ret;
switch (m) { switch (m) {
...@@ -113,11 +112,9 @@ static int ad5504_read_raw(struct iio_dev *indio_dev, ...@@ -113,11 +112,9 @@ static int ad5504_read_raw(struct iio_dev *indio_dev,
return IIO_VAL_INT; return IIO_VAL_INT;
case IIO_CHAN_INFO_SCALE: case IIO_CHAN_INFO_SCALE:
scale_uv = (st->vref_mv * 1000) >> chan->scan_type.realbits; *val = st->vref_mv;
*val = scale_uv / 1000; *val2 = chan->scan_type.realbits;
*val2 = (scale_uv % 1000) * 1000; return IIO_VAL_FRACTIONAL_LOG2;
return IIO_VAL_INT_PLUS_MICRO;
} }
return -EINVAL; return -EINVAL;
} }
......
...@@ -50,15 +50,12 @@ static int ad5624r_read_raw(struct iio_dev *indio_dev, ...@@ -50,15 +50,12 @@ static int ad5624r_read_raw(struct iio_dev *indio_dev,
long m) long m)
{ {
struct ad5624r_state *st = iio_priv(indio_dev); struct ad5624r_state *st = iio_priv(indio_dev);
unsigned long scale_uv;
switch (m) { switch (m) {
case IIO_CHAN_INFO_SCALE: case IIO_CHAN_INFO_SCALE:
scale_uv = (st->vref_mv * 1000) >> chan->scan_type.realbits; *val = st->vref_mv;
*val = scale_uv / 1000; *val2 = chan->scan_type.realbits;
*val2 = (scale_uv % 1000) * 1000; return IIO_VAL_FRACTIONAL_LOG2;
return IIO_VAL_INT_PLUS_MICRO;
} }
return -EINVAL; return -EINVAL;
} }
......
...@@ -201,7 +201,6 @@ static int ad5686_read_raw(struct iio_dev *indio_dev, ...@@ -201,7 +201,6 @@ static int ad5686_read_raw(struct iio_dev *indio_dev,
long m) long m)
{ {
struct ad5686_state *st = iio_priv(indio_dev); struct ad5686_state *st = iio_priv(indio_dev);
unsigned long scale_uv;
int ret; int ret;
switch (m) { switch (m) {
...@@ -214,12 +213,9 @@ static int ad5686_read_raw(struct iio_dev *indio_dev, ...@@ -214,12 +213,9 @@ static int ad5686_read_raw(struct iio_dev *indio_dev,
*val = ret; *val = ret;
return IIO_VAL_INT; return IIO_VAL_INT;
case IIO_CHAN_INFO_SCALE: case IIO_CHAN_INFO_SCALE:
scale_uv = (st->vref_mv * 100000) *val = st->vref_mv;
>> (chan->scan_type.realbits); *val2 = chan->scan_type.realbits;
*val = scale_uv / 100000; return IIO_VAL_FRACTIONAL_LOG2;
*val2 = (scale_uv % 100000) * 10;
return IIO_VAL_INT_PLUS_MICRO;
} }
return -EINVAL; return -EINVAL;
} }
......
...@@ -253,15 +253,6 @@ static inline int ad5755_get_offset(struct ad5755_state *st, ...@@ -253,15 +253,6 @@ static inline int ad5755_get_offset(struct ad5755_state *st,
return (min * (1 << chan->scan_type.realbits)) / (max - min); return (min * (1 << chan->scan_type.realbits)) / (max - min);
} }
static inline int ad5755_get_scale(struct ad5755_state *st,
struct iio_chan_spec const *chan)
{
int min, max;
ad5755_get_min_max(st, chan, &min, &max);
return ((max - min) * 1000000000ULL) >> chan->scan_type.realbits;
}
static int ad5755_chan_reg_info(struct ad5755_state *st, static int ad5755_chan_reg_info(struct ad5755_state *st,
struct iio_chan_spec const *chan, long info, bool write, struct iio_chan_spec const *chan, long info, bool write,
unsigned int *reg, unsigned int *shift, unsigned int *offset) unsigned int *reg, unsigned int *shift, unsigned int *offset)
...@@ -303,13 +294,15 @@ static int ad5755_read_raw(struct iio_dev *indio_dev, ...@@ -303,13 +294,15 @@ static int ad5755_read_raw(struct iio_dev *indio_dev,
{ {
struct ad5755_state *st = iio_priv(indio_dev); struct ad5755_state *st = iio_priv(indio_dev);
unsigned int reg, shift, offset; unsigned int reg, shift, offset;
int min, max;
int ret; int ret;
switch (info) { switch (info) {
case IIO_CHAN_INFO_SCALE: case IIO_CHAN_INFO_SCALE:
*val = 0; ad5755_get_min_max(st, chan, &min, &max);
*val2 = ad5755_get_scale(st, chan); *val = max - min;
return IIO_VAL_INT_PLUS_NANO; *val2 = chan->scan_type.realbits;
return IIO_VAL_FRACTIONAL_LOG2;
case IIO_CHAN_INFO_OFFSET: case IIO_CHAN_INFO_OFFSET:
*val = ad5755_get_offset(st, chan); *val = ad5755_get_offset(st, chan);
return IIO_VAL_INT; return IIO_VAL_INT;
......
...@@ -217,7 +217,6 @@ static int ad5764_read_raw(struct iio_dev *indio_dev, ...@@ -217,7 +217,6 @@ static int ad5764_read_raw(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan, int *val, int *val2, long info) struct iio_chan_spec const *chan, int *val, int *val2, long info)
{ {
struct ad5764_state *st = iio_priv(indio_dev); struct ad5764_state *st = iio_priv(indio_dev);
unsigned long scale_uv;
unsigned int reg; unsigned int reg;
int vref; int vref;
int ret; int ret;
...@@ -245,15 +244,14 @@ static int ad5764_read_raw(struct iio_dev *indio_dev, ...@@ -245,15 +244,14 @@ static int ad5764_read_raw(struct iio_dev *indio_dev,
*val = sign_extend32(*val, 5); *val = sign_extend32(*val, 5);
return IIO_VAL_INT; return IIO_VAL_INT;
case IIO_CHAN_INFO_SCALE: case IIO_CHAN_INFO_SCALE:
/* vout = 4 * vref + ((dac_code / 65535) - 0.5) */ /* vout = 4 * vref + ((dac_code / 65536) - 0.5) */
vref = ad5764_get_channel_vref(st, chan->channel); vref = ad5764_get_channel_vref(st, chan->channel);
if (vref < 0) if (vref < 0)
return vref; return vref;
scale_uv = (vref * 4 * 100) >> chan->scan_type.realbits; *val = vref * 4 / 1000;
*val = scale_uv / 100000; *val2 = chan->scan_type.realbits;
*val2 = (scale_uv % 100000) * 10; return IIO_VAL_FRACTIONAL_LOG2;
return IIO_VAL_INT_PLUS_MICRO;
case IIO_CHAN_INFO_OFFSET: case IIO_CHAN_INFO_OFFSET:
*val = -(1 << chan->scan_type.realbits) / 2; *val = -(1 << chan->scan_type.realbits) / 2;
return IIO_VAL_INT; return IIO_VAL_INT;
......
...@@ -270,9 +270,9 @@ static int ad5791_read_raw(struct iio_dev *indio_dev, ...@@ -270,9 +270,9 @@ static int ad5791_read_raw(struct iio_dev *indio_dev,
*val >>= chan->scan_type.shift; *val >>= chan->scan_type.shift;
return IIO_VAL_INT; return IIO_VAL_INT;
case IIO_CHAN_INFO_SCALE: case IIO_CHAN_INFO_SCALE:
*val = 0; *val = st->vref_mv;
*val2 = (((u64)st->vref_mv) * 1000000ULL) >> chan->scan_type.realbits; *val2 = (1 << chan->scan_type.realbits) - 1;
return IIO_VAL_INT_PLUS_MICRO; return IIO_VAL_FRACTIONAL;
case IIO_CHAN_INFO_OFFSET: case IIO_CHAN_INFO_OFFSET:
val64 = (((u64)st->vref_neg_mv) << chan->scan_type.realbits); val64 = (((u64)st->vref_neg_mv) << chan->scan_type.realbits);
do_div(val64, st->vref_mv); do_div(val64, st->vref_mv);
......
...@@ -82,15 +82,13 @@ static int max517_read_raw(struct iio_dev *indio_dev, ...@@ -82,15 +82,13 @@ static int max517_read_raw(struct iio_dev *indio_dev,
long m) long m)
{ {
struct max517_data *data = iio_priv(indio_dev); struct max517_data *data = iio_priv(indio_dev);
unsigned int scale_uv;
switch (m) { switch (m) {
case IIO_CHAN_INFO_SCALE: case IIO_CHAN_INFO_SCALE:
/* Corresponds to Vref / 2^(bits) */ /* Corresponds to Vref / 2^(bits) */
scale_uv = (data->vref_mv[chan->channel] * 1000) >> 8; *val = data->vref_mv[chan->channel];
*val = scale_uv / 1000000; *val2 = 8;
*val2 = scale_uv % 1000000; return IIO_VAL_FRACTIONAL_LOG2;
return IIO_VAL_INT_PLUS_MICRO;
default: default:
break; break;
} }
......
...@@ -239,17 +239,15 @@ static int mcp4725_read_raw(struct iio_dev *indio_dev, ...@@ -239,17 +239,15 @@ static int mcp4725_read_raw(struct iio_dev *indio_dev,
int *val, int *val2, long mask) int *val, int *val2, long mask)
{ {
struct mcp4725_data *data = iio_priv(indio_dev); struct mcp4725_data *data = iio_priv(indio_dev);
unsigned long scale_uv;
switch (mask) { switch (mask) {
case IIO_CHAN_INFO_RAW: case IIO_CHAN_INFO_RAW:
*val = data->dac_value; *val = data->dac_value;
return IIO_VAL_INT; return IIO_VAL_INT;
case IIO_CHAN_INFO_SCALE: case IIO_CHAN_INFO_SCALE:
scale_uv = (data->vref_mv * 1000) >> 12; *val = data->vref_mv;
*val = scale_uv / 1000000; *val2 = 12;
*val2 = scale_uv % 1000000; return IIO_VAL_FRACTIONAL_LOG2;
return IIO_VAL_INT_PLUS_MICRO;
} }
return -EINVAL; return -EINVAL;
} }
......
...@@ -51,7 +51,6 @@ static int adis16080_read_sample(struct iio_dev *indio_dev, ...@@ -51,7 +51,6 @@ static int adis16080_read_sample(struct iio_dev *indio_dev,
u16 addr, int *val) u16 addr, int *val)
{ {
struct adis16080_state *st = iio_priv(indio_dev); struct adis16080_state *st = iio_priv(indio_dev);
struct spi_message m;
int ret; int ret;
struct spi_transfer t[] = { struct spi_transfer t[] = {
{ {
...@@ -66,11 +65,7 @@ static int adis16080_read_sample(struct iio_dev *indio_dev, ...@@ -66,11 +65,7 @@ static int adis16080_read_sample(struct iio_dev *indio_dev,
st->buf = cpu_to_be16(addr | ADIS16080_DIN_WRITE); st->buf = cpu_to_be16(addr | ADIS16080_DIN_WRITE);
spi_message_init(&m); ret = spi_sync_transfer(st->us, t, ARRAY_SIZE(t));
spi_message_add_tail(&t[0], &m);
spi_message_add_tail(&t[1], &m);
ret = spi_sync(st->us, &m);
if (ret == 0) if (ret == 0)
*val = sign_extend32(be16_to_cpu(st->buf), 11); *val = sign_extend32(be16_to_cpu(st->buf), 11);
......
...@@ -47,7 +47,6 @@ static int adis16130_spi_read(struct iio_dev *indio_dev, u8 reg_addr, u32 *val) ...@@ -47,7 +47,6 @@ static int adis16130_spi_read(struct iio_dev *indio_dev, u8 reg_addr, u32 *val)
{ {
int ret; int ret;
struct adis16130_state *st = iio_priv(indio_dev); struct adis16130_state *st = iio_priv(indio_dev);
struct spi_message msg;
struct spi_transfer xfer = { struct spi_transfer xfer = {
.tx_buf = st->buf, .tx_buf = st->buf,
.rx_buf = st->buf, .rx_buf = st->buf,
...@@ -59,10 +58,7 @@ static int adis16130_spi_read(struct iio_dev *indio_dev, u8 reg_addr, u32 *val) ...@@ -59,10 +58,7 @@ static int adis16130_spi_read(struct iio_dev *indio_dev, u8 reg_addr, u32 *val)
st->buf[0] = ADIS16130_CON_RD | reg_addr; st->buf[0] = ADIS16130_CON_RD | reg_addr;
st->buf[1] = st->buf[2] = st->buf[3] = 0; st->buf[1] = st->buf[2] = st->buf[3] = 0;
spi_message_init(&msg); ret = spi_sync_transfer(st->us, &xfer, 1);
spi_message_add_tail(&xfer, &msg);
ret = spi_sync(st->us, &msg);
if (ret == 0) if (ret == 0)
*val = (st->buf[1] << 16) | (st->buf[2] << 8) | st->buf[3]; *val = (st->buf[1] << 16) | (st->buf[2] << 8) | st->buf[3];
mutex_unlock(&st->buf_lock); mutex_unlock(&st->buf_lock);
......
...@@ -90,7 +90,6 @@ static int adxrs450_spi_read_reg_16(struct iio_dev *indio_dev, ...@@ -90,7 +90,6 @@ static int adxrs450_spi_read_reg_16(struct iio_dev *indio_dev,
u8 reg_address, u8 reg_address,
u16 *val) u16 *val)
{ {
struct spi_message msg;
struct adxrs450_state *st = iio_priv(indio_dev); struct adxrs450_state *st = iio_priv(indio_dev);
u32 tx; u32 tx;
int ret; int ret;
...@@ -114,10 +113,7 @@ static int adxrs450_spi_read_reg_16(struct iio_dev *indio_dev, ...@@ -114,10 +113,7 @@ static int adxrs450_spi_read_reg_16(struct iio_dev *indio_dev,
tx |= ADXRS450_P; tx |= ADXRS450_P;
st->tx = cpu_to_be32(tx); st->tx = cpu_to_be32(tx);
spi_message_init(&msg); ret = spi_sync_transfer(st->us, xfers, ARRAY_SIZE(xfers));
spi_message_add_tail(&xfers[0], &msg);
spi_message_add_tail(&xfers[1], &msg);
ret = spi_sync(st->us, &msg);
if (ret) { if (ret) {
dev_err(&st->us->dev, "problem while reading 16 bit register 0x%02x\n", dev_err(&st->us->dev, "problem while reading 16 bit register 0x%02x\n",
reg_address); reg_address);
...@@ -169,7 +165,6 @@ static int adxrs450_spi_write_reg_16(struct iio_dev *indio_dev, ...@@ -169,7 +165,6 @@ static int adxrs450_spi_write_reg_16(struct iio_dev *indio_dev,
**/ **/
static int adxrs450_spi_sensor_data(struct iio_dev *indio_dev, s16 *val) static int adxrs450_spi_sensor_data(struct iio_dev *indio_dev, s16 *val)
{ {
struct spi_message msg;
struct adxrs450_state *st = iio_priv(indio_dev); struct adxrs450_state *st = iio_priv(indio_dev);
int ret; int ret;
struct spi_transfer xfers[] = { struct spi_transfer xfers[] = {
...@@ -188,10 +183,7 @@ static int adxrs450_spi_sensor_data(struct iio_dev *indio_dev, s16 *val) ...@@ -188,10 +183,7 @@ static int adxrs450_spi_sensor_data(struct iio_dev *indio_dev, s16 *val)
mutex_lock(&st->buf_lock); mutex_lock(&st->buf_lock);
st->tx = cpu_to_be32(ADXRS450_SENSOR_DATA); st->tx = cpu_to_be32(ADXRS450_SENSOR_DATA);
spi_message_init(&msg); ret = spi_sync_transfer(st->us, xfers, ARRAY_SIZE(xfers));
spi_message_add_tail(&xfers[0], &msg);
spi_message_add_tail(&xfers[1], &msg);
ret = spi_sync(st->us, &msg);
if (ret) { if (ret) {
dev_err(&st->us->dev, "Problem while reading sensor data\n"); dev_err(&st->us->dev, "Problem while reading sensor data\n");
goto error_ret; goto error_ret;
......
...@@ -275,6 +275,12 @@ static int hid_time_probe(struct platform_device *pdev) ...@@ -275,6 +275,12 @@ static int hid_time_probe(struct platform_device *pdev)
return ret; return ret;
} }
ret = sensor_hub_device_open(hsdev);
if (ret) {
dev_err(&pdev->dev, "failed to open sensor hub device!\n");
goto err_open;
}
time_state->rtc = devm_rtc_device_register(&pdev->dev, time_state->rtc = devm_rtc_device_register(&pdev->dev,
"hid-sensor-time", &hid_time_rtc_ops, "hid-sensor-time", &hid_time_rtc_ops,
THIS_MODULE); THIS_MODULE);
...@@ -282,17 +288,24 @@ static int hid_time_probe(struct platform_device *pdev) ...@@ -282,17 +288,24 @@ static int hid_time_probe(struct platform_device *pdev)
if (IS_ERR_OR_NULL(time_state->rtc)) { if (IS_ERR_OR_NULL(time_state->rtc)) {
ret = time_state->rtc ? PTR_ERR(time_state->rtc) : -ENODEV; ret = time_state->rtc ? PTR_ERR(time_state->rtc) : -ENODEV;
time_state->rtc = NULL; time_state->rtc = NULL;
sensor_hub_remove_callback(hsdev, HID_USAGE_SENSOR_TIME);
dev_err(&pdev->dev, "rtc device register failed!\n"); dev_err(&pdev->dev, "rtc device register failed!\n");
goto err_rtc;
} }
return ret; return ret;
err_rtc:
sensor_hub_device_close(hsdev);
err_open:
sensor_hub_remove_callback(hsdev, HID_USAGE_SENSOR_TIME);
return ret;
} }
static int hid_time_remove(struct platform_device *pdev) static int hid_time_remove(struct platform_device *pdev)
{ {
struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data; struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data;
sensor_hub_device_close(hsdev);
sensor_hub_remove_callback(hsdev, HID_USAGE_SENSOR_TIME); sensor_hub_remove_callback(hsdev, HID_USAGE_SENSOR_TIME);
return 0; return 0;
......
...@@ -13,6 +13,17 @@ Would be nice ...@@ -13,6 +13,17 @@ Would be nice
3) Expand device set. Lots of other maxim adc's have very 3) Expand device set. Lots of other maxim adc's have very
similar interfaces. similar interfaces.
MXS LRADC driver:
This is a classic MFD device as it combines the following subdevices
- touchscreen controller (input subsystem related device)
- general purpose ADC channels
- battery voltage monitor (power subsystem related device)
- die temperature monitor (thermal management)
At least the battery voltage and die temperature feature is required in-kernel
by a driver of the SoC's battery charging unit to avoid any damage to the
silicon and the battery.
TSL2561 TSL2561
Would be nice Would be nice
1) Open question of userspace vs kernel space balance when 1) Open question of userspace vs kernel space balance when
......
...@@ -102,7 +102,6 @@ static ssize_t adis16220_capture_buffer_read(struct iio_dev *indio_dev, ...@@ -102,7 +102,6 @@ static ssize_t adis16220_capture_buffer_read(struct iio_dev *indio_dev,
int addr) int addr)
{ {
struct adis16220_state *st = iio_priv(indio_dev); struct adis16220_state *st = iio_priv(indio_dev);
struct spi_message msg;
struct spi_transfer xfers[] = { struct spi_transfer xfers[] = {
{ {
.tx_buf = st->tx, .tx_buf = st->tx,
...@@ -147,10 +146,7 @@ static ssize_t adis16220_capture_buffer_read(struct iio_dev *indio_dev, ...@@ -147,10 +146,7 @@ static ssize_t adis16220_capture_buffer_read(struct iio_dev *indio_dev,
} }
xfers[1].len = count; xfers[1].len = count;
spi_message_init(&msg); ret = spi_sync_transfer(st->adis.spi, xfers, ARRAY_SIZE(xfers));
spi_message_add_tail(&xfers[0], &msg);
spi_message_add_tail(&xfers[1], &msg);
ret = spi_sync(st->adis.spi, &msg);
if (ret) { if (ret) {
mutex_unlock(&st->buf_lock); mutex_unlock(&st->buf_lock);
......
...@@ -783,7 +783,6 @@ static int ad7280_read_raw(struct iio_dev *indio_dev, ...@@ -783,7 +783,6 @@ static int ad7280_read_raw(struct iio_dev *indio_dev,
long m) long m)
{ {
struct ad7280_state *st = iio_priv(indio_dev); struct ad7280_state *st = iio_priv(indio_dev);
unsigned int scale_uv;
int ret; int ret;
switch (m) { switch (m) {
...@@ -804,13 +803,12 @@ static int ad7280_read_raw(struct iio_dev *indio_dev, ...@@ -804,13 +803,12 @@ static int ad7280_read_raw(struct iio_dev *indio_dev,
return IIO_VAL_INT; return IIO_VAL_INT;
case IIO_CHAN_INFO_SCALE: case IIO_CHAN_INFO_SCALE:
if ((chan->address & 0xFF) <= AD7280A_CELL_VOLTAGE_6) if ((chan->address & 0xFF) <= AD7280A_CELL_VOLTAGE_6)
scale_uv = (4000 * 1000) >> AD7280A_BITS; *val = 4000;
else else
scale_uv = (5000 * 1000) >> AD7280A_BITS; *val = 5000;
*val = scale_uv / 1000; *val2 = AD7280A_BITS;
*val2 = (scale_uv % 1000) * 1000; return IIO_VAL_FRACTIONAL_LOG2;
return IIO_VAL_INT_PLUS_MICRO;
} }
return -EINVAL; return -EINVAL;
} }
......
...@@ -85,7 +85,6 @@ static int ad7606_read_raw(struct iio_dev *indio_dev, ...@@ -85,7 +85,6 @@ static int ad7606_read_raw(struct iio_dev *indio_dev,
{ {
int ret; int ret;
struct ad7606_state *st = iio_priv(indio_dev); struct ad7606_state *st = iio_priv(indio_dev);
unsigned int scale_uv;
switch (m) { switch (m) {
case IIO_CHAN_INFO_RAW: case IIO_CHAN_INFO_RAW:
...@@ -101,11 +100,9 @@ static int ad7606_read_raw(struct iio_dev *indio_dev, ...@@ -101,11 +100,9 @@ static int ad7606_read_raw(struct iio_dev *indio_dev,
*val = (short) ret; *val = (short) ret;
return IIO_VAL_INT; return IIO_VAL_INT;
case IIO_CHAN_INFO_SCALE: case IIO_CHAN_INFO_SCALE:
scale_uv = (st->range * 1000 * 2) *val = st->range * 2;
>> st->chip_info->channels[0].scan_type.realbits; *val2 = st->chip_info->channels[0].scan_type.realbits;
*val = scale_uv / 1000; return IIO_VAL_FRACTIONAL_LOG2;
*val2 = (scale_uv % 1000) * 1000;
return IIO_VAL_INT_PLUS_MICRO;
} }
return -EINVAL; return -EINVAL;
} }
......
...@@ -90,17 +90,14 @@ static int ad7780_read_raw(struct iio_dev *indio_dev, ...@@ -90,17 +90,14 @@ static int ad7780_read_raw(struct iio_dev *indio_dev,
long m) long m)
{ {
struct ad7780_state *st = iio_priv(indio_dev); struct ad7780_state *st = iio_priv(indio_dev);
unsigned long scale_uv;
switch (m) { switch (m) {
case IIO_CHAN_INFO_RAW: case IIO_CHAN_INFO_RAW:
return ad_sigma_delta_single_conversion(indio_dev, chan, val); return ad_sigma_delta_single_conversion(indio_dev, chan, val);
case IIO_CHAN_INFO_SCALE: case IIO_CHAN_INFO_SCALE:
scale_uv = (st->int_vref_mv * 100000 * st->gain) *val = st->int_vref_mv * st->gain;
>> (chan->scan_type.realbits - 1); *val2 = chan->scan_type.realbits - 1;
*val = scale_uv / 100000; return IIO_VAL_FRACTIONAL_LOG2;
*val2 = (scale_uv % 100000) * 10;
return IIO_VAL_INT_PLUS_MICRO;
case IIO_CHAN_INFO_OFFSET: case IIO_CHAN_INFO_OFFSET:
*val -= (1 << (chan->scan_type.realbits - 1)); *val -= (1 << (chan->scan_type.realbits - 1));
return IIO_VAL_INT; return IIO_VAL_INT;
......
...@@ -163,7 +163,6 @@ static int ad799x_read_raw(struct iio_dev *indio_dev, ...@@ -163,7 +163,6 @@ static int ad799x_read_raw(struct iio_dev *indio_dev,
{ {
int ret; int ret;
struct ad799x_state *st = iio_priv(indio_dev); struct ad799x_state *st = iio_priv(indio_dev);
unsigned int scale_uv;
switch (m) { switch (m) {
case IIO_CHAN_INFO_RAW: case IIO_CHAN_INFO_RAW:
...@@ -180,10 +179,9 @@ static int ad799x_read_raw(struct iio_dev *indio_dev, ...@@ -180,10 +179,9 @@ static int ad799x_read_raw(struct iio_dev *indio_dev,
RES_MASK(chan->scan_type.realbits); RES_MASK(chan->scan_type.realbits);
return IIO_VAL_INT; return IIO_VAL_INT;
case IIO_CHAN_INFO_SCALE: case IIO_CHAN_INFO_SCALE:
scale_uv = (st->int_vref_mv * 1000) >> chan->scan_type.realbits; *val = st->int_vref_mv;
*val = scale_uv / 1000; *val2 = chan->scan_type.realbits;
*val2 = (scale_uv % 1000) * 1000; return IIO_VAL_FRACTIONAL_LOG2;
return IIO_VAL_INT_PLUS_MICRO;
} }
return -EINVAL; return -EINVAL;
} }
......
This diff is collapsed.
...@@ -168,10 +168,9 @@ static int spear_read_raw(struct iio_dev *indio_dev, ...@@ -168,10 +168,9 @@ static int spear_read_raw(struct iio_dev *indio_dev,
return IIO_VAL_INT; return IIO_VAL_INT;
case IIO_CHAN_INFO_SCALE: case IIO_CHAN_INFO_SCALE:
scale_mv = (info->vref_external * 1000) >> DATA_BITS; *val = info->vref_external;
*val = scale_mv / 1000; *val2 = DATA_BITS;
*val2 = (scale_mv % 1000) * 1000; return IIO_VAL_FRACTIONAL_LOG2;
return IIO_VAL_INT_PLUS_MICRO;
} }
return -EINVAL; return -EINVAL;
......
...@@ -656,20 +656,21 @@ static int ad7746_read_raw(struct iio_dev *indio_dev, ...@@ -656,20 +656,21 @@ static int ad7746_read_raw(struct iio_dev *indio_dev,
switch (chan->type) { switch (chan->type) {
case IIO_CAPACITANCE: case IIO_CAPACITANCE:
/* 8.192pf / 2^24 */ /* 8.192pf / 2^24 */
*val2 = 488;
*val = 0; *val = 0;
*val2 = 488;
ret = IIO_VAL_INT_PLUS_NANO;
break; break;
case IIO_VOLTAGE: case IIO_VOLTAGE:
/* 1170mV / 2^23 */ /* 1170mV / 2^23 */
*val2 = 139475; *val = 1170;
*val = 0; *val2 = 23;
ret = IIO_VAL_FRACTIONAL_LOG2;
break; break;
default: default:
ret = -EINVAL; ret = -EINVAL;
goto out; break;
} }
ret = IIO_VAL_INT_PLUS_NANO;
break; break;
default: default:
ret = -EINVAL; ret = -EINVAL;
......
...@@ -67,7 +67,6 @@ static ssize_t ad9852_set_parameter(struct device *dev, ...@@ -67,7 +67,6 @@ static ssize_t ad9852_set_parameter(struct device *dev,
const char *buf, const char *buf,
size_t len) size_t len)
{ {
struct spi_message msg;
struct spi_transfer xfer; struct spi_transfer xfer;
int ret; int ret;
struct ad9852_config *config = (struct ad9852_config *)buf; struct ad9852_config *config = (struct ad9852_config *)buf;
...@@ -78,99 +77,77 @@ static ssize_t ad9852_set_parameter(struct device *dev, ...@@ -78,99 +77,77 @@ static ssize_t ad9852_set_parameter(struct device *dev,
xfer.tx_buf = &config->phajst0[0]; xfer.tx_buf = &config->phajst0[0];
mutex_lock(&st->lock); mutex_lock(&st->lock);
spi_message_init(&msg); ret = spi_sync_transfer(st->sdev, &xfer, 1);
spi_message_add_tail(&xfer, &msg);
ret = spi_sync(st->sdev, &msg);
if (ret) if (ret)
goto error_ret; goto error_ret;
xfer.len = 3; xfer.len = 3;
xfer.tx_buf = &config->phajst1[0]; xfer.tx_buf = &config->phajst1[0];
spi_message_init(&msg); ret = spi_sync_transfer(st->sdev, &xfer, 1);
spi_message_add_tail(&xfer, &msg);
ret = spi_sync(st->sdev, &msg);
if (ret) if (ret)
goto error_ret; goto error_ret;
xfer.len = 6; xfer.len = 6;
xfer.tx_buf = &config->fretun1[0]; xfer.tx_buf = &config->fretun1[0];
spi_message_init(&msg); ret = spi_sync_transfer(st->sdev, &xfer, 1);
spi_message_add_tail(&xfer, &msg);
ret = spi_sync(st->sdev, &msg);
if (ret) if (ret)
goto error_ret; goto error_ret;
xfer.len = 6; xfer.len = 6;
xfer.tx_buf = &config->fretun2[0]; xfer.tx_buf = &config->fretun2[0];
spi_message_init(&msg); ret = spi_sync_transfer(st->sdev, &xfer, 1);
spi_message_add_tail(&xfer, &msg);
ret = spi_sync(st->sdev, &msg);
if (ret) if (ret)
goto error_ret; goto error_ret;
xfer.len = 6; xfer.len = 6;
xfer.tx_buf = &config->dltafre[0]; xfer.tx_buf = &config->dltafre[0];
spi_message_init(&msg); ret = spi_sync_transfer(st->sdev, &xfer, 1);
spi_message_add_tail(&xfer, &msg);
ret = spi_sync(st->sdev, &msg);
if (ret) if (ret)
goto error_ret; goto error_ret;
xfer.len = 5; xfer.len = 5;
xfer.tx_buf = &config->updtclk[0]; xfer.tx_buf = &config->updtclk[0];
spi_message_init(&msg); ret = spi_sync_transfer(st->sdev, &xfer, 1);
spi_message_add_tail(&xfer, &msg);
ret = spi_sync(st->sdev, &msg);
if (ret) if (ret)
goto error_ret; goto error_ret;
xfer.len = 4; xfer.len = 4;
xfer.tx_buf = &config->ramprat[0]; xfer.tx_buf = &config->ramprat[0];
spi_message_init(&msg); ret = spi_sync_transfer(st->sdev, &xfer, 1);
spi_message_add_tail(&xfer, &msg);
ret = spi_sync(st->sdev, &msg);
if (ret) if (ret)
goto error_ret; goto error_ret;
xfer.len = 5; xfer.len = 5;
xfer.tx_buf = &config->control[0]; xfer.tx_buf = &config->control[0];
spi_message_init(&msg); ret = spi_sync_transfer(st->sdev, &xfer, 1);
spi_message_add_tail(&xfer, &msg);
ret = spi_sync(st->sdev, &msg);
if (ret) if (ret)
goto error_ret; goto error_ret;
xfer.len = 3; xfer.len = 3;
xfer.tx_buf = &config->outpskm[0]; xfer.tx_buf = &config->outpskm[0];
spi_message_init(&msg); ret = spi_sync_transfer(st->sdev, &xfer, 1);
spi_message_add_tail(&xfer, &msg);
ret = spi_sync(st->sdev, &msg);
if (ret) if (ret)
goto error_ret; goto error_ret;
xfer.len = 2; xfer.len = 2;
xfer.tx_buf = &config->outpskr[0]; xfer.tx_buf = &config->outpskr[0];
spi_message_init(&msg); ret = spi_sync_transfer(st->sdev, &xfer, 1);
spi_message_add_tail(&xfer, &msg);
ret = spi_sync(st->sdev, &msg);
if (ret) if (ret)
goto error_ret; goto error_ret;
xfer.len = 3; xfer.len = 3;
xfer.tx_buf = &config->daccntl[0]; xfer.tx_buf = &config->daccntl[0];
spi_message_init(&msg); ret = spi_sync_transfer(st->sdev, &xfer, 1);
spi_message_add_tail(&xfer, &msg);
ret = spi_sync(st->sdev, &msg);
if (ret) if (ret)
goto error_ret; goto error_ret;
error_ret: error_ret:
......
...@@ -119,7 +119,6 @@ static ssize_t ad9910_set_parameter(struct device *dev, ...@@ -119,7 +119,6 @@ static ssize_t ad9910_set_parameter(struct device *dev,
const char *buf, const char *buf,
size_t len) size_t len)
{ {
struct spi_message msg;
struct spi_transfer xfer; struct spi_transfer xfer;
int ret; int ret;
struct ad9910_config *config = (struct ad9910_config *)buf; struct ad9910_config *config = (struct ad9910_config *)buf;
...@@ -130,152 +129,118 @@ static ssize_t ad9910_set_parameter(struct device *dev, ...@@ -130,152 +129,118 @@ static ssize_t ad9910_set_parameter(struct device *dev,
xfer.tx_buf = &config->auxdac[0]; xfer.tx_buf = &config->auxdac[0];
mutex_lock(&st->lock); mutex_lock(&st->lock);
spi_message_init(&msg); ret = spi_sync_transfer(st->sdev, &xfer, 1);
spi_message_add_tail(&xfer, &msg);
ret = spi_sync(st->sdev, &msg);
if (ret) if (ret)
goto error_ret; goto error_ret;
xfer.len = 5; xfer.len = 5;
xfer.tx_buf = &config->ioupd[0]; xfer.tx_buf = &config->ioupd[0];
spi_message_init(&msg); ret = spi_sync_transfer(st->sdev, &xfer, 1);
spi_message_add_tail(&xfer, &msg);
ret = spi_sync(st->sdev, &msg);
if (ret) if (ret)
goto error_ret; goto error_ret;
xfer.len = 5; xfer.len = 5;
xfer.tx_buf = &config->ftw[0]; xfer.tx_buf = &config->ftw[0];
spi_message_init(&msg); ret = spi_sync_transfer(st->sdev, &xfer, 1);
spi_message_add_tail(&xfer, &msg);
ret = spi_sync(st->sdev, &msg);
if (ret) if (ret)
goto error_ret; goto error_ret;
xfer.len = 3; xfer.len = 3;
xfer.tx_buf = &config->pow[0]; xfer.tx_buf = &config->pow[0];
spi_message_init(&msg); ret = spi_sync_transfer(st->sdev, &xfer, 1);
spi_message_add_tail(&xfer, &msg);
ret = spi_sync(st->sdev, &msg);
if (ret) if (ret)
goto error_ret; goto error_ret;
xfer.len = 5; xfer.len = 5;
xfer.tx_buf = &config->asf[0]; xfer.tx_buf = &config->asf[0];
spi_message_init(&msg); ret = spi_sync_transfer(st->sdev, &xfer, 1);
spi_message_add_tail(&xfer, &msg);
ret = spi_sync(st->sdev, &msg);
if (ret) if (ret)
goto error_ret; goto error_ret;
xfer.len = 5; xfer.len = 5;
xfer.tx_buf = &config->multc[0]; xfer.tx_buf = &config->multc[0];
spi_message_init(&msg); ret = spi_sync_transfer(st->sdev, &xfer, 1);
spi_message_add_tail(&xfer, &msg);
ret = spi_sync(st->sdev, &msg);
if (ret) if (ret)
goto error_ret; goto error_ret;
xfer.len = 9; xfer.len = 9;
xfer.tx_buf = &config->dig_rampl[0]; xfer.tx_buf = &config->dig_rampl[0];
spi_message_init(&msg); ret = spi_sync_transfer(st->sdev, &xfer, 1);
spi_message_add_tail(&xfer, &msg);
ret = spi_sync(st->sdev, &msg);
if (ret) if (ret)
goto error_ret; goto error_ret;
xfer.len = 9; xfer.len = 9;
xfer.tx_buf = &config->dig_ramps[0]; xfer.tx_buf = &config->dig_ramps[0];
spi_message_init(&msg); ret = spi_sync_transfer(st->sdev, &xfer, 1);
spi_message_add_tail(&xfer, &msg);
ret = spi_sync(st->sdev, &msg);
if (ret) if (ret)
goto error_ret; goto error_ret;
xfer.len = 5; xfer.len = 5;
xfer.tx_buf = &config->dig_rampr[0]; xfer.tx_buf = &config->dig_rampr[0];
spi_message_init(&msg); ret = spi_sync_transfer(st->sdev, &xfer, 1);
spi_message_add_tail(&xfer, &msg);
ret = spi_sync(st->sdev, &msg);
if (ret) if (ret)
goto error_ret; goto error_ret;
xfer.len = 9; xfer.len = 9;
xfer.tx_buf = &config->sin_tonep0[0]; xfer.tx_buf = &config->sin_tonep0[0];
spi_message_init(&msg); ret = spi_sync_transfer(st->sdev, &xfer, 1);
spi_message_add_tail(&xfer, &msg);
ret = spi_sync(st->sdev, &msg);
if (ret) if (ret)
goto error_ret; goto error_ret;
xfer.len = 9; xfer.len = 9;
xfer.tx_buf = &config->sin_tonep1[0]; xfer.tx_buf = &config->sin_tonep1[0];
spi_message_init(&msg); ret = spi_sync_transfer(st->sdev, &xfer, 1);
spi_message_add_tail(&xfer, &msg);
ret = spi_sync(st->sdev, &msg);
if (ret) if (ret)
goto error_ret; goto error_ret;
xfer.len = 9; xfer.len = 9;
xfer.tx_buf = &config->sin_tonep2[0]; xfer.tx_buf = &config->sin_tonep2[0];
spi_message_init(&msg); ret = spi_sync_transfer(st->sdev, &xfer, 1);
spi_message_add_tail(&xfer, &msg);
ret = spi_sync(st->sdev, &msg);
if (ret) if (ret)
goto error_ret; goto error_ret;
xfer.len = 9; xfer.len = 9;
xfer.tx_buf = &config->sin_tonep3[0]; xfer.tx_buf = &config->sin_tonep3[0];
spi_message_init(&msg); ret = spi_sync_transfer(st->sdev, &xfer, 1);
spi_message_add_tail(&xfer, &msg);
ret = spi_sync(st->sdev, &msg);
if (ret) if (ret)
goto error_ret; goto error_ret;
xfer.len = 9; xfer.len = 9;
xfer.tx_buf = &config->sin_tonep4[0]; xfer.tx_buf = &config->sin_tonep4[0];
spi_message_init(&msg); ret = spi_sync_transfer(st->sdev, &xfer, 1);
spi_message_add_tail(&xfer, &msg);
ret = spi_sync(st->sdev, &msg);
if (ret) if (ret)
goto error_ret; goto error_ret;
xfer.len = 9; xfer.len = 9;
xfer.tx_buf = &config->sin_tonep5[0]; xfer.tx_buf = &config->sin_tonep5[0];
spi_message_init(&msg); ret = spi_sync_transfer(st->sdev, &xfer, 1);
spi_message_add_tail(&xfer, &msg);
ret = spi_sync(st->sdev, &msg);
if (ret) if (ret)
goto error_ret; goto error_ret;
xfer.len = 9; xfer.len = 9;
xfer.tx_buf = &config->sin_tonep6[0]; xfer.tx_buf = &config->sin_tonep6[0];
spi_message_init(&msg); ret = spi_sync_transfer(st->sdev, &xfer, 1);
spi_message_add_tail(&xfer, &msg);
ret = spi_sync(st->sdev, &msg);
if (ret) if (ret)
goto error_ret; goto error_ret;
xfer.len = 9; xfer.len = 9;
xfer.tx_buf = &config->sin_tonep7[0]; xfer.tx_buf = &config->sin_tonep7[0];
spi_message_init(&msg); ret = spi_sync_transfer(st->sdev, &xfer, 1);
spi_message_add_tail(&xfer, &msg);
ret = spi_sync(st->sdev, &msg);
if (ret) if (ret)
goto error_ret; goto error_ret;
error_ret: error_ret:
...@@ -288,7 +253,6 @@ static IIO_DEVICE_ATTR(dds, S_IWUSR, NULL, ad9910_set_parameter, 0); ...@@ -288,7 +253,6 @@ static IIO_DEVICE_ATTR(dds, S_IWUSR, NULL, ad9910_set_parameter, 0);
static void ad9910_init(struct ad9910_state *st) static void ad9910_init(struct ad9910_state *st)
{ {
struct spi_message msg;
struct spi_transfer xfer; struct spi_transfer xfer;
int ret; int ret;
u8 cfr[5]; u8 cfr[5];
...@@ -304,9 +268,7 @@ static void ad9910_init(struct ad9910_state *st) ...@@ -304,9 +268,7 @@ static void ad9910_init(struct ad9910_state *st)
xfer.len = 5; xfer.len = 5;
xfer.tx_buf = &cfr; xfer.tx_buf = &cfr;
spi_message_init(&msg); ret = spi_sync_transfer(st->sdev, &xfer, 1);
spi_message_add_tail(&xfer, &msg);
ret = spi_sync(st->sdev, &msg);
if (ret) if (ret)
goto error_ret; goto error_ret;
...@@ -319,9 +281,7 @@ static void ad9910_init(struct ad9910_state *st) ...@@ -319,9 +281,7 @@ static void ad9910_init(struct ad9910_state *st)
xfer.len = 5; xfer.len = 5;
xfer.tx_buf = &cfr; xfer.tx_buf = &cfr;
spi_message_init(&msg); ret = spi_sync_transfer(st->sdev, &xfer, 1);
spi_message_add_tail(&xfer, &msg);
ret = spi_sync(st->sdev, &msg);
if (ret) if (ret)
goto error_ret; goto error_ret;
...@@ -334,9 +294,7 @@ static void ad9910_init(struct ad9910_state *st) ...@@ -334,9 +294,7 @@ static void ad9910_init(struct ad9910_state *st)
xfer.len = 5; xfer.len = 5;
xfer.tx_buf = &cfr; xfer.tx_buf = &cfr;
spi_message_init(&msg); ret = spi_sync_transfer(st->sdev, &xfer, 1);
spi_message_add_tail(&xfer, &msg);
ret = spi_sync(st->sdev, &msg);
if (ret) if (ret)
goto error_ret; goto error_ret;
......
...@@ -60,7 +60,6 @@ static ssize_t ad9951_set_parameter(struct device *dev, ...@@ -60,7 +60,6 @@ static ssize_t ad9951_set_parameter(struct device *dev,
const char *buf, const char *buf,
size_t len) size_t len)
{ {
struct spi_message msg;
struct spi_transfer xfer; struct spi_transfer xfer;
int ret; int ret;
struct ad9951_config *config = (struct ad9951_config *)buf; struct ad9951_config *config = (struct ad9951_config *)buf;
...@@ -71,36 +70,28 @@ static ssize_t ad9951_set_parameter(struct device *dev, ...@@ -71,36 +70,28 @@ static ssize_t ad9951_set_parameter(struct device *dev,
xfer.tx_buf = &config->asf[0]; xfer.tx_buf = &config->asf[0];
mutex_lock(&st->lock); mutex_lock(&st->lock);
spi_message_init(&msg); ret = spi_sync_transfer(st->sdev, &xfer, 1);
spi_message_add_tail(&xfer, &msg);
ret = spi_sync(st->sdev, &msg);
if (ret) if (ret)
goto error_ret; goto error_ret;
xfer.len = 2; xfer.len = 2;
xfer.tx_buf = &config->arr[0]; xfer.tx_buf = &config->arr[0];
spi_message_init(&msg); ret = spi_sync_transfer(st->sdev, &xfer, 1);
spi_message_add_tail(&xfer, &msg);
ret = spi_sync(st->sdev, &msg);
if (ret) if (ret)
goto error_ret; goto error_ret;
xfer.len = 5; xfer.len = 5;
xfer.tx_buf = &config->ftw0[0]; xfer.tx_buf = &config->ftw0[0];
spi_message_init(&msg); ret = spi_sync_transfer(st->sdev, &xfer, 1);
spi_message_add_tail(&xfer, &msg);
ret = spi_sync(st->sdev, &msg);
if (ret) if (ret)
goto error_ret; goto error_ret;
xfer.len = 3; xfer.len = 3;
xfer.tx_buf = &config->ftw1[0]; xfer.tx_buf = &config->ftw1[0];
spi_message_init(&msg); ret = spi_sync_transfer(st->sdev, &xfer, 1);
spi_message_add_tail(&xfer, &msg);
ret = spi_sync(st->sdev, &msg);
if (ret) if (ret)
goto error_ret; goto error_ret;
error_ret: error_ret:
...@@ -113,7 +104,6 @@ static IIO_DEVICE_ATTR(dds, S_IWUSR, NULL, ad9951_set_parameter, 0); ...@@ -113,7 +104,6 @@ static IIO_DEVICE_ATTR(dds, S_IWUSR, NULL, ad9951_set_parameter, 0);
static void ad9951_init(struct ad9951_state *st) static void ad9951_init(struct ad9951_state *st)
{ {
struct spi_message msg;
struct spi_transfer xfer; struct spi_transfer xfer;
int ret; int ret;
u8 cfr[5]; u8 cfr[5];
...@@ -129,9 +119,7 @@ static void ad9951_init(struct ad9951_state *st) ...@@ -129,9 +119,7 @@ static void ad9951_init(struct ad9951_state *st)
xfer.len = 5; xfer.len = 5;
xfer.tx_buf = &cfr; xfer.tx_buf = &cfr;
spi_message_init(&msg); ret = spi_sync_transfer(st->sdev, &xfer, 1);
spi_message_add_tail(&xfer, &msg);
ret = spi_sync(st->sdev, &msg);
if (ret) if (ret)
goto error_ret; goto error_ret;
...@@ -143,9 +131,7 @@ static void ad9951_init(struct ad9951_state *st) ...@@ -143,9 +131,7 @@ static void ad9951_init(struct ad9951_state *st)
xfer.len = 4; xfer.len = 4;
xfer.tx_buf = &cfr; xfer.tx_buf = &cfr;
spi_message_init(&msg); ret = spi_sync_transfer(st->sdev, &xfer, 1);
spi_message_add_tail(&xfer, &msg);
ret = spi_sync(st->sdev, &msg);
if (ret) if (ret)
goto error_ret; goto error_ret;
......
This diff is collapsed.
...@@ -47,11 +47,13 @@ struct hid_sensor_hub_attribute_info { ...@@ -47,11 +47,13 @@ struct hid_sensor_hub_attribute_info {
* @hdev: Stores the hid instance. * @hdev: Stores the hid instance.
* @vendor_id: Vendor id of hub device. * @vendor_id: Vendor id of hub device.
* @product_id: Product id of hub device. * @product_id: Product id of hub device.
* @ref_cnt: Number of MFD clients have opened this device
*/ */
struct hid_sensor_hub_device { struct hid_sensor_hub_device {
struct hid_device *hdev; struct hid_device *hdev;
u32 vendor_id; u32 vendor_id;
u32 product_id; u32 product_id;
int ref_cnt;
}; };
/** /**
...@@ -74,6 +76,22 @@ struct hid_sensor_hub_callbacks { ...@@ -74,6 +76,22 @@ struct hid_sensor_hub_callbacks {
void *priv); void *priv);
}; };
/**
* sensor_hub_device_open() - Open hub device
* @hsdev: Hub device instance.
*
* Used to open hid device for sensor hub.
*/
int sensor_hub_device_open(struct hid_sensor_hub_device *hsdev);
/**
* sensor_hub_device_clode() - Close hub device
* @hsdev: Hub device instance.
*
* Used to clode hid device for sensor hub.
*/
void sensor_hub_device_close(struct hid_sensor_hub_device *hsdev);
/* Registration functions */ /* Registration functions */
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment