aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVinod Koul <vinod.koul@intel.com>2016-07-26 08:36:41 -0400
committerMark Brown <broonie@kernel.org>2016-08-08 06:54:59 -0400
commit73a675816d704337ef7e8cb441f094a82fcc1018 (patch)
tree9d7fbe44540c377e2a72713e573f5d363bc4d2e8
parentb7c505554c11cc7978ab942b544d86dd92d59dcf (diff)
ASoC: Intel: Skylake: modify skl_get_dsp_ops()
To query the ops used for a platform, we use skl_get_dsp_ops() which return index and then we load the ops. Rather than this return the ops, this way it cna be used later to query the ops in rest of the driver. Signed-off-by: Vinod Koul <vinod.koul@intel.com> Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--sound/soc/intel/skylake/skl-messages.c30
-rw-r--r--sound/soc/intel/skylake/skl.h1
2 files changed, 17 insertions, 14 deletions
diff --git a/sound/soc/intel/skylake/skl-messages.c b/sound/soc/intel/skylake/skl-messages.c
index 44ab595ce21a..25d057679f2c 100644
--- a/sound/soc/intel/skylake/skl-messages.c
+++ b/sound/soc/intel/skylake/skl-messages.c
@@ -219,16 +219,16 @@ static const struct skl_dsp_ops dsp_ops[] = {
219 }, 219 },
220}; 220};
221 221
222static int skl_get_dsp_ops(int pci_id) 222const struct skl_dsp_ops *skl_get_dsp_ops(int pci_id)
223{ 223{
224 int i; 224 int i;
225 225
226 for (i = 0; i < ARRAY_SIZE(dsp_ops); i++) { 226 for (i = 0; i < ARRAY_SIZE(dsp_ops); i++) {
227 if (dsp_ops[i].id == pci_id) 227 if (dsp_ops[i].id == pci_id)
228 return i; 228 return &dsp_ops[i];
229 } 229 }
230 230
231 return -EINVAL; 231 return NULL;
232} 232}
233 233
234int skl_init_dsp(struct skl *skl) 234int skl_init_dsp(struct skl *skl)
@@ -238,7 +238,8 @@ int skl_init_dsp(struct skl *skl)
238 struct hdac_bus *bus = ebus_to_hbus(ebus); 238 struct hdac_bus *bus = ebus_to_hbus(ebus);
239 struct skl_dsp_loader_ops loader_ops; 239 struct skl_dsp_loader_ops loader_ops;
240 int irq = bus->irq; 240 int irq = bus->irq;
241 int ret, index; 241 const struct skl_dsp_ops *ops;
242 int ret;
242 243
243 /* enable ppcap interrupt */ 244 /* enable ppcap interrupt */
244 snd_hdac_ext_bus_ppcap_enable(&skl->ebus, true); 245 snd_hdac_ext_bus_ppcap_enable(&skl->ebus, true);
@@ -251,13 +252,14 @@ int skl_init_dsp(struct skl *skl)
251 return -ENXIO; 252 return -ENXIO;
252 } 253 }
253 254
254 index = skl_get_dsp_ops(skl->pci->device); 255 ops = skl_get_dsp_ops(skl->pci->device);
255 if (index < 0) 256 if (!ops)
256 return -EINVAL; 257 return -EIO;
257 258
258 loader_ops = dsp_ops[index].loader_ops(); 259 loader_ops = ops->loader_ops();
259 ret = dsp_ops[index].init(bus->dev, mmio_base, irq, 260 ret = ops->init(bus->dev, mmio_base, irq,
260 skl->fw_name, loader_ops, &skl->skl_sst); 261 skl->fw_name, loader_ops,
262 &skl->skl_sst);
261 263
262 if (ret < 0) 264 if (ret < 0)
263 return ret; 265 return ret;
@@ -273,16 +275,16 @@ int skl_free_dsp(struct skl *skl)
273 struct hdac_ext_bus *ebus = &skl->ebus; 275 struct hdac_ext_bus *ebus = &skl->ebus;
274 struct hdac_bus *bus = ebus_to_hbus(ebus); 276 struct hdac_bus *bus = ebus_to_hbus(ebus);
275 struct skl_sst *ctx = skl->skl_sst; 277 struct skl_sst *ctx = skl->skl_sst;
276 int index; 278 const struct skl_dsp_ops *ops;
277 279
278 /* disable ppcap interrupt */ 280 /* disable ppcap interrupt */
279 snd_hdac_ext_bus_ppcap_int_enable(&skl->ebus, false); 281 snd_hdac_ext_bus_ppcap_int_enable(&skl->ebus, false);
280 282
281 index = skl_get_dsp_ops(skl->pci->device); 283 ops = skl_get_dsp_ops(skl->pci->device);
282 if (index < 0) 284 if (!ops)
283 return -EIO; 285 return -EIO;
284 286
285 dsp_ops[index].cleanup(bus->dev, ctx); 287 ops->cleanup(bus->dev, ctx);
286 288
287 if (ctx->dsp->addr.lpe) 289 if (ctx->dsp->addr.lpe)
288 iounmap(ctx->dsp->addr.lpe); 290 iounmap(ctx->dsp->addr.lpe);
diff --git a/sound/soc/intel/skylake/skl.h b/sound/soc/intel/skylake/skl.h
index 9064e5b0d676..c3538f8b17d9 100644
--- a/sound/soc/intel/skylake/skl.h
+++ b/sound/soc/intel/skylake/skl.h
@@ -123,4 +123,5 @@ int skl_free_dsp(struct skl *skl);
123int skl_suspend_dsp(struct skl *skl); 123int skl_suspend_dsp(struct skl *skl);
124int skl_resume_dsp(struct skl *skl); 124int skl_resume_dsp(struct skl *skl);
125void skl_cleanup_resources(struct skl *skl); 125void skl_cleanup_resources(struct skl *skl);
126const struct skl_dsp_ops *skl_get_dsp_ops(int pci_id);
126#endif /* __SOUND_SOC_SKL_H */ 127#endif /* __SOUND_SOC_SKL_H */