Commit de871da92081b17d6f286b5774ce24a938065f0b
Committed by
Vaibhav Hiremath
1 parent
7295475758
Exists in
v3.2_SMARCT335xPSP_04.06.00.11
and in
3 other branches
IIO: ti_adc: Properly handle out of memory situation.
If we fail to allocate a buffer, unmask the interrupt to allow a retry. The interrupt handler will be re-run, and our workqueue rescheduled. If we are able to allocate memory next time around, everything will continue as normal, otherwise, we will eventually get an underrun. Before this patch, the driver would stop capturing without any indication of error to the IIO subsystem or the user. Signed-off-by: Russ Dill <Russ.Dill@ti.com>
Showing 1 changed file with 4 additions and 3 deletions Side-by-side Diff
drivers/staging/iio/adc/ti_adc.c
... | ... | @@ -194,7 +194,7 @@ |
194 | 194 | fifo1count = adc_readl(adc_dev, TSCADC_REG_FIFO1CNT); |
195 | 195 | iBuf = kmalloc((fifo1count + 1) * sizeof(u32), GFP_KERNEL); |
196 | 196 | if (iBuf == NULL) |
197 | - return; | |
197 | + goto out; | |
198 | 198 | |
199 | 199 | /* |
200 | 200 | * Wait for ADC sequencer to settle down. |
201 | 201 | |
... | ... | @@ -211,12 +211,13 @@ |
211 | 211 | } |
212 | 212 | |
213 | 213 | buffer->access->store_to(buffer, (u8 *) iBuf, iio_get_time_ns()); |
214 | + kfree(iBuf); | |
215 | + | |
216 | +out: | |
214 | 217 | adc_writel(adc_dev, TSCADC_REG_IRQSTATUS, |
215 | 218 | TSCADC_IRQENB_FIFO1THRES); |
216 | 219 | adc_writel(adc_dev, TSCADC_REG_IRQENABLE, |
217 | 220 | TSCADC_IRQENB_FIFO1THRES); |
218 | - | |
219 | - kfree(iBuf); | |
220 | 221 | } |
221 | 222 | |
222 | 223 | static int tiadc_buffer_preenable(struct iio_dev *idev) |