All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Jander <david.jander@protonic.nl>
To: alsa-devel@alsa-project.org, Jon Smirl <jonsmirl@gmail.com>
Cc: Mark Brown <broonie@opensource.wolfsonmicro.com>,
	Liam Girdwood <lrg@ti.com>
Subject: ASoC driver parts probing order (MPC5200/MPC5121)
Date: Thu, 20 Oct 2011 12:23:17 +0200	[thread overview]
Message-ID: <20111020122317.6c705289@archvile> (raw)


Hi all,

I am writing a AC97 ASoC driver for the MPC5121e SoC from Freescale. This SoC
has almost the same PSC (Programmable Serial Controllers) as the MPC5200B, for
which there already is an AC97 driver: sound/soc/fsl/mpc5200-ac97.c, so I'd
like to extend that one to also support the MPC5121e.
This driver is supposed to work together with a second part, implementing the
actual PCM driver: sound/soc/fsl/mpc5200_dma.c.
Both drivers register themselves via platform_driver_register() in a regular
module init function.
The problem is, they do share the same driver data struct!
So psc_ac97_of_probe() starts off calling 

	psc_dma = dev_get_drvdata(&op->dev);

right ahead and accessing it without checking. The DMA part of the driver does
indeed create this struct psc_dma and calls dev_set_drvdata() on it at the end
of the probe function. So obviously, it is supposed that the DMA driver
somehow gets probed before the PSC driver, but I can't see where this is
enforced. AFAIK, the order is fairly random, so it could be the other way
around.... and indeed, in my case it is.
Unfortunately I don't have MPC5200 hardware with AC97 to test this out, but
only a MPC5121e based board. If I mimic this on the MPC5121e, it won't work,
because the PSC driver gets probed first and obviously crashes with a
NULL-pointer dereference in the next line of code!

If this is supposed to be broken, I'd like to fix it of course, but:

1.- I can't test it on a MPC5200B, so therefor I need help.
2.- Simply turning the dev_get/set_drvdata and chip initialization order
around does work in my case, but doesn't seem a robust solution to me. Any
idea how this should be handled?

Best regards,

-- 
David Jander
Protonic Holland.

             reply	other threads:[~2011-10-20 10:23 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-20 10:23 David Jander [this message]
2011-10-20 10:59 ` ASoC driver parts probing order (MPC5200/MPC5121) Wolfram Sang
2011-10-20 11:37   ` David Jander
2011-10-20 12:13     ` Wolfram Sang
2011-10-20 12:27       ` David Jander
2011-10-20 12:35 ` Mark Brown
2011-10-20 13:26   ` David Jander

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=20111020122317.6c705289@archvile \
    --to=david.jander@protonic.nl \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@opensource.wolfsonmicro.com \
    --cc=jonsmirl@gmail.com \
    --cc=lrg@ti.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 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.