Commit 8b425aa1 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

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

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

Jonathan writes:

First found of IIO fixes for the 3.15 cycle.

* Fix the platform data support for the at91 adc driver.
* A couple of related follow up patches get the support working again
  for at91sam9260 and at91sam9g45 as the earlier patch results in a device
  name change.
* A default timer value in the at91 adc driver was bonkers.  Make it sane.
* Fix incorrect reporting of the integration time for the cm32181 light sensor
* Fix a missing break in the ad2s1200 driver which would have give a false
  error return.
* Make sure buffer scan mask queries from userspace return 0/1 rather than
  a fairly random value depending on their implementation of test_bit
* Fix leak of the i2c client and a null pointer dereference in the cm36651
  driver.
* Fix a build warning on avr32 for the mxs-lradc (not exactly a critical
  combination - but the issue was real).
parents a798c10f e036f71e
...@@ -1296,7 +1296,7 @@ static struct resource adc_resources[] = { ...@@ -1296,7 +1296,7 @@ static struct resource adc_resources[] = {
}; };
static struct platform_device at91_adc_device = { static struct platform_device at91_adc_device = {
.name = "at91_adc", .name = "at91sam9260-adc",
.id = -1, .id = -1,
.dev = { .dev = {
.platform_data = &adc_data, .platform_data = &adc_data,
......
...@@ -1204,7 +1204,7 @@ static struct resource adc_resources[] = { ...@@ -1204,7 +1204,7 @@ static struct resource adc_resources[] = {
}; };
static struct platform_device at91_adc_device = { static struct platform_device at91_adc_device = {
.name = "at91_adc", .name = "at91sam9g45-adc",
.id = -1, .id = -1,
.dev = { .dev = {
.platform_data = &adc_data, .platform_data = &adc_data,
......
...@@ -765,14 +765,17 @@ static int at91_adc_probe_pdata(struct at91_adc_state *st, ...@@ -765,14 +765,17 @@ static int at91_adc_probe_pdata(struct at91_adc_state *st,
if (!pdata) if (!pdata)
return -EINVAL; return -EINVAL;
st->caps = (struct at91_adc_caps *)
platform_get_device_id(pdev)->driver_data;
st->use_external = pdata->use_external_triggers; st->use_external = pdata->use_external_triggers;
st->vref_mv = pdata->vref; st->vref_mv = pdata->vref;
st->channels_mask = pdata->channels_used; st->channels_mask = pdata->channels_used;
st->num_channels = pdata->num_channels; st->num_channels = st->caps->num_channels;
st->startup_time = pdata->startup_time; st->startup_time = pdata->startup_time;
st->trigger_number = pdata->trigger_number; st->trigger_number = pdata->trigger_number;
st->trigger_list = pdata->trigger_list; st->trigger_list = pdata->trigger_list;
st->registers = pdata->registers; st->registers = &st->caps->registers;
return 0; return 0;
} }
...@@ -1004,8 +1007,11 @@ static int at91_adc_probe(struct platform_device *pdev) ...@@ -1004,8 +1007,11 @@ static int at91_adc_probe(struct platform_device *pdev)
* the best converted final value between two channels selection * the best converted final value between two channels selection
* The formula thus is : Sample and Hold Time = (shtim + 1) / ADCClock * The formula thus is : Sample and Hold Time = (shtim + 1) / ADCClock
*/ */
shtim = round_up((st->sample_hold_time * adc_clk_khz / if (st->sample_hold_time > 0)
1000) - 1, 1); shtim = round_up((st->sample_hold_time * adc_clk_khz / 1000)
- 1, 1);
else
shtim = 0;
reg = AT91_ADC_PRESCAL_(prsc) & st->registers->mr_prescal_mask; reg = AT91_ADC_PRESCAL_(prsc) & st->registers->mr_prescal_mask;
reg |= AT91_ADC_STARTUP_(ticks) & st->registers->mr_startup_mask; reg |= AT91_ADC_STARTUP_(ticks) & st->registers->mr_startup_mask;
...@@ -1101,7 +1107,6 @@ static int at91_adc_remove(struct platform_device *pdev) ...@@ -1101,7 +1107,6 @@ static int at91_adc_remove(struct platform_device *pdev)
return 0; return 0;
} }
#ifdef CONFIG_OF
static struct at91_adc_caps at91sam9260_caps = { static struct at91_adc_caps at91sam9260_caps = {
.calc_startup_ticks = calc_startup_ticks_9260, .calc_startup_ticks = calc_startup_ticks_9260,
.num_channels = 4, .num_channels = 4,
...@@ -1154,11 +1159,27 @@ static const struct of_device_id at91_adc_dt_ids[] = { ...@@ -1154,11 +1159,27 @@ static const struct of_device_id at91_adc_dt_ids[] = {
{}, {},
}; };
MODULE_DEVICE_TABLE(of, at91_adc_dt_ids); MODULE_DEVICE_TABLE(of, at91_adc_dt_ids);
#endif
static const struct platform_device_id at91_adc_ids[] = {
{
.name = "at91sam9260-adc",
.driver_data = (unsigned long)&at91sam9260_caps,
}, {
.name = "at91sam9g45-adc",
.driver_data = (unsigned long)&at91sam9g45_caps,
}, {
.name = "at91sam9x5-adc",
.driver_data = (unsigned long)&at91sam9x5_caps,
}, {
/* terminator */
}
};
MODULE_DEVICE_TABLE(platform, at91_adc_ids);
static struct platform_driver at91_adc_driver = { static struct platform_driver at91_adc_driver = {
.probe = at91_adc_probe, .probe = at91_adc_probe,
.remove = at91_adc_remove, .remove = at91_adc_remove,
.id_table = at91_adc_ids,
.driver = { .driver = {
.name = DRIVER_NAME, .name = DRIVER_NAME,
.of_match_table = of_match_ptr(at91_adc_dt_ids), .of_match_table = of_match_ptr(at91_adc_dt_ids),
......
...@@ -165,7 +165,8 @@ static ssize_t iio_scan_el_show(struct device *dev, ...@@ -165,7 +165,8 @@ static ssize_t iio_scan_el_show(struct device *dev,
int ret; int ret;
struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct iio_dev *indio_dev = dev_to_iio_dev(dev);
ret = test_bit(to_iio_dev_attr(attr)->address, /* Ensure ret is 0 or 1. */
ret = !!test_bit(to_iio_dev_attr(attr)->address,
indio_dev->buffer->scan_mask); indio_dev->buffer->scan_mask);
return sprintf(buf, "%d\n", ret); return sprintf(buf, "%d\n", ret);
...@@ -862,7 +863,8 @@ int iio_scan_mask_query(struct iio_dev *indio_dev, ...@@ -862,7 +863,8 @@ int iio_scan_mask_query(struct iio_dev *indio_dev,
if (!buffer->scan_mask) if (!buffer->scan_mask)
return 0; return 0;
return test_bit(bit, buffer->scan_mask); /* Ensure return value is 0 or 1. */
return !!test_bit(bit, buffer->scan_mask);
}; };
EXPORT_SYMBOL_GPL(iio_scan_mask_query); EXPORT_SYMBOL_GPL(iio_scan_mask_query);
......
...@@ -221,6 +221,7 @@ static int cm32181_read_raw(struct iio_dev *indio_dev, ...@@ -221,6 +221,7 @@ static int cm32181_read_raw(struct iio_dev *indio_dev,
*val = cm32181->calibscale; *val = cm32181->calibscale;
return IIO_VAL_INT; return IIO_VAL_INT;
case IIO_CHAN_INFO_INT_TIME: case IIO_CHAN_INFO_INT_TIME:
*val = 0;
ret = cm32181_read_als_it(cm32181, val2); ret = cm32181_read_als_it(cm32181, val2);
return ret; return ret;
} }
......
...@@ -652,7 +652,19 @@ static int cm36651_probe(struct i2c_client *client, ...@@ -652,7 +652,19 @@ static int cm36651_probe(struct i2c_client *client,
cm36651->client = client; cm36651->client = client;
cm36651->ps_client = i2c_new_dummy(client->adapter, cm36651->ps_client = i2c_new_dummy(client->adapter,
CM36651_I2C_ADDR_PS); CM36651_I2C_ADDR_PS);
if (!cm36651->ps_client) {
dev_err(&client->dev, "%s: new i2c device failed\n", __func__);
ret = -ENODEV;
goto error_disable_reg;
}
cm36651->ara_client = i2c_new_dummy(client->adapter, CM36651_ARA); cm36651->ara_client = i2c_new_dummy(client->adapter, CM36651_ARA);
if (!cm36651->ara_client) {
dev_err(&client->dev, "%s: new i2c device failed\n", __func__);
ret = -ENODEV;
goto error_i2c_unregister_ps;
}
mutex_init(&cm36651->lock); mutex_init(&cm36651->lock);
indio_dev->dev.parent = &client->dev; indio_dev->dev.parent = &client->dev;
indio_dev->channels = cm36651_channels; indio_dev->channels = cm36651_channels;
...@@ -664,7 +676,7 @@ static int cm36651_probe(struct i2c_client *client, ...@@ -664,7 +676,7 @@ static int cm36651_probe(struct i2c_client *client,
ret = cm36651_setup_reg(cm36651); ret = cm36651_setup_reg(cm36651);
if (ret) { if (ret) {
dev_err(&client->dev, "%s: register setup failed\n", __func__); dev_err(&client->dev, "%s: register setup failed\n", __func__);
goto error_disable_reg; goto error_i2c_unregister_ara;
} }
ret = request_threaded_irq(client->irq, NULL, cm36651_irq_handler, ret = request_threaded_irq(client->irq, NULL, cm36651_irq_handler,
...@@ -672,7 +684,7 @@ static int cm36651_probe(struct i2c_client *client, ...@@ -672,7 +684,7 @@ static int cm36651_probe(struct i2c_client *client,
"cm36651", indio_dev); "cm36651", indio_dev);
if (ret) { if (ret) {
dev_err(&client->dev, "%s: request irq failed\n", __func__); dev_err(&client->dev, "%s: request irq failed\n", __func__);
goto error_disable_reg; goto error_i2c_unregister_ara;
} }
ret = iio_device_register(indio_dev); ret = iio_device_register(indio_dev);
...@@ -685,6 +697,10 @@ static int cm36651_probe(struct i2c_client *client, ...@@ -685,6 +697,10 @@ static int cm36651_probe(struct i2c_client *client,
error_free_irq: error_free_irq:
free_irq(client->irq, indio_dev); free_irq(client->irq, indio_dev);
error_i2c_unregister_ara:
i2c_unregister_device(cm36651->ara_client);
error_i2c_unregister_ps:
i2c_unregister_device(cm36651->ps_client);
error_disable_reg: error_disable_reg:
regulator_disable(cm36651->vled_reg); regulator_disable(cm36651->vled_reg);
return ret; return ret;
...@@ -698,6 +714,8 @@ static int cm36651_remove(struct i2c_client *client) ...@@ -698,6 +714,8 @@ static int cm36651_remove(struct i2c_client *client)
iio_device_unregister(indio_dev); iio_device_unregister(indio_dev);
regulator_disable(cm36651->vled_reg); regulator_disable(cm36651->vled_reg);
free_irq(client->irq, indio_dev); free_irq(client->irq, indio_dev);
i2c_unregister_device(cm36651->ps_client);
i2c_unregister_device(cm36651->ara_client);
return 0; return 0;
} }
......
...@@ -1526,7 +1526,7 @@ static int mxs_lradc_probe(struct platform_device *pdev) ...@@ -1526,7 +1526,7 @@ static int mxs_lradc_probe(struct platform_device *pdev)
struct resource *iores; struct resource *iores;
int ret = 0, touch_ret; int ret = 0, touch_ret;
int i, s; int i, s;
unsigned int scale_uv; uint64_t scale_uv;
/* Allocate the IIO device. */ /* Allocate the IIO device. */
iio = devm_iio_device_alloc(dev, sizeof(*lradc)); iio = devm_iio_device_alloc(dev, sizeof(*lradc));
......
...@@ -70,6 +70,7 @@ static int ad2s1200_read_raw(struct iio_dev *indio_dev, ...@@ -70,6 +70,7 @@ static int ad2s1200_read_raw(struct iio_dev *indio_dev,
vel = (((s16)(st->rx[0])) << 4) | ((st->rx[1] & 0xF0) >> 4); vel = (((s16)(st->rx[0])) << 4) | ((st->rx[1] & 0xF0) >> 4);
vel = (vel << 4) >> 4; vel = (vel << 4) >> 4;
*val = vel; *val = vel;
break;
default: default:
mutex_unlock(&st->lock); mutex_unlock(&st->lock);
return -EINVAL; return -EINVAL;
......
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