staging/iio/mxs-lradc: cleanup masklength
Subsystems (4)
PATCH 1/2 staging/iio/mxs-lradc: cleanup masklength
We know the exact iio->masklength = LRADC_MAX_TOTAL_CHANS. Let's use it consistently.
--- drivers/staging/iio/adc/mxs-lradc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/staging/iio/adc/mxs-lradc.c +4 -4
@@ -620,7 +620,7 @@ static irqreturn_t mxs_lradc_trigger_handler(int irq, void *p) ((LRADC_DELAY_TIMER_LOOP -1 ) <<LRADC_CH_NUM_SAMPLES_OFFSET );unsigned int i, j =0 ; -for_each_set_bit (i, iio->active_scan_mask, iio->masklength) { +for_each_set_bit (i, iio->active_scan_mask,LRADC_MAX_TOTAL_CHANS ) { lradc->buffer[j] =readl (lradc->base +LRADC_CH (j));writel (chan_value, lradc->base +LRADC_CH (j)); lradc->buffer[j] &=LRADC_CH_VALUE_MASK ;
@@ -775,8 +775,7 @@ static bool mxs_lradc_validate_scan_mask(struct iio_dev *iio, const unsigned long *mask) {struct mxs_lradc *lradc =iio_priv (iio); -const int len = iio->masklength; -const int map_chans =bitmap_weight (mask, len); +const int map_chans =bitmap_weight (mask,LRADC_MAX_TOTAL_CHANS );int rsvd_chans =0 ;unsigned long rsvd_mask =0 ;
@@ -793,7 +792,7 @@ static bool mxs_lradc_validate_scan_mask(struct iio_dev *iio, rsvd_chans++;/* Test for attempts to map channels with special mode of operation. */ -if (bitmap_intersects (mask, &rsvd_mask, len)) +if (bitmap_intersects (mask, &rsvd_mask,LRADC_MAX_TOTAL_CHANS ))return false;/* Test for attempts to map more channels then available slots. */
@@ -969,6 +968,7 @@ static int mxs_lradc_probe(struct platform_device *pdev) iio->modes =INDIO_DIRECT_MODE ; iio->channels = mxs_lradc_chan_spec; iio->num_channels =ARRAY_SIZE (mxs_lradc_chan_spec); + iio->masklength =LRADC_MAX_TOTAL_CHANS ; ret = iio_triggered_buffer_setup(iio, &iio_pollfunc_store_time, &mxs_lradc_trigger_handler,
Signature · 1 line
1.7.10.4
PATCH 2/2 staging/iio/mxs-lradc: fix preenable for multiple buffers
This fixes 'preenable failed: -EINVAL' error when using this driver.
--- drivers/staging/iio/adc/mxs-lradc.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/staging/iio/adc/mxs-lradc.c +2 -3
@@ -690,7 +690,6 @@ static void mxs_lradc_trigger_remove(struct iio_dev *iio)static int mxs_lradc_buffer_preenable (struct iio_dev *iio) {struct mxs_lradc *lradc =iio_priv (iio); -struct iio_buffer *buffer = iio->buffer;int ret =0 , chan, ofs =0 ;unsigned long enable =0 ;uint32_t ctrl4_set =0 ;
@@ -698,7 +697,7 @@ static int mxs_lradc_buffer_preenable(struct iio_dev *iio)uint32_t ctrl1_irq =0 ;const uint32_t chan_value =LRADC_CH_ACCUMULATE | ((LRADC_DELAY_TIMER_LOOP -1 ) <<LRADC_CH_NUM_SAMPLES_OFFSET ); -const int len =bitmap_weight (buffer->scan_mask,LRADC_MAX_TOTAL_CHANS ); +const int len =bitmap_weight (iio->active_scan_mask,LRADC_MAX_TOTAL_CHANS );if (!len)return -EINVAL ;
@@ -725,7 +724,7 @@ static int mxs_lradc_buffer_preenable(struct iio_dev *iio) lradc->base + LRADC_CTRL1 + STMP_OFFSET_REG_CLR);writel (0xff , lradc->base +LRADC_CTRL0 +STMP_OFFSET_REG_CLR ); -for_each_set_bit (chan, buffer->scan_mask,LRADC_MAX_TOTAL_CHANS ) { +for_each_set_bit (chan, iio->active_scan_mask,LRADC_MAX_TOTAL_CHANS ) { ctrl4_set |= chan <<LRADC_CTRL4_LRADCSELECT_OFFSET (ofs); ctrl4_clr |=LRADC_CTRL4_LRADCSELECT_MASK (ofs); ctrl1_irq |=LRADC_CTRL1_LRADC_IRQ_EN (ofs);
Signature · 1 line
1.7.10.4
PATCH 2/2 staging/iio/mxs-lradc: fix preenable for multiple buffers
Quoted 2 lines · Micha? Miros?aw
This fixes 'preenable failed:
-EINVAL' error when using this driver.
For future patches, please cleanly separate out (in a different series) the bug fixes from the cleanups. This one has been applied to the fixes-togreg branch of iio.git wherease the first patch will go through the togreg branch and hit one kernel cycle later.
Applied to the fixes-togreg
Quoted 36 lines
Signed-off-by Micha? Miros?aw <[email protected]>--- drivers/staging/iio/adc/mxs-lradc.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)drivers/staging/iio/adc/mxs-lradc.c +2
-3@@ -690,7 +690,6 @@ static void mxs_lradc_trigger_remove(struct iio_dev *iio)static int mxs_lradc_buffer_preenable (struct iio_dev *iio) {struct mxs_lradc *lradc =iio_priv (iio); -struct iio_buffer *buffer = iio->buffer;int ret =0 , chan, ofs =0 ;unsigned long enable =0 ;uint32_t ctrl4_set =0 ;@@ -698,7 +697,7 @@ static int mxs_lradc_buffer_preenable(struct iio_dev *iio)uint32_t ctrl1_irq =0 ;const uint32_t chan_value =LRADC_CH_ACCUMULATE | ((LRADC_DELAY_TIMER_LOOP -1 ) <<LRADC_CH_NUM_SAMPLES_OFFSET ); -const int len =bitmap_weight (buffer->scan_mask,LRADC_MAX_TOTAL_CHANS ); +const int len =bitmap_weight (iio->active_scan_mask,LRADC_MAX_TOTAL_CHANS );if (!len)return -EINVAL ;@@ -725,7 +724,7 @@ static int mxs_lradc_buffer_preenable(struct iio_dev *iio) lradc->base + LRADC_CTRL1 + STMP_OFFSET_REG_CLR);writel (0xff , lradc->base +LRADC_CTRL0 +STMP_OFFSET_REG_CLR ); -for_each_set_bit (chan, buffer->scan_mask,LRADC_MAX_TOTAL_CHANS ) { +for_each_set_bit (chan, iio->active_scan_mask,LRADC_MAX_TOTAL_CHANS ) { ctrl4_set |= chan <<LRADC_CTRL4_LRADCSELECT_OFFSET (ofs); ctrl4_clr |=LRADC_CTRL4_LRADCSELECT_MASK (ofs); ctrl1_irq |=LRADC_CTRL1_LRADC_IRQ_EN (ofs);
Jonathan Cameron
maintainerPATCH 1/2 staging/iio/mxs-lradc: cleanup masklength
In reply to Michał MirosławQuoted 2 lines · Micha? Miros?aw
We know the exact
iio->masklength=LRADC_MAX_TOTAL_CHANS. Let's use it consistently.
I guess this gives a small improvement in clarity so applied to togreg branch of iio.git.
Thanks,
Quoted 47 lines
Signed-off-by Micha? Miros?aw <[email protected]>--- drivers/staging/iio/adc/mxs-lradc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)drivers/staging/iio/adc/mxs-lradc.c +4
-4@@ -620,7 +620,7 @@ static irqreturn_t mxs_lradc_trigger_handler(int irq, void *p) ((LRADC_DELAY_TIMER_LOOP -1 ) <<LRADC_CH_NUM_SAMPLES_OFFSET );unsigned int i, j =0 ; -for_each_set_bit (i, iio->active_scan_mask, iio->masklength) { +for_each_set_bit (i, iio->active_scan_mask,LRADC_MAX_TOTAL_CHANS ) { lradc->buffer[j] =readl (lradc->base +LRADC_CH (j));writel (chan_value, lradc->base +LRADC_CH (j)); lradc->buffer[j] &=LRADC_CH_VALUE_MASK ;@@ -775,8 +775,7 @@ static bool mxs_lradc_validate_scan_mask(struct iio_dev *iio, const unsigned long *mask) {struct mxs_lradc *lradc =iio_priv (iio); -const int len = iio->masklength; -const int map_chans =bitmap_weight (mask, len); +const int map_chans =bitmap_weight (mask,LRADC_MAX_TOTAL_CHANS );int rsvd_chans =0 ;unsigned long rsvd_mask =0 ;@@ -793,7 +792,7 @@ static bool mxs_lradc_validate_scan_mask(struct iio_dev *iio, rsvd_chans++;/* Test for attempts to map channels with special mode of operation. */ -if (bitmap_intersects (mask, &rsvd_mask, len)) +if (bitmap_intersects (mask, &rsvd_mask,LRADC_MAX_TOTAL_CHANS ))return false;/* Test for attempts to map more channels then available slots. */ @@ -969,6 +968,7 @@ static int mxs_lradc_probe(struct platform_device *pdev) iio->modes =INDIO_DIRECT_MODE ; iio->channels = mxs_lradc_chan_spec; iio->num_channels =ARRAY_SIZE (mxs_lradc_chan_spec); + iio->masklength =LRADC_MAX_TOTAL_CHANS ; ret = iio_triggered_buffer_setup(iio, &iio_pollfunc_store_time, &mxs_lradc_trigger_handler,