Skip to content

Commit 9f12754

Browse files
committed
Merge tag 'char-misc-6.1-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc
Pull char/misc fixes from Greg KH: "Some small driver fixes for 6.1-rc3. They include: - iio driver bugfixes - counter driver bugfixes - coresight bugfixes, including a revert and then a second fix to get it right. All of these have been in linux-next with no reported problems" * tag 'char-misc-6.1-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc: (21 commits) misc: sgi-gru: use explicitly signed char coresight: cti: Fix hang in cti_disable_hw() Revert "coresight: cti: Fix hang in cti_disable_hw()" counter: 104-quad-8: Fix race getting function mode and direction counter: microchip-tcb-capture: Handle Signal1 read and Synapse coresight: cti: Fix hang in cti_disable_hw() coresight: Fix possible deadlock with lock dependency counter: ti-ecap-capture: fix IS_ERR() vs NULL check counter: Reduce DEFINE_COUNTER_ARRAY_POLARITY() to defining counter_array iio: bmc150-accel-core: Fix unsafe buffer attributes iio: adxl367: Fix unsafe buffer attributes iio: adxl372: Fix unsafe buffer attributes iio: at91-sama5d2_adc: Fix unsafe buffer attributes iio: temperature: ltc2983: allocate iio channels once tools: iio: iio_utils: fix digit calculation iio: adc: stm32-adc: fix channel sampling time init iio: adc: mcp3911: mask out device ID in debug prints iio: adc: mcp3911: use correct id bits iio: adc: mcp3911: return proper error code on failure to allocate trigger iio: adc: mcp3911: fix sizeof() vs ARRAY_SIZE() bug ...
2 parents c4d25ce + 6770473 commit 9f12754

File tree

17 files changed

+175
-91
lines changed

17 files changed

+175
-91
lines changed

drivers/counter/104-quad-8.c

Lines changed: 42 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -232,34 +232,45 @@ static const enum counter_function quad8_count_functions_list[] = {
232232
COUNTER_FUNCTION_QUADRATURE_X4,
233233
};
234234

235+
static int quad8_function_get(const struct quad8 *const priv, const size_t id,
236+
enum counter_function *const function)
237+
{
238+
if (!priv->quadrature_mode[id]) {
239+
*function = COUNTER_FUNCTION_PULSE_DIRECTION;
240+
return 0;
241+
}
242+
243+
switch (priv->quadrature_scale[id]) {
244+
case 0:
245+
*function = COUNTER_FUNCTION_QUADRATURE_X1_A;
246+
return 0;
247+
case 1:
248+
*function = COUNTER_FUNCTION_QUADRATURE_X2_A;
249+
return 0;
250+
case 2:
251+
*function = COUNTER_FUNCTION_QUADRATURE_X4;
252+
return 0;
253+
default:
254+
/* should never reach this path */
255+
return -EINVAL;
256+
}
257+
}
258+
235259
static int quad8_function_read(struct counter_device *counter,
236260
struct counter_count *count,
237261
enum counter_function *function)
238262
{
239263
struct quad8 *const priv = counter_priv(counter);
240-
const int id = count->id;
241264
unsigned long irqflags;
265+
int retval;
242266

243267
spin_lock_irqsave(&priv->lock, irqflags);
244268

245-
if (priv->quadrature_mode[id])
246-
switch (priv->quadrature_scale[id]) {
247-
case 0:
248-
*function = COUNTER_FUNCTION_QUADRATURE_X1_A;
249-
break;
250-
case 1:
251-
*function = COUNTER_FUNCTION_QUADRATURE_X2_A;
252-
break;
253-
case 2:
254-
*function = COUNTER_FUNCTION_QUADRATURE_X4;
255-
break;
256-
}
257-
else
258-
*function = COUNTER_FUNCTION_PULSE_DIRECTION;
269+
retval = quad8_function_get(priv, count->id, function);
259270

260271
spin_unlock_irqrestore(&priv->lock, irqflags);
261272

262-
return 0;
273+
return retval;
263274
}
264275

