mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Alexandre Belloni <alexandre.belloni@free-electrons.com>
To: Jonathan Cameron <^Cc23@kernel.org>
Cc: lars@metafoo.de, Marek Vasut <marex@denx.de>,
	harald@ccbib.org, hector.palacios@digi.com,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
	Alexandre Belloni <alexandre.belloni@free-electrons.com>
Subject: [PATCHv5 4/4] iio: mxs-lradc: convert is_divided to a bitmap
Date: Mon, 23 Dec 2013 18:45:35 +0100	[thread overview]
Message-ID: <1387820735-28031-5-git-send-email-alexandre.belloni@free-electrons.com> (raw)
In-Reply-To: <1387820735-28031-1-git-send-email-alexandre.belloni@free-electrons.com>

mxs_lradc.is_divided was an unsigned long array. Convert it to a bitmap to save
some memory.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 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 a58c6aaa94d3..df71669bb60e 100644
--- a/drivers/staging/iio/adc/mxs-lradc.c
+++ b/drivers/staging/iio/adc/mxs-lradc.c
@@ -211,7 +211,7 @@ struct mxs_lradc {
 
 	const uint32_t		*vref_mv;
 	struct mxs_lradc_scale	scale_avail[LRADC_MAX_TOTAL_CHANS][2];
-	unsigned int		is_divided[LRADC_MAX_TOTAL_CHANS];
+	unsigned long		is_divided;
 
 	/*
 	 * Touchscreen LRADC channels receives a private slot in the CTRL4
@@ -920,7 +920,7 @@ static int mxs_lradc_read_raw(struct iio_dev *iio_dev,
 
 		*val = lradc->vref_mv[chan->channel];
 		*val2 = chan->scan_type.realbits -
-			lradc->is_divided[chan->channel];
+			test_bit(chan->channel, &lradc->is_divided);
 		return IIO_VAL_FRACTIONAL_LOG2;
 
 	case IIO_CHAN_INFO_OFFSET:
@@ -965,14 +965,14 @@ static int mxs_lradc_write_raw(struct iio_dev *iio_dev,
 			/* divider by two disabled */
 			writel(1 << LRADC_CTRL2_DIVIDE_BY_TWO_OFFSET,
 			       lradc->base + LRADC_CTRL2 + STMP_OFFSET_REG_CLR);
-			lradc->is_divided[chan->channel] = 0;
+			clear_bit(chan->channel, &lradc->is_divided);
 			ret = 0;
 		} else if (val == scale_avail[MXS_LRADC_DIV_ENABLED].integer &&
 			   val2 == scale_avail[MXS_LRADC_DIV_ENABLED].nano) {
 			/* divider by two enabled */
 			writel(1 << LRADC_CTRL2_DIVIDE_BY_TWO_OFFSET,
 			       lradc->base + LRADC_CTRL2 + STMP_OFFSET_REG_SET);
-			lradc->is_divided[chan->channel] = 1;
+			set_bit(chan->channel, &lradc->is_divided);
 			ret = 0;
 		}
 
-- 
1.8.3.2


      parent reply	other threads:[~2013-12-23 17:46 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-23 17:45 [PATCHv5 0/4] iio: mxs-lradc: add support to optional divider_by_two Alexandre Belloni
2013-12-23 17:45 ` [PATCHv5 1/4] iio: mxs-lradc: add scale attribute to channels Alexandre Belloni
2013-12-23 17:45 ` [PATCHv5 2/4] iio: mxs-lradc: add scale_available file " Alexandre Belloni
2013-12-23 17:45 ` [PATCHv5 3/4] iio: mxs-lradc: add write_raw function to modify scale Alexandre Belloni
2013-12-23 17:45 ` Alexandre Belloni [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1387820735-28031-5-git-send-email-alexandre.belloni@free-electrons.com \
    --to=alexandre.belloni@free-electrons.com \
    --cc=^Cc23@kernel.org \
    --cc=harald@ccbib.org \
    --cc=hector.palacios@digi.com \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marex@denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®