Skip to content

Commit 2544785

Browse files
committed
Merge tag 'char-misc-7.1-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc
Pull char/misc/iio fixes from Greg KH: "Here are some small char/misc/iio driver fixes for 7.1-rc6. Included in here are: - lots of small IIO driver fixes for reported problems. - Android binder bugfixes for reported issues. - small comedi test driver fixes - counter driver fix - parport driver fix (people still use this?) - rpi driver fix - uio driver fix All of these have been in linux-next for over a week with no reported problems" * tag 'char-misc-7.1-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc: (41 commits) Revert "gpib: cb7210: Fix region leak when request_irq fails" misc: rp1: Send IACK on IRQ activate to fix kdump/kexec gpib: cb7210: Fix region leak when request_irq fails parport: Fix race between port and client registration uio: uio_pci_generic_sva: fix double free of devm_kzalloc() memory rust_binder: Avoid holding lock when dropping delivered_death rust_binder: avoid calling pending_oneway_finished() on TF_UPDATE_TXN comedi: comedi_test: fix check for valid scan_begin_src in waveform_ai_cmdtest() comedi: comedi_test: Fix limiting of convert_arg in waveform_ai_cmdtest() iio: adc: viperboard: Fix error handling in vprbrd_iio_read_raw iio: gyro: itg3200: fix i2c read into the wrong stack location iio: dac: ad5686: fix powerdown control on dual-channel devices iio: dac: ad5686: acquire lock when doing powerdown control iio: temperature: tsys01: fix broken PROM checksum validation iio: dac: ad3530r: Fix AD3531/AD3531R powerdown mode strings iio: buffer: hw-consumer: fix use-after-free in error path iio: dac: ad5686: fix input raw value check iio: dac: ad5686: fix ref bit initialization for single-channel parts iio: ssp_sensors: cancel delayed work_refresh on remove iio: adc: meson-saradc: fix calibration buffer leak on error ...
2 parents 1246c24 + 05d5d79 commit 2544785

36 files changed

Lines changed: 235 additions & 109 deletions

drivers/android/binder/allocation.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,14 @@ impl Allocation {
157157
self.get_or_init_info().target_node = Some(target_node);
158158
}
159159

