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.
 -----BEGIN PGP SIGNATURE-----
 
 iQJFBAABCAAvFiEEbilms4eEBlKRJoGxVIU0mcT0FogFAlkjMIARHGppYzIzQGtl
 cm5lbC5vcmcACgkQVIU0mcT0FojKvA//aDwMkrmHT15IsP6kRWRp8MJ66253YIDK
 ZRwr5pu4TXPX6df3HIV7meSi1mYOTX/UHryGsMIx3iwr69jhTQzSf+frZsYVMkLy
 IsliKjkbUrkzFlPxicpt4aq1w8xqwkpdWzo27Y1xQMf2UOiNtWSSCRsjBgxr7mmg
 Xk5yrvbk4XQ17P/pZrg6NJukSd8XXyJn1Jf9cfBpYfmSwgbRNJZbAmrU3uCtL0li
 HK/akyaJYRHVcuv8GdT4eosOd/mw8EkMPe4v5Uv/4p1JWuHJNtCLhEA4AdrMBheK
 5GrPpviNRD0aQTvTDRqZW9e2CIwS1UTWYPA+gboOhSkErta36+DnVdVJhVquD3t5
 mSifsp2DYC7oMdHtYpihyJClkYm0xNZl/R/cMtroDJzt/nymS9jWgVE4TQEDxpa2
 tLbVqre6L9ZOUd+XXvmEyMoPtRELPfmi87TDdnxinAaSyCcWOEjf0B+cwTMXrcWb
 yJ8P8lTqQN/aBeQviEV0SjXk2GptN6zMaeIge8TPBljFRhae1ECbSGPflPQNzASJ
 qLL5ZV0fTc9ZwKdbAtfDh74dOGU1aRh6UK7ZooTR5HZmoHdyFh2lg/aKtGtVRYG1
 5FAnTSZxgYkRviZhVLnJzpVRepy1Xa3llzt4J46Uyufy6hQUt9qECwR/udrO/52V
 lfu9dzVe6bE=
 =luks
 -----END PGP SIGNATURE-----

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.
This commit is contained in:
Greg Kroah-Hartman 2017-05-22 21:53:09 +02:00
commit 5a4733df7e
7 changed files with 44 additions and 35 deletions

View File

@ -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);
}
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 intr_status;
@ -167,7 +167,7 @@ static irqreturn_t iproc_adc_interrupt_handler(int irq, void *data)
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;
struct iproc_adc_priv *adc_priv;
@ -181,7 +181,7 @@ static irqreturn_t iproc_adc_interrupt_thread(int irq, void *data)
adc_priv = iio_priv(indio_dev);
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_channels = (intr_status & IPROC_ADC_INTR_MASK) >> IPROC_ADC_INTR;
@ -566,8 +566,8 @@ static int iproc_adc_probe(struct platform_device *pdev)
}
ret = devm_request_threaded_irq(&pdev->dev, adc_priv->irqno,
iproc_adc_interrupt_thread,
iproc_adc_interrupt_handler,
iproc_adc_interrupt_thread,
IRQF_SHARED, "iproc-adc", indio_dev);
if (ret) {
dev_err(&pdev->dev, "request_irq error %d\n", ret);

View File

@ -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));
unsigned int i, r;
i = max9611->shunt_resistor_uohm / 1000;
r = max9611->shunt_resistor_uohm % 1000;
i = max9611->shunt_resistor_uohm / 1000000;
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,
@ -536,8 +536,8 @@ static int max9611_probe(struct i2c_client *client,
int ret;
indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*max9611));
if (IS_ERR(indio_dev))
return PTR_ERR(indio_dev);
if (!indio_dev)
return -ENOMEM;
i2c_set_clientdata(client, indio_dev);

View File

