Patchwork [5/7] ASoC: fsl: convert pcm030-audio-fabric to a platform-driver

login
register
mail settings
Submitter Eric Millbrandt
Date Sept. 13, 2012, 9:43 p.m.
Message ID <1347572596-37540-6-git-send-email-emillbrandt@dekaresearch.com>
Download mbox | patch
Permalink /patch/183745/
State Superseded
Delegated to: Anatolij Gustschin
Headers show

Comments

Eric Millbrandt - Sept. 13, 2012, 9:43 p.m.
This patch converts the pcm030-audio-fabric driver to a platform-driver and
adds a remove function.

Signed-off-by: Eric Millbrandt <emillbrandt@dekaresearch.com>
Mark Brown - Sept. 19, 2012, 3:03 a.m.
On Thu, Sep 13, 2012 at 05:43:14PM -0400, Eric Millbrandt wrote:

> +static int __devexit pcm030_fabric_remove(struct platform_device *op)
> +{
> +	struct platform_device *pdev = platform_get_drvdata(op);
> +
> +	platform_device_unregister(pdev);
> +
> +	return 0;
> +}

This seems really confused...  why is a platform device registering
another platform device?  Do you mean to convert to
snd_soc_register_card()?
Eric Millbrandt - Sept. 19, 2012, 2:35 p.m.
On 2012-09-18 Mark Brown wrote:
> On Thu, Sep 13, 2012 at 05:43:14PM -0400, Eric Millbrandt wrote:
>
>> +static int __devexit pcm030_fabric_remove(struct platform_device *op)
>> +{ + struct platform_device *pdev = platform_get_drvdata(op); +
>> +    platform_device_unregister(pdev); + +   return 0; +}
>
> This seems really confused...  why is a platform device registering
> another platform device?  Do you mean to convert to
> snd_soc_register_card()?
>
That was an artifact of me splitting the changes to pcm030-audio-fabric.c
into multiple patches.  I changed the driver to a platform device in this
patch and converted to snd_soc_register_card() in the next patch.  I can
merge the two patches back together if you think that is cleaner and
easier to understand.

Thanks
Eric


-DISCLAIMER: an automatically appended disclaimer may follow. By posting-
-to a public e-mail mailing list I hereby grant permission to distribute-
-and copy this message.-

This e-mail and the information, including any attachments, it contains are intended to be a confidential communication only to the person or entity to whom it is addressed and may contain information that is privileged. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please immediately notify the sender and destroy the original message.

Thank you.

Please consider the environment before printing this email.
Mark Brown - Sept. 19, 2012, 8:46 p.m.
On Wed, Sep 19, 2012 at 10:35:45AM -0400, Eric Millbrandt wrote:

> That was an artifact of me splitting the changes to pcm030-audio-fabric.c
> into multiple patches.  I changed the driver to a platform device in this
> patch and converted to snd_soc_register_card() in the next patch.  I can
> merge the two patches back together if you think that is cleaner and
> easier to understand.

Yes, please.

Patch

diff --git a/sound/soc/fsl/pcm030-audio-fabric.c b/sound/soc/fsl/pcm030-audio-fabric.c
index 1353e8f..5c8e2d6 100644
--- a/sound/soc/fsl/pcm030-audio-fabric.c
+++ b/sound/soc/fsl/pcm030-audio-fabric.c
@@ -48,7 +48,7 @@  static struct snd_soc_card card = {
 	.num_links = ARRAY_SIZE(pcm030_fabric_dai),
 };
 
-static __init int pcm030_fabric_init(void)
+static int __init pcm030_fabric_probe(struct platform_device *op)
 {
 	struct platform_device *pdev;
 	int rc;
@@ -62,6 +62,7 @@  static __init int pcm030_fabric_init(void)
 		return -ENODEV;
 	}
 
+	platform_set_drvdata(op, pdev);
 	platform_set_drvdata(pdev, &card);
 
 	rc = platform_device_add(pdev);
@@ -73,7 +74,32 @@  static __init int pcm030_fabric_init(void)
 	return 0;
 }
 
-module_init(pcm030_fabric_init);
+static int __devexit pcm030_fabric_remove(struct platform_device *op)
+{
+	struct platform_device *pdev = platform_get_drvdata(op);
+
+	platform_device_unregister(pdev);
+
+	return 0;
+}
+
+static struct of_device_id pcm030_audio_match[] = {
+	{ .compatible = "phytec,pcm030-audio-fabric", },
+	{}
+};
+MODULE_DEVICE_TABLE(of, pcm030_audio_match);
+
+static struct platform_driver pcm030_fabric_driver = {
+	.probe		= pcm030_fabric_probe,
+	.remove		= __devexit_p(pcm030_fabric_remove),
+	.driver		= {
+		.name	= DRV_NAME,
+		.owner	= THIS_MODULE,
+		.of_match_table    = pcm030_audio_match,
+	},
+};
+
+module_platform_driver(pcm030_fabric_driver);
 
 
 MODULE_AUTHOR("Jon Smirl <jonsmirl@gmail.com>");