public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Samuel Ortiz <sameo@linux.intel.com>
To: Peter Ujfalusi <peter.ujfalusi@nokia.com>
Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org,
	linux-omap@vger.kernel.org, tony@atomide.com,
	broonie@opensource.wolfsonmicro.com
Subject: Re: [PATCH 1/4] MFD: twl4030: add twl4030_codec MFD as a new child to the core
Date: Thu, 22 Oct 2009 01:13:11 +0200	[thread overview]
Message-ID: <20091021231311.GF17796@sortiz.org> (raw)
In-Reply-To: <1255956140-4829-2-git-send-email-peter.ujfalusi@nokia.com>

Hi Peter,

On Mon, Oct 19, 2009 at 03:42:17PM +0300, Peter Ujfalusi wrote:
> New MFD child to twl4030 MFD device.
> This MFD device will be used by the drivers, which needs resources
> from the twl4030 codec like audio and vibra.
> 
> The platform specific configuration data is passed along to the
> child drivers (audio, vibra).
Some comments on your code:

> +config TWL4030_CODEC
> +	bool "Support codec part of the TWL4030 family chips"
> +	depends on TWL4030_CORE
> +	help
> +	  Say yes here if you want to use the codec resources on the
> +	  TWL4030 family chips. The codec in TWL4030 provides the audio
> +	  functionality and also has the vibrator controls.
> +
> +	  This driver provides MFD device to be used for drivers, which needs
> +	  access to the codec part, the board-specific data is passed from this
> +	  driver to the childs as platform data with the board specific
> +	  configuration.
> +
As Mark noticed already, you dont really want users to explicitely select this
obscure mfd driver to get their audio and vibre driver selectable. It should
be the other way around, and I think you already agreed with that.


> +static struct device *
> +twl4030_codec_new_child(const char *name, void *pdata, unsigned pdata_len)
> +{
> +	struct platform_device	*pdev;
> +	int			status = 0;
> +
> +	pdev = platform_device_alloc(name, -1);
> +	if (!pdev) {
> +		dev_dbg(&twl4030_codec_dev->dev, "can't alloc dev (%s)\n",
> +									name);
> +		return ERR_PTR(-ENOMEM);
> +	}
> +	pdev->dev.parent = &twl4030_codec_dev->dev;
> +
> +	if (pdata) {
> +		status = platform_device_add_data(pdev, pdata, pdata_len);
> +		if (status < 0) {
> +			dev_dbg(&pdev->dev, "can't add platform_data\n");
> +			goto err;
> +		}
> +	}
> +	status = platform_device_add(pdev);
> +	if (status < 0) {
> +		dev_dbg(&pdev->dev, "Adding platform device failed\n");
> +		goto err;
> +	}
> +
> +	return &pdev->dev;
> +err:
> +	platform_device_put(pdev);
> +	dev_err(&twl4030_codec_dev->dev, "can't add %s dev\n", name);
> +	return ERR_PTR(status);
> +}
This could really use the mfd-core API, and avoid duplicating code.
You just would have to define a couple cells, and call mfd_add_devices on
them.


> +static int __devexit twl4030_codec_remove(struct platform_device *pdev)
> +{
> +	struct twl4030_codec *codec = platform_get_drvdata(pdev);
> +
> +	platform_set_drvdata(pdev, NULL);
> +	kfree(codec);
> +	twl4030_codec_dev = NULL;
> +
> +	return 0;
> +}
I think you're missing a platform_device_unregister() here (or an
mfd_remove_devices() if you're going to switch to the mfd-core API)

Cheers,
Samuel.

-- 
Intel Open Source Technology Centre
http://oss.intel.com/

  parent reply	other threads:[~2009-10-21 23:11 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-19 12:42 [PATCH 0/4] twl4030 codec as MFD device Peter Ujfalusi
2009-10-19 12:42 ` [PATCH 1/4] MFD: twl4030: add twl4030_codec MFD as a new child to the core Peter Ujfalusi
2009-10-19 12:42   ` [PATCH 2/4] OMAP: Platform support for twl4030_codec MFD Peter Ujfalusi
2009-10-19 12:42     ` [PATCH 3/4] ASoC: TWL4030: Only update the needed bits in *set_dai_sysclk Peter Ujfalusi
2009-10-19 12:42       ` [PATCH 4/4] ASoC: TWL4030: Driver registration via twl4030_codec MFD Peter Ujfalusi
2009-10-20 10:25         ` Mark Brown
2009-10-20 11:30           ` Peter Ujfalusi
2009-10-20 11:51             ` Mark Brown
2009-10-20 12:01               ` Peter Ujfalusi
2009-10-19 12:55       ` [PATCH 3/4] ASoC: TWL4030: Only update the needed bits in *set_dai_sysclk Mark Brown
2009-10-19 12:59         ` Peter Ujfalusi
2009-10-20 19:01     ` [PATCH 2/4] OMAP: Platform support for twl4030_codec MFD Tony Lindgren
2009-10-20 10:03   ` [PATCH 1/4] MFD: twl4030: add twl4030_codec MFD as a new child to the core Mark Brown
2009-10-20 11:16     ` [alsa-devel] " Peter Ujfalusi
2009-10-21 23:13   ` Samuel Ortiz [this message]
2009-10-22  6:04     ` Peter Ujfalusi
2009-10-22  7:57       ` Samuel Ortiz
2009-10-22 10:55         ` Mark Brown
2009-10-22 11:02           ` Peter Ujfalusi
2009-10-21  8:56 ` [PATCH 0/4] twl4030 codec as MFD device Peter Ujfalusi

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=20091021231311.GF17796@sortiz.org \
    --to=sameo@linux.intel.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@opensource.wolfsonmicro.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=peter.ujfalusi@nokia.com \
    --cc=tony@atomide.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