diff options
author | Sreedhara DS <sreedhara.ds@intel.com> | 2010-07-19 04:37:42 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-07-19 16:17:37 -0400 |
commit | b4fd4f890bca2291a12bb0807027db40f929a82d (patch) | |
tree | 12d55f40767af5841778b858e3b1085d18bb130c | |
parent | a9f7f2e74ae0e6a801a2433dc8e9124d73da0cb4 (diff) |
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: Sreedhara DS <sreedhara.ds@intel.com>
Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | drivers/platform/x86/intel_scu_ipc.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/drivers/platform/x86/intel_scu_ipc.c b/drivers/platform/x86/intel_scu_ipc.c index 40658e3385b4..bb2f1fba637b 100644 --- a/drivers/platform/x86/intel_scu_ipc.c +++ b/drivers/platform/x86/intel_scu_ipc.c | |||
@@ -489,7 +489,7 @@ int intel_scu_ipc_simple_command(int cmd, int sub) | |||
489 | mutex_unlock(&ipclock); | 489 | mutex_unlock(&ipclock); |
490 | return -ENODEV; | 490 | return -ENODEV; |
491 | } | 491 | } |
492 | ipc_command(cmd << 12 | sub); | 492 | ipc_command(sub << 12 | cmd); |
493 | err = busy_loop(); | 493 | err = busy_loop(); |
494 | mutex_unlock(&ipclock); | 494 | mutex_unlock(&ipclock); |
495 | return err; | 495 | return err; |
@@ -501,9 +501,9 @@ EXPORT_SYMBOL(intel_scu_ipc_simple_command); | |||
501 | * @cmd: command | 501 | * @cmd: command |
502 | * @sub: sub type | 502 | * @sub: sub type |
503 | * @in: input data | 503 | * @in: input data |
504 | * @inlen: input length | 504 | * @inlen: input length in dwords |
505 | * @out: output data | 505 | * @out: output data |
506 | * @outlein: output length | 506 | * @outlein: output length in dwords |
507 | * | 507 | * |
508 | * Issue a command to the SCU which involves data transfers. Do the | 508 | * Issue a command to the SCU which involves data transfers. Do the |
509 | * data copies under the lock but leave it for the caller to interpret | 509 | * 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 | for (i = 0; i < inlen; i++) | 524 | for (i = 0; i < inlen; i++) |
525 | ipc_data_writel(*in++, 4 * i); | 525 | ipc_data_writel(*in++, 4 * i); |
526 | 526 | ||
527 | ipc_command((cmd << 12) | sub | (inlen << 18)); | 527 | ipc_command((sub << 12) | cmd | (inlen << 18)); |
528 | err = busy_loop(); | 528 | err = busy_loop(); |
529 | 529 | ||
530 | for (i = 0; i < outlen; i++) | 530 | for (i = 0; i < outlen; i++) |
@@ -556,6 +556,10 @@ int intel_scu_ipc_i2c_cntrl(u32 addr, u32 *data) | |||
556 | u32 cmd = 0; | 556 | u32 cmd = 0; |
557 | 557 | ||
558 | mutex_lock(&ipclock); | 558 | mutex_lock(&ipclock); |
559 | if (ipcdev.pdev == NULL) { | ||
560 | mutex_unlock(&ipclock); | ||
561 | return -ENODEV; | ||
562 | } | ||
559 | cmd = (addr >> 24) & 0xFF; | 563 | cmd = (addr >> 24) & 0xFF; |
560 | if (cmd == IPC_I2C_READ) { | 564 | if (cmd == IPC_I2C_READ) { |
561 | writel(addr, ipcdev.i2c_base + IPC_I2C_CNTRL_ADDR); | 565 | writel(addr, ipcdev.i2c_base + IPC_I2C_CNTRL_ADDR); |