265276
static int quad8_function_write(struct counter_device *counter,
@@ -359,6 +370,7 @@ static int quad8_action_read(struct counter_device *counter,
359370
enum counter_synapse_action *action)
360371
{
361372
struct quad8 *const priv = counter_priv(counter);
373+
unsigned long irqflags;
362374
int err;
363375
enum counter_function function;
364376
const size_t signal_a_id = count->synapses[0].signal->id;
@@ -374,9 +386,21 @@ static int quad8_action_read(struct counter_device *counter,
374386
return 0;
375387
}
376388

377-
err = quad8_function_read(counter, count, &function);
378-
if (err)
389+
spin_lock_irqsave(&priv->lock, irqflags);
390+
391+
/* Get Count function and direction atomically */
392+
err = quad8_function_get(priv, count->id, &function);
393+
if (err) {
394+
spin_unlock_irqrestore(&priv->lock, irqflags);
395+
return err;
396+
}
397+
err = quad8_direction_read(counter, count, &direction);
398+
if (err) {
399+
spin_unlock_irqrestore(&priv->lock, irqflags);
379400
return err;
401+
}
402+
403+
spin_unlock_irqrestore(&priv->lock, irqflags);
380404

381405
/* Default action mode */
382406
*action = COUNTER_SYNAPSE_ACTION_NONE;
@@ -389,10 +413,6 @@ static int quad8_action_read(struct counter_device *counter,
389413
return 0;
390414
case COUNTER_FUNCTION_QUADRATURE_X1_A:
391415
if (synapse->signal->id == signal_a_id) {
392-
err = quad8_direction_read(counter, count, &direction);
393-
if (err)
394-
return err;
395-
396416
if (direction == COUNTER_COUNT_DIRECTION_FORWARD)
397417
*action = COUNTER_SYNAPSE_ACTION_RISING_EDGE;
398418
else

drivers/counter/microchip-tcb-capture.c

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ struct mchp_tc_data {
2828
int qdec_mode;
2929
int num_channels;
3030
int channel[2];
31-
bool trig_inverted;
3231
};
3332

3433
static const enum counter_function mchp_tc_count_functions[] = {
@@ -153,7 +152,7 @@ static int mchp_tc_count_signal_read(struct counter_device *counter,
153152

154153
regmap_read(priv->regmap, ATMEL_TC_REG(priv->channel[0], SR), &sr);
155154

156-
if (priv->trig_inverted)
155+
if (signal->id == 1)
157156
sigstatus = (sr & ATMEL_TC_MTIOB);
158157
else
159158
sigstatus = (sr & ATMEL_TC_MTIOA);
@@ -171,6 +170,17 @@ static int mchp_tc_count_action_read(struct counter_device *counter,
171170
struct mchp_tc_data *const priv = counter_priv(counter);
172171
u32 cmr;
173172

173+
if (priv->qdec_mode) {
174+
*action = COUNTER_SYNAPSE_ACTION_BOTH_EDGES;
175+
return 0;
176+
}
177+
178+
/* Only TIOA signal is evaluated in non-QDEC mode */
179+
if (synapse->signal->id != 0) {
180+
*action = COUNTER_SYNAPSE_ACTION_NONE;
181+
return 0;
182+
}
183+
174184
regmap_read(priv->regmap, ATMEL_TC_REG(priv->channel[0], CMR), &cmr);
175185

176186
switch (cmr & ATMEL_TC_ETRGEDG) {
@@ -199,8 +209,8 @@ static int mchp_tc_count_action_write(struct counter_device *counter,
199209
struct mchp_tc_data *const priv = counter_priv(counter);
200210
u32 edge = ATMEL_TC_ETRGEDG_NONE;
201211

202-
/* QDEC mode is rising edge only */
203-
if (priv->qdec_mode)
212+
/* QDEC mode is rising edge only; only TIOA handled in non-QDEC mode */
213+
if (priv->qdec_mode || synapse->signal->id != 0)
204214
return -EINVAL;
205215

206216
switch (action) {

drivers/counter/ti-ecap-capture.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,8 @@ static const enum counter_signal_polarity ecap_cnt_pol_avail[] = {
377377
COUNTER_SIGNAL_POLARITY_NEGATIVE,
378378
};
379379

380-
static DEFINE_COUNTER_ARRAY_POLARITY(ecap_cnt_pol_array, ecap_cnt_pol_avail, ECAP_NB_CEVT);
380+
static DEFINE_COUNTER_AVAILABLE(ecap_cnt_pol_available, ecap_cnt_pol_avail);
381+
static DEFINE_COUNTER_ARRAY_POLARITY(ecap_cnt_pol_array, ecap_cnt_pol_available, ECAP_NB_CEVT);
381382

382383
static struct counter_comp ecap_cnt_signal_ext[] = {
383384
COUNTER_COMP_ARRAY_POLARITY(ecap_cnt_pol_read, ecap_cnt_pol_write, ecap_cnt_pol_array),
@@ -479,8 +480,8 @@ static int ecap_cnt_probe(struct platform_device *pdev)
479480
int ret;
480481

481482
counter_dev = devm_counter_alloc(dev, sizeof(*ecap_dev));
482-
if (IS_ERR(counter_dev))
483-
return PTR_ERR(counter_dev);
483+
if (!counter_dev)
484+
return -ENOMEM;
484485

485486
counter_dev->name = ECAP_DRV_NAME;
486487
counter_dev->parent = dev;

drivers/hwtracing/coresight/coresight-core.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1687,14 +1687,15 @@ struct coresight_device *coresight_register(struct coresight_desc *desc)
16871687
ret = coresight_fixup_device_conns(csdev);
16881688
if (!ret)
16891689
ret = coresight_fixup_orphan_conns(csdev);
1690-
if (!ret && cti_assoc_ops && cti_assoc_ops->add)
1691-
cti_assoc_ops->add(csdev);
16921690

16931691
out_unlock:
16941692
mutex_unlock(&coresight_mutex);
16951693
/* Success */
1696-
if (!ret)
1694+
if (!ret) {
1695+
if (cti_assoc_ops && cti_assoc_ops->add)
1696+
cti_assoc_ops->add(csdev);
16971697
return csdev;
1698+
}
16981699

16991700
/* Unregister the device if needed */
17001701
if (registered) {

drivers/hwtracing/coresight/coresight-cti-core.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,9 @@ void cti_write_all_hw_regs(struct cti_drvdata *drvdata)
9090
static int cti_enable_hw(struct cti_drvdata *drvdata)
9191
{
9292
struct cti_config *config = &drvdata->config;
93-
struct device *dev = &drvdata->csdev->dev;
9493
unsigned long flags;
9594
int rc = 0;
9695

97-
pm_runtime_get_sync(dev->parent);
9896
spin_lock_irqsave(&drvdata->spinlock, flags);
9997

10098
/* no need to do anything if enabled or unpowered*/
@@ -119,7 +117,6 @@ static int cti_enable_hw(struct cti_drvdata *drvdata)
119117
/* cannot enable due to error */
120118
cti_err_not_enabled:
121119
spin_unlock_irqrestore(&drvdata->spinlock, flags);
122-
pm_runtime_put(dev->parent);
123120
return rc;
124121
}
125122

@@ -153,7 +150,6 @@ static void cti_cpuhp_enable_hw(struct cti_drvdata *drvdata)
153150
static int cti_disable_hw(struct cti_drvdata *drvdata)
154151
{
155152
struct cti_config *config = &drvdata->config;
156-
struct device *dev = &drvdata->csdev->dev;
157153
struct coresight_device *csdev = drvdata->csdev;
158154

159155
spin_lock(&drvdata->spinlock);
@@ -175,7 +171,6 @@ static int cti_disable_hw(struct cti_drvdata *drvdata)
175171
coresight_disclaim_device_unlocked(csdev);
176172
CS_LOCK(drvdata->base);
177173
spin_unlock(&drvdata->spinlock);
178-
pm_runtime_put(dev->parent);
179174
return 0;
180175

181176
/* not disabled this call */
@@ -541,7 +536,7 @@ cti_match_fixup_csdev(struct cti_device *ctidev, const char *node_name,
541536
/*
542537
* Search the cti list to add an associated CTI into the supplied CS device
543538
* This will set the association if CTI declared before the CS device.
544-
* (called from coresight_register() with coresight_mutex locked).
539+
* (called from coresight_register() without coresight_mutex locked).
545540
*/
546541
static void cti_add_assoc_to_csdev(struct coresight_device *csdev)
547542
{
@@ -569,7 +564,8 @@ static void cti_add_assoc_to_csdev(struct coresight_device *csdev)
569564
* if we found a matching csdev then update the ECT
570565
* association pointer for the device with this CTI.
571566
*/
572-
csdev->ect_dev = ect_item->csdev;
567+
coresight_set_assoc_ectdev_mutex(csdev->ect_dev,
568+
ect_item->csdev);
573569
break;
574570
}
575571
}

drivers/iio/accel/adxl367.c

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1185,17 +1185,30 @@ static ssize_t adxl367_get_fifo_watermark(struct device *dev,
11851185
return sysfs_emit(buf, "%d\n", fifo_watermark);
11861186
}
11871187

1188-
static IIO_CONST_ATTR(hwfifo_watermark_min, "1");
1189-
static IIO_CONST_ATTR(hwfifo_watermark_max,
1190-
__stringify(ADXL367_FIFO_MAX_WATERMARK));
1188+
static ssize_t hwfifo_watermark_min_show(struct device *dev,
1189+
struct device_attribute *attr,
1190+
char *buf)
1191+
{
1192+
return sysfs_emit(buf, "%s\n", "1");
1193+
}
1194+
1195+
static ssize_t hwfifo_watermark_max_show(struct device *dev,
1196+
struct device_attribute *attr,
1197+
char *buf)
1198+
{
1199+
return sysfs_emit(buf, "%s\n", __stringify(ADXL367_FIFO_MAX_WATERMARK));
1200+
}
1201+
1202+
static IIO_DEVICE_ATTR_RO(hwfifo_watermark_min, 0);
1203+
static IIO_DEVICE_ATTR_RO(hwfifo_watermark_max, 0);
11911204
static IIO_DEVICE_ATTR(hwfifo_watermark, 0444,
11921205
adxl367_get_fifo_watermark, NULL, 0);
11931206
static IIO_DEVICE_ATTR(hwfifo_enabled, 0444,
11941207
adxl367_get_fifo_enabled, NULL, 0);
11951208

11961209
static const struct attribute *adxl367_fifo_attributes[] = {
1197-
&iio_const_attr_hwfifo_watermark_min.dev_attr.attr,
1198-
&iio_const_attr_hwfifo_watermark_max.dev_attr.attr,
1210+
&iio_dev_attr_hwfifo_watermark_min.dev_attr.attr,
1211+
&iio_dev_attr_hwfifo_watermark_max.dev_attr.attr,
11991212
&iio_dev_attr_hwfifo_watermark.dev_attr.attr,
12001213
&iio_dev_attr_hwfifo_enabled.dev_attr.attr,
12011214
NULL,

drivers/iio/accel/adxl372.c

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -998,17 +998,30 @@ static ssize_t adxl372_get_fifo_watermark(struct device *dev,
998998
return sprintf(buf, "%d\n", st->watermark);
999999
}
10001000

1001-
static IIO_CONST_ATTR(hwfifo_watermark_min, "1");
1002-
static IIO_CONST_ATTR(hwfifo_watermark_max,
1003-
__stringify(ADXL372_FIFO_SIZE));
1001+
static ssize_t hwfifo_watermark_min_show(struct device *dev,
1002+
struct device_attribute *attr,
1003+
char *buf)
1004+
{
1005+
return sysfs_emit(buf, "%s\n", "1");
1006+
}
1007+
1008+
static ssize_t hwfifo_watermark_max_show(struct device *dev,
1009+
struct device_attribute *attr,
1010+
char *buf)
1011+
{
1012+
return sysfs_emit(buf, "%s\n", __stringify(ADXL372_FIFO_SIZE));
1013+
}
1014+
1015+
static IIO_DEVICE_ATTR_RO(hwfifo_watermark_min, 0);
1016+
static IIO_DEVICE_ATTR_RO(hwfifo_watermark_max, 0);
10041017
static IIO_DEVICE_ATTR(hwfifo_watermark, 0444,
10051018
adxl372_get_fifo_watermark, NULL, 0);
10061019
static IIO_DEVICE_ATTR(hwfifo_enabled, 0444,
10071020
adxl372_get_fifo_enabled, NULL, 0);
10081021

10091022
static const struct attribute *adxl372_fifo_attributes[] = {
1010-
&iio_const_attr_hwfifo_watermark_min.dev_attr.attr,
1011-
&iio_const_attr_hwfifo_watermark_max.dev_attr.attr,
1023+
&iio_dev_attr_hwfifo_watermark_min.dev_attr.attr,
1024+
&iio_dev_attr_hwfifo_watermark_max.dev_attr.attr,
10121025
&iio_dev_attr_hwfifo_watermark.dev_attr.attr,
10131026
&iio_dev_attr_hwfifo_enabled.dev_attr.attr,
10141027
NULL,

drivers/iio/accel/bmc150-accel-core.c

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -925,17 +925,30 @@ static const struct iio_chan_spec_ext_info bmc150_accel_ext_info[] = {
925925
{ }
926926
};
927927

928-
static IIO_CONST_ATTR(hwfifo_watermark_min, "1");
929-
static IIO_CONST_ATTR(hwfifo_watermark_max,
930-
__stringify(BMC150_ACCEL_FIFO_LENGTH));
928+
static ssize_t hwfifo_watermark_min_show(struct device *dev,
929+
struct device_attribute *attr,
930+
char *buf)
931+
{
932+
return sysfs_emit(buf, "%s\n", "1");
933+
}
934+
935+
static ssize_t hwfifo_watermark_max_show(struct device *dev,
936+
struct device_attribute *attr,
937+
char *buf)
938+
{
939+
return sysfs_emit(buf, "%s\n", __stringify(BMC150_ACCEL_FIFO_LENGTH));
940+
}
941+
942+
static IIO_DEVICE_ATTR_RO(hwfifo_watermark_min, 0);
943+
static IIO_DEVICE_ATTR_RO(hwfifo_watermark_max, 0);
931944
static IIO_DEVICE_ATTR(hwfifo_enabled, S_IRUGO,
932945
bmc150_accel_get_fifo_state, NULL, 0);
933946
static IIO_DEVICE_ATTR(hwfifo_watermark, S_IRUGO,
934947
bmc150_accel_get_fifo_watermark, NULL, 0);
935948

936949
static const struct attribute *bmc150_accel_fifo_attributes[] = {
937-
&iio_const_attr_hwfifo_watermark_min.dev_attr.attr,
938-
&iio_const_attr_hwfifo_watermark_max.dev_attr.attr,
950+
&iio_dev_attr_hwfifo_watermark_min.dev_attr.attr,
951+
&iio_dev_attr_hwfifo_watermark_max.dev_attr.attr,
939952
&iio_dev_attr_hwfifo_watermark.dev_attr.attr,
940953
&iio_dev_attr_hwfifo_enabled.dev_attr.attr,
941954
NULL,

drivers/iio/adc/at91-sama5d2_adc.c

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2193,17 +2193,30 @@ static ssize_t at91_adc_get_watermark(struct device *dev,
21932193
return scnprintf(buf, PAGE_SIZE, "%d\n", st->dma_st.watermark);
21942194
}
21952195

2196+
static ssize_t hwfifo_watermark_min_show(struct device *dev,
2197+
struct device_attribute *attr,
2198+
char *buf)
2199+
{
2200+
return sysfs_emit(buf, "%s\n", "2");
2201+
}
2202+
2203+
static ssize_t hwfifo_watermark_max_show(struct device *dev,
2204+
struct device_attribute *attr,
2205+
char *buf)
2206+
{
2207+
return sysfs_emit(buf, "%s\n", AT91_HWFIFO_MAX_SIZE_STR);
2208+
}
2209+
21962210
static IIO_DEVICE_ATTR(hwfifo_enabled, 0444,
21972211
at91_adc_get_fifo_state, NULL, 0);
21982212
static IIO_DEVICE_ATTR(hwfifo_watermark, 0444,
21992213
at91_adc_get_watermark, NULL, 0);
2200-
2201-
static IIO_CONST_ATTR(hwfifo_watermark_min, "2");
2202-
static IIO_CONST_ATTR(hwfifo_watermark_max, AT91_HWFIFO_MAX_SIZE_STR);
2214+
static IIO_DEVICE_ATTR_RO(hwfifo_watermark_min, 0);
2215+
static IIO_DEVICE_ATTR_RO(hwfifo_watermark_max, 0);
22032216

22042217
static const struct attribute *at91_adc_fifo_attributes[] = {
2205-
&iio_const_attr_hwfifo_watermark_min.dev_attr.attr,
2206-
&iio_const_attr_hwfifo_watermark_max.dev_attr.attr,
2218+
&iio_dev_attr_hwfifo_watermark_min.dev_attr.attr,
2219+
&iio_dev_attr_hwfifo_watermark_max.dev_attr.attr,
22072220
&iio_dev_attr_hwfifo_watermark.dev_attr.attr,
22082221
&iio_dev_attr_hwfifo_enabled.dev_attr.attr,
22092222
NULL,

0 commit comments

Comments
 (0)