aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/platform/x86/intel_scu_ipc.c
diff options
context:
space:
mode:
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>2015-01-21 14:38:10 -0500
committerDarren Hart <dvhart@linux.intel.com>2015-01-29 00:21:10 -0500
commitf0295a36dc31774019be278468e22c254f9626e4 (patch)
treed12cf699e782c7a6b107842f180c129ffc801428 /drivers/platform/x86/intel_scu_ipc.c
parent7c2e3c74767cf108635d1a5bd9fe014474c61ebf (diff)
intel_scu_ipc: move error check out of the loop
This is small performance optimization of the busy_loop(). While here, use BIT() macro instead of plain integers when check the status. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Darren Hart <dvhart@linux.intel.com>
Diffstat (limited to 'drivers/platform/x86/intel_scu_ipc.c')
-rw-r--r--drivers/platform/x86/intel_scu_ipc.c25
1 files changed, 12 insertions, 13 deletions
diff --git a/drivers/platform/x86/intel_scu_ipc.c b/drivers/platform/x86/intel_scu_ipc.c
index 8938c31be447..e6430a3454cf 100644
--- a/drivers/platform/x86/intel_scu_ipc.c
+++ b/drivers/platform/x86/intel_scu_ipc.c
@@ -176,21 +176,21 @@ static inline u32 ipc_data_readl(u32 offset) /* Read ipc u32 data */
176/* Wait till scu status is busy */ 176/* Wait till scu status is busy */
177static inline int busy_loop(void) 177static inline int busy_loop(void)
178{ 178{
179 u32 status = 0; 179 u32 status = ipc_read_status();
180 u32 loop_count = 0; 180 u32 loop_count = 100000;
181 181
182 status = ipc_read_status(); 182 /* break if scu doesn't reset busy bit after huge retry */
183 while (status & 1) { 183 while ((status & BIT(0)) && --loop_count) {
184 udelay(1); /* scu processing time is in few u secods */ 184 udelay(1); /* scu processing time is in few u secods */
185 status = ipc_read_status(); 185 status = ipc_read_status();
186 loop_count++;
187 /* break if scu doesn't reset busy bit after huge retry */
188 if (loop_count > 100000) {
189 dev_err(&ipcdev.pdev->dev, "IPC timed out");
190 return -ETIMEDOUT;
191 }
192 } 186 }
193 if ((status >> 1) & 1) 187
188 if (status & BIT(0)) {
189 dev_err(&ipcdev.pdev->dev, "IPC timed out");
190 return -ETIMEDOUT;
191 }
192
193 if (status & BIT(1))
194 return -EIO; 194 return -EIO;
195 195
196 return 0; 196 return 0;
@@ -208,8 +208,7 @@ static inline int ipc_wait_for_interrupt(void)
208 } 208 }
209 209
210 status = ipc_read_status(); 210 status = ipc_read_status();
211 211 if (status & BIT(1))
212 if ((status >> 1) & 1)
213 return -EIO; 212 return -EIO;
214 213
215 return 0; 214 return 0;