160+
pub(crate) fn take_oneway_node(&mut self) -> Option<DArc<Node>> {
161+
if let Some(info) = self.allocation_info.as_mut() {
162+
info.oneway_node.take()
163+
} else {
164+
None
165+
}
166+
}
167+
160168
/// Reserve enough space to push at least `num_fds` fds.
161169
pub(crate) fn info_add_fd_reserve(&mut self, num_fds: usize) -> Result {
162170
self.get_or_init_info()

drivers/android/binder/process.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1402,7 +1402,12 @@ impl Process {
14021402
// Clear delivered_deaths list.
14031403
//
14041404
// Scope ensures that MutexGuard is dropped while executing the body.
1405-
while let Some(delivered_death) = { self.inner.lock().delivered_deaths.pop_front() } {
1405+
while let Some(delivered_death) = {
1406+
// Explicitly bind to avoid tail expression lifetime extension of the lockguard
1407+
// Can be removed when the kernel moves to edition 2024
1408+
let maybe_death = self.inner.lock().delivered_deaths.pop_front();
1409+
maybe_death
1410+
} {
14061411
drop(delivered_death);
14071412
}
14081413

drivers/android/binder/transaction.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,8 @@ impl Transaction {
270270
/// Not used for replies.
271271
pub(crate) fn submit(self: DLArc<Self>, info: &mut TransactionInfo) -> BinderResult {
272272
// Defined before `process_inner` so that the destructor runs after releasing the lock.
273-
let mut _t_outdated;
273+
let _t_outdated;
274+
let _oneway_node;
274275

275276
let oneway = self.flags & TF_ONE_WAY != 0;
276277
let process = self.to.clone();
@@ -287,6 +288,14 @@ impl Transaction {
287288
if let Some(t_outdated) =
288289
target_node.take_outdated_transaction(&self, &mut process_inner)
289290
{
291+
let mut alloc_guard = t_outdated.allocation.lock();
292+
if let Some(alloc) = (*alloc_guard).as_mut() {
293+
// Take the oneway node to prevent `Allocation::drop` from calling
294+
// `pending_oneway_finished()`, which would be incorrect as this
295+
// transaction is not being submitted.
296+
_oneway_node = alloc.take_oneway_node();
297+
}
298+
drop(alloc_guard);
290299
// Save the transaction to be dropped after locks are released.
291300
_t_outdated = t_outdated;
292301
}

drivers/comedi/drivers/comedi_test.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,7 @@ static int waveform_ai_cmdtest(struct comedi_device *dev,
274274
/* Step 2a : make sure trigger sources are unique */
275275

276276
err |= comedi_check_trigger_is_unique(cmd->convert_src);
277+
err |= comedi_check_trigger_is_unique(cmd->scan_begin_src);
277278
err |= comedi_check_trigger_is_unique(cmd->stop_src);
278279

279280
/* Step 2b : and mutually compatible */
@@ -324,10 +325,10 @@ static int waveform_ai_cmdtest(struct comedi_device *dev,
324325
arg = min(arg,
325326
rounddown(UINT_MAX, (unsigned int)NSEC_PER_USEC));
326327
arg = NSEC_PER_USEC * DIV_ROUND_CLOSEST(arg, NSEC_PER_USEC);
327-
if (cmd->scan_begin_arg == TRIG_TIMER) {
328+
if (cmd->scan_begin_src == TRIG_TIMER) {
328329
/* limit convert_arg to keep scan_begin_arg in range */
329330
limit = UINT_MAX / cmd->scan_end_arg;
330-
limit = rounddown(limit, (unsigned int)NSEC_PER_SEC);
331+
limit = rounddown(limit, (unsigned int)NSEC_PER_USEC);
331332
arg = min(arg, limit);
332333
}
333334
err |= comedi_check_trigger_arg_is(&cmd->convert_arg, arg);

drivers/counter/counter-core.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,8 @@ struct counter_device *counter_alloc(size_t sizeof_priv)
124124

125125
err_dev_set_name:
126126

127-
counter_chrdev_remove(counter);
127+
put_device(dev);
128+
return NULL;
128129
err_chrdev_add:
129130

130131
ida_free(&counter_ida, dev->id);

drivers/iio/adc/ad4695.c

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -876,14 +876,14 @@ static int ad4695_offload_buffer_postenable(struct iio_dev *indio_dev)
876876
if (ret)
877877
goto err_unoptimize_message;
878878

879-
ret = spi_offload_trigger_enable(st->offload, st->offload_trigger,
880-
&config);
879+
ret = ad4695_enter_advanced_sequencer_mode(st, num_slots);
881880
if (ret)
882881
goto err_disable_busy_output;
883882

884-
ret = ad4695_enter_advanced_sequencer_mode(st, num_slots);
883+
ret = spi_offload_trigger_enable(st->offload, st->offload_trigger,
884+
&config);
885885
if (ret)
886-
goto err_offload_trigger_disable;
886+
goto err_exit_conversion_mode;
887887

888888
mutex_lock(&st->cnv_pwm_lock);
889889
pwm_get_state(st->cnv_pwm, &state);
@@ -895,23 +895,16 @@ static int ad4695_offload_buffer_postenable(struct iio_dev *indio_dev)
895895
ret = pwm_apply_might_sleep(st->cnv_pwm, &state);
896896
mutex_unlock(&st->cnv_pwm_lock);
897897
if (ret)
898-
goto err_offload_exit_conversion_mode;
898+
goto err_offload_trigger_disable;
899899

900900
return 0;
901901

902-
err_offload_exit_conversion_mode:
903-
/*
904-
* We have to unwind in a different order to avoid triggering offload.
905-
* ad4695_exit_conversion_mode() triggers a conversion, so it has to be
906-
* done after spi_offload_trigger_disable().
907-
*/
908-
spi_offload_trigger_disable(st->offload, st->offload_trigger);
909-
ad4695_exit_conversion_mode(st);
910-
goto err_disable_busy_output;
911-
912902
err_offload_trigger_disable:
913903
spi_offload_trigger_disable(st->offload, st->offload_trigger);
914904

905+
err_exit_conversion_mode:
906+
ad4695_exit_conversion_mode(st);
907+
915908
err_disable_busy_output:
916909
regmap_clear_bits(st->regmap, AD4695_REG_GP_MODE,
917910
AD4695_REG_GP_MODE_BUSY_GP_EN);

drivers/iio/adc/meson_saradc.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -817,9 +817,11 @@ static int meson_sar_adc_temp_sensor_init(struct iio_dev *indio_dev)
817817
}
818818

819819
priv->tsc_regmap = syscon_regmap_lookup_by_phandle(dev->of_node, "amlogic,hhi-sysctrl");
820-
if (IS_ERR(priv->tsc_regmap))
820+
if (IS_ERR(priv->tsc_regmap)) {
821+
kfree(buf);
821822
return dev_err_probe(dev, PTR_ERR(priv->tsc_regmap),
822823
"failed to get amlogic,hhi-sysctrl regmap\n");
824+
}
823825

824826
trimming_bits = priv->param->temperature_trimming_bits;
825827
trimming_mask = BIT(trimming_bits) - 1;

drivers/iio/adc/mt6359-auxadc.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,7 @@ static int mt6358_read_imp(struct mt6359_auxadc *adc_dev,
497497
return ret;
498498

499499
/* Read the params before stopping */
500+
val_v = 0;
500501
regmap_read(regmap, reg_adc0 + (cinfo->imp_adc_num << 1), &val_v);
501502

502503
mt6358_stop_imp_conv(adc_dev);

drivers/iio/adc/npcm_adc.c

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ static int npcm_adc_probe(struct platform_device *pdev)
231231
if (IS_ERR(info->reset))
232232
return PTR_ERR(info->reset);
233233

234-
info->adc_clk = devm_clk_get(&pdev->dev, NULL);
234+
info->adc_clk = devm_clk_get_enabled(&pdev->dev, NULL);
235235
if (IS_ERR(info->adc_clk)) {
236236
dev_warn(&pdev->dev, "ADC clock failed: can't read clk\n");
237237
return PTR_ERR(info->adc_clk);
@@ -244,25 +244,21 @@ static int npcm_adc_probe(struct platform_device *pdev)
244244
info->adc_sample_hz = clk_get_rate(info->adc_clk) / ((div + 1) * 2);
245245

246246
irq = platform_get_irq(pdev, 0);
247-
if (irq < 0) {
248-
ret = irq;
249-
goto err_disable_clk;
250-
}
247+
if (irq < 0)
248+
return irq;
251249

252250
ret = devm_request_irq(&pdev->dev, irq, npcm_adc_isr, 0,
253251
"NPCM_ADC", indio_dev);
254-
if (ret < 0) {
255-
dev_err(dev, "failed requesting interrupt\n");
256-
goto err_disable_clk;
257-
}
252+
if (ret < 0)
253+
return ret;
258254

259255
reg_con = ioread32(info->regs + NPCM_ADCCON);
260256
info->vref = devm_regulator_get_optional(&pdev->dev, "vref");
261257
if (!IS_ERR(info->vref)) {
262258
ret = regulator_enable(info->vref);
263259
if (ret) {
264260
dev_err(&pdev->dev, "Can't enable ADC reference voltage\n");
265-
goto err_disable_clk;
261+
return ret;
266262
}
267263

268264
iowrite32(reg_con & ~NPCM_ADCCON_REFSEL,
@@ -272,10 +268,8 @@ static int npcm_adc_probe(struct platform_device *pdev)
272268
* Any error which is not ENODEV indicates the regulator
273269
* has been specified and so is a failure case.
274270
*/
275-
if (PTR_ERR(info->vref) != -ENODEV) {
276-
ret = PTR_ERR(info->vref);
277-
goto err_disable_clk;
278-
}
271+
if (PTR_ERR(info->vref) != -ENODEV)
272+
return PTR_ERR(info->vref);
279273

280274
/* Use internal reference */
281275
iowrite32(reg_con | NPCM_ADCCON_REFSEL,
@@ -314,8 +308,6 @@ static int npcm_adc_probe(struct platform_device *pdev)
314308
iowrite32(reg_con & ~NPCM_ADCCON_ADC_EN, info->regs + NPCM_ADCCON);
315309
if (!IS_ERR(info->vref))
316310
regulator_disable(info->vref);
317-
err_disable_clk:
318-
clk_disable_unprepare(info->adc_clk);
319311

320312
return ret;
321313
}
@@ -332,7 +324,6 @@ static void npcm_adc_remove(struct platform_device *pdev)
332324
iowrite32(regtemp & ~NPCM_ADCCON_ADC_EN, info->regs + NPCM_ADCCON);
333325
if (!IS_ERR(info->vref))
334326
regulator_disable(info->vref);
335-
clk_disable_unprepare(info->adc_clk);
336327
}
337328

338329
static struct platform_driver npcm_adc_driver = {

drivers/iio/adc/nxp-sar-adc.c

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,15 @@ static void nxp_sar_adc_irq_cfg(struct nxp_sar_adc *info, bool enable)
198198
writel(0, NXP_SAR_ADC_IMR(info->regs));
199199
}
200200

201+
static void nxp_sar_adc_wait_for(struct nxp_sar_adc *info, unsigned int cycles)
202+
{
203+
u64 rate;
204+
205+
rate = clk_get_rate(info->clk);
206+
if (rate)
207+
ndelay(div64_u64(NSEC_PER_SEC, rate * cycles));
208+
}
209+
201210
static bool nxp_sar_adc_set_enabled(struct nxp_sar_adc *info, bool enable)
202211
{
203212
u32 mcr;
@@ -221,7 +230,7 @@ static bool nxp_sar_adc_set_enabled(struct nxp_sar_adc *info, bool enable)
221230
* configuration of NCMR and the setting of NSTART.
222231
*/
223232
if (enable)
224-
ndelay(div64_u64(NSEC_PER_SEC, clk_get_rate(info->clk) * 3));
233+
nxp_sar_adc_wait_for(info, 3);
225234

226235
return pwdn;
227236
}
@@ -469,7 +478,7 @@ static void nxp_sar_adc_stop_conversion(struct nxp_sar_adc *info)
469478
* only when the capture finishes. The delay will be very
470479
* short, usec-ish, which is acceptable in the atomic context.
471480
*/
472-
ndelay(div64_u64(NSEC_PER_SEC, clk_get_rate(info->clk)) * 80);
481+
nxp_sar_adc_wait_for(info, 80);
473482
}
474483

475484
static int nxp_sar_adc_start_conversion(struct nxp_sar_adc *info, bool raw)
@@ -560,6 +569,9 @@ static int nxp_sar_adc_write_raw(struct iio_dev *indio_dev, struct iio_chan_spec
560569

561570
switch (mask) {
562571
case IIO_CHAN_INFO_SAMP_FREQ:
572+
if (val <= 0)
573+
return -EINVAL;
574+
563575
/*
564576
* Configures the sample period duration in terms of the SAR
565577
* controller clock. The minimum acceptable value is 8.
@@ -568,7 +580,11 @@ static int nxp_sar_adc_write_raw(struct iio_dev *indio_dev, struct iio_chan_spec
568580
* sampling timing which gives us the number of cycles expected.
569581
* The value is 8-bit wide, consequently the max value is 0xFF.
570582
*/
571-
inpsamp = clk_get_rate(info->clk) / val - NXP_SAR_ADC_CONV_TIME;
583+
inpsamp = clk_get_rate(info->clk) / val;
584+
if (inpsamp < NXP_SAR_ADC_CONV_TIME)
585+
return -EINVAL;
586+
587+
inpsamp -= NXP_SAR_ADC_CONV_TIME;
572588
nxp_sar_adc_conversion_timing_set(info, inpsamp);
573589
return 0;
574590

@@ -660,7 +676,7 @@ static void nxp_sar_adc_dma_cb(void *data)
660676
static int nxp_sar_adc_start_cyclic_dma(struct iio_dev *indio_dev)
661677
{
662678
struct nxp_sar_adc *info = iio_priv(indio_dev);
663-
struct dma_slave_config config;
679+
struct dma_slave_config config = { };
664680
struct dma_async_tx_descriptor *desc;
665681
int ret;
666682

0 commit comments

Comments
 (0)