Skip to content

Commit e967b60

Browse files
miquelraynalLee Jones
authored andcommitted
mfd: ti_am335x_tscadc: Clarify the maximum values for DT entries
Clearly define the maximum open delay and sample delay. Use these definitions in place of a mask (which works because this is the first field in the register) and an open-coded value. While at it reword a little bit the error messages to make them look clearer and similar. Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Lee Jones <lee.jones@linaro.org> Link: https://lore.kernel.org/r/20211015081506.933180-29-miquel.raynal@bootlin.com
1 parent b7cb7bf commit e967b60

2 files changed

Lines changed: 11 additions & 9 deletions

File tree

‎drivers/iio/adc/ti_am335x_adc.c‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ static void tiadc_step_config(struct iio_dev *indio_dev)
126126
chan = adc_dev->channel_line[i];
127127

128128
if (adc_dev->step_avg[i] > STEPCONFIG_AVG_16) {
129-
dev_warn(dev, "chan %d step_avg truncating to %ld\n",
129+
dev_warn(dev, "chan %d: wrong step avg, truncated to %ld\n",
130130
chan, STEPCONFIG_AVG_16);
131131
adc_dev->step_avg[i] = STEPCONFIG_AVG_16;
132132
}
@@ -147,16 +147,16 @@ static void tiadc_step_config(struct iio_dev *indio_dev)
147147
STEPCONFIG_RFP_VREFP |
148148
STEPCONFIG_RFM_VREFN);
149149

150-
if (adc_dev->open_delay[i] > STEPDELAY_OPEN_MASK) {
151-
dev_warn(dev, "chan %d open delay truncating to 0x3FFFF\n",
152-
chan);
153-
adc_dev->open_delay[i] = STEPDELAY_OPEN_MASK;
150+
if (adc_dev->open_delay[i] > STEPCONFIG_MAX_OPENDLY) {
151+
dev_warn(dev, "chan %d: wrong open delay, truncated to 0x%lX\n",
152+
chan, STEPCONFIG_MAX_OPENDLY);
153+
adc_dev->open_delay[i] = STEPCONFIG_MAX_OPENDLY;
154154
}
155155

156-
if (adc_dev->sample_delay[i] > 0xFF) {
157-
dev_warn(dev, "chan %d sample delay truncating to 0xFF\n",
158-
chan);
159-
adc_dev->sample_delay[i] = 0xFF;
156+
if (adc_dev->sample_delay[i] > STEPCONFIG_MAX_SAMPLE) {
157+
dev_warn(dev, "chan %d: wrong sample delay, truncated to 0x%lX\n",
158+
chan, STEPCONFIG_MAX_SAMPLE);
159+
adc_dev->sample_delay[i] = STEPCONFIG_MAX_SAMPLE;
160160
}
161161

162162
tiadc_writel(adc_dev, REG_STEPDELAY(steps),

‎include/linux/mfd/ti_am335x_tscadc.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,9 @@
8484
#define STEPCONFIG_OPENDLY STEPDELAY_OPEN(0x098)
8585
#define STEPDELAY_SAMPLE_MASK GENMASK(31, 24)
8686
#define STEPDELAY_SAMPLE(val) FIELD_PREP(STEPDELAY_SAMPLE_MASK, (val))
87+
#define STEPCONFIG_MAX_OPENDLY GENMASK(17, 0)
8788
#define STEPCONFIG_SAMPLEDLY STEPDELAY_SAMPLE(0)
89+
#define STEPCONFIG_MAX_SAMPLE GENMASK(7, 0)
8890

8991
/* Charge Config */
9092
#define STEPCHARGE_RFP_MASK GENMASK(14, 12)

0 commit comments

Comments
 (0)