All of lore.kernel.org
 help / color / mirror / Atom feed
From: Matthias Kaehlcke <matthias.list-RprLehDfhQ3k1uMJSBkQmQ@public.gmane.org>
To: "Patil, Rachna" <rachna-l0cyMroinI0@public.gmane.org>
Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-input-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-iio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Dmitry Torokhov
	<dmitry.torokhov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	Dmitry Torokhov <dtor-JGs/UdohzUI@public.gmane.org>,
	Jonathan Cameron <jic23-KWPb1pKIrIJaa/9Udqfwiw@public.gmane.org>,
	Samuel Ortiz <sameo-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
Subject: Re: [PATCH 4/5] IIO : ADC: tiadc: Add support of TI's ADC driver
Date: Thu, 23 Aug 2012 21:02:39 +0200	[thread overview]
Message-ID: <20120823190239.GF27787@darwin> (raw)
In-Reply-To: <1345719021-22835-1-git-send-email-rachna-l0cyMroinI0@public.gmane.org>

Hi,

El Thu, Aug 23, 2012 at 04:20:21PM +0530 Patil, Rachna ha dit:

> This patch adds support for TI's ADC driver.
> This is a multifunctional device.
> Analog input lines are provided on which
> voltage measurements can be carried out.
> You can have upto 8 input lines.
> 
> Signed-off-by: Patil, Rachna <rachna-l0cyMroinI0@public.gmane.org>
> ---
>
> diff --git a/drivers/iio/adc/ti_adc.c b/drivers/iio/adc/ti_adc.c
> ...
> +static int __devinit tiadc_probe(struct platform_device *pdev)
> +{
> +	struct iio_dev		*idev;
> +	int			err;
> +	struct adc_device	*adc_dev = NULL;
> +	struct ti_tscadc_dev	*tscadc_dev = pdev->dev.platform_data;
> +	struct mfd_tscadc_board	*board_data;
> +
> +	board_data = (struct mfd_tscadc_board *)tscadc_dev->dev->platform_data;
> +	if (!board_data) {
> +		dev_err(tscadc_dev->dev, "Could not find platform data\n");
> +		return -EINVAL;
> +	}
> +
> +	idev = iio_device_alloc(sizeof(struct adc_device));
> +	if (idev == NULL) {
> +		dev_err(&pdev->dev, "failed to allocate iio device.\n");
> +		err = -ENOMEM;
> +		goto err_ret;
> +	}
> +	adc_dev = iio_priv(idev);
> +
> +	tscadc_dev->adc = adc_dev;
> +	adc_dev->mfd_tscadc = tscadc_dev;
> +	adc_dev->idev = idev;
> +	adc_dev->adc_channels = board_data->adc_init->adc_channels;
> +
> +	idev->dev.parent = &pdev->dev;
> +	idev->name = dev_name(&pdev->dev);
> +	idev->modes = INDIO_DIRECT_MODE;
> +	idev->info = &tiadc_info;
> +
> +	adc_step_config(adc_dev);
> +
> +	err = tiadc_channel_init(idev, adc_dev);
> +	if (err < 0)
> +		goto err_fail;
> +
> +	err = iio_device_register(idev);
> +	if (err)
> +		goto err_free_channels;
> +
> +	dev_info(&pdev->dev, "attached adc driver\n");
> +	platform_set_drvdata(pdev, idev);
> +
> +	return 0;
> +
> +err_free_channels:
> +	tiadc_channel_remove(idev);
> +err_fail:
> +	iio_device_unregister(idev);
> +	iio_device_free(idev);
> +err_ret:
> +	platform_set_drvdata(pdev, NULL);

not necessary, the platform device doesn't exist anymore

> +	iio_device_free(idev);

already done some lines above and could be executed without having
allocated the iio device (when iio_device_alloc() fails)

> +static int __devexit tiadc_remove(struct platform_device *pdev)
> +{
> +	struct ti_tscadc_dev   *tscadc_dev = pdev->dev.platform_data;
> +	struct adc_device	*adc_dev = tscadc_dev->adc;
> +	struct iio_dev		*idev = adc_dev->idev;
> +
> +	iio_device_unregister(idev);
> +	tiadc_channel_remove(idev);
> +
> +	tscadc_dev->adc = NULL;
> +
> +	iio_device_free(idev);
> +	platform_set_drvdata(pdev, NULL);

see above

best regards

-- 
Matthias Kaehlcke
Embedded Linux Developer
Amsterdam

               If sharing a thing in no way diminishes it,
               it is not rightly owned if it is not shared
                                                                 .''`.
    using free software / Debian GNU/Linux | http://debian.org  : :'  :
                                                                `. `'`
gpg --keyserver pgp.mit.edu --recv-keys 47D8E5D4                  `-

WARNING: multiple messages have this Message-ID (diff)
From: Matthias Kaehlcke <matthias.list@kaehlcke.net>
To: "Patil, Rachna" <rachna@ti.com>
Cc: linux-kernel@vger.kernel.org, linux-input@vger.kernel.org,
	linux-iio@vger.kernel.org,
	Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	Dmitry Torokhov <dtor@mail.ru>,
	Jonathan Cameron <jic23@cam.ac.uk>,
	Samuel Ortiz <sameo@linux.intel.com>
Subject: Re: [PATCH 4/5] IIO : ADC: tiadc: Add support of TI's ADC driver
Date: Thu, 23 Aug 2012 21:02:39 +0200	[thread overview]
Message-ID: <20120823190239.GF27787@darwin> (raw)
In-Reply-To: <1345719021-22835-1-git-send-email-rachna@ti.com>

Hi,

El Thu, Aug 23, 2012 at 04:20:21PM +0530 Patil, Rachna ha dit:

> This patch adds support for TI's ADC driver.
> This is a multifunctional device.
> Analog input lines are provided on which
> voltage measurements can be carried out.
> You can have upto 8 input lines.
> 
> Signed-off-by: Patil, Rachna <rachna@ti.com>
> ---
>
> diff --git a/drivers/iio/adc/ti_adc.c b/drivers/iio/adc/ti_adc.c
> ...
> +static int __devinit tiadc_probe(struct platform_device *pdev)
> +{
> +	struct iio_dev		*idev;
> +	int			err;
> +	struct adc_device	*adc_dev = NULL;
> +	struct ti_tscadc_dev	*tscadc_dev = pdev->dev.platform_data;
> +	struct mfd_tscadc_board	*board_data;
> +
> +	board_data = (struct mfd_tscadc_board *)tscadc_dev->dev->platform_data;
> +	if (!board_data) {
> +		dev_err(tscadc_dev->dev, "Could not find platform data\n");
> +		return -EINVAL;
> +	}
> +
> +	idev = iio_device_alloc(sizeof(struct adc_device));
> +	if (idev == NULL) {
> +		dev_err(&pdev->dev, "failed to allocate iio device.\n");
> +		err = -ENOMEM;
> +		goto err_ret;
> +	}
> +	adc_dev = iio_priv(idev);
> +
> +	tscadc_dev->adc = adc_dev;
> +	adc_dev->mfd_tscadc = tscadc_dev;
> +	adc_dev->idev = idev;
> +	adc_dev->adc_channels = board_data->adc_init->adc_channels;
> +
> +	idev->dev.parent = &pdev->dev;
> +	idev->name = dev_name(&pdev->dev);
> +	idev->modes = INDIO_DIRECT_MODE;
> +	idev->info = &tiadc_info;
> +
> +	adc_step_config(adc_dev);
> +
> +	err = tiadc_channel_init(idev, adc_dev);
> +	if (err < 0)
> +		goto err_fail;
> +
> +	err = iio_device_register(idev);
> +	if (err)
> +		goto err_free_channels;
> +
> +	dev_info(&pdev->dev, "attached adc driver\n");
> +	platform_set_drvdata(pdev, idev);
> +
> +	return 0;
> +
> +err_free_channels:
> +	tiadc_channel_remove(idev);
> +err_fail:
> +	iio_device_unregister(idev);
> +	iio_device_free(idev);
> +err_ret:
> +	platform_set_drvdata(pdev, NULL);

not necessary, the platform device doesn't exist anymore

> +	iio_device_free(idev);

already done some lines above and could be executed without having
allocated the iio device (when iio_device_alloc() fails)

> +static int __devexit tiadc_remove(struct platform_device *pdev)
> +{
> +	struct ti_tscadc_dev   *tscadc_dev = pdev->dev.platform_data;
> +	struct adc_device	*adc_dev = tscadc_dev->adc;
> +	struct iio_dev		*idev = adc_dev->idev;
> +
> +	iio_device_unregister(idev);
> +	tiadc_channel_remove(idev);
> +
> +	tscadc_dev->adc = NULL;
> +
> +	iio_device_free(idev);
> +	platform_set_drvdata(pdev, NULL);

see above

best regards

-- 
Matthias Kaehlcke
Embedded Linux Developer
Amsterdam

               If sharing a thing in no way diminishes it,
               it is not rightly owned if it is not shared
                                                                 .''`.
    using free software / Debian GNU/Linux | http://debian.org  : :'  :
                                                                `. `'`
gpg --keyserver pgp.mit.edu --recv-keys 47D8E5D4                  `-

  parent reply	other threads:[~2012-08-23 19:02 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-23 10:50 [PATCH 4/5] IIO : ADC: tiadc: Add support of TI's ADC driver Patil, Rachna
2012-08-23 10:50 ` Patil, Rachna
     [not found] ` <1345719021-22835-1-git-send-email-rachna-l0cyMroinI0@public.gmane.org>
2012-08-23 19:02   ` Matthias Kaehlcke [this message]
2012-08-23 19:02     ` Matthias Kaehlcke
2012-08-28 10:23     ` Patil, Rachna

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=20120823190239.GF27787@darwin \
    --to=matthias.list-rprlehdfhq3k1umjsbkqmq@public.gmane.org \
    --cc=dmitry.torokhov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=dtor-JGs/UdohzUI@public.gmane.org \
    --cc=jic23-KWPb1pKIrIJaa/9Udqfwiw@public.gmane.org \
    --cc=linux-iio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-input-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=rachna-l0cyMroinI0@public.gmane.org \
    --cc=sameo-VuQAYsv1563Yd54FQh9/CA@public.gmane.org \
    /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.