Commit b4fd4f89 authored by Sreedhara DS's avatar Sreedhara DS Committed by Linus Torvalds

intel_scu_ipc: Oops/crash fixes

- fix reversing of command/sub arguments
- fix a crash if the i2c interface is called before the device is found
Signed-off-by: default avatarSreedhara DS <sreedhara.ds@intel.com>
Signed-off-by: default avatarAlan Cox <alan@linux.intel.com>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent a9f7f2e7
...@@ -489,7 +489,7 @@ int intel_scu_ipc_simple_command(int cmd, int sub) ...@@ -489,7 +489,7 @@ int intel_scu_ipc_simple_command(int cmd, int sub)
mutex_unlock(&ipclock); mutex_unlock(&ipclock);
return -ENODEV; return -ENODEV;
} }
ipc_command(cmd << 12 | sub); ipc_command(sub << 12 | cmd);
err = busy_loop(); err = busy_loop();
mutex_unlock(&ipclock); mutex_unlock(&ipclock);
return err; return err;
...@@ -501,9 +501,9 @@ EXPORT_SYMBOL(intel_scu_ipc_simple_command); ...@@ -501,9 +501,9 @@ EXPORT_SYMBOL(intel_scu_ipc_simple_command);
* @cmd: command * @cmd: command
* @sub: sub type * @sub: sub type
* @in: input data * @in: input data
* @inlen: input length * @inlen: input length in dwords
* @out: output data * @out: output data
* @outlein: output length * @outlein: output length in dwords
* *
* Issue a command to the SCU which involves data transfers. Do the * Issue a command to the SCU which involves data transfers. Do the
* data copies under the lock but leave it for the caller to interpret * data copies under the lock but leave it for the caller to interpret
...@@ -524,7 +524,7 @@ int intel_scu_ipc_command(int cmd, int sub, u32 *in, int inlen, ...@@ -524,7 +524,7 @@ int intel_scu_ipc_command(int cmd, int sub, u32 *in, int inlen,
for (i = 0; i < inlen; i++) for (i = 0; i < inlen; i++)
ipc_data_writel(*in++, 4 * i); ipc_data_writel(*in++, 4 * i);
ipc_command((cmd << 12) | sub | (inlen << 18)); ipc_command((sub << 12) | cmd | (inlen << 18));
err = busy_loop(); err = busy_loop();
for (i = 0; i < outlen; i++) for (i = 0; i < outlen; i++)
...@@ -556,6 +556,10 @@ int intel_scu_ipc_i2c_cntrl(u32 addr, u32 *data) ...@@ -556,6 +556,10 @@ int intel_scu_ipc_i2c_cntrl(u32 addr, u32 *data)
u32 cmd = 0; u32 cmd = 0;
mutex_lock(&ipclock); mutex_lock(&ipclock);
if (ipcdev.pdev == NULL) {
mutex_unlock(&ipclock);
return -ENODEV;
}
cmd = (addr >> 24) & 0xFF; cmd = (addr >> 24) & 0xFF;
if (cmd == IPC_I2C_READ) { if (cmd == IPC_I2C_READ) {
writel(addr, ipcdev.i2c_base + IPC_I2C_CNTRL_ADDR); writel(addr, ipcdev.i2c_base + IPC_I2C_CNTRL_ADDR);
......
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