@ -105,6 +105,8 @@ struct sun4i_gpadc_iio {
bool no_irq;
/* prevents concurrent reads of temperature and ADC */
struct mutex mutex;
struct thermal_zone_device *tzd;
struct device *sensor_device;
};
#define SUN4I_GPADC_ADC_CHANNEL(_channel, _name) { \
@ -502,7 +504,6 @@ static int sun4i_gpadc_probe_dt(struct platform_device *pdev,
{
struct sun4i_gpadc_iio *info = iio_priv(indio_dev);
const struct of_device_id *of_dev;
struct thermal_zone_device *tzd;
struct resource *mem;
void __iomem *base;
int ret;
@ -532,13 +533,14 @@ static int sun4i_gpadc_probe_dt(struct platform_device *pdev,
if (!IS_ENABLED(CONFIG_THERMAL_OF))
return 0;
tzd = devm_thermal_zone_of_sensor_register(&pdev->dev, 0, info,
&sun4i_ts_tz_ops);
if (IS_ERR(tzd))
info->sensor_device = &pdev->dev;
info->tzd = thermal_zone_of_sensor_register(info->sensor_device, 0,
info, &sun4i_ts_tz_ops);
if (IS_ERR(info->tzd))
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,
@ -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
* return the temperature.
*/
struct thermal_zone_device *tzd;
tzd = devm_thermal_zone_of_sensor_register(pdev->dev.parent, 0,
info,
&sun4i_ts_tz_ops);
if (IS_ERR(tzd)) {
info->sensor_device = pdev->dev.parent;
info->tzd = thermal_zone_of_sensor_register(info->sensor_device,
0, info,
&sun4i_ts_tz_ops);
if (IS_ERR(info->tzd)) {
dev_err(&pdev->dev,
"could not register thermal sensor: %ld\n",
PTR_ERR(tzd));
return PTR_ERR(tzd);
PTR_ERR(info->tzd));
return PTR_ERR(info->tzd);
}
} else {
indio_dev->num_channels =
@ -688,7 +690,13 @@ static int sun4i_gpadc_remove(struct platform_device *pdev)
pm_runtime_put(&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);
return 0;
@ -700,6 +708,7 @@ static const struct platform_device_id sun4i_gpadc_id[] = {
{ "sun6i-a31-gpadc-iio", (kernel_ulong_t)&sun6i_gpadc_data },
{ /* sentinel */ },
};
MODULE_DEVICE_TABLE(platform, sun4i_gpadc_id);
static struct platform_driver sun4i_gpadc_driver = {
.driver = {
@ -711,6 +720,7 @@ static struct platform_driver sun4i_gpadc_driver = {
.probe = sun4i_gpadc_probe,
.remove = sun4i_gpadc_remove,
};
MODULE_DEVICE_TABLE(of, sun4i_gpadc_of_id);
module_platform_driver(sun4i_gpadc_driver);

View File

@ -614,7 +614,7 @@ static int tiadc_probe(struct platform_device *pdev)
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) {
dev_err(&pdev->dev, "failed to allocate iio device\n");
return -ENOMEM;

View File

@ -451,7 +451,8 @@ static ssize_t iio_trigger_write_current(struct device *dev,
return len;
out_trigger_put:
iio_trigger_put(trig);
if (trig)
iio_trigger_put(trig);
return ret;
}

View File

@ -74,9 +74,9 @@ static const int int_time_mapping[] = {100000, 50000, 200000, 400000};
static const struct reg_field reg_field_it =
REG_FIELD(LTR501_ALS_MEAS_RATE, 3, 4);
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);
static const struct reg_field reg_field_ps_intr =
REG_FIELD(LTR501_INTR, 0, 0);
static const struct reg_field reg_field_als_rate =
REG_FIELD(LTR501_ALS_MEAS_RATE, 0, 2);
static const struct reg_field reg_field_ps_rate =

View File

@ -40,9 +40,9 @@
#define AS3935_AFE_PWR_BIT BIT(0)
#define AS3935_INT 0x03
#define AS3935_INT_MASK 0x07
#define AS3935_INT_MASK 0x0f
#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_MASK 0x3F
@ -215,7 +215,7 @@ static irqreturn_t as3935_trigger_handler(int irq, void *private)
st->buffer[0] = val & AS3935_DATA_MASK;
iio_push_to_buffers_with_timestamp(indio_dev, &st->buffer,
pf->timestamp);
iio_get_time_ns(indio_dev));
err_read:
iio_trigger_notify_done(indio_dev->trig);
@ -244,7 +244,7 @@ static void as3935_event_work(struct work_struct *work)
switch (val) {
case AS3935_EVENT_INT:
iio_trigger_poll(st->trig);
iio_trigger_poll_chained(st->trig);
break;
case AS3935_NOISE_INT:
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)
static void calibrate_as3935(struct as3935_state *st)
{
mutex_lock(&st->lock);
/* mask disturber interrupt bit */
as3935_write(st, AS3935_INT, BIT(5));
@ -280,8 +278,6 @@ static void calibrate_as3935(struct as3935_state *st)
mdelay(2);
as3935_write(st, AS3935_TUNE_CAP, (st->tune_cap / TUNE_CAP_DIV));
mutex_unlock(&st->lock);
}
#ifdef CONFIG_PM_SLEEP
@ -318,6 +314,8 @@ static int as3935_resume(struct device *dev)
val &= ~AS3935_AFE_PWR_BIT;
ret = as3935_write(st, AS3935_AFE_GAIN, val);
calibrate_as3935(st);
err_resume:
mutex_unlock(&st->lock);