Skip to content

Commit 68047c4

Browse files
committed
Merge tag 'char-misc-6.3-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc
Pull char/misc driver fixes from Greg KH: "Here are a small set of various small driver changes for 6.3-rc6. Included in here are: - iio driver fixes for reported problems - coresight hwtracing bugfix for reported problem - small counter driver bugfixes All have been in linux-next for a while with no reported problems" * tag 'char-misc-6.3-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc: coresight: etm4x: Do not access TRCIDR1 for identification coresight-etm4: Fix for() loop drvdata->nr_addr_cmp range bug iio: adc: ti-ads7950: Set `can_sleep` flag for GPIO chip iio: adc: palmas_gpadc: fix NULL dereference on rmmod counter: 104-quad-8: Fix Synapse action reported for Index signals counter: 104-quad-8: Fix race condition between FLAG and CNTR reads iio: adc: max11410: fix read_poll_timeout() usage iio: dac: cio-dac: Fix max DAC write value check for 12-bit iio: light: cm32181: Unregister second I2C client if present iio: accel: kionix-kx022a: Get the timestamp from the driver's private data in the trigger_handler iio: adc: ad7791: fix IRQ flags iio: buffer: make sure O_NONBLOCK is respected iio: buffer: correctly return bytes written in output buffers iio: light: vcnl4000: Fix WARN_ON on uninitialized lock iio: adis16480: select CONFIG_CRC32 drivers: iio: adc: ltc2497: fix LSB shift iio: adc: qcom-spmi-adc5: Fix the channel name
2 parents aa46fe3 + 4bffd2c commit 68047c4

File tree

15 files changed

+84
-77
lines changed

15 files changed

+84
-77
lines changed

drivers/counter/104-quad-8.c

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,6 @@ struct quad8 {
9797
struct quad8_reg __iomem *reg;
9898
};
9999

