Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

Pull staging driver fixes from Greg KH:
"Here are 3 small fixes for staging/IIO drivers for 3.11-rc5. Nothing
huge, two IIO driver fixes, and a zcache fix. All of these have been
in linux-next for a while"

* tag 'staging-3.11-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging:
staging: zcache: fix "zcache=" kernel parameter
iio: ti_am335x_adc: Fix wrong samples received on 1st read
iio:trigger: Fix use_count race condition

+66 -23
+22 -8
drivers/iio/adc/ti_am335x_adc.c
··· 60 60 { 61 61 unsigned int stepconfig; 62 62 int i, steps; 63 - u32 step_en; 64 63 65 64 /* 66 65 * There are 16 configurable steps and 8 analog input ··· 85 86 adc_dev->channel_step[i] = steps; 86 87 steps++; 87 88 } 88 - step_en = get_adc_step_mask(adc_dev); 89 - am335x_tsc_se_set(adc_dev->mfd_tscadc, step_en); 89 + 90 90 } 91 91 92 92 static const char * const chan_name_ain[] = { ··· 140 142 int *val, int *val2, long mask) 141 143 { 142 144 struct tiadc_device *adc_dev = iio_priv(indio_dev); 143 - int i; 144 - unsigned int fifo1count, read; 145 + int i, map_val; 146 + unsigned int fifo1count, read, stepid; 145 147 u32 step = UINT_MAX; 146 148 bool found = false; 149 + u32 step_en; 150 + unsigned long timeout = jiffies + usecs_to_jiffies 151 + (IDLE_TIMEOUT * adc_dev->channels); 152 + step_en = get_adc_step_mask(adc_dev); 153 + am335x_tsc_se_set(adc_dev->mfd_tscadc, step_en); 154 + 155 + /* Wait for ADC sequencer to complete sampling */ 156 + while (tiadc_readl(adc_dev, REG_ADCFSM) & SEQ_STATUS) { 157 + if (time_after(jiffies, timeout)) 158 + return -EAGAIN; 159 + } 160 + map_val = chan->channel + TOTAL_CHANNELS; 147 161 148 162 /* 149 163 * When the sub-system is first enabled, ··· 180 170 fifo1count = tiadc_readl(adc_dev, REG_FIFO1CNT); 181 171 for (i = 0; i < fifo1count; i++) { 182 172 read = tiadc_readl(adc_dev, REG_FIFO1); 183 - if (read >> 16 == step) { 184 - *val = read & 0xfff; 173 + stepid = read & FIFOREAD_CHNLID_MASK; 174 + stepid = stepid >> 0x10; 175 + 176 + if (stepid == map_val) { 177 + read = read & FIFOREAD_DATA_MASK; 185 178 found = true; 179 + *val = read; 186 180 } 187 181 } 188 - am335x_tsc_se_update(adc_dev->mfd_tscadc); 182 + 189 183 if (found == false) 190 184 return -EBUSY; 191 185 return IIO_VAL_INT;
+22 -12
drivers/iio/industrialio-trigger.c
··· 127 127 void iio_trigger_poll(struct iio_trigger *trig, s64 time) 128 128 { 129 129 int i; 130 - if (!trig->use_count) 131 - for (i = 0; i < CONFIG_IIO_CONSUMERS_PER_TRIGGER; i++) 132 - if (trig->subirqs[i].enabled) { 133 - trig->use_count++; 130 + 131 + if (!atomic_read(&trig->use_count)) { 132 + atomic_set(&trig->use_count, CONFIG_IIO_CONSUMERS_PER_TRIGGER); 133 + 134 + for (i = 0; i < CONFIG_IIO_CONSUMERS_PER_TRIGGER; i++) { 135 + if (trig->subirqs[i].enabled) 134 136 generic_handle_irq(trig->subirq_base + i); 135 - } 137 + else 138 + iio_trigger_notify_done(trig); 139 + } 140 + } 136 141 } 137 142 EXPORT_SYMBOL(iio_trigger_poll); 138 143 ··· 151 146 void iio_trigger_poll_chained(struct iio_trigger *trig, s64 time) 152 147 { 153 148 int i; 154 - if (!trig->use_count) 155 - for (i = 0; i < CONFIG_IIO_CONSUMERS_PER_TRIGGER; i++) 156 - if (trig->subirqs[i].enabled) { 157 - trig->use_count++; 149 + 150 + if (!atomic_read(&trig->use_count)) { 151 + atomic_set(&trig->use_count, CONFIG_IIO_CONSUMERS_PER_TRIGGER); 152 + 153 + for (i = 0; i < CONFIG_IIO_CONSUMERS_PER_TRIGGER; i++) { 154 + if (trig->subirqs[i].enabled) 158 155 handle_nested_irq(trig->subirq_base + i); 159 - } 156 + else 157 + iio_trigger_notify_done(trig); 158 + } 159 + } 160 160 } 161 161 EXPORT_SYMBOL(iio_trigger_poll_chained); 162 162 163 163 void iio_trigger_notify_done(struct iio_trigger *trig) 164 164 { 165 - trig->use_count--; 166 - if (trig->use_count == 0 && trig->ops && trig->ops->try_reenable) 165 + if (atomic_dec_and_test(&trig->use_count) && trig->ops && 166 + trig->ops->try_reenable) 167 167 if (trig->ops->try_reenable(trig)) 168 168 /* Missed an interrupt so launch new poll now */ 169 169 iio_trigger_poll(trig, 0);
+4 -2
drivers/staging/zcache/zcache-main.c
··· 1811 1811 #else 1812 1812 if (*zcache_comp_name != '\0') { 1813 1813 ret = crypto_has_comp(zcache_comp_name, 0, 0); 1814 - if (!ret) 1814 + if (!ret) { 1815 1815 pr_info("zcache: %s not supported\n", 1816 1816 zcache_comp_name); 1817 - goto out; 1817 + ret = 1; 1818 + goto out; 1819 + } 1818 1820 } 1819 1821 if (!ret) 1820 1822 strcpy(zcache_comp_name, "lzo");
+2 -1
include/linux/iio/trigger.h
··· 8 8 */ 9 9 #include <linux/irq.h> 10 10 #include <linux/module.h> 11 + #include <linux/atomic.h> 11 12 12 13 #ifndef _IIO_TRIGGER_H_ 13 14 #define _IIO_TRIGGER_H_ ··· 62 61 63 62 struct list_head list; 64 63 struct list_head alloc_list; 65 - int use_count; 64 + atomic_t use_count; 66 65 67 66 struct irq_chip subirq_chip; 68 67 int subirq_base;
+16
include/linux/mfd/ti_am335x_tscadc.h
··· 113 113 #define CNTRLREG_8WIRE CNTRLREG_AFE_CTRL(3) 114 114 #define CNTRLREG_TSCENB BIT(7) 115 115 116 + /* FIFO READ Register */ 117 + #define FIFOREAD_DATA_MASK (0xfff << 0) 118 + #define FIFOREAD_CHNLID_MASK (0xf << 16) 119 + 120 + /* Sequencer Status */ 121 + #define SEQ_STATUS BIT(5) 122 + 116 123 #define ADC_CLK 3000000 117 124 #define MAX_CLK_DIV 7 118 125 #define TOTAL_STEPS 16 119 126 #define TOTAL_CHANNELS 8 127 + 128 + /* 129 + * ADC runs at 3MHz, and it takes 130 + * 15 cycles to latch one data output. 131 + * Hence the idle time for ADC to 132 + * process one sample data would be 133 + * around 5 micro seconds. 134 + */ 135 + #define IDLE_TIMEOUT 5 /* microsec */ 120 136 121 137 #define TSCADC_CELLS 2 122 138