linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: michael.hennerich@analog.com
Cc: linux-iio@vger.kernel.org,
	device-drivers-devel@blackfin.uclinux.org, drivers@analog.com
Subject: Re: [PATCH 2/3] iio: core: Avoid NULL pointer de-ref in case indio_dev->setup_ops are not in use
Date: Wed, 29 Feb 2012 20:15:52 +0000	[thread overview]
Message-ID: <4F4E8778.1030309@kernel.org> (raw)
In-Reply-To: <1329913815-5382-2-git-send-email-michael.hennerich@analog.com>

On 02/22/2012 12:30 PM, michael.hennerich@analog.com wrote:
> From: Michael Hennerich <michael.hennerich@analog.com>
> 
> Drivers may not need setup_ops at all, so let the core supply
> some empty ops.
Makes sense.
> 
> Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
Acked-by: Jonathan Cameron <jic23@kernel.org>
> ---
>  drivers/staging/iio/industrialio-core.c |    6 ++++++
>  1 files changed, 6 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/staging/iio/industrialio-core.c b/drivers/staging/iio/industrialio-core.c
> index 82c9128..6fc1430 100644
> --- a/drivers/staging/iio/industrialio-core.c
> +++ b/drivers/staging/iio/industrialio-core.c
> @@ -800,6 +800,8 @@ static const struct file_operations iio_buffer_fileops = {
>  	.compat_ioctl = iio_ioctl,
>  };
>  
> +static const struct iio_buffer_setup_ops noop_ring_setup_ops;
> +
>  int iio_device_register(struct iio_dev *indio_dev)
>  {
>  	int ret;
> @@ -828,6 +830,10 @@ int iio_device_register(struct iio_dev *indio_dev)
>  	if (indio_dev->modes & INDIO_BUFFER_TRIGGERED)
>  		iio_device_register_trigger_consumer(indio_dev);
>  
> +	if ((indio_dev->modes & INDIO_ALL_BUFFER_MODES) &&
> +		indio_dev->setup_ops == NULL)
> +		indio_dev->setup_ops = &noop_ring_setup_ops;
> +
>  	ret = device_add(&indio_dev->dev);
>  	if (ret < 0)
>  		goto error_unreg_eventset;


  reply	other threads:[~2012-02-29 20:14 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-22 12:30 [PATCH 1/3] iio: core: Introduce debugfs support, add support for direct register access michael.hennerich
2012-02-22 12:30 ` [PATCH 2/3] iio: core: Avoid NULL pointer de-ref in case indio_dev->setup_ops are not in use michael.hennerich
2012-02-29 20:15   ` Jonathan Cameron [this message]
2012-02-22 12:30 ` [PATCH 3/3] iio: Convert platform_drivers to use module_platform_driver michael.hennerich
2012-02-29 20:16   ` Jonathan Cameron
2012-02-29 20:14 ` [PATCH 1/3] iio: core: Introduce debugfs support, add support for direct register access Jonathan Cameron
2012-03-01  9:44   ` Michael Hennerich
  -- strict thread matches above, loose matches on Subject: below --
2012-03-01  9:51 michael.hennerich
2012-03-01  9:51 ` [PATCH 2/3] iio: core: Avoid NULL pointer de-ref in case indio_dev->setup_ops are not in use michael.hennerich

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=4F4E8778.1030309@kernel.org \
    --to=jic23@kernel.org \
    --cc=device-drivers-devel@blackfin.uclinux.org \
    --cc=drivers@analog.com \
    --cc=linux-iio@vger.kernel.org \
    --cc=michael.hennerich@analog.com \
    /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).