From patchwork Sat May 4 13:19:35 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= X-Patchwork-Id: 2520601 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) by patchwork2.kernel.org (Postfix) with ESMTP id 9FCE5DF25A for ; Sat, 4 May 2013 13:21:04 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UYcOC-0006Ag-Gb; Sat, 04 May 2013 13:20:36 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UYcO0-0007em-EY; Sat, 04 May 2013 13:20:24 +0000 Received: from rere6.qmqm.pl ([2001:6a0:181::1] helo=rere.qmqm.pl) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UYcNi-0007cN-F4 for linux-arm-kernel@lists.infradead.org; Sat, 04 May 2013 13:20:07 +0000 Received: by rere.qmqm.pl (Postfix, from userid 1000) id 770F36084; Sat, 4 May 2013 15:19:35 +0200 (CEST) Message-Id: <6bb527db65fb20f60bb95814bff3abc513733a7c.1367671597.git.mirq-linux@rere.qmqm.pl> From: =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= Subject: [PATCH 1/2] staging/iio/mxs-lradc: cleanup masklength MIME-Version: 1.0 To: linux-iio@vger.kernel.org Date: Sat, 4 May 2013 15:19:35 +0200 (CEST) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130504_092006_948404_B2C2D63B X-CRM114-Status: UNSURE ( 8.26 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -4.4 (----) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-4.4 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record -2.5 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Greg Kroah-Hartman , Shawn Guo , Jonathan Cameron , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org We know the exact iio->masklength = LRADC_MAX_TOTAL_CHANS. Let's use it consistently. Signed-off-by: Micha? Miros?aw --- drivers/staging/iio/adc/mxs-lradc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/iio/adc/mxs-lradc.c b/drivers/staging/iio/adc/mxs-lradc.c index 2856b8f..03299ea 100644 --- a/drivers/staging/iio/adc/mxs-lradc.c +++ b/drivers/staging/iio/adc/mxs-lradc.c @@ -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,