First round of IIO fixes for the 3.17 cycle.
* Fix an overwritten error return that can prevent deferred probing when using of_iio_channel_get_by_name * A series that deals with an incorrect reference count when the default trigger is set within the main probe routine for a driver. Can result in a double free if the trigger is changed. * Fix a buglet with xilinx-xadc concerning setup of the address for an aux channel. * At91 adc driver could sometimes get a touchscreen reading rather than the intended adc channel. This is fixed by using the channel data register instead. * Fix some ST magnetometer gain values that differ in production parts from the prerelease ones used for driver development. -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAABAgAGBQJUFfUOAAoJEFSFNJnE9BaIcyoQAKYclsqsYvWfNmxaGncSCwjZ hPh/YrlOv/Gto9yvLRbLHlvP966STHvi6T0g0dXGxAMy5q2vvYzP9T9iHexUIeW/ l/UJ0lGTz7YNl0/RwoLD9l8CrNscKPh6ZDsR+Y73mlJzsl4oTsGYlv00PKbleSLk 8qqLqagTa1ToiujOE2j9H+rvea3G9nzCvPYQbJR+tDQ/LqBSquyhpF+/oumwPTCP EVajxFzh/MUQdRtPd27IVP1g/lbssvhCburrf/KVbfskwTcV0Mhpj4joU18dMjy8 VvRLRJbjqxaKPYux97WEFhDh5eQbS5GZ8NX4xZgDfvn8RBFG0P4T7jNXH1p0QGoN /tbDJcTeDfJYZoD/p2ZZWjr0CnR5t12kY6EVPRje79S3rkaS0NN0B7A4ywRhoUnC r5e7R+zqtM4QibkcZSw71mgh83cWt9mAn3hgUn/riqkjcp4hyZxVR3RhrUZKpl/J EBFNVGXJXoLBgtg4n+LM+2MeESVutVEytlv/ORMCrphI7+H1d2GP0nrITpClDBVZ tkikHJoRrf21ceJDxY+b3bTemrbH/9METu9AyzYjoHyNOvqoZQcSoB7gOxBcmCHm X/uJLEzJHJrz6XlBQKqxt11li6rmczaPta3AN78GArN1/cmaCPNDiAKq4edq+gAn uvn5V8GTfs/XRJk/kVrl =MS7C -----END PGP SIGNATURE----- Merge tag 'iio-fixes-3.17a' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-linus Jonathan writes: First round of IIO fixes for the 3.17 cycle. * Fix an overwritten error return that can prevent deferred probing when using of_iio_channel_get_by_name * A series that deals with an incorrect reference count when the default trigger is set within the main probe routine for a driver. Can result in a double free if the trigger is changed. * Fix a buglet with xilinx-xadc concerning setup of the address for an aux channel. * At91 adc driver could sometimes get a touchscreen reading rather than the intended adc channel. This is fixed by using the channel data register instead. * Fix some ST magnetometer gain values that differ in production parts from the prerelease ones used for driver development.
This commit is contained in:
Коммит
922b83b4aa
|
@ -571,7 +571,7 @@ static int bma180_probe(struct i2c_client *client,
|
||||||
trig->ops = &bma180_trigger_ops;
|
trig->ops = &bma180_trigger_ops;
|
||||||
iio_trigger_set_drvdata(trig, indio_dev);
|
iio_trigger_set_drvdata(trig, indio_dev);
|
||||||
data->trig = trig;
|
data->trig = trig;
|
||||||
indio_dev->trig = trig;
|
indio_dev->trig = iio_trigger_get(trig);
|
||||||
|
|
||||||
ret = iio_trigger_register(trig);
|
ret = iio_trigger_register(trig);
|
||||||
if (ret)
|
if (ret)
|
||||||
|
|
|
@ -472,7 +472,7 @@ static int ad_sd_probe_trigger(struct iio_dev *indio_dev)
|
||||||
goto error_free_irq;
|
goto error_free_irq;
|
||||||
|
|
||||||
/* select default trigger */
|
/* select default trigger */
|
||||||
indio_dev->trig = sigma_delta->trig;
|
indio_dev->trig = iio_trigger_get(sigma_delta->trig);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
|
|
@ -196,6 +196,7 @@ struct at91_adc_state {
|
||||||
bool done;
|
bool done;
|
||||||
int irq;
|
int irq;
|
||||||
u16 last_value;
|
u16 last_value;
|
||||||
|
int chnb;
|
||||||
struct mutex lock;
|
struct mutex lock;
|
||||||
u8 num_channels;
|
u8 num_channels;
|
||||||
void __iomem *reg_base;
|
void __iomem *reg_base;
|
||||||
|
@ -274,7 +275,7 @@ void handle_adc_eoc_trigger(int irq, struct iio_dev *idev)
|
||||||
disable_irq_nosync(irq);
|
disable_irq_nosync(irq);
|
||||||
iio_trigger_poll(idev->trig);
|
iio_trigger_poll(idev->trig);
|
||||||
} else {
|
} else {
|
||||||
st->last_value = at91_adc_readl(st, AT91_ADC_LCDR);
|
st->last_value = at91_adc_readl(st, AT91_ADC_CHAN(st, st->chnb));
|
||||||
st->done = true;
|
st->done = true;
|
||||||
wake_up_interruptible(&st->wq_data_avail);
|
wake_up_interruptible(&st->wq_data_avail);
|
||||||
}
|
}
|
||||||
|
@ -351,7 +352,7 @@ static irqreturn_t at91_adc_rl_interrupt(int irq, void *private)
|
||||||
unsigned int reg;
|
unsigned int reg;
|
||||||
|
|
||||||
status &= at91_adc_readl(st, AT91_ADC_IMR);
|
status &= at91_adc_readl(st, AT91_ADC_IMR);
|
||||||
if (status & st->registers->drdy_mask)
|
if (status & GENMASK(st->num_channels - 1, 0))
|
||||||
handle_adc_eoc_trigger(irq, idev);
|
handle_adc_eoc_trigger(irq, idev);
|
||||||
|
|
||||||
if (status & AT91RL_ADC_IER_PEN) {
|
if (status & AT91RL_ADC_IER_PEN) {
|
||||||
|
@ -418,7 +419,7 @@ static irqreturn_t at91_adc_9x5_interrupt(int irq, void *private)
|
||||||
AT91_ADC_IER_YRDY |
|
AT91_ADC_IER_YRDY |
|
||||||
AT91_ADC_IER_PRDY;
|
AT91_ADC_IER_PRDY;
|
||||||
|
|
||||||
if (status & st->registers->drdy_mask)
|
if (status & GENMASK(st->num_channels - 1, 0))
|
||||||
handle_adc_eoc_trigger(irq, idev);
|
handle_adc_eoc_trigger(irq, idev);
|
||||||
|
|
||||||
if (status & AT91_ADC_IER_PEN) {
|
if (status & AT91_ADC_IER_PEN) {
|
||||||
|
@ -689,9 +690,10 @@ static int at91_adc_read_raw(struct iio_dev *idev,
|
||||||
case IIO_CHAN_INFO_RAW:
|
case IIO_CHAN_INFO_RAW:
|
||||||
mutex_lock(&st->lock);
|
mutex_lock(&st->lock);
|
||||||
|
|
||||||
|
st->chnb = chan->channel;
|
||||||
at91_adc_writel(st, AT91_ADC_CHER,
|
at91_adc_writel(st, AT91_ADC_CHER,
|
||||||
AT91_ADC_CH(chan->channel));
|
AT91_ADC_CH(chan->channel));
|
||||||
at91_adc_writel(st, AT91_ADC_IER, st->registers->drdy_mask);
|
at91_adc_writel(st, AT91_ADC_IER, BIT(chan->channel));
|
||||||
at91_adc_writel(st, AT91_ADC_CR, AT91_ADC_START);
|
at91_adc_writel(st, AT91_ADC_CR, AT91_ADC_START);
|
||||||
|
|
||||||
ret = wait_event_interruptible_timeout(st->wq_data_avail,
|
ret = wait_event_interruptible_timeout(st->wq_data_avail,
|
||||||
|
@ -708,7 +710,7 @@ static int at91_adc_read_raw(struct iio_dev *idev,
|
||||||
|
|
||||||
at91_adc_writel(st, AT91_ADC_CHDR,
|
at91_adc_writel(st, AT91_ADC_CHDR,
|
||||||
AT91_ADC_CH(chan->channel));
|
AT91_ADC_CH(chan->channel));
|
||||||
at91_adc_writel(st, AT91_ADC_IDR, st->registers->drdy_mask);
|
at91_adc_writel(st, AT91_ADC_IDR, BIT(chan->channel));
|
||||||
|
|
||||||
st->last_value = 0;
|
st->last_value = 0;
|
||||||
st->done = false;
|
st->done = false;
|
||||||
|
|
|
@ -1126,7 +1126,7 @@ static int xadc_parse_dt(struct iio_dev *indio_dev, struct device_node *np,
|
||||||
chan->address = XADC_REG_VPVN;
|
chan->address = XADC_REG_VPVN;
|
||||||
} else {
|
} else {
|
||||||
chan->scan_index = 15 + reg;
|
chan->scan_index = 15 + reg;
|
||||||
chan->scan_index = XADC_REG_VAUX(reg - 1);
|
chan->address = XADC_REG_VAUX(reg - 1);
|
||||||
}
|
}
|
||||||
num_channels++;
|
num_channels++;
|
||||||
chan++;
|
chan++;
|
||||||
|
|
|
@ -122,7 +122,8 @@ int hid_sensor_setup_trigger(struct iio_dev *indio_dev, const char *name,
|
||||||
dev_err(&indio_dev->dev, "Trigger Register Failed\n");
|
dev_err(&indio_dev->dev, "Trigger Register Failed\n");
|
||||||
goto error_free_trig;
|
goto error_free_trig;
|
||||||
}
|
}
|
||||||
indio_dev->trig = attrb->trigger = trig;
|
attrb->trigger = trig;
|
||||||
|
indio_dev->trig = iio_trigger_get(trig);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ int st_sensors_allocate_trigger(struct iio_dev *indio_dev,
|
||||||
dev_err(&indio_dev->dev, "failed to register iio trigger.\n");
|
dev_err(&indio_dev->dev, "failed to register iio trigger.\n");
|
||||||
goto iio_trigger_register_error;
|
goto iio_trigger_register_error;
|
||||||
}
|
}
|
||||||
indio_dev->trig = sdata->trig;
|
indio_dev->trig = iio_trigger_get(sdata->trig);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
|
|
@ -132,7 +132,7 @@ int itg3200_probe_trigger(struct iio_dev *indio_dev)
|
||||||
goto error_free_irq;
|
goto error_free_irq;
|
||||||
|
|
||||||
/* select default trigger */
|
/* select default trigger */
|
||||||
indio_dev->trig = st->trig;
|
indio_dev->trig = iio_trigger_get(st->trig);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
|
|
@ -135,7 +135,7 @@ int inv_mpu6050_probe_trigger(struct iio_dev *indio_dev)
|
||||||
ret = iio_trigger_register(st->trig);
|
ret = iio_trigger_register(st->trig);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto error_free_irq;
|
goto error_free_irq;
|
||||||
indio_dev->trig = st->trig;
|
indio_dev->trig = iio_trigger_get(st->trig);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
|
|
@ -178,7 +178,7 @@ static struct iio_channel *of_iio_channel_get_by_name(struct device_node *np,
|
||||||
index = of_property_match_string(np, "io-channel-names",
|
index = of_property_match_string(np, "io-channel-names",
|
||||||
name);
|
name);
|
||||||
chan = of_iio_channel_get(np, index);
|
chan = of_iio_channel_get(np, index);
|
||||||
if (!IS_ERR(chan))
|
if (!IS_ERR(chan) || PTR_ERR(chan) == -EPROBE_DEFER)
|
||||||
break;
|
break;
|
||||||
else if (name && index >= 0) {
|
else if (name && index >= 0) {
|
||||||
pr_err("ERROR: could not get IIO channel %s:%s(%i)\n",
|
pr_err("ERROR: could not get IIO channel %s:%s(%i)\n",
|
||||||
|
|
|
@ -42,7 +42,8 @@
|
||||||
#define ST_MAGN_FS_AVL_5600MG 5600
|
#define ST_MAGN_FS_AVL_5600MG 5600
|
||||||
#define ST_MAGN_FS_AVL_8000MG 8000
|
#define ST_MAGN_FS_AVL_8000MG 8000
|
||||||
#define ST_MAGN_FS_AVL_8100MG 8100
|
#define ST_MAGN_FS_AVL_8100MG 8100
|
||||||
#define ST_MAGN_FS_AVL_10000MG 10000
|
#define ST_MAGN_FS_AVL_12000MG 12000
|
||||||
|
#define ST_MAGN_FS_AVL_16000MG 16000
|
||||||
|
|
||||||
/* CUSTOM VALUES FOR SENSOR 1 */
|
/* CUSTOM VALUES FOR SENSOR 1 */
|
||||||
#define ST_MAGN_1_WAI_EXP 0x3c
|
#define ST_MAGN_1_WAI_EXP 0x3c
|
||||||
|
@ -69,20 +70,20 @@
|
||||||
#define ST_MAGN_1_FS_AVL_4700_VAL 0x05
|
#define ST_MAGN_1_FS_AVL_4700_VAL 0x05
|
||||||
#define ST_MAGN_1_FS_AVL_5600_VAL 0x06
|
#define ST_MAGN_1_FS_AVL_5600_VAL 0x06
|
||||||
#define ST_MAGN_1_FS_AVL_8100_VAL 0x07
|
#define ST_MAGN_1_FS_AVL_8100_VAL 0x07
|
||||||
#define ST_MAGN_1_FS_AVL_1300_GAIN_XY 1100
|
#define ST_MAGN_1_FS_AVL_1300_GAIN_XY 909
|
||||||
#define ST_MAGN_1_FS_AVL_1900_GAIN_XY 855
|
#define ST_MAGN_1_FS_AVL_1900_GAIN_XY 1169
|
||||||
#define ST_MAGN_1_FS_AVL_2500_GAIN_XY 670
|
#define ST_MAGN_1_FS_AVL_2500_GAIN_XY 1492
|
||||||
#define ST_MAGN_1_FS_AVL_4000_GAIN_XY 450
|
#define ST_MAGN_1_FS_AVL_4000_GAIN_XY 2222
|
||||||
#define ST_MAGN_1_FS_AVL_4700_GAIN_XY 400
|
#define ST_MAGN_1_FS_AVL_4700_GAIN_XY 2500
|
||||||
#define ST_MAGN_1_FS_AVL_5600_GAIN_XY 330
|
#define ST_MAGN_1_FS_AVL_5600_GAIN_XY 3030
|
||||||
#define ST_MAGN_1_FS_AVL_8100_GAIN_XY 230
|
#define ST_MAGN_1_FS_AVL_8100_GAIN_XY 4347
|
||||||
#define ST_MAGN_1_FS_AVL_1300_GAIN_Z 980
|
#define ST_MAGN_1_FS_AVL_1300_GAIN_Z 1020
|
||||||
#define ST_MAGN_1_FS_AVL_1900_GAIN_Z 760
|
#define ST_MAGN_1_FS_AVL_1900_GAIN_Z 1315
|
||||||
#define ST_MAGN_1_FS_AVL_2500_GAIN_Z 600
|
#define ST_MAGN_1_FS_AVL_2500_GAIN_Z 1666
|
||||||
#define ST_MAGN_1_FS_AVL_4000_GAIN_Z 400
|
#define ST_MAGN_1_FS_AVL_4000_GAIN_Z 2500
|
||||||
#define ST_MAGN_1_FS_AVL_4700_GAIN_Z 355
|
#define ST_MAGN_1_FS_AVL_4700_GAIN_Z 2816
|
||||||
#define ST_MAGN_1_FS_AVL_5600_GAIN_Z 295
|
#define ST_MAGN_1_FS_AVL_5600_GAIN_Z 3389
|
||||||
#define ST_MAGN_1_FS_AVL_8100_GAIN_Z 205
|
#define ST_MAGN_1_FS_AVL_8100_GAIN_Z 4878
|
||||||
#define ST_MAGN_1_MULTIREAD_BIT false
|
#define ST_MAGN_1_MULTIREAD_BIT false
|
||||||
|
|
||||||
/* CUSTOM VALUES FOR SENSOR 2 */
|
/* CUSTOM VALUES FOR SENSOR 2 */
|
||||||
|
@ -105,10 +106,12 @@
|
||||||
#define ST_MAGN_2_FS_MASK 0x60
|
#define ST_MAGN_2_FS_MASK 0x60
|
||||||
#define ST_MAGN_2_FS_AVL_4000_VAL 0x00
|
#define ST_MAGN_2_FS_AVL_4000_VAL 0x00
|
||||||
#define ST_MAGN_2_FS_AVL_8000_VAL 0x01
|
#define ST_MAGN_2_FS_AVL_8000_VAL 0x01
|
||||||
#define ST_MAGN_2_FS_AVL_10000_VAL 0x02
|
#define ST_MAGN_2_FS_AVL_12000_VAL 0x02
|
||||||
#define ST_MAGN_2_FS_AVL_4000_GAIN 430
|
#define ST_MAGN_2_FS_AVL_16000_VAL 0x03
|
||||||
#define ST_MAGN_2_FS_AVL_8000_GAIN 230
|
#define ST_MAGN_2_FS_AVL_4000_GAIN 146
|
||||||
#define ST_MAGN_2_FS_AVL_10000_GAIN 230
|
#define ST_MAGN_2_FS_AVL_8000_GAIN 292
|
||||||
|
#define ST_MAGN_2_FS_AVL_12000_GAIN 438
|
||||||
|
#define ST_MAGN_2_FS_AVL_16000_GAIN 584
|
||||||
#define ST_MAGN_2_MULTIREAD_BIT false
|
#define ST_MAGN_2_MULTIREAD_BIT false
|
||||||
#define ST_MAGN_2_OUT_X_L_ADDR 0x28
|
#define ST_MAGN_2_OUT_X_L_ADDR 0x28
|
||||||
#define ST_MAGN_2_OUT_Y_L_ADDR 0x2a
|
#define ST_MAGN_2_OUT_Y_L_ADDR 0x2a
|
||||||
|
@ -266,9 +269,14 @@ static const struct st_sensors st_magn_sensors[] = {
|
||||||
.gain = ST_MAGN_2_FS_AVL_8000_GAIN,
|
.gain = ST_MAGN_2_FS_AVL_8000_GAIN,
|
||||||
},
|
},
|
||||||
[2] = {
|
[2] = {
|
||||||
.num = ST_MAGN_FS_AVL_10000MG,
|
.num = ST_MAGN_FS_AVL_12000MG,
|
||||||
.value = ST_MAGN_2_FS_AVL_10000_VAL,
|
.value = ST_MAGN_2_FS_AVL_12000_VAL,
|
||||||
.gain = ST_MAGN_2_FS_AVL_10000_GAIN,
|
.gain = ST_MAGN_2_FS_AVL_12000_GAIN,
|
||||||
|
},
|
||||||
|
[3] = {
|
||||||
|
.num = ST_MAGN_FS_AVL_16000MG,
|
||||||
|
.value = ST_MAGN_2_FS_AVL_16000_VAL,
|
||||||
|
.gain = ST_MAGN_2_FS_AVL_16000_GAIN,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -85,7 +85,7 @@ int ade7758_probe_trigger(struct iio_dev *indio_dev)
|
||||||
ret = iio_trigger_register(st->trig);
|
ret = iio_trigger_register(st->trig);
|
||||||
|
|
||||||
/* select default trigger */
|
/* select default trigger */
|
||||||
indio_dev->trig = st->trig;
|
indio_dev->trig = iio_trigger_get(st->trig);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto error_free_irq;
|
goto error_free_irq;
|
||||||
|
|
||||||
|
|
|
@ -84,10 +84,12 @@ static inline void iio_trigger_put(struct iio_trigger *trig)
|
||||||
put_device(&trig->dev);
|
put_device(&trig->dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void iio_trigger_get(struct iio_trigger *trig)
|
static inline struct iio_trigger *iio_trigger_get(struct iio_trigger *trig)
|
||||||
{
|
{
|
||||||
get_device(&trig->dev);
|
get_device(&trig->dev);
|
||||||
__module_get(trig->ops->owner);
|
__module_get(trig->ops->owner);
|
||||||
|
|
||||||
|
return trig;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Загрузка…
Ссылка в новой задаче