Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/sound/sof.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
5 changes: 2 additions & 3 deletions sound/soc/sof/control.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
22 changes: 7 additions & 15 deletions sound/soc/sof/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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",
Expand Down
16 changes: 8 additions & 8 deletions sound/soc/sof/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
Expand All @@ -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;
Expand Down
2 changes: 0 additions & 2 deletions sound/soc/sof/intel/hda-dai.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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) {
Expand Down
5 changes: 3 additions & 2 deletions sound/soc/sof/intel/hda.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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 */
Expand Down
25 changes: 10 additions & 15 deletions sound/soc/sof/ipc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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),
Expand All @@ -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 */
Expand Down
4 changes: 1 addition & 3 deletions sound/soc/sof/loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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 */
Expand Down
38 changes: 18 additions & 20 deletions sound/soc/sof/ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

Expand All @@ -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);

Expand All @@ -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;

Expand All @@ -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);

Expand Down Expand Up @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions sound/soc/sof/ops.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion sound/soc/sof/pcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Loading