From: Viresh Kumar <viresh.kumar@st.com>
To: Stefan Roese <sr@denx.de>
Cc: "linux-iio@vger.kernel.org" <linux-iio@vger.kernel.org>,
"devicetree-discuss@ozlabs.org" <devicetree-discuss@ozlabs.org>,
spear-devel <spear-devel@list.st.com>,
Jonathan Cameron <jic23@cam.ac.uk>
Subject: Re: [PATCH] staging:iio:adc: Add SPEAr ADC driver
Date: Thu, 12 Apr 2012 11:42:02 +0530 [thread overview]
Message-ID: <4F867232.3070509@st.com> (raw)
In-Reply-To: <1334150388-23296-1-git-send-email-sr@denx.de>
On 4/11/2012 6:49 PM, Stefan Roese wrote:
> +static int __devinit spear_adc_probe(struct platform_device *pdev)
> +{
> + struct device_node *np = pdev->dev.of_node;
> + struct spear_adc_info *info;
> + struct resource *res;
> + int retval = -ENODEV;
> + struct iio_dev *iodev = NULL;
> + int irq;
> +
> + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> + if (!res) {
> + dev_err(&pdev->dev, "failed to get platform I/O memory\n");
> + retval = -EBUSY;
> + goto errout1;
> + }
> +
> + iodev = iio_allocate_device(sizeof(struct spear_adc_info));
> + if (!iodev) {
> + dev_err(&pdev->dev, "failed allocating iio device\n");
> + retval = -ENOMEM;
> + goto errout1;
> + }
> +
> + info = iio_priv(iodev);
> + info->np = np;
> +
> + /*
> + * SPEAr600 has a different register layout than other SPEAr SoC's
> + * (e.g. SPEAr3xx). Let's provide two register base addresses
> + * to support multi-arch kernels.
> + */
> + info->adc_base_spear6xx = ioremap(res->start, resource_size(res));
> + if (!info->adc_base_spear6xx) {
> + dev_err(&pdev->dev, "failed mapping memory\n");
> + retval = -EBUSY;
> + goto errout2;
> + }
This must be a DT only driver and so you can use of_iomap() instead of
ioremap() and platform_get_resource()
> + info->adc_base_spear3xx =
> + (struct adc_regs_spear3xx *)info->adc_base_spear6xx;
> +
> + info->clk = clk_get(&pdev->dev, NULL);
> + if (IS_ERR(info->clk)) {
> + dev_err(&pdev->dev, "failed getting clock\n");
> + goto errout3;
> + }
patch for devm_* variant of clk is also there.
> + clk_enable(info->clk);
clk_prepare() is required now, before enable.
> +
> + irq = platform_get_irq(pdev, 0);
> + if ((irq < 0) || (irq >= NR_IRQS)) {
> + dev_err(&pdev->dev, "failed getting interrupt resource\n");
> + retval = -EINVAL;
> + goto errout4;
> + }
> +
> + retval = request_irq(irq, spear_adc_isr, 0, MOD_NAME, info);
> + if (retval < 0) {
> + dev_err(&pdev->dev, "failed requesting interrupt\n");
> + goto errout4;
> + }
> +
can use devm_* variants wherever possible.
--
viresh
WARNING: multiple messages have this Message-ID (diff)
From: Viresh Kumar <viresh.kumar-qxv4g6HH51o@public.gmane.org>
To: Stefan Roese <sr-ynQEQJNshbs@public.gmane.org>
Cc: "linux-iio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<linux-iio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
"devicetree-discuss-mnsaURCQ41sdnm+yROfE0A@public.gmane.org"
<devicetree-discuss-mnsaURCQ41sdnm+yROfE0A@public.gmane.org>,
spear-devel <spear-devel-nkJGhpqTU55BDgjK7y7TUQ@public.gmane.org>,
Jonathan Cameron <jic23-KWPb1pKIrIJaa/9Udqfwiw@public.gmane.org>
Subject: Re: [PATCH] staging:iio:adc: Add SPEAr ADC driver
Date: Thu, 12 Apr 2012 11:42:02 +0530 [thread overview]
Message-ID: <4F867232.3070509@st.com> (raw)
In-Reply-To: <1334150388-23296-1-git-send-email-sr-ynQEQJNshbs@public.gmane.org>
On 4/11/2012 6:49 PM, Stefan Roese wrote:
> +static int __devinit spear_adc_probe(struct platform_device *pdev)
> +{
> + struct device_node *np = pdev->dev.of_node;
> + struct spear_adc_info *info;
> + struct resource *res;
> + int retval = -ENODEV;
> + struct iio_dev *iodev = NULL;
> + int irq;
> +
> + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> + if (!res) {
> + dev_err(&pdev->dev, "failed to get platform I/O memory\n");
> + retval = -EBUSY;
> + goto errout1;
> + }
> +
> + iodev = iio_allocate_device(sizeof(struct spear_adc_info));
> + if (!iodev) {
> + dev_err(&pdev->dev, "failed allocating iio device\n");
> + retval = -ENOMEM;
> + goto errout1;
> + }
> +
> + info = iio_priv(iodev);
> + info->np = np;
> +
> + /*
> + * SPEAr600 has a different register layout than other SPEAr SoC's
> + * (e.g. SPEAr3xx). Let's provide two register base addresses
> + * to support multi-arch kernels.
> + */
> + info->adc_base_spear6xx = ioremap(res->start, resource_size(res));
> + if (!info->adc_base_spear6xx) {
> + dev_err(&pdev->dev, "failed mapping memory\n");
> + retval = -EBUSY;
> + goto errout2;
> + }
This must be a DT only driver and so you can use of_iomap() instead of
ioremap() and platform_get_resource()
> + info->adc_base_spear3xx =
> + (struct adc_regs_spear3xx *)info->adc_base_spear6xx;
> +
> + info->clk = clk_get(&pdev->dev, NULL);
> + if (IS_ERR(info->clk)) {
> + dev_err(&pdev->dev, "failed getting clock\n");
> + goto errout3;
> + }
patch for devm_* variant of clk is also there.
> + clk_enable(info->clk);
clk_prepare() is required now, before enable.
> +
> + irq = platform_get_irq(pdev, 0);
> + if ((irq < 0) || (irq >= NR_IRQS)) {
> + dev_err(&pdev->dev, "failed getting interrupt resource\n");
> + retval = -EINVAL;
> + goto errout4;
> + }
> +
> + retval = request_irq(irq, spear_adc_isr, 0, MOD_NAME, info);
> + if (retval < 0) {
> + dev_err(&pdev->dev, "failed requesting interrupt\n");
> + goto errout4;
> + }
> +
can use devm_* variants wherever possible.
--
viresh
next prev parent reply other threads:[~2012-04-12 6:12 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-11 13:19 [PATCH] staging:iio:adc: Add SPEAr ADC driver Stefan Roese
2012-04-11 13:19 ` Stefan Roese
2012-04-11 13:40 ` Jonathan Cameron
2012-04-11 13:40 ` Jonathan Cameron
2012-04-12 6:01 ` Stefan Roese
2012-04-12 6:01 ` Stefan Roese
2012-04-12 6:12 ` Viresh Kumar [this message]
2012-04-12 6:12 ` Viresh Kumar
2012-04-12 7:03 ` Stefan Roese
2012-04-12 7:03 ` Stefan Roese
2012-04-12 7:41 ` Viresh Kumar
2012-04-12 7:41 ` Viresh Kumar
2012-04-12 8:15 ` Stefan Roese
2012-04-12 8:15 ` Stefan Roese
2012-04-12 8:21 ` Viresh Kumar
2012-04-12 8:21 ` Viresh Kumar
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=4F867232.3070509@st.com \
--to=viresh.kumar@st.com \
--cc=devicetree-discuss@ozlabs.org \
--cc=jic23@cam.ac.uk \
--cc=linux-iio@vger.kernel.org \
--cc=spear-devel@list.st.com \
--cc=sr@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 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.