diff --git a/include/sound/sof.h b/include/sound/sof.h index 4ed6e23791412e1..c69d636a0c30a91 100644 --- a/include/sound/sof.h +++ b/include/sound/sof.h @@ -42,7 +42,7 @@ struct snd_sof_pdata { const struct sof_dev_desc *desc; /* SPI data */ - unsigned int gpio; + int gpio; unsigned int active; /* machine */ diff --git a/sound/soc/sof/control.c b/sound/soc/sof/control.c index 2000f62e931b6e4..3587f9f26a74731 100644 --- a/sound/soc/sof/control.c +++ b/sound/soc/sof/control.c @@ -297,7 +297,7 @@ int snd_sof_bytes_ext_put(struct snd_kcontrol *kcontrol, /* The maximum length that can be copied is limited by IPC max * length and topology defined length for ext bytes control. */ - max_size = (be->max < max_size) ? be->max : max_size; + max_size = min(be->max, max_size); if (header.length > max_size) { dev_err(sdev->dev, "error: Bytes data size %d exceeds max %d.\n", header.length, max_size); @@ -392,8 +392,7 @@ int snd_sof_bytes_ext_get(struct snd_kcontrol *kcontrol, /* Prevent read of other kernel data or possibly corrupt response */ data_size = cdata->data->size + sizeof(const struct sof_abi_hdr); - max_size = (size < max_size) ? size : max_size; - max_size = (be->max < max_size) ? be->max : max_size; + max_size = min3(be->max, max_size, (int)size); if (data_size > max_size) { dev_err(sdev->dev, "error: user data size %d exceeds max size %d.\n", data_size, max_size); diff --git a/sound/soc/sof/core.c b/sound/soc/sof/core.c index 480e4a3110ddf62..46c9962c7bba599 100644 --- a/sound/soc/sof/core.c +++ b/sound/soc/sof/core.c @@ -15,8 +15,8 @@ #include "ops.h" /* SOF defaults if not provided by the platform in ms */ -#define TIMEOUT_DEFAULT_IPC 5 -#define TIMEOUT_DEFAULT_BOOT 100 +#define TIMEOUT_DEFAULT_IPC_MS 5 +#define TIMEOUT_DEFAULT_BOOT_MS 100 /* * Generic object lookup APIs. @@ -107,10 +107,7 @@ struct snd_sof_dai *snd_sof_find_dai(struct snd_sof_dev *sdev, struct snd_sof_dai *dai = NULL; list_for_each_entry(dai, &sdev->dai_list, list) { - if (!dai->name) - continue; - - if (strcmp(name, dai->name) == 0) + if (dai->name && (strcmp(name, dai->name) == 0)) return dai; } @@ -259,11 +256,11 @@ static int sof_probe(struct platform_device *pdev) /* set default timeouts if none provided */ if (plat_data->desc->ipc_timeout == 0) - sdev->ipc_timeout = TIMEOUT_DEFAULT_IPC; + sdev->ipc_timeout = TIMEOUT_DEFAULT_IPC_MS; else sdev->ipc_timeout = plat_data->desc->ipc_timeout; if (plat_data->desc->boot_timeout == 0) - sdev->boot_timeout = TIMEOUT_DEFAULT_BOOT; + sdev->boot_timeout = TIMEOUT_DEFAULT_BOOT_MS; else sdev->boot_timeout = plat_data->desc->boot_timeout; @@ -333,7 +330,7 @@ static int sof_probe(struct platform_device *pdev) /* register machine driver, pass machine info as pdata */ plat_data->pdev_mach = platform_device_register_data(sdev->dev, drv_name, - -1, mach, size); + PLATFORM_DEVID_NONE, mach, size); if (IS_ERR(plat_data->pdev_mach)) { ret = PTR_ERR(plat_data->pdev_mach); @@ -365,7 +362,7 @@ static int sof_remove(struct platform_device *pdev) struct snd_sof_dev *sdev = dev_get_drvdata(&pdev->dev); struct snd_sof_pdata *pdata = sdev->pdata; - if (pdata && !IS_ERR(pdata->pdev_mach)) + if (pdata && !IS_ERR_OR_NULL(pdata->pdev_mach)) platform_device_unregister(pdata->pdev_mach); snd_soc_unregister_component(&pdev->dev); @@ -377,11 +374,6 @@ static int sof_remove(struct platform_device *pdev) return 0; } -void snd_sof_shutdown(struct device *dev) -{ -} -EXPORT_SYMBOL(snd_sof_shutdown); - static struct platform_driver sof_driver = { .driver = { .name = "sof-audio", diff --git a/sound/soc/sof/debug.c b/sound/soc/sof/debug.c index 67f6cf79b729474..2224d0865665357 100644 --- a/sound/soc/sof/debug.c +++ b/sound/soc/sof/debug.c @@ -31,7 +31,8 @@ static ssize_t sof_dfsentry_read(struct file *file, char __user *buffer, int size; u32 *buf; loff_t pos = *ppos; - size_t ret; + size_t size_ret; + int ret; size = dfse->size; @@ -40,11 +41,10 @@ static ssize_t sof_dfsentry_read(struct file *file, char __user *buffer, return -EINVAL; if (pos >= size || !count) return 0; - if (count > size - pos) - count = size - pos; + count = min(count, (size_t)(size - pos)); /* intermediate buffer size must be u32 multiple */ - size = (count + 3) & ~3; + size = round_up(count, 4); buf = kzalloc(size, GFP_KERNEL); if (!buf) return -ENOMEM; @@ -60,17 +60,17 @@ static ssize_t sof_dfsentry_read(struct file *file, char __user *buffer, */ ret = pm_runtime_put_sync_autosuspend(sdev->dev); if (ret < 0) - dev_warn(sdev->dev, "warn: debugFS failed to autosuspend %zd\n", + dev_warn(sdev->dev, "warn: debugFS failed to autosuspend %d\n", ret); /* copy to userspace */ - ret = copy_to_user(buffer, buf, count); + size_ret = copy_to_user(buffer, buf, count); kfree(buf); /* update count & position if copy succeeded */ - if (ret == count) + if (size_ret == count) return -EFAULT; - count -= ret; + count -= size_ret; *ppos = pos + count; return count; diff --git a/sound/soc/sof/intel/hda-dai.c b/sound/soc/sof/intel/hda-dai.c index 801d45e0218e8e9..ae7258450f3d2c3 100644 --- a/sound/soc/sof/intel/hda-dai.c +++ b/sound/soc/sof/intel/hda-dai.c @@ -210,7 +210,6 @@ static int hda_link_hw_free(struct snd_pcm_substream *substream, unsigned int stream_tag; struct hdac_bus *bus; struct hdac_ext_link *link; - struct snd_sof_dev *sdev; struct hdac_stream *hstream; struct hdac_ext_stream *stream; struct snd_soc_pcm_runtime *rtd; @@ -234,7 +233,6 @@ static int hda_link_hw_free(struct snd_pcm_substream *substream, link_dev->link_prepared = 0; } else { /* release all hda streams when dai link is unloaded */ - sdev = snd_soc_component_get_drvdata(dai->component); pcm_substream.stream = SNDRV_PCM_STREAM_PLAYBACK; stream = snd_soc_dai_get_dma_data(dai, &pcm_substream); if (stream) { diff --git a/sound/soc/sof/intel/hda.c b/sound/soc/sof/intel/hda.c index b726e2708210275..14942829ff16aaa 100644 --- a/sound/soc/sof/intel/hda.c +++ b/sound/soc/sof/intel/hda.c @@ -458,7 +458,8 @@ int hda_dsp_probe(struct snd_sof_dev *sdev) hdev->desc = chip; hdev->dmic_dev = platform_device_register_data(&pci->dev, "dmic-codec", - -1, NULL, 0); + PLATFORM_DEVID_NONE, + NULL, 0); if (IS_ERR(hdev->dmic_dev)) { dev_err(&pci->dev, "error: failed to create DMIC device\n"); return PTR_ERR(hdev->dmic_dev); @@ -661,7 +662,7 @@ int hda_dsp_remove(struct snd_sof_dev *sdev) snd_hdac_ext_bus_device_remove(bus); #endif - if (sdev->hda && (!IS_ERR(sdev->hda->dmic_dev))) + if (sdev->hda && (!IS_ERR_OR_NULL(sdev->hda->dmic_dev))) platform_device_unregister(sdev->hda->dmic_dev); /* disable DSP IRQ */ diff --git a/sound/soc/sof/ipc.c b/sound/soc/sof/ipc.c index 918cd7b732ddf08..0fdd72a801f73fc 100644 --- a/sound/soc/sof/ipc.c +++ b/sound/soc/sof/ipc.c @@ -15,10 +15,10 @@ #include "ops.h" /* - * IPC message default size and timeout (msecs). + * IPC message default size and timeout (ms). * TODO: allow platforms to set size and timeout. */ -#define IPC_TIMEOUT_MSECS 300 +#define IPC_TIMEOUT_MS 300 #define IPC_EMPTY_LIST_SIZE 8 static void ipc_trace_message(struct snd_sof_dev *sdev, u32 msg_id); @@ -202,7 +202,7 @@ static int tx_wait_done(struct snd_sof_ipc *ipc, struct snd_sof_ipc_msg *msg, /* wait for DSP IPC completion */ ret = wait_event_timeout(msg->waitq, msg->ipc_complete, - msecs_to_jiffies(IPC_TIMEOUT_MSECS)); + msecs_to_jiffies(IPC_TIMEOUT_MS)); spin_lock_irqsave(&sdev->ipc_lock, flags); @@ -312,15 +312,11 @@ static struct snd_sof_ipc_msg *sof_ipc_reply_find_msg(struct snd_sof_ipc *ipc, header = SOF_IPC_MESSAGE_ID(header); - if (list_empty(&ipc->reply_list)) - goto err; - list_for_each_entry(msg, &ipc->reply_list, list) { if (SOF_IPC_MESSAGE_ID(msg->header) == header) return msg; } -err: dev_err(sdev->dev, "error: rx list empty but received 0x%x\n", header); return NULL; @@ -725,10 +721,10 @@ int snd_sof_ipc_valid(struct snd_sof_dev *sdev) struct sof_ipc_fw_version *v = &ready->version; dev_info(sdev->dev, - " Firmware info: version %d:%d:%d-%s\n", v->major, v->minor, + "Firmware info: version %d:%d:%d-%s\n", v->major, v->minor, v->micro, v->tag); dev_info(sdev->dev, - " Firmware: ABI %d:%d:%d Kernel ABI %d:%d:%d\n", + "Firmware: ABI %d:%d:%d Kernel ABI %d:%d:%d\n", SOF_ABI_VERSION_MAJOR(v->abi_version), SOF_ABI_VERSION_MINOR(v->abi_version), SOF_ABI_VERSION_PATCH(v->abi_version), @@ -741,15 +737,14 @@ int snd_sof_ipc_valid(struct snd_sof_dev *sdev) if (ready->debug.bits.build) { dev_info(sdev->dev, - " Firmware debug build %d on %s-%s - options:\n" - " GDB: %s\n" - " lock debug: %s\n" - " lock vdebug: %s\n", + "Firmware debug build %d on %s-%s - options:\n" + " GDB: %s\n" + " lock debug: %s\n" + " lock vdebug: %s\n", v->build, v->date, v->time, ready->debug.bits.gdb ? "enabled" : "disabled", ready->debug.bits.locks ? "enabled" : "disabled", - ready->debug.bits.locks_verbose ? - "enabled" : "disabled"); + ready->debug.bits.locks_verbose ? "enabled" : "disabled"); } /* copy the fw_version into debugfs at first boot */ diff --git a/sound/soc/sof/loader.c b/sound/soc/sof/loader.c index dbadd8c521e6052..70b3038e3e2b59e 100644 --- a/sound/soc/sof/loader.c +++ b/sound/soc/sof/loader.c @@ -18,8 +18,6 @@ static int get_ext_windows(struct snd_sof_dev *sdev, struct sof_ipc_ext_data_hdr *ext_hdr) { struct sof_ipc_window *w = (struct sof_ipc_window *)ext_hdr; - - int ret = 0; size_t size; if (w->num_windows == 0 || w->num_windows > SOF_IPC_MAX_ELEMS) @@ -32,7 +30,7 @@ static int get_ext_windows(struct snd_sof_dev *sdev, if (!sdev->info_window) return -ENOMEM; - return ret; + return 0; } /* parse the extended FW boot data structures from FW boot message */ diff --git a/sound/soc/sof/ops.c b/sound/soc/sof/ops.c index 41143fd97772122..1eb759c6569c765 100644 --- a/sound/soc/sof/ops.c +++ b/sound/soc/sof/ops.c @@ -14,7 +14,6 @@ int snd_sof_pci_update_bits_unlocked(struct snd_sof_dev *sdev, u32 offset, u32 mask, u32 value) { - bool change; unsigned int old, new; u32 ret = ~0; /* explicit init to remove uninitialized use warnings */ @@ -25,14 +24,14 @@ int snd_sof_pci_update_bits_unlocked(struct snd_sof_dev *sdev, u32 offset, old = ret; new = (old & (~mask)) | (value & mask); - change = (old != new); - if (change) { - pci_write_config_dword(sdev->pci, offset, new); - dev_dbg(sdev->dev, "Debug PCIW: %8.8x at %8.8x\n", value, - offset); - } + if (old == new) + return false; - return change; + pci_write_config_dword(sdev->pci, offset, new); + dev_dbg(sdev->dev, "Debug PCIW: %8.8x at %8.8x\n", value, + offset); + + return true; } EXPORT_SYMBOL(snd_sof_pci_update_bits_unlocked); @@ -52,7 +51,6 @@ EXPORT_SYMBOL(snd_sof_pci_update_bits); int snd_sof_dsp_update_bits_unlocked(struct snd_sof_dev *sdev, u32 bar, u32 offset, u32 mask, u32 value) { - bool change; unsigned int old, new; u32 ret; @@ -61,29 +59,30 @@ int snd_sof_dsp_update_bits_unlocked(struct snd_sof_dev *sdev, u32 bar, old = ret; new = (old & (~mask)) | (value & mask); - change = (old != new); - if (change) - snd_sof_dsp_write(sdev, bar, offset, new); + if (old == new) + return false; - return change; + snd_sof_dsp_write(sdev, bar, offset, new); + + return true; } EXPORT_SYMBOL(snd_sof_dsp_update_bits_unlocked); int snd_sof_dsp_update_bits64_unlocked(struct snd_sof_dev *sdev, u32 bar, u32 offset, u64 mask, u64 value) { - bool change; u64 old, new; old = snd_sof_dsp_read64(sdev, bar, offset); new = (old & (~mask)) | (value & mask); - change = (old != new); - if (change) - snd_sof_dsp_write64(sdev, bar, offset, new); + if (old == new) + return false; - return change; + snd_sof_dsp_write64(sdev, bar, offset, new); + + return true; } EXPORT_SYMBOL(snd_sof_dsp_update_bits64_unlocked); @@ -165,8 +164,7 @@ int snd_sof_dsp_register_poll(struct snd_sof_dev *sdev, u32 bar, u32 offset, timeout /= 10; for (time = timeout; time > 0; time--) { - if ((snd_sof_dsp_read(sdev, bar, offset) & mask) == - target) + if ((snd_sof_dsp_read(sdev, bar, offset) & mask) == target) break; usleep_range(5000, 10000); diff --git a/sound/soc/sof/ops.h b/sound/soc/sof/ops.h index 405e39155645a95..fc4868712af9ae9 100644 --- a/sound/soc/sof/ops.h +++ b/sound/soc/sof/ops.h @@ -157,8 +157,7 @@ static inline void snd_sof_dsp_write64(struct snd_sof_dev *sdev, u32 bar, u32 offset, u64 value) { if (sdev->ops->write64) - sdev->ops->write64(sdev, - sdev->bar[bar] + offset, value); + sdev->ops->write64(sdev, sdev->bar[bar] + offset, value); } static inline u32 snd_sof_dsp_read(struct snd_sof_dev *sdev, u32 bar, diff --git a/sound/soc/sof/pcm.c b/sound/soc/sof/pcm.c index 1b01383a380dbad..a6b11217ee509ec 100644 --- a/sound/soc/sof/pcm.c +++ b/sound/soc/sof/pcm.c @@ -703,7 +703,7 @@ static int sof_pcm_probe(struct snd_soc_component *component) /* enable runtime PM with auto suspend */ pm_runtime_set_autosuspend_delay(component->dev, - SND_SOF_SUSPEND_DELAY); + SND_SOF_SUSPEND_DELAY_MS); pm_runtime_use_autosuspend(component->dev); pm_runtime_enable(component->dev); diff --git a/sound/soc/sof/sof-acpi-dev.c b/sound/soc/sof/sof-acpi-dev.c index 52de8ac8ede0e8b..ad9902bc7062179 100644 --- a/sound/soc/sof/sof-acpi-dev.c +++ b/sound/soc/sof/sof-acpi-dev.c @@ -214,24 +214,19 @@ static int sof_acpi_probe(struct platform_device *pdev) } /* allow runtime_pm */ - pm_runtime_set_autosuspend_delay(dev, SND_SOF_SUSPEND_DELAY); + pm_runtime_set_autosuspend_delay(dev, SND_SOF_SUSPEND_DELAY_MS); pm_runtime_use_autosuspend(dev); pm_runtime_allow(dev); return ret; } -static void sof_acpi_shutdown(struct platform_device *pdev) -{ - snd_sof_shutdown(&pdev->dev); -} - static int sof_acpi_remove(struct platform_device *pdev) { struct sof_platform_priv *priv = dev_get_drvdata(&pdev->dev); struct snd_sof_pdata *sof_pdata = priv->sof_pdata; - if (!IS_ERR(priv->pdev_pcm)) + if (!IS_ERR_OR_NULL(priv->pdev_pcm)) platform_device_unregister(priv->pdev_pcm); release_firmware(sof_pdata->fw); @@ -257,7 +252,6 @@ MODULE_DEVICE_TABLE(acpi, sof_acpi_match); static struct platform_driver snd_sof_acpi_driver = { .probe = sof_acpi_probe, .remove = sof_acpi_remove, - .shutdown = sof_acpi_shutdown, .driver = { .name = "sof-audio-acpi", .pm = &sof_acpi_pm, diff --git a/sound/soc/sof/sof-pci-dev.c b/sound/soc/sof/sof-pci-dev.c index 449ff9cbc793aab..cf7976fb4335b2b 100644 --- a/sound/soc/sof/sof-pci-dev.c +++ b/sound/soc/sof/sof-pci-dev.c @@ -263,7 +263,7 @@ static int sof_pci_probe(struct pci_dev *pci, } /* allow runtime_pm */ - pm_runtime_set_autosuspend_delay(dev, SND_SOF_SUSPEND_DELAY); + pm_runtime_set_autosuspend_delay(dev, SND_SOF_SUSPEND_DELAY_MS); pm_runtime_use_autosuspend(dev); /* @@ -283,18 +283,13 @@ static int sof_pci_probe(struct pci_dev *pci, return ret; } -static void sof_pci_shutdown(struct pci_dev *pci) -{ - snd_sof_shutdown(&pci->dev); -} - static void sof_pci_remove(struct pci_dev *pci) { struct sof_platform_priv *priv = pci_get_drvdata(pci); struct snd_sof_pdata *sof_pdata = priv->sof_pdata; /* unregister sof-audio platform driver */ - if (!IS_ERR(priv->pdev_pcm)) + if (!IS_ERR_OR_NULL(priv->pdev_pcm)) platform_device_unregister(priv->pdev_pcm); /* release firmware */ @@ -351,7 +346,6 @@ static struct pci_driver snd_sof_pci_driver = { .id_table = sof_pci_ids, .probe = sof_pci_probe, .remove = sof_pci_remove, - .shutdown = sof_pci_shutdown, .driver = { .pm = &sof_pci_pm, }, diff --git a/sound/soc/sof/sof-priv.h b/sound/soc/sof/sof-priv.h index f3c609320a3bb28..a5f8f2d2baa9fca 100644 --- a/sound/soc/sof/sof-priv.h +++ b/sound/soc/sof/sof-priv.h @@ -33,7 +33,7 @@ #define SND_SOF_BARS 8 /* time in ms for runtime suspend delay */ -#define SND_SOF_SUSPEND_DELAY 2000 +#define SND_SOF_SUSPEND_DELAY_MS 2000 /* DMA buffer size for trace */ #define DMA_BUF_SIZE_FOR_TRACE (PAGE_SIZE * 16) @@ -396,7 +396,6 @@ struct sof_platform_priv { /* * Device Level. */ -void snd_sof_shutdown(struct device *dev); int snd_sof_runtime_suspend(struct device *dev); int snd_sof_runtime_resume(struct device *dev); int snd_sof_resume(struct device *dev); diff --git a/sound/soc/sof/sof-spi-dev.c b/sound/soc/sof/sof-spi-dev.c index 372a5d1ed00e75e..81d79bcee10f4d7 100644 --- a/sound/soc/sof/sof-spi-dev.c +++ b/sound/soc/sof/sof-spi-dev.c @@ -22,13 +22,6 @@ #include "hw-spi.h" #include "ops.h" -static const struct dev_pm_ops spi_pm = { - SET_SYSTEM_SLEEP_PM_OPS(snd_sof_suspend, snd_sof_resume) - SET_RUNTIME_PM_OPS(snd_sof_runtime_suspend, snd_sof_runtime_resume, - NULL) - .suspend_late = snd_sof_suspend_late, -}; - /* FIXME: replace with some meaningful values */ static struct snd_soc_acpi_mach spi_machines[] = { { @@ -147,7 +140,7 @@ static int sof_spi_probe(struct spi_device *spi) spi->irq = irq; /* allow runtime_pm */ - pm_runtime_set_autosuspend_delay(dev, SND_SOF_SUSPEND_DELAY); + pm_runtime_set_autosuspend_delay(dev, SND_SOF_SUSPEND_DELAY_MS); pm_runtime_use_autosuspend(dev); pm_runtime_allow(dev); @@ -159,7 +152,7 @@ static int sof_spi_remove(struct spi_device *spi) struct sof_platform_priv *priv = spi_get_drvdata(spi); struct snd_sof_pdata *sof_pdata = priv->sof_pdata; - if (!IS_ERR(priv->pdev_pcm)) + if (!IS_ERR_OR_NULL(priv->pdev_pcm)) platform_device_unregister(priv->pdev_pcm); release_firmware(sof_pdata->fw); diff --git a/sound/soc/sof/topology.c b/sound/soc/sof/topology.c index 06e94809aa3586f..b09db12d8298443 100644 --- a/sound/soc/sof/topology.c +++ b/sound/soc/sof/topology.c @@ -258,7 +258,6 @@ static int sof_control_load_volume(struct snd_soc_component *scomp, struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp); struct snd_soc_tplg_mixer_control *mc = (struct snd_soc_tplg_mixer_control *)hdr; - struct sof_ipc_ctrl_data *cdata; /* validate topology data */ if (le32_to_cpu(mc->num_channels) > SND_SOC_TPLG_MAX_CHAN) @@ -269,7 +268,6 @@ static int sof_control_load_volume(struct snd_soc_component *scomp, sizeof(struct sof_ipc_ctrl_value_chan) * le32_to_cpu(mc->num_channels); scontrol->control_data = kzalloc(scontrol->size, GFP_KERNEL); - cdata = scontrol->control_data; if (!scontrol->control_data) return -ENOMEM; @@ -2708,7 +2706,6 @@ EXPORT_SYMBOL(snd_sof_init_topology); int snd_sof_load_topology(struct snd_sof_dev *sdev, const char *file) { const struct firmware *fw; - struct snd_soc_tplg_hdr *hdr; int ret; if (sdev->tplg_loaded) { @@ -2725,7 +2722,6 @@ int snd_sof_load_topology(struct snd_sof_dev *sdev, const char *file) return ret; } - hdr = (struct snd_soc_tplg_hdr *)fw->data; ret = snd_soc_tplg_component_load(sdev->component, &sof_tplg_ops, fw, SND_SOC_TPLG_INDEX_ALL); diff --git a/sound/soc/sof/trace.c b/sound/soc/sof/trace.c index 9871a174f9ca119..c268b560b12f078 100644 --- a/sound/soc/sof/trace.c +++ b/sound/soc/sof/trace.c @@ -75,8 +75,7 @@ static ssize_t sof_dfsentry_trace_read(struct file *file, char __user *buffer, lpos_64 = lpos; lpos = do_div(lpos_64, buffer_size); - if (count > buffer_size - lpos) - count = buffer_size - lpos; + count = min(count, (size_t)(buffer_size - lpos)); /* get available count based on current host offset */ avail = sof_wait_trace_avail(sdev, lpos, buffer_size); @@ -86,7 +85,7 @@ static ssize_t sof_dfsentry_trace_read(struct file *file, char __user *buffer, } /* make sure count is <= avail */ - count = avail > count ? count : avail; + count = min(avail, count); /* copy available trace data to debugfs */ rem = copy_to_user(buffer, dfse->buf + lpos, count); diff --git a/sound/soc/sof/utils.c b/sound/soc/sof/utils.c index bf66e14bc258b1f..ccaf58d8c2264da 100644 --- a/sound/soc/sof/utils.c +++ b/sound/soc/sof/utils.c @@ -55,7 +55,8 @@ int sof_create_platform_device(struct sof_platform_priv *priv) struct device *dev = sof_pdata->dev; priv->pdev_pcm = - platform_device_register_data(dev, "sof-audio", -1, + platform_device_register_data(dev, "sof-audio", + PLATFORM_DEVID_NONE, sof_pdata, sizeof(*sof_pdata)); if (IS_ERR(priv->pdev_pcm)) { dev_err(dev, "error: cannot register device sof-audio. Error %d\n",