linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Ian Abbott <abbotti@mev.co.uk>
Cc: devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] staging: comedi: comedi_isadma: Use a non-NULL device for DMA API
Date: Thu, 25 Apr 2019 19:13:51 +0200	[thread overview]
Message-ID: <20190425171351.GB11105@kroah.com> (raw)
In-Reply-To: <20190425162644.21947-1-abbotti@mev.co.uk>

On Thu, Apr 25, 2019 at 05:26:44PM +0100, Ian Abbott wrote:
> The "comedi_isadma" module calls `dma_alloc_coherent()` and
> `dma_free_coherent()` with a NULL device pointer which is no longer
> allowed.  If the `hw_dev` member of the `struct comedi_device` has been
> set to a valid device, that can be used instead.  Unfortunately, all the
> current users of the "comedi_isadma" module leave the `hw_dev` member
> set to NULL.  In that case, use a static dummy fallback device structure
> with the coherent DMA mask set to the ISA bus limit of 16MB.
> 
> Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
> ---
>  drivers/staging/comedi/drivers/comedi_isadma.c | 15 +++++++++++++--
>  drivers/staging/comedi/drivers/comedi_isadma.h |  3 +++
>  2 files changed, 16 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/comedi/drivers/comedi_isadma.c b/drivers/staging/comedi/drivers/comedi_isadma.c
> index b77dc8d5d3ff..8929952516a1 100644
> --- a/drivers/staging/comedi/drivers/comedi_isadma.c
> +++ b/drivers/staging/comedi/drivers/comedi_isadma.c
> @@ -14,6 +14,16 @@
>  
>  #include "comedi_isadma.h"
>  
> +/*
> + * Fallback device used when hardware device is NULL.
> + * This can be removed after drivers have been converted to use isa_driver.
> + */
> +static struct device fallback_dev = {
> +	.init_name = "comedi_isadma fallback device",
> +	.coherent_dma_mask = DMA_BIT_MASK(24),
> +	.dma_mask = &fallback_dev.coherent_dma_mask,
> +};

Ick, no, static struct device are a very bad idea as this is a reference
counted structure and making it static can cause odd problems.

Why not just create a "real" one?  Or better yet, use the real device
for the comedi device as all of these drivers should have one now.

thanks,

greg k-h

  reply	other threads:[~2019-04-25 17:13 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-25 16:26 [PATCH] staging: comedi: comedi_isadma: Use a non-NULL device for DMA API Ian Abbott
2019-04-25 17:13 ` Greg Kroah-Hartman [this message]
2019-04-26  9:41   ` Ian Abbott
2019-04-27 13:00     ` Greg Kroah-Hartman
2019-04-26 13:54 ` [PATCH v2] " Ian Abbott

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=20190425171351.GB11105@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=abbotti@mev.co.uk \
    --cc=devel@driverdev.osuosl.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).