提交 d0c15ad7 编写于 作者: L Linus Torvalds

Merge tag 'staging-3.15-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging

Pull staging / IIO driver fixes from Greg KH:
 "Here are some small staging and IIO driver fixes for 3.15-rc3.

  Nothing major at all, just some assorted issues that people have
  reported"

* tag 'staging-3.15-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging:
  staging: comedi: usbdux: bug fix for accessing 'ao_chanlist' in private data
  iio: adc: mxs-lradc: fix warning when buidling on avr32
  iio: cm36651: Fix i2c client leak and possible NULL pointer dereference
  iio: querying buffer scan_mask should return 0/1
  staging:iio:ad2s1200 fix a missing break
  iio: adc: at91_adc: correct default shtim value
  ARM: at91: at91sam9260: change at91_adc name
  ARM: at91: at91sam9g45: change at91_adc name
  iio: cm32181: Fix read integration time function
  iio: adc: at91_adc: Repair broken platform_data support
...@@ -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;
} }
......
...@@ -493,7 +493,7 @@ static void usbduxsub_ao_isoc_irq(struct urb *urb) ...@@ -493,7 +493,7 @@ static void usbduxsub_ao_isoc_irq(struct urb *urb)
/* pointer to the DA */ /* pointer to the DA */
*datap++ = val & 0xff; *datap++ = val & 0xff;
*datap++ = (val >> 8) & 0xff; *datap++ = (val >> 8) & 0xff;
*datap++ = chan; *datap++ = chan << 6;
devpriv->ao_readback[chan] = val; devpriv->ao_readback[chan] = val;
s->async->events |= COMEDI_CB_BLOCK; s->async->events |= COMEDI_CB_BLOCK;
...@@ -1040,11 +1040,8 @@ static int usbdux_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s) ...@@ -1040,11 +1040,8 @@ static int usbdux_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
/* set current channel of the running acquisition to zero */ /* set current channel of the running acquisition to zero */
s->async->cur_chan = 0; s->async->cur_chan = 0;
for (i = 0; i < cmd->chanlist_len; ++i) { for (i = 0; i < cmd->chanlist_len; ++i)
unsigned int chan = CR_CHAN(cmd->chanlist[i]); devpriv->ao_chanlist[i] = CR_CHAN(cmd->chanlist[i]);
devpriv->ao_chanlist[i] = chan << 6;
}
/* we count in steps of 1ms (125us) */ /* we count in steps of 1ms (125us) */
/* 125us mode not used yet */ /* 125us mode not used yet */
......
...@@ -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% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册