100-
/* Borrow Toggle flip-flop */
101-
#define QUAD8_FLAG_BT BIT(0)
102-
/* Carry Toggle flip-flop */
103-
#define QUAD8_FLAG_CT BIT(1)
104100
/* Error flag */
105101
#define QUAD8_FLAG_E BIT(4)
106102
/* Up/Down flag */
@@ -133,6 +129,9 @@ struct quad8 {
133129
#define QUAD8_CMR_QUADRATURE_X2 0x10
134130
#define QUAD8_CMR_QUADRATURE_X4 0x18
135131

132+
/* Each Counter is 24 bits wide */
133+
#define LS7267_CNTR_MAX GENMASK(23, 0)
134+
136135
static int quad8_signal_read(struct counter_device *counter,
137136
struct counter_signal *signal,
138137
enum counter_signal_level *level)
@@ -156,18 +155,10 @@ static int quad8_count_read(struct counter_device *counter,
156155
{
157156
struct quad8 *const priv = counter_priv(counter);
158157
struct channel_reg __iomem *const chan = priv->reg->channel + count->id;
159-
unsigned int flags;
160-
unsigned int borrow;
161-
unsigned int carry;
162158
unsigned long irqflags;
163159
int i;
164160

165-
flags = ioread8(&chan->control);
166-
borrow = flags & QUAD8_FLAG_BT;
167-
carry = !!(flags & QUAD8_FLAG_CT);
168-
169-
/* Borrow XOR Carry effectively doubles count range */
170-
*val = (unsigned long)(borrow ^ carry) << 24;
161+
*val = 0;
171162

172163
spin_lock_irqsave(&priv->lock, irqflags);
173164

@@ -191,8 +182,7 @@ static int quad8_count_write(struct counter_device *counter,
191182
unsigned long irqflags;
192183
int i;
193184

194-
/* Only 24-bit values are supported */
195-
if (val > 0xFFFFFF)
185+
if (val > LS7267_CNTR_MAX)
196186
return -ERANGE;
197187

198188
spin_lock_irqsave(&priv->lock, irqflags);
@@ -378,7 +368,7 @@ static int quad8_action_read(struct counter_device *counter,
378368

379369
/* Handle Index signals */
380370
if (synapse->signal->id >= 16) {
381-
if (priv->preset_enable[count->id])
371+
if (!priv->preset_enable[count->id])
382372
*action = COUNTER_SYNAPSE_ACTION_RISING_EDGE;
383373
else
384374
*action = COUNTER_SYNAPSE_ACTION_NONE;
@@ -806,8 +796,7 @@ static int quad8_count_preset_write(struct counter_device *counter,
806796
struct quad8 *const priv = counter_priv(counter);
807797
unsigned long irqflags;
808798

809-
/* Only 24-bit values are supported */
810-
if (preset > 0xFFFFFF)
799+
if (preset > LS7267_CNTR_MAX)
811800
return -ERANGE;
812801

813802
spin_lock_irqsave(&priv->lock, irqflags);
@@ -834,8 +823,7 @@ static int quad8_count_ceiling_read(struct counter_device *counter,
834823
*ceiling = priv->preset[count->id];
835824
break;
836825
default:
837-
/* By default 0x1FFFFFF (25 bits unsigned) is maximum count */
838-
*ceiling = 0x1FFFFFF;
826+
*ceiling = LS7267_CNTR_MAX;
839827
break;
840828
}
841829

@@ -850,8 +838,7 @@ static int quad8_count_ceiling_write(struct counter_device *counter,
850838
struct quad8 *const priv = counter_priv(counter);
851839
unsigned long irqflags;
852840

853-
/* Only 24-bit values are supported */
854-
if (ceiling > 0xFFFFFF)
841+
if (ceiling > LS7267_CNTR_MAX)
855842
return -ERANGE;
856843

857844
spin_lock_irqsave(&priv->lock, irqflags);

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

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ static int etm4_enable_hw(struct etmv4_drvdata *drvdata)
472472
if (etm4x_sspcicrn_present(drvdata, i))
473473
etm4x_relaxed_write32(csa, config->ss_pe_cmp[i], TRCSSPCICRn(i));
474474
}
475-
for (i = 0; i < drvdata->nr_addr_cmp; i++) {
475+
for (i = 0; i < drvdata->nr_addr_cmp * 2; i++) {
476476
etm4x_relaxed_write64(csa, config->addr_val[i], TRCACVRn(i));
477477
etm4x_relaxed_write64(csa, config->addr_acc[i], TRCACATRn(i));
478478
}
@@ -1070,25 +1070,21 @@ static bool etm4_init_iomem_access(struct etmv4_drvdata *drvdata,
10701070
struct csdev_access *csa)
10711071
{
10721072
u32 devarch = readl_relaxed(drvdata->base + TRCDEVARCH);
1073-
u32 idr1 = readl_relaxed(drvdata->base + TRCIDR1);
10741073

10751074
/*
10761075
* All ETMs must implement TRCDEVARCH to indicate that
1077-
* the component is an ETMv4. To support any broken
1078-
* implementations we fall back to TRCIDR1 check, which
1079-
* is not really reliable.
1076+
* the component is an ETMv4. Even though TRCIDR1 also
1077+
* contains the information, it is part of the "Trace"
1078+
* register and must be accessed with the OSLK cleared,
1079+
* with MMIO. But we cannot touch the OSLK until we are
1080+
* sure this is an ETM. So rely only on the TRCDEVARCH.
10801081
*/
1081-
if ((devarch & ETM_DEVARCH_ID_MASK) == ETM_DEVARCH_ETMv4x_ARCH) {
1082-
drvdata->arch = etm_devarch_to_arch(devarch);
1083-
} else {
1084-
pr_warn("CPU%d: ETM4x incompatible TRCDEVARCH: %x, falling back to TRCIDR1\n",
1085-
smp_processor_id(), devarch);
1086-
1087-
if (ETM_TRCIDR1_ARCH_MAJOR(idr1) != ETM_TRCIDR1_ARCH_ETMv4)
1088-
return false;
1089-
drvdata->arch = etm_trcidr_to_arch(idr1);
1082+
if ((devarch & ETM_DEVARCH_ID_MASK) != ETM_DEVARCH_ETMv4x_ARCH) {
1083+
pr_warn_once("TRCDEVARCH doesn't match ETMv4 architecture\n");
1084+
return false;
10901085
}
10911086

1087+
drvdata->arch = etm_devarch_to_arch(devarch);
10921088
*csa = CSDEV_ACCESS_IOMEM(drvdata->base);
10931089
return true;
10941090
}

drivers/hwtracing/coresight/coresight-etm4x.h

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -753,14 +753,12 @@
753753
* TRCDEVARCH - CoreSight architected register
754754
* - Bits[15:12] - Major version
755755
* - Bits[19:16] - Minor version
756-
* TRCIDR1 - ETM architected register
757-
* - Bits[11:8] - Major version
758-
* - Bits[7:4] - Minor version
759-
* We must rely on TRCDEVARCH for the version information,
760-
* however we don't want to break the support for potential
761-
* old implementations which might not implement it. Thus
762-
* we fall back to TRCIDR1 if TRCDEVARCH is not implemented
763-
* for memory mapped components.
756+
*
757+
* We must rely only on TRCDEVARCH for the version information. Even though,
758+
* TRCIDR1 also provides the architecture version, it is a "Trace" register
759+
* and as such must be accessed only with Trace power domain ON. This may
760+
* not be available at probe time.
761+
*
764762
* Now to make certain decisions easier based on the version
765763
* we use an internal representation of the version in the
766764
* driver, as follows :
@@ -786,12 +784,6 @@ static inline u8 etm_devarch_to_arch(u32 devarch)
786784
ETM_DEVARCH_REVISION(devarch));
787785
}
788786

789-
static inline u8 etm_trcidr_to_arch(u32 trcidr1)
790-
{
791-
return ETM_ARCH_VERSION(ETM_TRCIDR1_ARCH_MAJOR(trcidr1),
792-
ETM_TRCIDR1_ARCH_MINOR(trcidr1));
793-
}
794-
795787
enum etm_impdef_type {
796788
ETM4_IMPDEF_HISI_CORE_COMMIT,
797789
ETM4_IMPDEF_FEATURE_MAX,

drivers/iio/accel/kionix-kx022a.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -864,7 +864,7 @@ static irqreturn_t kx022a_trigger_handler(int irq, void *p)
864864
if (ret < 0)
865865
goto err_read;
866866

867-
iio_push_to_buffers_with_timestamp(idev, data->buffer, pf->timestamp);
867+
iio_push_to_buffers_with_timestamp(idev, data->buffer, data->timestamp);
868868
err_read:
869869
iio_trigger_notify_done(idev->trig);
870870

drivers/iio/adc/ad7791.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ static const struct ad_sigma_delta_info ad7791_sigma_delta_info = {
253253
.has_registers = true,
254254
.addr_shift = 4,
255255
.read_mask = BIT(3),
256-
.irq_flags = IRQF_TRIGGER_LOW,
256+
.irq_flags = IRQF_TRIGGER_FALLING,
257257
};
258258

259259
static int ad7791_read_raw(struct iio_dev *indio_dev,

drivers/iio/adc/ltc2497.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ struct ltc2497_driverdata {
2828
struct ltc2497core_driverdata common_ddata;
2929
struct i2c_client *client;
3030
u32 recv_size;
31-
u32 sub_lsb;
3231
/*
3332
* DMA (thus cache coherency maintenance) may require the
3433
* transfer buffers to live in their own cache lines.
@@ -65,10 +64,10 @@ static int ltc2497_result_and_measure(struct ltc2497core_driverdata *ddata,
6564
* equivalent to a sign extension.
6665
*/
6766
if (st->recv_size == 3) {
68-
*val = (get_unaligned_be24(st->data.d8) >> st->sub_lsb)
67+
*val = (get_unaligned_be24(st->data.d8) >> 6)
6968
- BIT(ddata->chip_info->resolution + 1);
7069
} else {
71-
*val = (be32_to_cpu(st->data.d32) >> st->sub_lsb)
70+
*val = (be32_to_cpu(st->data.d32) >> 6)
7271
- BIT(ddata->chip_info->resolution + 1);
7372
}
7473

@@ -122,7 +121,6 @@ static int ltc2497_probe(struct i2c_client *client)
122121
st->common_ddata.chip_info = chip_info;
123122

124123
resolution = chip_info->resolution;
125-
st->sub_lsb = 31 - (resolution + 1);
126124
st->recv_size = BITS_TO_BYTES(resolution) + 1;
127125

128126
return ltc2497core_probe(dev, indio_dev);

drivers/iio/adc/max11410.c

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -414,13 +414,17 @@ static int max11410_sample(struct max11410_state *st, int *sample_raw,
414414
if (!ret)
415415
return -ETIMEDOUT;
416416
} else {
417+
int ret2;
418+
417419
/* Wait for status register Conversion Ready flag */
418-
ret = read_poll_timeout(max11410_read_reg, ret,
419-
ret || (val & MAX11410_STATUS_CONV_READY_BIT),
420+
ret = read_poll_timeout(max11410_read_reg, ret2,
421+
ret2 || (val & MAX11410_STATUS_CONV_READY_BIT),
420422
5000, MAX11410_CONVERSION_TIMEOUT_MS * 1000,
421423
true, st, MAX11410_REG_STATUS, &val);
422424
if (ret)
423425
return ret;
426+
if (ret2)
427+
return ret2;
424428
}
425429

426430
/* Read ADC Data */
@@ -851,17 +855,21 @@ static int max11410_init_vref(struct device *dev,
851855

852856
static int max11410_calibrate(struct max11410_state *st, u32 cal_type)
853857
{
854-
int ret, val;
858+
int ret, ret2, val;
855859

856860
ret = max11410_write_reg(st, MAX11410_REG_CAL_START, cal_type);
857861
if (ret)
858862
return ret;
859863

860864
/* Wait for status register Calibration Ready flag */
861-
return read_poll_timeout(max11410_read_reg, ret,
862-
ret || (val & MAX11410_STATUS_CAL_READY_BIT),
863-
50000, MAX11410_CALIB_TIMEOUT_MS * 1000, true,
864-
st, MAX11410_REG_STATUS, &val);
865+
ret = read_poll_timeout(max11410_read_reg, ret2,
866+
ret2 || (val & MAX11410_STATUS_CAL_READY_BIT),
867+
50000, MAX11410_CALIB_TIMEOUT_MS * 1000, true,
868+
st, MAX11410_REG_STATUS, &val);
869+
if (ret)
870+
return ret;
871+
872+
return ret2;
865873
}
866874

867875
static int max11410_self_calibrate(struct max11410_state *st)

drivers/iio/adc/palmas_gpadc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,7 @@ static int palmas_gpadc_probe(struct platform_device *pdev)
639639

640640
static int palmas_gpadc_remove(struct platform_device *pdev)
641641
{
642-
struct iio_dev *indio_dev = dev_to_iio_dev(&pdev->dev);
642+
struct iio_dev *indio_dev = dev_get_drvdata(&pdev->dev);
643643
struct palmas_gpadc *adc = iio_priv(indio_dev);
644644

645645
if (adc->wakeup1_enable || adc->wakeup2_enable)

drivers/iio/adc/qcom-spmi-adc5.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -628,12 +628,20 @@ static int adc5_get_fw_channel_data(struct adc5_chip *adc,
628628
struct fwnode_handle *fwnode,
629629
const struct adc5_data *data)
630630
{
631-
const char *name = fwnode_get_name(fwnode), *channel_name;
631+
const char *channel_name;
632+
char *name;
632633
u32 chan, value, varr[2];
633634
u32 sid = 0;
634635
int ret;
635636
struct device *dev = adc->dev;
636637

638+
name = devm_kasprintf(dev, GFP_KERNEL, "%pfwP", fwnode);
639+
if (!name)
640+
return -ENOMEM;
641+
642+
/* Cut the address part */
643+
name[strchrnul(name, '@') - name] = '\0';
644+
637645
ret = fwnode_property_read_u32(fwnode, "reg", &chan);
638646
if (ret) {
639647
dev_err(dev, "invalid channel number %s\n", name);

drivers/iio/adc/ti-ads7950.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,7 @@ static int ti_ads7950_probe(struct spi_device *spi)
634634
st->chip.label = dev_name(&st->spi->dev);
635635
st->chip.parent = &st->spi->dev;
636636
st->chip.owner = THIS_MODULE;
637+
st->chip.can_sleep = true;
637638
st->chip.base = -1;
638639
st->chip.ngpio = TI_ADS7950_NUM_GPIOS;
639640
st->chip.get_direction = ti_ads7950_get_direction;

0 commit comments

Comments
 (0)