diff options
Diffstat (limited to 'sound/soc/samsung/i2s.c')
-rw-r--r-- | sound/soc/samsung/i2s.c | 42 |
1 files changed, 14 insertions, 28 deletions
diff --git a/sound/soc/samsung/i2s.c b/sound/soc/samsung/i2s.c index bff42bf370b..87a874dc7a3 100644 --- a/sound/soc/samsung/i2s.c +++ b/sound/soc/samsung/i2s.c | |||
@@ -15,6 +15,7 @@ | |||
15 | #include <linux/clk.h> | 15 | #include <linux/clk.h> |
16 | #include <linux/io.h> | 16 | #include <linux/io.h> |
17 | #include <linux/module.h> | 17 | #include <linux/module.h> |
18 | #include <linux/pm_runtime.h> | ||
18 | 19 | ||
19 | #include <sound/soc.h> | 20 | #include <sound/soc.h> |
20 | #include <sound/pcm_params.h> | 21 | #include <sound/pcm_params.h> |
@@ -881,7 +882,7 @@ static int samsung_i2s_dai_probe(struct snd_soc_dai *dai) | |||
881 | writel(CON_RSTCLR, i2s->addr + I2SCON); | 882 | writel(CON_RSTCLR, i2s->addr + I2SCON); |
882 | 883 | ||
883 | if (i2s->quirks & QUIRK_SEC_DAI) | 884 | if (i2s->quirks & QUIRK_SEC_DAI) |
884 | idma_reg_addr_init((void *)i2s->addr, | 885 | idma_reg_addr_init(i2s->addr, |
885 | i2s->sec_dai->idma_playback.dma_addr); | 886 | i2s->sec_dai->idma_playback.dma_addr); |
886 | 887 | ||
887 | probe_exit: | 888 | probe_exit: |
@@ -923,7 +924,7 @@ static int samsung_i2s_dai_remove(struct snd_soc_dai *dai) | |||
923 | return 0; | 924 | return 0; |
924 | } | 925 | } |
925 | 926 | ||
926 | static struct snd_soc_dai_ops samsung_i2s_dai_ops = { | 927 | static const struct snd_soc_dai_ops samsung_i2s_dai_ops = { |
927 | .trigger = i2s_trigger, | 928 | .trigger = i2s_trigger, |
928 | .hw_params = i2s_hw_params, | 929 | .hw_params = i2s_hw_params, |
929 | .set_fmt = i2s_set_fmt, | 930 | .set_fmt = i2s_set_fmt, |
@@ -945,7 +946,7 @@ struct i2s_dai *i2s_alloc_dai(struct platform_device *pdev, bool sec) | |||
945 | { | 946 | { |
946 | struct i2s_dai *i2s; | 947 | struct i2s_dai *i2s; |
947 | 948 | ||
948 | i2s = kzalloc(sizeof(struct i2s_dai), GFP_KERNEL); | 949 | i2s = devm_kzalloc(&pdev->dev, sizeof(struct i2s_dai), GFP_KERNEL); |
949 | if (i2s == NULL) | 950 | if (i2s == NULL) |
950 | return NULL; | 951 | return NULL; |
951 | 952 | ||
@@ -972,10 +973,8 @@ struct i2s_dai *i2s_alloc_dai(struct platform_device *pdev, bool sec) | |||
972 | i2s->pdev = platform_device_register_resndata(NULL, | 973 | i2s->pdev = platform_device_register_resndata(NULL, |
973 | pdev->name, pdev->id + SAMSUNG_I2S_SECOFF, | 974 | pdev->name, pdev->id + SAMSUNG_I2S_SECOFF, |
974 | NULL, 0, NULL, 0); | 975 | NULL, 0, NULL, 0); |
975 | if (IS_ERR(i2s->pdev)) { | 976 | if (IS_ERR(i2s->pdev)) |
976 | kfree(i2s); | ||
977 | return NULL; | 977 | return NULL; |
978 | } | ||
979 | } | 978 | } |
980 | 979 | ||
981 | /* Pre-assign snd_soc_dai_set_drvdata */ | 980 | /* Pre-assign snd_soc_dai_set_drvdata */ |
@@ -1048,7 +1047,7 @@ static __devinit int samsung_i2s_probe(struct platform_device *pdev) | |||
1048 | if (!pri_dai) { | 1047 | if (!pri_dai) { |
1049 | dev_err(&pdev->dev, "Unable to alloc I2S_pri\n"); | 1048 | dev_err(&pdev->dev, "Unable to alloc I2S_pri\n"); |
1050 | ret = -ENOMEM; | 1049 | ret = -ENOMEM; |
1051 | goto err1; | 1050 | goto err; |
1052 | } | 1051 | } |
1053 | 1052 | ||
1054 | pri_dai->dma_playback.dma_addr = regs_base + I2STXD; | 1053 | pri_dai->dma_playback.dma_addr = regs_base + I2STXD; |
@@ -1073,7 +1072,7 @@ static __devinit int samsung_i2s_probe(struct platform_device *pdev) | |||
1073 | if (!sec_dai) { | 1072 | if (!sec_dai) { |
1074 | dev_err(&pdev->dev, "Unable to alloc I2S_sec\n"); | 1073 | dev_err(&pdev->dev, "Unable to alloc I2S_sec\n"); |
1075 | ret = -ENOMEM; | 1074 | ret = -ENOMEM; |
1076 | goto err2; | 1075 | goto err; |
1077 | } | 1076 | } |
1078 | sec_dai->dma_playback.dma_addr = regs_base + I2STXDS; | 1077 | sec_dai->dma_playback.dma_addr = regs_base + I2STXDS; |
1079 | sec_dai->dma_playback.client = | 1078 | sec_dai->dma_playback.client = |
@@ -1092,17 +1091,15 @@ static __devinit int samsung_i2s_probe(struct platform_device *pdev) | |||
1092 | if (i2s_pdata->cfg_gpio && i2s_pdata->cfg_gpio(pdev)) { | 1091 | if (i2s_pdata->cfg_gpio && i2s_pdata->cfg_gpio(pdev)) { |
1093 | dev_err(&pdev->dev, "Unable to configure gpio\n"); | 1092 | dev_err(&pdev->dev, "Unable to configure gpio\n"); |
1094 | ret = -EINVAL; | 1093 | ret = -EINVAL; |
1095 | goto err3; | 1094 | goto err; |
1096 | } | 1095 | } |
1097 | 1096 | ||
1098 | snd_soc_register_dai(&pri_dai->pdev->dev, &pri_dai->i2s_dai_drv); | 1097 | snd_soc_register_dai(&pri_dai->pdev->dev, &pri_dai->i2s_dai_drv); |
1099 | 1098 | ||
1099 | pm_runtime_enable(&pdev->dev); | ||
1100 | |||
1100 | return 0; | 1101 | return 0; |
1101 | err3: | 1102 | err: |
1102 | kfree(sec_dai); | ||
1103 | err2: | ||
1104 | kfree(pri_dai); | ||
1105 | err1: | ||
1106 | release_mem_region(regs_base, resource_size(res)); | 1103 | release_mem_region(regs_base, resource_size(res)); |
1107 | 1104 | ||
1108 | return ret; | 1105 | return ret; |
@@ -1111,6 +1108,7 @@ err1: | |||
1111 | static __devexit int samsung_i2s_remove(struct platform_device *pdev) | 1108 | static __devexit int samsung_i2s_remove(struct platform_device *pdev) |
1112 | { | 1109 | { |
1113 | struct i2s_dai *i2s, *other; | 1110 | struct i2s_dai *i2s, *other; |
1111 | struct resource *res; | ||
1114 | 1112 | ||
1115 | i2s = dev_get_drvdata(&pdev->dev); | 1113 | i2s = dev_get_drvdata(&pdev->dev); |
1116 | other = i2s->pri_dai ? : i2s->sec_dai; | 1114 | other = i2s->pri_dai ? : i2s->sec_dai; |
@@ -1119,7 +1117,7 @@ static __devexit int samsung_i2s_remove(struct platform_device *pdev) | |||
1119 | other->pri_dai = NULL; | 1117 | other->pri_dai = NULL; |
1120 | other->sec_dai = NULL; | 1118 | other->sec_dai = NULL; |
1121 | } else { | 1119 | } else { |
1122 | struct resource *res; | 1120 | pm_runtime_disable(&pdev->dev); |
1123 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 1121 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
1124 | if (res) | 1122 | if (res) |
1125 | release_mem_region(res->start, resource_size(res)); | 1123 | release_mem_region(res->start, resource_size(res)); |
@@ -1128,8 +1126,6 @@ static __devexit int samsung_i2s_remove(struct platform_device *pdev) | |||
1128 | i2s->pri_dai = NULL; | 1126 | i2s->pri_dai = NULL; |
1129 | i2s->sec_dai = NULL; | 1127 | i2s->sec_dai = NULL; |
1130 | 1128 | ||
1131 | kfree(i2s); | ||
1132 | |||
1133 | snd_soc_unregister_dai(&pdev->dev); | 1129 | snd_soc_unregister_dai(&pdev->dev); |
1134 | 1130 | ||
1135 | return 0; | 1131 | return 0; |
@@ -1144,17 +1140,7 @@ static struct platform_driver samsung_i2s_driver = { | |||
1144 | }, | 1140 | }, |
1145 | }; | 1141 | }; |
1146 | 1142 | ||
1147 | static int __init samsung_i2s_init(void) | 1143 | module_platform_driver(samsung_i2s_driver); |
1148 | { | ||
1149 | return platform_driver_register(&samsung_i2s_driver); | ||
1150 | } | ||
1151 | module_init(samsung_i2s_init); | ||
1152 | |||
1153 | static void __exit samsung_i2s_exit(void) | ||
1154 | { | ||
1155 | platform_driver_unregister(&samsung_i2s_driver); | ||
1156 | } | ||
1157 | module_exit(samsung_i2s_exit); | ||
1158 | 1144 | ||
1159 | /* Module information */ | 1145 | /* Module information */ |
1160 | MODULE_AUTHOR("Jaswinder Singh, <jassi.brar@samsung.com>"); | 1146 | MODULE_AUTHOR("Jaswinder Singh, <jassi.brar@samsung.com>"); |