From: Marek Vasut <marex@denx.de>
To: Ksenija Stanojevic <ksenija.stanojevic@gmail.com>,
linux-kernel@vger.kernel.org
Cc: lee.jones@linaro.org, dmitry.torokhov@gmail.com,
linux-input@vger.kernel.org, jic23@kernel.org, knaack.h@gmx.de,
lars@metafoo.de, pmeerw@pmeerw.net, linux-iio@vger.kernel.org,
harald@ccbib.org
Subject: Re: [PATCH 2/3] iio: adc: mxs-lradc: Add support for adc driver
Date: Fri, 29 Apr 2016 15:21:13 +0200 [thread overview]
Message-ID: <57235FC9.1090709@denx.de> (raw)
In-Reply-To: <eef892ac7b6e1efa0dcbff50f9b3e8f9a9489fbc.1461930102.git.ksenija.stanojevic@gmail.com>
On 04/29/2016 01:48 PM, Ksenija Stanojevic wrote:
> Add mxs-lradc adc driver.
Commit message could use some improvement ;-)
> Signed-off-by: Ksenija Stanojevic <ksenija.stanojevic@gmail.com>
> ---
> drivers/iio/adc/Kconfig | 37 +-
> drivers/iio/adc/Makefile | 1 +
> drivers/iio/adc/mxs-lradc-adc.c | 832 ++++++++++++++++++++++++++++++++++++++++
> 3 files changed, 858 insertions(+), 12 deletions(-)
> create mode 100644 drivers/iio/adc/mxs-lradc-adc.c
>
> diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig
> index 82c718c..50847b8 100644
> --- a/drivers/iio/adc/Kconfig
> +++ b/drivers/iio/adc/Kconfig
> @@ -233,6 +233,19 @@ config IMX7D_ADC
> This driver can also be built as a module. If so, the module will be
> called imx7d_adc.
>
> +config MXS_LRADC_ADC
> + tristate "Freescale i.MX23/i.MX28 LRADC ADC"
> + depends on MFD_MXS_LRADC
> + select IIO_BUFFER
> + select IIO_TRIGGERED_BUFFER
> + help
> + Say yes here to build support for the ADC functions of the
> + i.MX23/i.MX28 LRADC. This includes general-purpose ADC readings,
> + battery voltage measurement, and die temperature measurement.
> +
> + This driver can also be built as a module. If so, the module will be
> + called mxs-lradc-adc.
> +
> config LP8788_ADC
> tristate "LP8788 ADC driver"
> depends on MFD_LP8788
> @@ -306,18 +319,18 @@ config MEN_Z188_ADC
> called men_z188_adc.
>
> config MXS_LRADC
> - tristate "Freescale i.MX23/i.MX28 LRADC"
> - depends on (ARCH_MXS || COMPILE_TEST) && HAS_IOMEM
> - depends on INPUT
> - select STMP_DEVICE
> - select IIO_BUFFER
> - select IIO_TRIGGERED_BUFFER
> - help
> - Say yes here to build support for i.MX23/i.MX28 LRADC convertor
> - built into these chips.
> -
> - To compile this driver as a module, choose M here: the
> - module will be called mxs-lradc.
> + tristate "Freescale i.MX23/i.MX28 LRADC"
> + depends on (ARCH_MXS || COMPILE_TEST) && HAS_IOMEM
> + depends on INPUT
> + select STMP_DEVICE
> + select IIO_BUFFER
> + select IIO_TRIGGERED_BUFFER
> + help
> + Say yes here to build support for i.MX23/i.MX28 LRADC convertor
> + built into these chips.
> +
> + To compile this driver as a module, choose M here: the
> + module will be called mxs-lradc.
>
> config NAU7802
> tristate "Nuvoton NAU7802 ADC driver"
> diff --git a/drivers/iio/adc/Makefile b/drivers/iio/adc/Makefile
> index 0cb7921..ca7d6aa 100644
> --- a/drivers/iio/adc/Makefile
> +++ b/drivers/iio/adc/Makefile
> @@ -31,6 +31,7 @@ obj-$(CONFIG_MCP320X) += mcp320x.o
> obj-$(CONFIG_MCP3422) += mcp3422.o
> obj-$(CONFIG_MEN_Z188_ADC) += men_z188_adc.o
> obj-$(CONFIG_MXS_LRADC) += mxs-lradc.o
> +obj-$(CONFIG_MXS_LRADC_ADC) += mxs-lradc-adc.o
> obj-$(CONFIG_NAU7802) += nau7802.o
> obj-$(CONFIG_PALMAS_GPADC) += palmas_gpadc.o
> obj-$(CONFIG_QCOM_SPMI_IADC) += qcom-spmi-iadc.o
> diff --git a/drivers/iio/adc/mxs-lradc-adc.c b/drivers/iio/adc/mxs-lradc-adc.c
> new file mode 100644
> index 0000000..793c369
> --- /dev/null
> +++ b/drivers/iio/adc/mxs-lradc-adc.c
[...]
> + if (lradc->soc == IMX28_LRADC)
> + mxs_lradc_reg_clear(
> + lradc,
> + lradc->buffer_vchans << LRADC_CTRL1_LRADC_IRQ_EN_OFFSET,
> + LRADC_CTRL1);
Can you tweak the formatting here ?
if (lradc->soc == IMX28_LRADC) {
mxs_lradc_reg_clear(lradc,
lradc->buffer_vchans << LRADC_CTRL1_LRADC_IRQ_EN_OFFSET,
LRADC_CTRL1);
}
might look at least a bit less odd.
> + mxs_lradc_reg_clear(lradc, lradc->buffer_vchans, LRADC_CTRL0);
> +
> + 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);
> + mxs_lradc_reg_wrt(lradc, chan_value, LRADC_CH(ofs));
> + bitmap_set(&enable, ofs, 1);
> + ofs++;
> + }
> +
> + mxs_lradc_reg_clear(lradc, LRADC_DELAY_TRIGGER_LRADCS_MASK |
> + LRADC_DELAY_KICK, LRADC_DELAY(0));
> + mxs_lradc_reg_clear(lradc, ctrl4_clr, LRADC_CTRL4);
> + mxs_lradc_reg_set(lradc, ctrl4_set, LRADC_CTRL4);
> + mxs_lradc_reg_set(lradc, ctrl1_irq, LRADC_CTRL1);
> + mxs_lradc_reg_set(lradc, enable << LRADC_DELAY_TRIGGER_LRADCS_OFFSET,
> + LRADC_DELAY(0));
> +
> + return 0;
> +
> +err_mem:
> + mutex_unlock(&adc->lock);
> + return ret;
> +}
[...]
> +
> +static int mxs_lradc_adc_buffer_postdisable(struct iio_dev *iio)
> +{
> + struct mxs_lradc_adc *adc = iio_priv(iio);
> + struct mxs_lradc *lradc = adc->lradc;
> +
> + mxs_lradc_reg_clear(lradc, LRADC_DELAY_TRIGGER_LRADCS_MASK |
> + LRADC_DELAY_KICK, LRADC_DELAY(0));
> +
> + mxs_lradc_reg_clear(lradc, lradc->buffer_vchans, LRADC_CTRL0);
> + if (lradc->soc == IMX28_LRADC)
> + mxs_lradc_reg_clear(
> + lradc,
> + lradc->buffer_vchans << LRADC_CTRL1_LRADC_IRQ_EN_OFFSET,
> + LRADC_CTRL1);
Same here, this is horrible :)
> + kfree(adc->buffer);
> + mutex_unlock(&adc->lock);
> +
> + return 0;
> +}
[...]
Looks good otherwise :)
--
Best regards,
Marek Vasut
next prev parent reply other threads:[~2016-04-29 13:21 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-29 11:46 [PATCH 0/3] mxs-lradc: Split driver into MFD Ksenija Stanojevic
2016-04-29 11:46 ` Ksenija Stanojevic
[not found] ` <cover.1461930102.git.ksenija.stanojevic-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-04-29 11:47 ` [PATCH 1/3] mfd: mxs-lradc: Add support for mxs-lradc MFD Ksenija Stanojevic
2016-04-29 11:47 ` Ksenija Stanojevic
[not found] ` <a93050366ed452b147652abfad21a87f4af87bfb.1461930102.git.ksenija.stanojevic-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-04-29 13:15 ` Marek Vasut
2016-04-29 13:15 ` Marek Vasut
2016-04-29 13:43 ` Ksenija Stanojević
2016-04-29 14:12 ` Marek Vasut
2016-04-29 14:12 ` Marek Vasut
2016-04-29 17:19 ` Harald Geyer
2016-04-29 17:19 ` Harald Geyer
2016-05-01 13:06 ` Jonathan Cameron
2016-04-29 11:48 ` [PATCH 2/3] iio: adc: mxs-lradc: Add support for adc driver Ksenija Stanojevic
2016-04-29 13:21 ` Marek Vasut [this message]
[not found] ` <eef892ac7b6e1efa0dcbff50f9b3e8f9a9489fbc.1461930102.git.ksenija.stanojevic-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-05-01 16:38 ` Jonathan Cameron
2016-05-01 16:38 ` Jonathan Cameron
[not found] ` <9fc189a7-bcb0-4b1c-e63c-efbc275eb05f-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2016-05-28 17:49 ` Ksenija Stanojević
2016-05-28 17:49 ` Ksenija Stanojević
2016-05-29 16:46 ` Jonathan Cameron
2016-05-29 16:46 ` Jonathan Cameron
2016-04-29 11:49 ` [PATCH 3/3] input: touchscreen: mxs-lradc: Add support for touchscreen Ksenija Stanojevic
2016-04-29 13:22 ` Marek Vasut
[not found] ` <61fe1da2e8d82921f3222ec939047b6823f695e1.1461930102.git.ksenija.stanojevic-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-04-29 23:36 ` Dmitry Torokhov
2016-04-29 23:36 ` Dmitry Torokhov
2016-04-29 23:57 ` Marek Vasut
2016-04-29 23:57 ` Marek Vasut
[not found] ` <5723F4ED.5060303-ynQEQJNshbs@public.gmane.org>
2016-05-02 16:58 ` Dmitry Torokhov
2016-05-02 16:58 ` Dmitry Torokhov
2016-05-28 17:46 ` Ksenija Stanojević
2016-05-28 17:46 ` Ksenija Stanojević
2016-06-01 18:29 ` Dmitry Torokhov
2016-06-01 18:29 ` Dmitry Torokhov
2016-05-01 16:47 ` Jonathan Cameron
[not found] ` <bad220c7-7f72-55e8-fe41-e3a6ae7d7d2f-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2016-05-28 17:45 ` Ksenija Stanojević
2016-05-28 17:45 ` Ksenija Stanojević
2016-05-29 16:49 ` Jonathan Cameron
[not found] ` <e2e0aa2d-dc26-cd23-1d45-837456104286-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2016-05-29 18:00 ` Ksenija Stanojević
2016-05-29 18:00 ` Ksenija Stanojević
2016-05-29 18:00 ` Ksenija Stanojević
2016-05-29 19:53 ` Jonathan Cameron
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=57235FC9.1090709@denx.de \
--to=marex@denx.de \
--cc=dmitry.torokhov@gmail.com \
--cc=harald@ccbib.org \
--cc=jic23@kernel.org \
--cc=knaack.h@gmx.de \
--cc=ksenija.stanojevic@gmail.com \
--cc=lars@metafoo.de \
--cc=lee.jones@linaro.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pmeerw@pmeerw.net \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.