linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Maxime Ripard <maxime.ripard@free-electrons.com>
To: jic23@cam.ac.uk
Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
	guenter.roeck@ericsson.com, khali@linux-fr.org,
	dmitry.torokhov@gmail.com, broonie@opensource.wolfsonmicro.com,
	gregkh@suse.de, alan@lxorguk.ukuu.org.uk, arnd@arndb.de,
	linus.walleij@linaro.org, lars@metafoo.de
Subject: Re: [PATCH 1/6] IIO: Core sysfs only support.
Date: Wed, 01 Feb 2012 16:20:47 +0100	[thread overview]
Message-ID: <4F29584F.1060503@free-electrons.com> (raw)
In-Reply-To: <1320677563-18378-2-git-send-email-jic23@cam.ac.uk>

Hi,
I know that this patchset is probably a bit outdated but still...

On 07/11/2011 15:52, jic23@cam.ac.uk wrote:
> From: Jonathan Cameron <jic23@cam.ac.uk>
> 
> Add support for simple sysfs only interfaces.
> 
> Bulk of patch is concerned with taking struct iio_chan_spec
> arrays and generating all the relevant interfaces from them.
> 
> Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
First, you can add my
Tested-by: Maxime Ripard <maxime.ripard@free-electrons.com>

I have encountered a bug during my tests though, see below

> +struct iio_dev *iio_device_allocate(int sizeof_priv)
> +{
> +	struct iio_dev *dev;
> +	size_t alloc_size;
> +
> +	alloc_size = sizeof(struct iio_dev);
> +	if (sizeof_priv) {
> +		alloc_size = ALIGN(alloc_size, IIO_ALIGN);
> +		alloc_size += sizeof_priv;
> +	}
> +	/* ensure cacheline alignment of whole construct */
> +	alloc_size += IIO_ALIGN - 1;
> +
> +	dev = kzalloc(alloc_size, GFP_KERNEL);
> +
> +	if (dev) {
> +		dev->dev.groups = dev->groups;
> +		dev->dev.type = &iio_dev_type;
> +		dev->dev.bus = &iio_bus_type;
> +		device_initialize(&dev->dev);
> +		dev_set_drvdata(&dev->dev, (void *)dev);
> +		mutex_init(&dev->mlock);
> +	}
> +
> +	return dev;
> +}
> +EXPORT_SYMBOL_GPL(iio_device_allocate);
> +
> +void iio_device_free(struct iio_dev *dev)
> +{
> +	if (dev)
> +		iio_put_device(dev);
> +}
> +EXPORT_SYMBOL_GPL(iio_device_free);

Here, the iio_put_device is called in free, but get_device is never
called, but seem to be called in iio_device_register, which, if you ever
encounter an error in the probe function, you will never have called the
iio_device_register function, before calling the iio_device_free
function, which leads to a segfault.

Maxime

-- 
Maxime Ripard, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com

  parent reply	other threads:[~2012-02-01 15:21 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-07 14:52 [PATCH 0/6 V2] IIO: Out of staging step 1: The core jic23
2011-11-07 14:52 ` [PATCH 1/6] IIO: Core sysfs only support jic23
2011-11-11 10:40   ` Michael Hennerich
2012-02-01 15:20   ` Maxime Ripard [this message]
2011-11-07 14:52 ` [PATCH 2/6] IIO:ADC: max1363 initial import jic23
2011-11-07 14:52 ` [PATCH 3/6] IIO:ADC:ad799x " jic23
2011-11-08 13:07   ` Lars-Peter Clausen
2011-11-08 13:35     ` Jonathan Cameron
2011-11-07 14:52 ` [PATCH 4/6] IIO:light:tsl2563 initial move out of staging jic23
2011-11-07 14:52 ` [PATCH 5/6] IIO:imu:adis16400 partial move from staging jic23
2011-11-11 10:41   ` Michael Hennerich
2011-11-07 14:52 ` [PATCH 6/6] IIO: ABI documetation jic23
2011-11-11 10:41   ` Michael Hennerich
2011-11-08 13:32 ` [PATCH 0/6 V2] IIO: Out of staging step 1: The core Lars-Peter Clausen
2011-11-08 14:23   ` Jonathan Cameron
2011-11-08 14:53     ` Lars-Peter Clausen
2011-11-08 15:29       ` Jonathan Cameron
  -- strict thread matches above, loose matches on Subject: below --
2011-10-17 13:16 [PATCH 0/6] " Jonathan Cameron
2011-10-17 13:16 ` [PATCH 1/6] IIO: Core sysfs only support Jonathan Cameron
2011-10-17 13:42   ` Alexander Stein
2011-10-17 13:48     ` Jonathan Cameron
2011-10-17 16:27   ` 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=4F29584F.1060503@free-electrons.com \
    --to=maxime.ripard@free-electrons.com \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=arnd@arndb.de \
    --cc=broonie@opensource.wolfsonmicro.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=gregkh@suse.de \
    --cc=guenter.roeck@ericsson.com \
    --cc=jic23@cam.ac.uk \
    --cc=khali@linux-fr.org \
    --cc=lars@metafoo.de \
    --cc=linus.walleij@linaro.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).