Commit 6761f0ac authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

Merge tag 'iio-for-4.17b' of...

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

Jonathan writes:

Second set of new device support, features and cleanup for IIO in the 4.17 cycle

The uptick in staging cleanup is partly due to GSoC Applications
process being underway and one of Daniel's tasks being to try
cleaning up an IIO driver to move out of staging.
Naturally there is some normal staging cleanup progress in here
as well.

New device support
* Microchip mcp4018
  - New driver supproting MCP4017, MCP4018 and MCP4019 digital pots.
* On Semiconductor lv0104cs
  - New driver to support this ambient light sensor.

Cleanup
* axp20x_adc
  - remove a !! in favour of clear ternary operator.
* ad2s1210 (staging cleanup)
  - Reorganise to avoid ending a line with [
  - Remove some unnecessary defines.
  - Remove unsed variable.
* ad5380
  - Replace magic 0 with IIO_CHAN_INFO_RAW
* ad5764
  - Replace magic 0 with IIO_CHA_INFO_RAW
* ad7150 (staging cleanup)
  - Align arguements with parenthesis.
* ad7152 (staging cleanup)
  - Align arguements.
* ad7746 (staging cleanup)
  - Align arguements.
* ad7816
  - Remove pointless void pointer cast.
* ade7753
  - Replace IIO_DEV_ATTR_CH_OFF with equivalent to avoid confusing
    checkpatch (this macro didn't really help anyway).  Also drop the
    macro from the meter.h header.
* ade7754 (staging cleanup)
  - Add names to funciton definition arguements.
  - Align arguements with open parenthesis where possible.
* ade7758 (staging cleanup)
  - Remove __func__ from dev_dbg statements as provided by dynamic
    debug anyway.
  - Align arguements with open parenthesis where possible.
* ade7759 (staging cleanup)
  - Replace IIO_DEV_ATTR_CH_OFF with equiavalent to avoid confusing
    checkpatch.
* adis16201 (staging cleanup)
  - Headers in alphabetical order.
  - Blank lines before returns.
* adis16209 (staging cleanup)
  - Headers in alphabetical order
  - Change some definition names to make them more meaningful (2 rounds
    of this).
  - Add explicit _REG prefix to register names to make them
    obviously different from fields within those registers.
  - Remove some superflous comments and group definitions better.
  - Use a switch statement to make it semantically obvious that we
    only have two options (rather than an unlimited 'else').
  - Use sign_extent32 instead of open coding.
* adt7316 (staging cleanup)
  - Move an export next to symbol.
* bmc150
  - drop redundant __func__ in dynamic debug.
* ccs811
  - Rename varaible to better reflect what it does.
* cros_ec
  - Reduce sampling frequency before suspending to avoid preventing
    suspend.
* dummy
  - Correct whitespace in Kconfig.
  - Add extra description in Kconfig.
* ds1803
  - Remove a VLA which we always know is 2 long.
* hid-sensor-accel
  - Replace magic number 0 by IIO_CHAN_INFO_RAW.
* hid-sensor-gyro
  - Replace magic number 0 by IIO_CHAN_INFO_RAW.
* hid-sensor-light
  - Replace magic number 0 by IIO_CHAN_INFO_RAW.
* hid-sensor-magn
  - Replace magic number 0 by IIO_CHAN_INFO_RAW.
* lm3533
  - Replace magic number 0 by IIO_CHAN_INFO_RAW
* mlx90632
  - Squash a smatch warning - no runtime effect.
* stm32_dfsdm:
  - Cleanup the dt bindings.
* sx9500
  - Add GPIO ACPI mapping table to behave correctly when firmware
    doesn't provide the mapping.
* tsl2x7x (staging cleanup)
  - Fix the proximity sensor functionality.
  - Remove platform data provided power functions.  There are much
    better ways to do this these days.
  - Introduce some common functions to avoid various repititions.
  - Stop using mutex_trylock when mutex_lock and wait a bit is fine.
  - Improve error handling in various places.
  - Drop some 'Camel case' (which wasn't actually strickly camel case
    but was a bit odd.
  - Drop some _available sysfs attributes for things that don't exist
    (for particular supported parts).
parents fdff8622 9aa5134a
......@@ -32,6 +32,10 @@ Optional properties:
to "clock" property. Frequency must be a multiple of the rcc
clock frequency. If not, SPI CLKOUT frequency will not be
accurate.
- pinctrl-names: Set to "default".
- pinctrl-0: List of phandles pointing to pin configuration
nodes to set pins in mode of operation for dfsdm
on external pin.
Contents of a STM32 DFSDM child nodes:
--------------------------------------
......@@ -68,8 +72,8 @@ Optional properties:
- st,adc-channel-types: Single-ended channel input type.
- "SPI_R": SPI with data on rising edge (default)
- "SPI_F": SPI with data on falling edge
- "MANCH_R": manchester codec, rising edge = logic 0
- "MANCH_F": manchester codec, falling edge = logic 1
- "MANCH_R": manchester codec, rising edge = logic 0, falling edge = logic 1
- "MANCH_F": manchester codec, rising edge = logic 1, falling edge = logic 0
- st,adc-channel-clk-src: Conversion clock source.
- "CLKIN": external SPI clock (CLKIN x)
- "CLKOUT": internal SPI clock (CLKOUT) (default)
......
......@@ -8585,11 +8585,12 @@ W: https://linuxtv.org
S: Maintained
F: drivers/media/radio/radio-maxiradio*
MCP4531 MICROCHIP DIGITAL POTENTIOMETER DRIVER
MCP4018 AND MCP4531 MICROCHIP DIGITAL POTENTIOMETER DRIVERS
M: Peter Rosin <peda@axentia.se>
L: linux-iio@vger.kernel.org
S: Maintained
F: Documentation/ABI/testing/sysfs-bus-iio-potentiometer-mcp4531
F: drivers/iio/potentiometer/mcp4018.c
F: drivers/iio/potentiometer/mcp4531.c
MEASUREMENT COMPUTING CIO-DAC IIO DRIVER
......
......@@ -336,8 +336,7 @@ static int bmc150_accel_update_slope(struct bmc150_accel_data *data)
return ret;
}
dev_dbg(dev, "%s: %x %x\n", __func__, data->slope_thres,
data->slope_dur);
dev_dbg(dev, "%x %x\n", data->slope_thres, data->slope_dur);
return ret;
}
......@@ -1716,7 +1715,6 @@ static int bmc150_accel_runtime_suspend(struct device *dev)
struct bmc150_accel_data *data = iio_priv(indio_dev);
int ret;
dev_dbg(dev, __func__);
ret = bmc150_accel_set_mode(data, BMC150_ACCEL_SLEEP_MODE_SUSPEND, 0);
if (ret < 0)
return -EAGAIN;
......@@ -1731,8 +1729,6 @@ static int bmc150_accel_runtime_resume(struct device *dev)
int ret;
int sleep_val;
dev_dbg(dev, __func__);
ret = bmc150_accel_set_mode(data, BMC150_ACCEL_SLEEP_MODE_NORMAL, 0);
if (ret < 0)
return ret;
......
......@@ -155,7 +155,7 @@ static int accel_3d_read_raw(struct iio_dev *indio_dev,
*val = 0;
*val2 = 0;
switch (mask) {
case 0:
case IIO_CHAN_INFO_RAW:
hid_sensor_power_state(&accel_state->common_attributes, true);
report_id = accel_state->accel[chan->scan_index].report_id;
address = accel_3d_addresses[chan->scan_index];
......
......@@ -445,7 +445,7 @@ static int axp20x_adc_offset_voltage(struct iio_dev *indio_dev, int channel,
return -EINVAL;
}
*val = !!(*val) * 700000;
*val = *val ? 700000 : 0;
return IIO_VAL_INT;
}
......@@ -542,15 +542,17 @@ static int axp20x_write_raw(struct iio_dev *indio_dev,
if (val != 0 && val != 700000)
return -EINVAL;
val = val ? 1 : 0;
switch (chan->channel) {
case AXP20X_GPIO0_V:
reg = AXP20X_GPIO10_IN_RANGE_GPIO0;
regval = AXP20X_GPIO10_IN_RANGE_GPIO0_VAL(!!val);
regval = AXP20X_GPIO10_IN_RANGE_GPIO0_VAL(val);
break;
case AXP20X_GPIO1_V:
reg = AXP20X_GPIO10_IN_RANGE_GPIO1;
regval = AXP20X_GPIO10_IN_RANGE_GPIO1_VAL(!!val);
regval = AXP20X_GPIO10_IN_RANGE_GPIO1_VAL(val);
break;
default:
......
......@@ -69,7 +69,7 @@ struct ccs811_reading {
__be16 voc;
u8 status;
u8 error;
__be16 resistance;
__be16 raw_data;
} __attribute__((__packed__));
struct ccs811_data {
......@@ -210,12 +210,12 @@ static int ccs811_read_raw(struct iio_dev *indio_dev,
switch (chan->type) {
case IIO_VOLTAGE:
*val = be16_to_cpu(data->buffer.resistance) &
*val = be16_to_cpu(data->buffer.raw_data) &
CCS811_VOLTAGE_MASK;
ret = IIO_VAL_INT;
break;
case IIO_CURRENT:
*val = be16_to_cpu(data->buffer.resistance) >> 10;
*val = be16_to_cpu(data->buffer.raw_data) >> 10;
ret = IIO_VAL_INT;
break;
case IIO_CONCENTRATION:
......
......@@ -289,6 +289,7 @@ MODULE_DEVICE_TABLE(platform, cros_ec_sensors_ids);
static struct platform_driver cros_ec_sensors_platform_driver = {
.driver = {
.name = "cros-ec-sensors",
.pm = &cros_ec_sensors_pm_ops,
},
.probe = cros_ec_sensors_probe,
.id_table = cros_ec_sensors_ids,
......
......@@ -446,5 +446,54 @@ int cros_ec_sensors_core_write(struct cros_ec_sensors_core_state *st,
}
EXPORT_SYMBOL_GPL(cros_ec_sensors_core_write);
static int __maybe_unused cros_ec_sensors_prepare(struct device *dev)
{
struct platform_device *pdev = to_platform_device(dev);
struct iio_dev *indio_dev = platform_get_drvdata(pdev);
struct cros_ec_sensors_core_state *st = iio_priv(indio_dev);
if (st->curr_sampl_freq == 0)
return 0;
/*
* If the sensors are sampled at high frequency, we will not be able to
* sleep. Set sampling to a long period if necessary.
*/
if (st->curr_sampl_freq < CROS_EC_MIN_SUSPEND_SAMPLING_FREQUENCY) {
mutex_lock(&st->cmd_lock);
st->param.cmd = MOTIONSENSE_CMD_EC_RATE;
st->param.ec_rate.data = CROS_EC_MIN_SUSPEND_SAMPLING_FREQUENCY;
cros_ec_motion_send_host_cmd(st, 0);
mutex_unlock(&st->cmd_lock);
}
return 0;
}
static void __maybe_unused cros_ec_sensors_complete(struct device *dev)
{
struct platform_device *pdev = to_platform_device(dev);
struct iio_dev *indio_dev = platform_get_drvdata(pdev);
struct cros_ec_sensors_core_state *st = iio_priv(indio_dev);
if (st->curr_sampl_freq == 0)
return;
if (st->curr_sampl_freq < CROS_EC_MIN_SUSPEND_SAMPLING_FREQUENCY) {
mutex_lock(&st->cmd_lock);
st->param.cmd = MOTIONSENSE_CMD_EC_RATE;
st->param.ec_rate.data = st->curr_sampl_freq;
cros_ec_motion_send_host_cmd(st, 0);
mutex_unlock(&st->cmd_lock);
}
}
const struct dev_pm_ops cros_ec_sensors_pm_ops = {
#ifdef CONFIG_PM_SLEEP
.prepare = cros_ec_sensors_prepare,
.complete = cros_ec_sensors_complete
#endif
};
EXPORT_SYMBOL_GPL(cros_ec_sensors_pm_ops);
MODULE_DESCRIPTION("ChromeOS EC sensor hub core functions");
MODULE_LICENSE("GPL v2");
......@@ -169,6 +169,8 @@ int cros_ec_sensors_core_write(struct cros_ec_sensors_core_state *st,
struct iio_chan_spec const *chan,
int val, int val2, long mask);
extern const struct dev_pm_ops cros_ec_sensors_pm_ops;
/* List of extended channel specification for all sensors */
extern const struct iio_chan_spec_ext_info cros_ec_sensors_ext_info[];
......
......@@ -158,7 +158,7 @@ static unsigned int ad5380_info_to_reg(struct iio_chan_spec const *chan,
long info)
{
switch (info) {
case 0:
case IIO_CHAN_INFO_RAW:
return AD5380_REG_DATA(chan->address);
case IIO_CHAN_INFO_CALIBBIAS:
return AD5380_REG_OFFSET(chan->address);
......
......@@ -168,7 +168,7 @@ static int ad5764_read(struct iio_dev *indio_dev, unsigned int reg,
static int ad5764_chan_info_to_reg(struct iio_chan_spec const *chan, long info)
{
switch (info) {
case 0:
case IIO_CHAN_INFO_RAW:
return AD5764_REG_DATA(chan->address);
case IIO_CHAN_INFO_CALIBBIAS:
return AD5764_REG_OFFSET(chan->address);
......
......@@ -24,6 +24,10 @@ config IIO_SIMPLE_DUMMY_EVENTS
help
Add some dummy events to the simple dummy driver.
The purpose of this is to generate 'fake' event interrupts thus
allowing that driver's code to be as close as possible to that
a normal driver talking to hardware.
config IIO_SIMPLE_DUMMY_BUFFER
bool "Buffered capture support"
select IIO_BUFFER
......@@ -32,6 +36,9 @@ config IIO_SIMPLE_DUMMY_BUFFER
help
Add buffered data capture to the simple dummy driver.
Buffer handling elements of industrial I/O reference driver.
Uses the kfifo buffer.
endif # IIO_SIMPLE_DUMMY
endmenu
......@@ -115,7 +115,7 @@ static int gyro_3d_read_raw(struct iio_dev *indio_dev,
*val = 0;
*val2 = 0;
switch (mask) {
case 0:
case IIO_CHAN_INFO_RAW:
hid_sensor_power_state(&gyro_state->common_attributes, true);
report_id = gyro_state->gyro[chan->scan_index].report_id;
address = gyro_3d_addresses[chan->scan_index];
......
......@@ -275,6 +275,16 @@ config LTR501
This driver can also be built as a module. If so, the module
will be called ltr501.
config LV0104CS
tristate "LV0104CS Ambient Light Sensor"
depends on I2C
help
Say Y here if you want to build support for the On Semiconductor
LV0104CS ambient light sensor.
To compile this driver as a module, choose M here:
the module will be called lv0104cs.
config MAX44000
tristate "MAX44000 Ambient and Infrared Proximity Sensor"
depends on I2C
......
......@@ -26,6 +26,7 @@ obj-$(CONFIG_ISL29125) += isl29125.o
obj-$(CONFIG_JSA1212) += jsa1212.o
obj-$(CONFIG_SENSORS_LM3533) += lm3533-als.o
obj-$(CONFIG_LTR501) += ltr501.o
obj-$(CONFIG_LV0104CS) += lv0104cs.o
obj-$(CONFIG_MAX44000) += max44000.o
obj-$(CONFIG_OPT3001) += opt3001.o
obj-$(CONFIG_PA12203001) += pa12203001.o
......
......@@ -276,6 +276,7 @@ MODULE_DEVICE_TABLE(platform, cros_ec_light_prox_ids);
static struct platform_driver cros_ec_light_prox_platform_driver = {
.driver = {
.name = "cros-ec-light-prox",
.pm = &cros_ec_sensors_pm_ops,
},
.probe = cros_ec_light_prox_probe,
.id_table = cros_ec_light_prox_ids,
......
......@@ -97,7 +97,7 @@ static int als_read_raw(struct iio_dev *indio_dev,
*val = 0;
*val2 = 0;
switch (mask) {
case 0:
case IIO_CHAN_INFO_RAW:
switch (chan->scan_index) {
case CHANNEL_SCAN_INDEX_INTENSITY:
case CHANNEL_SCAN_INDEX_ILLUM:
......
......@@ -199,7 +199,7 @@ static int lm3533_als_read_raw(struct iio_dev *indio_dev,
int ret;
switch (mask) {
case 0:
case IIO_CHAN_INFO_RAW:
switch (chan->type) {
case IIO_LIGHT:
ret = lm3533_als_get_adc(indio_dev, false, val);
......
This diff is collapsed.
......@@ -167,7 +167,7 @@ static int magn_3d_read_raw(struct iio_dev *indio_dev,
*val = 0;
*val2 = 0;
switch (mask) {
case 0:
case IIO_CHAN_INFO_RAW:
hid_sensor_power_state(&magn_state->magn_flux_attributes, true);
report_id =
magn_state->magn[chan->address].report_id;
......
......@@ -47,6 +47,17 @@ config MAX5487
To compile this driver as a module, choose M here: the
module will be called max5487.
config MCP4018
tristate "Microchip MCP4017/18/19 Digital Potentiometer driver"
depends on I2C
help
Say yes here to build support for the Microchip
MCP4017, MCP4018, MCP4019
digital potentiometer chips.
To compile this driver as a module, choose M here: the
module will be called mcp4018.
config MCP4131
tristate "Microchip MCP413X/414X/415X/416X/423X/424X/425X/426X Digital Potentiometer driver"
depends on SPI
......
......@@ -8,6 +8,7 @@ obj-$(CONFIG_AD5272) += ad5272.o
obj-$(CONFIG_DS1803) += ds1803.o
obj-$(CONFIG_MAX5481) += max5481.o
obj-$(CONFIG_MAX5487) += max5487.o
obj-$(CONFIG_MCP4018) += mcp4018.o
obj-$(CONFIG_MCP4131) += mcp4131.o
obj-$(CONFIG_MCP4531) += mcp4531.o
obj-$(CONFIG_TPL0102) += tpl0102.o
......@@ -64,7 +64,7 @@ static int ds1803_read_raw(struct iio_dev *indio_dev,
struct ds1803_data *data = iio_priv(indio_dev);
int pot = chan->channel;
int ret;
u8 result[indio_dev->num_channels];
u8 result[ARRAY_SIZE(ds1803_channels)];
switch (mask) {
case IIO_CHAN_INFO_RAW:
......
// SPDX-License-Identifier: GPL-2.0
/*
* Industrial I/O driver for Microchip digital potentiometers
* Copyright (c) 2018 Axentia Technologies AB
* Author: Peter Rosin <peda@axentia.se>
*
* Datasheet: http://www.microchip.com/downloads/en/DeviceDoc/22147a.pdf
*
* DEVID #Wipers #Positions Resistor Opts (kOhm)
* mcp4017 1 128 5, 10, 50, 100
* mcp4018 1 128 5, 10, 50, 100
* mcp4019 1 128 5, 10, 50, 100
*/
#include <linux/err.h>
#include <linux/i2c.h>
#include <linux/iio/iio.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/of_device.h>
#define MCP4018_WIPER_MAX 127
struct mcp4018_cfg {
int kohms;
};
enum mcp4018_type {
MCP4018_502,
MCP4018_103,
MCP4018_503,
MCP4018_104,
};
static const struct mcp4018_cfg mcp4018_cfg[] = {
[MCP4018_502] = { .kohms = 5, },
[MCP4018_103] = { .kohms = 10, },
[MCP4018_503] = { .kohms = 50, },
[MCP4018_104] = { .kohms = 100, },
};
struct mcp4018_data {
struct i2c_client *client;
const struct mcp4018_cfg *cfg;
};
static const struct iio_chan_spec mcp4018_channel = {
.type = IIO_RESISTANCE,
.indexed = 1,
.output = 1,
.channel = 0,
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
.info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),
};
static int mcp4018_read_raw(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan,
int *val, int *val2, long mask)
{
struct mcp4018_data *data = iio_priv(indio_dev);
s32 ret;
switch (mask) {
case IIO_CHAN_INFO_RAW:
ret = i2c_smbus_read_byte(data->client);
if (ret < 0)
return ret;
*val = ret;
return IIO_VAL_INT;
case IIO_CHAN_INFO_SCALE:
*val = 1000 * data->cfg->kohms;
*val2 = MCP4018_WIPER_MAX;
return IIO_VAL_FRACTIONAL;
}
return -EINVAL;
}
static int mcp4018_write_raw(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan,
int val, int val2, long mask)
{
struct mcp4018_data *data = iio_priv(indio_dev);
switch (mask) {
case IIO_CHAN_INFO_RAW:
if (val > MCP4018_WIPER_MAX || val < 0)
return -EINVAL;
break;
default:
return -EINVAL;
}
return i2c_smbus_write_byte(data->client, val);
}
static const struct iio_info mcp4018_info = {
.read_raw = mcp4018_read_raw,
.write_raw = mcp4018_write_raw,
};
#ifdef CONFIG_OF
#define MCP4018_COMPATIBLE(of_compatible, cfg) { \
.compatible = of_compatible, \
.data = &mcp4018_cfg[cfg], \
}
static const struct of_device_id mcp4018_of_match[] = {
MCP4018_COMPATIBLE("microchip,mcp4017-502", MCP4018_502),
MCP4018_COMPATIBLE("microchip,mcp4017-103", MCP4018_103),
MCP4018_COMPATIBLE("microchip,mcp4017-503", MCP4018_503),
MCP4018_COMPATIBLE("microchip,mcp4017-104", MCP4018_104),
MCP4018_COMPATIBLE("microchip,mcp4018-502", MCP4018_502),
MCP4018_COMPATIBLE("microchip,mcp4018-103", MCP4018_103),
MCP4018_COMPATIBLE("microchip,mcp4018-503", MCP4018_503),
MCP4018_COMPATIBLE("microchip,mcp4018-104", MCP4018_104),
MCP4018_COMPATIBLE("microchip,mcp4019-502", MCP4018_502),
MCP4018_COMPATIBLE("microchip,mcp4019-103", MCP4018_103),
MCP4018_COMPATIBLE("microchip,mcp4019-503", MCP4018_503),
MCP4018_COMPATIBLE("microchip,mcp4019-104", MCP4018_104),
{ /* sentinel */ }
};
MODULE_DEVICE_TABLE(of, mcp4018_of_match);
#endif
static int mcp4018_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
struct device *dev = &client->dev;
struct mcp4018_data *data;
struct iio_dev *indio_dev;
const struct of_device_id *match;
if (!i2c_check_functionality(client->adapter,
I2C_FUNC_SMBUS_BYTE)) {
dev_err(dev, "SMBUS Byte transfers not supported\n");
return -EOPNOTSUPP;
}
indio_dev = devm_iio_device_alloc(dev, sizeof(*data));
if (!indio_dev)
return -ENOMEM;
data = iio_priv(indio_dev);
i2c_set_clientdata(client, indio_dev);
data->client = client;
match = of_match_device(of_match_ptr(mcp4018_of_match), dev);
if (match)
data->cfg = of_device_get_match_data(dev);
else
data->cfg = &mcp4018_cfg[id->driver_data];
indio_dev->dev.parent = dev;
indio_dev->info = &mcp4018_info;
indio_dev->channels = &mcp4018_channel;
indio_dev->num_channels = 1;
indio_dev->name = client->name;
return devm_iio_device_register(dev, indio_dev);
}
static const struct i2c_device_id mcp4018_id[] = {
{ "mcp4017-502", MCP4018_502 },
{ "mcp4017-103", MCP4018_103 },
{ "mcp4017-503", MCP4018_503 },
{ "mcp4017-104", MCP4018_104 },
{ "mcp4018-502", MCP4018_502 },
{ "mcp4018-103", MCP4018_103 },
{ "mcp4018-503", MCP4018_503 },
{ "mcp4018-104", MCP4018_104 },
{ "mcp4019-502", MCP4018_502 },
{ "mcp4019-103", MCP4018_103 },
{ "mcp4019-503", MCP4018_503 },
{ "mcp4019-104", MCP4018_104 },
{}
};
MODULE_DEVICE_TABLE(i2c, mcp4018_id);
static struct i2c_driver mcp4018_driver = {
.driver = {
.name = "mcp4018",
.of_match_table = of_match_ptr(mcp4018_of_match),
},
.probe = mcp4018_probe,
.id_table = mcp4018_id,
};
module_i2c_driver(mcp4018_driver);
MODULE_AUTHOR("Peter Rosin <peda@axentia.se>");
MODULE_DESCRIPTION("MCP4018 digital potentiometer");
MODULE_LICENSE("GPL");
......@@ -32,9 +32,6 @@
#define SX9500_DRIVER_NAME "sx9500"
#define SX9500_IRQ_NAME "sx9500_event"
#define SX9500_GPIO_INT "interrupt"
#define SX9500_GPIO_RESET "reset"
/* Register definitions. */
#define SX9500_REG_IRQ_SRC 0x00
#define SX9500_REG_STAT 0x01
......@@ -866,26 +863,44 @@ static int sx9500_init_device(struct iio_dev *indio_dev)
return sx9500_init_compensation(indio_dev);
}
static const struct acpi_gpio_params reset_gpios = { 0, 0, false };
static const struct acpi_gpio_params interrupt_gpios = { 2, 0, false };
static const struct acpi_gpio_mapping acpi_sx9500_gpios[] = {
{ "reset-gpios", &reset_gpios, 1 },
/*
* Some platforms have a bug in ACPI GPIO description making IRQ
* GPIO to be output only. Ask the GPIO core to ignore this limit.
*/
{ "interrupt-gpios", &interrupt_gpios, 1, ACPI_GPIO_QUIRK_NO_IO_RESTRICTION },
{ },
};
static void sx9500_gpio_probe(struct i2c_client *client,
struct sx9500_data *data)
{
struct gpio_desc *gpiod_int;
struct device *dev;
int ret;
if (!client)
return;
dev = &client->dev;
ret = devm_acpi_dev_add_driver_gpios(dev, acpi_sx9500_gpios);
if (ret)
dev_dbg(dev, "Unable to add GPIO mapping table\n");
if (client->irq <= 0) {
gpiod_int = devm_gpiod_get(dev, SX9500_GPIO_INT, GPIOD_IN);
gpiod_int = devm_gpiod_get(dev, "interrupt", GPIOD_IN);
if (IS_ERR(gpiod_int))
dev_err(dev, "gpio get irq failed\n");
else
client->irq = gpiod_to_irq(gpiod_int);
}
data->gpiod_rst = devm_gpiod_get(dev, SX9500_GPIO_RESET, GPIOD_OUT_HIGH);
data->gpiod_rst = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH);
if (IS_ERR(data->gpiod_rst)) {
dev_warn(dev, "gpio get reset pin failed\n");
data->gpiod_rst = NULL;
......
......@@ -506,6 +506,8 @@ static int mlx90632_calc_ambient_dsp105(struct mlx90632_data *data, int *val)
ret = mlx90632_read_ambient_raw(data->regmap, &ambient_new_raw,
&ambient_old_raw);
if (ret < 0)
return ret;
*val = mlx90632_calc_temp_ambient(ambient_new_raw, ambient_old_raw,
PT, PR, PG, PO, Gb);
return ret;
......
......@@ -7,13 +7,13 @@
*/
#include <linux/delay.h>
#include <linux/mutex.h>
#include <linux/device.h>
#include <linux/kernel.h>
#include <linux/spi/spi.h>
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/slab.h>
#include <linux/spi/spi.h>
#include <linux/sysfs.h>
#include <linux/module.h>
#include <linux/iio/iio.h>
#include <linux/iio/sysfs.h>
......@@ -232,6 +232,7 @@ static int adis16201_read_raw(struct iio_dev *indio_dev,
*val = val16;
return IIO_VAL_INT;
}
return -EINVAL;
}
......@@ -262,6 +263,7 @@ static int adis16201_write_raw(struct iio_dev *indio_dev,
addr = adis16201_addresses[chan->scan_index];
return adis_write_reg_16(st, addr, val16);
}
return -EINVAL;
}
......@@ -336,6 +338,7 @@ static int adis16201_probe(struct spi_device *spi)
ret = adis_init(st, indio_dev, spi, &adis16201_data);
if (ret)
return ret;
ret = adis_setup_buffer_and_trigger(st, indio_dev, NULL);
if (ret)
return ret;
......@@ -348,6 +351,7 @@ static int adis16201_probe(struct spi_device *spi)
ret = iio_device_register(indio_dev);
if (ret < 0)
goto error_cleanup_buffer_trigger;
return 0;
error_cleanup_buffer_trigger:
......
This diff is collapsed.
......@@ -254,7 +254,7 @@ static const struct attribute_group ad7816_attribute_group = {
static irqreturn_t ad7816_event_handler(int irq, void *private)
{
iio_push_event(private, IIO_EVENT_CODE_AD7816_OTI,
iio_get_time_ns((struct iio_dev *)private));
iio_get_time_ns(private));
return IRQ_HANDLED;
}
......
......@@ -2079,9 +2079,8 @@ static int adt7316_enable(struct device *dev)
return _adt7316_store_enabled(chip, 1);
}
SIMPLE_DEV_PM_OPS(adt7316_pm_ops, adt7316_disable, adt7316_enable);
EXPORT_SYMBOL_GPL(adt7316_pm_ops);
SIMPLE_DEV_PM_OPS(adt7316_pm_ops, adt7316_disable, adt7316_enable);
#endif
static const struct iio_info adt7316_info = {
......
......@@ -124,7 +124,8 @@ static int ad7150_read_raw(struct iio_dev *indio_dev,
}
static int ad7150_read_event_config(struct iio_dev *indio_dev,
const struct iio_chan_spec *chan, enum iio_event_type type,
const struct iio_chan_spec *chan,
enum iio_event_type type,
enum iio_event_direction dir)
{
int ret;
......
This diff is collapsed.
......@@ -21,7 +21,6 @@
#ifndef __TSL2X7X_H
#define __TSL2X7X_H
#include <linux/pm.h>
struct tsl2x7x_lux {
unsigned int ratio;
......@@ -79,6 +78,8 @@ struct tsl2x7x_settings {
int prox_thres_high;
int prox_pulse_count;
int prox_max_samples_cal;
int prox_diode;
int prox_power;
};
/**
......@@ -91,9 +92,6 @@ struct tsl2x7x_settings {
*
*/
struct tsl2X7X_platform_data {
int (*platform_power)(struct device *dev, pm_message_t);
int (*power_on)(struct iio_dev *indio_dev);
int (*power_off)(struct i2c_client *dev);
struct tsl2x7x_lux platform_lux_table[TSL2X7X_MAX_LUX_TABLE_SIZE];
struct tsl2x7x_settings *platform_default_settings;
};
......
......@@ -388,11 +388,13 @@ static IIO_DEV_ATTR_VPERIOD(0444,
ade7753_read_16bit,
NULL,
ADE7753_PERIOD);
static IIO_DEV_ATTR_CH_OFF(1, 0644,
static IIO_DEVICE_ATTR(choff_1, 0644,
ade7753_read_8bit,
ade7753_write_8bit,
ADE7753_CH1OS);
static IIO_DEV_ATTR_CH_OFF(2, 0644,
static IIO_DEVICE_ATTR(choff_2, 0644,
ade7753_read_8bit,
ade7753_write_8bit,
ADE7753_CH2OS);
......
......@@ -132,7 +132,7 @@ static int ade7754_spi_write_reg_8(struct device *dev, u8 reg_address, u8 val)
}
static int ade7754_spi_write_reg_16(struct device *dev,
u8 reg_address, u16 value)
u8 reg_address, u16 val)
{
int ret;
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
......@@ -140,8 +140,8 @@ static int ade7754_spi_write_reg_16(struct device *dev,
mutex_lock(&st->buf_lock);
st->tx[0] = ADE7754_WRITE_REG(reg_address);
st->tx[1] = (value >> 8) & 0xFF;
st->tx[2] = value & 0xFF;
st->tx[1] = (val >> 8) & 0xFF;
st->tx[2] = val & 0xFF;
ret = spi_write(st->us, st->tx, 3);
mutex_unlock(&st->buf_lock);
......
......@@ -34,7 +34,7 @@ static int ade7758_data_rdy_trigger_set_state(struct iio_trigger *trig,
{
struct iio_dev *indio_dev = iio_trigger_get_drvdata(trig);
dev_dbg(&indio_dev->dev, "%s (%d)\n", __func__, state);
dev_dbg(&indio_dev->dev, "(%d)\n", state);
return ade7758_set_irq(&indio_dev->dev, state);
}
......
......@@ -328,11 +328,13 @@ static IIO_DEV_ATTR_ACTIVE_POWER_GAIN(0644,
ade7759_read_16bit,
ade7759_write_16bit,
ADE7759_APGAIN);
static IIO_DEV_ATTR_CH_OFF(1, 0644,
static IIO_DEVICE_ATTR(choff_1, 0644,
ade7759_read_8bit,
ade7759_write_8bit,
ADE7759_CH1OS);
static IIO_DEV_ATTR_CH_OFF(2, 0644,
static IIO_DEVICE_ATTR(choff_2, 0644,
ade7759_read_8bit,
ade7759_write_8bit,
ADE7759_CH2OS);
......
......@@ -17,7 +17,7 @@
static int ade7854_i2c_write_reg_8(struct device *dev,
u16 reg_address,
u8 value)
u8 val)
{
int ret;
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
......@@ -26,7 +26,7 @@ static int ade7854_i2c_write_reg_8(struct device *dev,
mutex_lock(&st->buf_lock);
st->tx[0] = (reg_address >> 8) & 0xFF;
st->tx[1] = reg_address & 0xFF;
st->tx[2] = value;
st->tx[2] = val;
ret = i2c_master_send(st->i2c, st->tx, 3);
mutex_unlock(&st->buf_lock);
......@@ -36,7 +36,7 @@ static int ade7854_i2c_write_reg_8(struct device *dev,
static int ade7854_i2c_write_reg_16(struct device *dev,
u16 reg_address,
u16 value)
u16 val)
{
int ret;
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
......@@ -45,8 +45,8 @@ static int ade7854_i2c_write_reg_16(struct device *dev,
mutex_lock(&st->buf_lock);
st->tx[0] = (reg_address >> 8) & 0xFF;
st->tx[1] = reg_address & 0xFF;
st->tx[2] = (value >> 8) & 0xFF;
st->tx[3] = value & 0xFF;
st->tx[2] = (val >> 8) & 0xFF;
st->tx[3] = val & 0xFF;
ret = i2c_master_send(st->i2c, st->tx, 4);
mutex_unlock(&st->buf_lock);
......@@ -56,7 +56,7 @@ static int ade7854_i2c_write_reg_16(struct device *dev,
static int ade7854_i2c_write_reg_24(struct device *dev,
u16 reg_address,
u32 value)
u32 val)
{
int ret;
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
......@@ -65,9 +65,9 @@ static int ade7854_i2c_write_reg_24(struct device *dev,
mutex_lock(&st->buf_lock);
st->tx[0] = (reg_address >> 8) & 0xFF;
st->tx[1] = reg_address & 0xFF;
st->tx[2] = (value >> 16) & 0xFF;
st->tx[3] = (value >> 8) & 0xFF;
st->tx[4] = value & 0xFF;
st->tx[2] = (val >> 16) & 0xFF;
st->tx[3] = (val >> 8) & 0xFF;
st->tx[4] = val & 0xFF;
ret = i2c_master_send(st->i2c, st->tx, 5);
mutex_unlock(&st->buf_lock);
......@@ -77,7 +77,7 @@ static int ade7854_i2c_write_reg_24(struct device *dev,
static int ade7854_i2c_write_reg_32(struct device *dev,
u16 reg_address,
u32 value)
u32 val)
{
int ret;
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
......@@ -86,10 +86,10 @@ static int ade7854_i2c_write_reg_32(struct device *dev,
mutex_lock(&st->buf_lock);
st->tx[0] = (reg_address >> 8) & 0xFF;
st->tx[1] = reg_address & 0xFF;
st->tx[2] = (value >> 24) & 0xFF;
st->tx[3] = (value >> 16) & 0xFF;
st->tx[4] = (value >> 8) & 0xFF;
st->tx[5] = value & 0xFF;
st->tx[2] = (val >> 24) & 0xFF;
st->tx[3] = (val >> 16) & 0xFF;
st->tx[4] = (val >> 8) & 0xFF;
st->tx[5] = val & 0xFF;
ret = i2c_master_send(st->i2c, st->tx, 6);
mutex_unlock(&st->buf_lock);
......
......@@ -17,7 +17,7 @@
static int ade7854_spi_write_reg_8(struct device *dev,
u16 reg_address,
u8 value)
u8 val)
{
int ret;
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
......@@ -32,7 +32,7 @@ static int ade7854_spi_write_reg_8(struct device *dev,
st->tx[0] = ADE7854_WRITE_REG;
st->tx[1] = (reg_address >> 8) & 0xFF;
st->tx[2] = reg_address & 0xFF;
st->tx[3] = value & 0xFF;
st->tx[3] = val & 0xFF;
ret = spi_sync_transfer(st->spi, &xfer, 1);
mutex_unlock(&st->buf_lock);
......@@ -42,7 +42,7 @@ static int ade7854_spi_write_reg_8(struct device *dev,
static int ade7854_spi_write_reg_16(struct device *dev,
u16 reg_address,
u16 value)
u16 val)
{
int ret;
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
......@@ -57,8 +57,8 @@ static int ade7854_spi_write_reg_16(struct device *dev,
st->tx[0] = ADE7854_WRITE_REG;
st->tx[1] = (reg_address >> 8) & 0xFF;
st->tx[2] = reg_address & 0xFF;
st->tx[3] = (value >> 8) & 0xFF;
st->tx[4] = value & 0xFF;
st->tx[3] = (val >> 8) & 0xFF;
st->tx[4] = val & 0xFF;
ret = spi_sync_transfer(st->spi, &xfer, 1);
mutex_unlock(&st->buf_lock);
......@@ -68,7 +68,7 @@ static int ade7854_spi_write_reg_16(struct device *dev,
static int ade7854_spi_write_reg_24(struct device *dev,
u16 reg_address,
u32 value)
u32 val)
{
int ret;
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
......@@ -83,9 +83,9 @@ static int ade7854_spi_write_reg_24(struct device *dev,
st->tx[0] = ADE7854_WRITE_REG;
st->tx[1] = (reg_address >> 8) & 0xFF;
st->tx[2] = reg_address & 0xFF;
st->tx[3] = (value >> 16) & 0xFF;
st->tx[4] = (value >> 8) & 0xFF;
st->tx[5] = value & 0xFF;
st->tx[3] = (val >> 16) & 0xFF;
st->tx[4] = (val >> 8) & 0xFF;
st->tx[5] = val & 0xFF;
ret = spi_sync_transfer(st->spi, &xfer, 1);
mutex_unlock(&st->buf_lock);
......@@ -95,7 +95,7 @@ static int ade7854_spi_write_reg_24(struct device *dev,
static int ade7854_spi_write_reg_32(struct device *dev,
u16 reg_address,
u32 value)
u32 val)
{
int ret;
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
......@@ -110,10 +110,10 @@ static int ade7854_spi_write_reg_32(struct device *dev,
st->tx[0] = ADE7854_WRITE_REG;
st->tx[1] = (reg_address >> 8) & 0xFF;
st->tx[2] = reg_address & 0xFF;
st->tx[3] = (value >> 24) & 0xFF;
st->tx[4] = (value >> 16) & 0xFF;
st->tx[5] = (value >> 8) & 0xFF;
st->tx[6] = value & 0xFF;
st->tx[3] = (val >> 24) & 0xFF;
st->tx[4] = (val >> 16) & 0xFF;
st->tx[5] = (val >> 8) & 0xFF;
st->tx[6] = val & 0xFF;
ret = spi_sync_transfer(st->spi, &xfer, 1);
mutex_unlock(&st->buf_lock);
......
......@@ -154,14 +154,14 @@
struct ade7854_state {
struct spi_device *spi;
struct i2c_client *i2c;
int (*read_reg_8)(struct device *, u16, u8 *);
int (*read_reg_16)(struct device *, u16, u16 *);
int (*read_reg_24)(struct device *, u16, u32 *);
int (*read_reg_32)(struct device *, u16, u32 *);
int (*write_reg_8)(struct device *, u16, u8);
int (*write_reg_16)(struct device *, u16, u16);
int (*write_reg_24)(struct device *, u16, u32);
int (*write_reg_32)(struct device *, u16, u32);
int (*read_reg_8)(struct device *dev, u16 reg_address, u8 *val);
int (*read_reg_16)(struct device *dev, u16 reg_address, u16 *val);
int (*read_reg_24)(struct device *dev, u16 reg_address, u32 *val);
int (*read_reg_32)(struct device *dev, u16 reg_address, u32 *val);
int (*write_reg_8)(struct device *dev, u16 reg_address, u8 val);
int (*write_reg_16)(struct device *dev, u16 reg_address, u16 val);
int (*write_reg_24)(struct device *dev, u16 reg_address, u32 val);
int (*write_reg_32)(struct device *dev, u16 reg_address, u32 val);
int irq;
struct mutex buf_lock;
u8 tx[ADE7854_MAX_TX] ____cacheline_aligned;
......
......@@ -348,9 +348,6 @@
#define IIO_DEV_ATTR_VPERIOD(_mode, _show, _store, _addr) \
IIO_DEVICE_ATTR(vperiod, _mode, _show, _store, _addr)
#define IIO_DEV_ATTR_CH_OFF(_num, _mode, _show, _store, _addr) \
IIO_DEVICE_ATTR(choff_##_num, _mode, _show, _store, _addr)
/* active energy register, AENERGY, is more than half full */
#define IIO_EVENT_ATTR_AENERGY_HALF_FULL(_evlist, _show, _store, _mask) \
IIO_EVENT_ATTR_SH(aenergy_half_full, _evlist, _show, _store, _mask)
......
......@@ -35,8 +35,6 @@
#define AD2S1210_SET_RES1 0x02
#define AD2S1210_SET_RES0 0x01
#define AD2S1210_SET_ENRESOLUTION (AD2S1210_SET_ENRES1 | \
AD2S1210_SET_ENRES0)
#define AD2S1210_SET_RESOLUTION (AD2S1210_SET_RES1 | AD2S1210_SET_RES0)
#define AD2S1210_REG_POSITION 0x80
......@@ -53,10 +51,6 @@
#define AD2S1210_REG_SOFT_RESET 0xF0
#define AD2S1210_REG_FAULT 0xFF
/* pin SAMPLE, A0, A1, RES0, RES1, is controlled by driver */
#define AD2S1210_SAA 3
#define AD2S1210_PN (AD2S1210_SAA + AD2S1210_RES)
#define AD2S1210_MIN_CLKIN 6144000
#define AD2S1210_MAX_CLKIN 10240000
#define AD2S1210_MIN_EXCIT 2000
......@@ -64,10 +58,6 @@
#define AD2S1210_MIN_FCW 0x4
#define AD2S1210_MAX_FCW 0x50
/* default input clock on serial interface */
#define AD2S1210_DEF_CLKIN 8192000
/* clock period in nano second */
#define AD2S1210_DEF_TCK (1000000000 / AD2S1210_DEF_CLKIN)
#define AD2S1210_DEF_EXCIT 10000
enum ad2s1210_mode {
......@@ -86,7 +76,6 @@ struct ad2s1210_state {
unsigned int fclkin;
unsigned int fexcit;
bool hysteresis;
bool old_data;
u8 resolution;
enum ad2s1210_mode mode;
u8 rx[2] ____cacheline_aligned;
......@@ -117,7 +106,6 @@ static int ad2s1210_config_write(struct ad2s1210_state *st, u8 data)
ret = spi_write(st->sdev, st->tx, 1);
if (ret < 0)
return ret;
st->old_data = true;
return 0;
}
......@@ -139,7 +127,6 @@ static int ad2s1210_config_read(struct ad2s1210_state *st,
ret = spi_sync_transfer(st->sdev, &xfer, 1);
if (ret < 0)
return ret;
st->old_data = true;
return st->rx[1];
}
......@@ -165,9 +152,10 @@ int ad2s1210_update_frequency_control_word(struct ad2s1210_state *st)
static unsigned char ad2s1210_read_resolution_pin(struct ad2s1210_state *st)
{
return ad2s1210_resolution_value[
(gpio_get_value(st->pdata->res[0]) << 1) |
gpio_get_value(st->pdata->res[1])];
int resolution = (gpio_get_value(st->pdata->res[0]) << 1) |
gpio_get_value(st->pdata->res[1]);
return ad2s1210_resolution_value[resolution];
}
static const int ad2s1210_res_pins[4][2] = {
......
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