Commit 6b8cb1a5 authored by Dirk Behme's avatar Dirk Behme Committed by Kevin Hilman

ARM: DAVINCI: Convert audio driver to platform_driver

This patch converts audio driver to use platform driver (and minor
style changes).

This fixes broken standby resume as reported in

http://linux.omap.com/pipermail/davinci-linux-open-source/2008-January/004919.html

Switching to platform_driver, the driver suspends and resumes properly
now. platform_resume_early() doesn't call uninitialized tasklet worker
function audio_dsr_handler() any more. From oops reported in link
above:

(audio_dsr_handler+0x0/0x7c) from [<c014f848>]
(platform_resume_early+0x30)
Signed-off-by: default avatarDirk Behme <dirk.behme@gmail.com>
Signed-off-by: default avatarKevin Hilman <khilman@mvista.com>
parent a5cc88c0
...@@ -59,7 +59,7 @@ ...@@ -59,7 +59,7 @@
/***************************** MACROS ************************************/ /***************************** MACROS ************************************/
#undef DEBUG #undef DEBUG
//#define DEBUG /* #define DEBUG */
#ifdef DEBUG #ifdef DEBUG
#define DPRINTK printk #define DPRINTK printk
#define FN_IN printk("[davinci_audio.c:[%s] start\n", __FUNCTION__) #define FN_IN printk("[davinci_audio.c:[%s] start\n", __FUNCTION__)
...@@ -110,17 +110,15 @@ static int audio_open(struct inode *inode, struct file *file); ...@@ -110,17 +110,15 @@ static int audio_open(struct inode *inode, struct file *file);
static int audio_release(struct inode *inode, struct file *file); static int audio_release(struct inode *inode, struct file *file);
static int audio_probe(struct device *dev); static int audio_probe(struct platform_device *dev);
static int audio_remove(struct device *dev); static int audio_remove(struct platform_device *dev);
static void audio_shutdown(struct device *dev); static void audio_shutdown(struct platform_device *dev);
static int audio_suspend(struct device *dev, pm_message_t state); static int audio_suspend(struct platform_device *dev, pm_message_t state);
static int audio_resume(struct device *dev); static int audio_resume(struct platform_device *dev);
static void audio_free(struct device *dev);
/***************************** Data Structures ********************************/ /***************************** Data Structures ********************************/
...@@ -146,14 +144,15 @@ static struct file_operations davinci_audio_fops = { ...@@ -146,14 +144,15 @@ static struct file_operations davinci_audio_fops = {
}; };
/* Driver information */ /* Driver information */
static struct device_driver davinci_audio_driver = { static struct platform_driver davinci_audio_driver = {
.name = DAVINCI_AUDIO_NAME,
.bus = &platform_bus_type,
.probe = audio_probe, .probe = audio_probe,
.remove = audio_remove, .remove = audio_remove,
.suspend = audio_suspend, .suspend = audio_suspend,
.resume = audio_resume, .resume = audio_resume,
.shutdown = audio_shutdown, .shutdown = audio_shutdown,
.driver = {
.name = DAVINCI_AUDIO_NAME,
},
}; };
/* Device Information */ /* Device Information */
...@@ -161,20 +160,14 @@ static struct platform_device davinci_audio_device = { ...@@ -161,20 +160,14 @@ static struct platform_device davinci_audio_device = {
.name = DAVINCI_AUDIO_NAME, .name = DAVINCI_AUDIO_NAME,
.dev = { .dev = {
.driver_data = &audio_state, .driver_data = &audio_state,
.release = audio_free,
}, },
.id = 0, .id = 0,
}; };
/***************************** GLOBAL FUNCTIONs *******************************/ /***************************** GLOBAL FUNCTIONs *******************************/
/* Power Management Functions for Linux Device Model */
/* DEBUG PUPOSES ONLY! */
#ifdef CONFIG_PM
//#undef CONFIG_PM
#endif
#ifdef CONFIG_PM #ifdef CONFIG_PM
/* Power Management Functions for Linux Device Model */
/******************************************************************************* /*******************************************************************************
* *
* audio_ldm_suspend(): Suspend operation * audio_ldm_suspend(): Suspend operation
...@@ -270,24 +263,13 @@ static int audio_ldm_resume(void *data) ...@@ -270,24 +263,13 @@ static int audio_ldm_resume(void *data)
} }
#endif /* End of #ifdef CONFIG_PM */ #endif /* End of #ifdef CONFIG_PM */
/*******************************************************************************
*
* audio_free(): The Audio driver release function
* This is a dummy function required by the platform driver
*
******************************************************************************/
static void audio_free(struct device *dev)
{
/* Nothing to Release! */
}
/******************************************************************************* /*******************************************************************************
* *
* audio_probe(): The Audio driver probe function * audio_probe(): The Audio driver probe function
* WARNING!!!! : It is expected that the codec would have registered with us by now * WARNING!!!! : It is expected that the codec would have registered with us by now
* *
******************************************************************************/ ******************************************************************************/
static int audio_probe(struct device *dev) static int audio_probe(struct platform_device *dev)
{ {
int ret; int ret;
FN_IN; FN_IN;
...@@ -305,7 +287,7 @@ static int audio_probe(struct device *dev) ...@@ -305,7 +287,7 @@ static int audio_probe(struct device *dev)
* audio_remove() Function to handle removal operations * audio_remove() Function to handle removal operations
* *
******************************************************************************/ ******************************************************************************/
static int audio_remove(struct device *dev) static int audio_remove(struct platform_device *dev)
{ {
FN_IN; FN_IN;
if (audio_state.hw_remove) { if (audio_state.hw_remove) {
...@@ -320,7 +302,7 @@ static int audio_remove(struct device *dev) ...@@ -320,7 +302,7 @@ static int audio_remove(struct device *dev)
* audio_shutdown(): Function to handle shutdown operations * audio_shutdown(): Function to handle shutdown operations
* *
******************************************************************************/ ******************************************************************************/
static void audio_shutdown(struct device *dev) static void audio_shutdown(struct platform_device *dev)
{ {
FN_IN; FN_IN;
if (audio_state.hw_cleanup) { if (audio_state.hw_cleanup) {
...@@ -335,24 +317,24 @@ static void audio_shutdown(struct device *dev) ...@@ -335,24 +317,24 @@ static void audio_shutdown(struct device *dev)
* audio_suspend(): Function to handle suspend operations * audio_suspend(): Function to handle suspend operations
* *
******************************************************************************/ ******************************************************************************/
static int audio_suspend(struct device *dev, pm_message_t state) static int audio_suspend(struct platform_device *dev, pm_message_t state)
{ {
int ret = 0; int ret = 0;
#ifdef CONFIG_PM #ifdef CONFIG_PM
void *data = dev->driver_data; void *data = dev->dev.platform_data;
FN_IN; FN_IN;
if (audio_state.hw_suspend) { if (audio_state.hw_suspend) {
ret = audio_ldm_suspend(data); ret = audio_ldm_suspend(&data);
if (ret == 0) if (ret == 0)
ret = audio_state.hw_suspend(); ret = audio_state.hw_suspend();
} }
if (ret) { if (ret) {
DPRINTK("Audio Suspend Failed \n"); DPRINTK("Audio suspend failed\n");
} else { } else {
DPRINTK("Audio Suspend Success \n"); DPRINTK("Audio suspend success\n");
} }
#endif /* CONFIG_PM */ #endif /* CONFIG_PM */
FN_OUT(ret); FN_OUT(ret);
return ret; return ret;
...@@ -363,24 +345,24 @@ static int audio_suspend(struct device *dev, pm_message_t state) ...@@ -363,24 +345,24 @@ static int audio_suspend(struct device *dev, pm_message_t state)
* audio_resume(): Function to handle resume operations * audio_resume(): Function to handle resume operations
* *
******************************************************************************/ ******************************************************************************/
static int audio_resume(struct device *dev) static int audio_resume(struct platform_device *dev)
{ {
int ret = 0; int ret = 0;
#ifdef CONFIG_PM #ifdef CONFIG_PM
void *data = dev->driver_data; void *data = dev->dev.platform_data;
FN_IN; FN_IN;
if (audio_state.hw_resume) { if (audio_state.hw_resume) {
ret = audio_ldm_resume(data); ret = audio_ldm_resume(&data);
if (ret == 0) if (ret == 0)
ret = audio_state.hw_resume(); ret = audio_state.hw_resume();
} }
if (ret) { if (ret) {
DPRINTK(" Audio Resume Failed \n"); DPRINTK("Audio resume failed \n");
} else { } else {
DPRINTK(" Audio Resume Success \n"); DPRINTK("Audio resume success \n");
} }
#endif /* CONFIG_PM */ #endif /* CONFIG_PM */
FN_OUT(ret); FN_OUT(ret);
return ret; return ret;
...@@ -445,20 +427,20 @@ int audio_register_codec(audio_state_t * codec_state) ...@@ -445,20 +427,20 @@ int audio_register_codec(audio_state_t * codec_state)
ret = platform_device_register(&davinci_audio_device); ret = platform_device_register(&davinci_audio_device);
if (ret != 0) { if (ret != 0) {
DPRINTK("Platform dev_register failed =%d\n", ret); DPRINTK("Platform device register failed =%d\n", ret);
ret = -ENODEV; ret = -ENODEV;
goto register_out; goto register_out;
} }
ret = driver_register(&davinci_audio_driver); ret = platform_driver_register(&davinci_audio_driver);
if (ret != 0) { if (ret != 0) {
DPRINTK("Device Register failed =%d\n", ret); DPRINTK("Platform driver register failed =%d\n", ret);
ret = -ENODEV; ret = -ENODEV;
platform_device_unregister(&davinci_audio_device); platform_device_unregister(&davinci_audio_device);
goto register_out; goto register_out;
} }
DPRINTK("audio driver register success\n"); DPRINTK("Audio driver register success\n");
register_out: register_out:
...@@ -487,7 +469,7 @@ int audio_unregister_codec(audio_state_t * codec_state) ...@@ -487,7 +469,7 @@ int audio_unregister_codec(audio_state_t * codec_state)
return -EPERM; return -EPERM;
} }
driver_unregister(&davinci_audio_driver); platform_driver_unregister(&davinci_audio_driver);
platform_device_unregister(&davinci_audio_device); platform_device_unregister(&davinci_audio_device);
memset(&audio_state, 0, sizeof(audio_state_t)); memset(&audio_state, 0, sizeof(audio_state_t));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment