Commit 5a4733df authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

Merge tag 'iio-fixes-for-4.12a' of...

Merge tag 'iio-fixes-for-4.12a' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-linus

Jonathan writes:

First set of IIO fixes in the 4.12 cycle.

Matt finally set up the lightning storm he needed to test the as3935.

* core
  - Fix a null pointer deference in iio_trigger_write_current when changing
  from a non existent trigger to another non existent trigger.
* a3935
  - Recalibrate the RCO after resume.
  - Fix interrupt mask so that we actually get some interrupts.
  - Use iio_trigger_poll_chained as we aren't in interrupt context.
* am335x
  - Fix wrong allocation size provided for private data to iio_device_alloc.
* bcm_iproc
  - Swapped primary and secondary isr handlers.
* ltr501
  - Fix swapped als/ps register fields when enabling interrupts
* max9611
  - Wrong scale factor for the shunt_resistor attribute.
* sun4-gpadc
  - Module autoloading fixes by adding the device table declarations.
  - Fix parent device being used in devm functions.
parents 08332893 82237f26
...@@ -143,7 +143,7 @@ static void iproc_adc_reg_dump(struct iio_dev *indio_dev) ...@@ -143,7 +143,7 @@ static void iproc_adc_reg_dump(struct iio_dev *indio_dev)
iproc_adc_dbg_reg(dev, adc_priv, IPROC_SOFT_BYPASS_DATA); iproc_adc_dbg_reg(dev, adc_priv, IPROC_SOFT_BYPASS_DATA);
} }
static irqreturn_t iproc_adc_interrupt_handler(int irq, void *data) static irqreturn_t iproc_adc_interrupt_thread(int irq, void *data)
{ {
u32 channel_intr_status; u32 channel_intr_status;
u32 intr_status; u32 intr_status;
...@@ -167,7 +167,7 @@ static irqreturn_t iproc_adc_interrupt_handler(int irq, void *data) ...@@ -167,7 +167,7 @@ static irqreturn_t iproc_adc_interrupt_handler(int irq, void *data)
return IRQ_NONE; return IRQ_NONE;
} }
static irqreturn_t iproc_adc_interrupt_thread(int irq, void *data) static irqreturn_t iproc_adc_interrupt_handler(int irq, void *data)
{ {
irqreturn_t retval = IRQ_NONE; irqreturn_t retval = IRQ_NONE;
struct iproc_adc_priv *adc_priv; struct iproc_adc_priv *adc_priv;
...@@ -181,7 +181,7 @@ static irqreturn_t iproc_adc_interrupt_thread(int irq, void *data) ...@@ -181,7 +181,7 @@ static irqreturn_t iproc_adc_interrupt_thread(int irq, void *data)
adc_priv = iio_priv(indio_dev); adc_priv = iio_priv(indio_dev);
regmap_read(adc_priv->regmap, IPROC_INTERRUPT_STATUS, &intr_status); regmap_read(adc_priv->regmap, IPROC_INTERRUPT_STATUS, &intr_status);
dev_dbg(&indio_dev->dev, "iproc_adc_interrupt_thread(),INTRPT_STS:%x\n", dev_dbg(&indio_dev->dev, "iproc_adc_interrupt_handler(),INTRPT_STS:%x\n",
intr_status); intr_status);
intr_channels = (intr_status & IPROC_ADC_INTR_MASK) >> IPROC_ADC_INTR; intr_channels = (intr_status & IPROC_ADC_INTR_MASK) >> IPROC_ADC_INTR;
...@@ -566,8 +566,8 @@ static int iproc_adc_probe(struct platform_device *pdev) ...@@ -566,8 +566,8 @@ static int iproc_adc_probe(struct platform_device *pdev)
} }
ret = devm_request_threaded_irq(&pdev->dev, adc_priv->irqno, ret = devm_request_threaded_irq(&pdev->dev, adc_priv->irqno,
iproc_adc_interrupt_thread,
iproc_adc_interrupt_handler, iproc_adc_interrupt_handler,
iproc_adc_interrupt_thread,
IRQF_SHARED, "iproc-adc", indio_dev); IRQF_SHARED, "iproc-adc", indio_dev);
if (ret) { if (ret) {
dev_err(&pdev->dev, "request_irq error %d\n", ret); dev_err(&pdev->dev, "request_irq error %d\n", ret);
......
...@@ -438,10 +438,10 @@ static ssize_t max9611_shunt_resistor_show(struct device *dev, ...@@ -438,10 +438,10 @@ static ssize_t max9611_shunt_resistor_show(struct device *dev,
struct max9611_dev *max9611 = iio_priv(dev_to_iio_dev(dev)); struct max9611_dev *max9611 = iio_priv(dev_to_iio_dev(dev));
unsigned int i, r; unsigned int i, r;
i = max9611->shunt_resistor_uohm / 1000; i = max9611->shunt_resistor_uohm / 1000000;
r = max9611->shunt_resistor_uohm % 1000; r = max9611->shunt_resistor_uohm % 1000000;
return sprintf(buf, "%u.%03u\n", i, r); return sprintf(buf, "%u.%06u\n", i, r);
} }
static IIO_DEVICE_ATTR(in_power_shunt_resistor, 0444, static IIO_DEVICE_ATTR(in_power_shunt_resistor, 0444,
...@@ -536,8 +536,8 @@ static int max9611_probe(struct i2c_client *client, ...@@ -536,8 +536,8 @@ static int max9611_probe(struct i2c_client *client,
int ret; int ret;
indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*max9611)); indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*max9611));
if (IS_ERR(indio_dev)) if (!indio_dev)
return PTR_ERR(indio_dev); return -ENOMEM;
i2c_set_clientdata(client, indio_dev); i2c_set_clientdata(client, indio_dev);
......
...@@ -105,6 +105,8 @@ struct sun4i_gpadc_iio { ...@@ -105,6 +105,8 @@ struct sun4i_gpadc_iio {
bool no_irq; bool no_irq;
/* prevents concurrent reads of temperature and ADC */ /* prevents concurrent reads of temperature and ADC */
struct mutex mutex; struct mutex mutex;
struct thermal_zone_device *tzd;
struct device *sensor_device;
}; };
#define SUN4I_GPADC_ADC_CHANNEL(_channel, _name) { \ #define SUN4I_GPADC_ADC_CHANNEL(_channel, _name) { \
...@@ -502,7 +504,6 @@ static int sun4i_gpadc_probe_dt(struct platform_device *pdev, ...@@ -502,7 +504,6 @@ static int sun4i_gpadc_probe_dt(struct platform_device *pdev,
{ {
struct sun4i_gpadc_iio *info = iio_priv(indio_dev); struct sun4i_gpadc_iio *info = iio_priv(indio_dev);
const struct of_device_id *of_dev; const struct of_device_id *of_dev;
struct thermal_zone_device *tzd;
struct resource *mem; struct resource *mem;
void __iomem *base; void __iomem *base;
int ret; int ret;
...@@ -532,13 +533,14 @@ static int sun4i_gpadc_probe_dt(struct platform_device *pdev, ...@@ -532,13 +533,14 @@ static int sun4i_gpadc_probe_dt(struct platform_device *pdev,
if (!IS_ENABLED(CONFIG_THERMAL_OF)) if (!IS_ENABLED(CONFIG_THERMAL_OF))
return 0; return 0;
tzd = devm_thermal_zone_of_sensor_register(&pdev->dev, 0, info, info->sensor_device = &pdev->dev;
&sun4i_ts_tz_ops); info->tzd = thermal_zone_of_sensor_register(info->sensor_device, 0,
if (IS_ERR(tzd)) info, &sun4i_ts_tz_ops);
if (IS_ERR(info->tzd))
dev_err(&pdev->dev, "could not register thermal sensor: %ld\n", dev_err(&pdev->dev, "could not register thermal sensor: %ld\n",
PTR_ERR(tzd)); PTR_ERR(info->tzd));
return PTR_ERR_OR_ZERO(tzd); return PTR_ERR_OR_ZERO(info->tzd);
} }
static int sun4i_gpadc_probe_mfd(struct platform_device *pdev, static int sun4i_gpadc_probe_mfd(struct platform_device *pdev,
...@@ -584,15 +586,15 @@ static int sun4i_gpadc_probe_mfd(struct platform_device *pdev, ...@@ -584,15 +586,15 @@ static int sun4i_gpadc_probe_mfd(struct platform_device *pdev,
* of_node, and the device from this driver as third argument to * of_node, and the device from this driver as third argument to
* return the temperature. * return the temperature.
*/ */
struct thermal_zone_device *tzd; info->sensor_device = pdev->dev.parent;
tzd = devm_thermal_zone_of_sensor_register(pdev->dev.parent, 0, info->tzd = thermal_zone_of_sensor_register(info->sensor_device,
info, 0, info,
&sun4i_ts_tz_ops); &sun4i_ts_tz_ops);
if (IS_ERR(tzd)) { if (IS_ERR(info->tzd)) {
dev_err(&pdev->dev, dev_err(&pdev->dev,
"could not register thermal sensor: %ld\n", "could not register thermal sensor: %ld\n",
PTR_ERR(tzd)); PTR_ERR(info->tzd));
return PTR_ERR(tzd); return PTR_ERR(info->tzd);
} }
} else { } else {
indio_dev->num_channels = indio_dev->num_channels =
...@@ -688,7 +690,13 @@ static int sun4i_gpadc_remove(struct platform_device *pdev) ...@@ -688,7 +690,13 @@ static int sun4i_gpadc_remove(struct platform_device *pdev)
pm_runtime_put(&pdev->dev); pm_runtime_put(&pdev->dev);
pm_runtime_disable(&pdev->dev); pm_runtime_disable(&pdev->dev);
if (!info->no_irq && IS_ENABLED(CONFIG_THERMAL_OF))
if (!IS_ENABLED(CONFIG_THERMAL_OF))
return 0;
thermal_zone_of_sensor_unregister(info->sensor_device, info->tzd);
if (!info->no_irq)
iio_map_array_unregister(indio_dev); iio_map_array_unregister(indio_dev);
return 0; return 0;
...@@ -700,6 +708,7 @@ static const struct platform_device_id sun4i_gpadc_id[] = { ...@@ -700,6 +708,7 @@ static const struct platform_device_id sun4i_gpadc_id[] = {
{ "sun6i-a31-gpadc-iio", (kernel_ulong_t)&sun6i_gpadc_data }, { "sun6i-a31-gpadc-iio", (kernel_ulong_t)&sun6i_gpadc_data },
{ /* sentinel */ }, { /* sentinel */ },
}; };
MODULE_DEVICE_TABLE(platform, sun4i_gpadc_id);
static struct platform_driver sun4i_gpadc_driver = { static struct platform_driver sun4i_gpadc_driver = {
.driver = { .driver = {
...@@ -711,6 +720,7 @@ static struct platform_driver sun4i_gpadc_driver = { ...@@ -711,6 +720,7 @@ static struct platform_driver sun4i_gpadc_driver = {
.probe = sun4i_gpadc_probe, .probe = sun4i_gpadc_probe,
.remove = sun4i_gpadc_remove, .remove = sun4i_gpadc_remove,
}; };
MODULE_DEVICE_TABLE(of, sun4i_gpadc_of_id);
module_platform_driver(sun4i_gpadc_driver); module_platform_driver(sun4i_gpadc_driver);
......
...@@ -614,7 +614,7 @@ static int tiadc_probe(struct platform_device *pdev) ...@@ -614,7 +614,7 @@ static int tiadc_probe(struct platform_device *pdev)
return -EINVAL; return -EINVAL;
} }
indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*indio_dev)); indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*adc_dev));
if (indio_dev == NULL) { if (indio_dev == NULL) {
dev_err(&pdev->dev, "failed to allocate iio device\n"); dev_err(&pdev->dev, "failed to allocate iio device\n");
return -ENOMEM; return -ENOMEM;
......
...@@ -451,6 +451,7 @@ static ssize_t iio_trigger_write_current(struct device *dev, ...@@ -451,6 +451,7 @@ static ssize_t iio_trigger_write_current(struct device *dev,
return len; return len;
out_trigger_put: out_trigger_put:
if (trig)
iio_trigger_put(trig); iio_trigger_put(trig);
return ret; return ret;
} }
......
...@@ -74,9 +74,9 @@ static const int int_time_mapping[] = {100000, 50000, 200000, 400000}; ...@@ -74,9 +74,9 @@ static const int int_time_mapping[] = {100000, 50000, 200000, 400000};
static const struct reg_field reg_field_it = static const struct reg_field reg_field_it =
REG_FIELD(LTR501_ALS_MEAS_RATE, 3, 4); REG_FIELD(LTR501_ALS_MEAS_RATE, 3, 4);
static const struct reg_field reg_field_als_intr = static const struct reg_field reg_field_als_intr =
REG_FIELD(LTR501_INTR, 0, 0);
static const struct reg_field reg_field_ps_intr =
REG_FIELD(LTR501_INTR, 1, 1); REG_FIELD(LTR501_INTR, 1, 1);
static const struct reg_field reg_field_ps_intr =
REG_FIELD(LTR501_INTR, 0, 0);
static const struct reg_field reg_field_als_rate = static const struct reg_field reg_field_als_rate =
REG_FIELD(LTR501_ALS_MEAS_RATE, 0, 2); REG_FIELD(LTR501_ALS_MEAS_RATE, 0, 2);
static const struct reg_field reg_field_ps_rate = static const struct reg_field reg_field_ps_rate =
......
...@@ -40,9 +40,9 @@ ...@@ -40,9 +40,9 @@
#define AS3935_AFE_PWR_BIT BIT(0) #define AS3935_AFE_PWR_BIT BIT(0)
#define AS3935_INT 0x03 #define AS3935_INT 0x03
#define AS3935_INT_MASK 0x07 #define AS3935_INT_MASK 0x0f
#define AS3935_EVENT_INT BIT(3) #define AS3935_EVENT_INT BIT(3)
#define AS3935_NOISE_INT BIT(1) #define AS3935_NOISE_INT BIT(0)
#define AS3935_DATA 0x07 #define AS3935_DATA 0x07
#define AS3935_DATA_MASK 0x3F #define AS3935_DATA_MASK 0x3F
...@@ -215,7 +215,7 @@ static irqreturn_t as3935_trigger_handler(int irq, void *private) ...@@ -215,7 +215,7 @@ static irqreturn_t as3935_trigger_handler(int irq, void *private)
st->buffer[0] = val & AS3935_DATA_MASK; st->buffer[0] = val & AS3935_DATA_MASK;
iio_push_to_buffers_with_timestamp(indio_dev, &st->buffer, iio_push_to_buffers_with_timestamp(indio_dev, &st->buffer,
pf->timestamp); iio_get_time_ns(indio_dev));
err_read: err_read:
iio_trigger_notify_done(indio_dev->trig); iio_trigger_notify_done(indio_dev->trig);
...@@ -244,7 +244,7 @@ static void as3935_event_work(struct work_struct *work) ...@@ -244,7 +244,7 @@ static void as3935_event_work(struct work_struct *work)
switch (val) { switch (val) {
case AS3935_EVENT_INT: case AS3935_EVENT_INT:
iio_trigger_poll(st->trig); iio_trigger_poll_chained(st->trig);
break; break;
case AS3935_NOISE_INT: case AS3935_NOISE_INT:
dev_warn(&st->spi->dev, "noise level is too high\n"); dev_warn(&st->spi->dev, "noise level is too high\n");
...@@ -269,8 +269,6 @@ static irqreturn_t as3935_interrupt_handler(int irq, void *private) ...@@ -269,8 +269,6 @@ static irqreturn_t as3935_interrupt_handler(int irq, void *private)
static void calibrate_as3935(struct as3935_state *st) static void calibrate_as3935(struct as3935_state *st)
{ {
mutex_lock(&st->lock);
/* mask disturber interrupt bit */ /* mask disturber interrupt bit */
as3935_write(st, AS3935_INT, BIT(5)); as3935_write(st, AS3935_INT, BIT(5));
...@@ -280,8 +278,6 @@ static void calibrate_as3935(struct as3935_state *st) ...@@ -280,8 +278,6 @@ static void calibrate_as3935(struct as3935_state *st)
mdelay(2); mdelay(2);
as3935_write(st, AS3935_TUNE_CAP, (st->tune_cap / TUNE_CAP_DIV)); as3935_write(st, AS3935_TUNE_CAP, (st->tune_cap / TUNE_CAP_DIV));
mutex_unlock(&st->lock);
} }
#ifdef CONFIG_PM_SLEEP #ifdef CONFIG_PM_SLEEP
...@@ -318,6 +314,8 @@ static int as3935_resume(struct device *dev) ...@@ -318,6 +314,8 @@ static int as3935_resume(struct device *dev)
val &= ~AS3935_AFE_PWR_BIT; val &= ~AS3935_AFE_PWR_BIT;
ret = as3935_write(st, AS3935_AFE_GAIN, val); ret = as3935_write(st, AS3935_AFE_GAIN, val);
calibrate_as3935(st);
err_resume: err_resume:
mutex_unlock(&st->lock); mutex_unlock(&st->lock);
......
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