@@ -214,17 +214,28 @@ static int psp_send_i2c_req(enum psp_i2c_req_type i2c_req_type)
214
214
PSP_I2C_REQ_RETRY_DELAY_US ,
215
215
PSP_I2C_REQ_RETRY_CNT * PSP_I2C_REQ_RETRY_DELAY_US ,
216
216
0 , req );
217
- if (ret )
217
+ if (ret ) {
218
+ dev_err (psp_i2c_dev , "Timed out waiting for PSP to %s I2C bus\n" ,
219
+ (i2c_req_type == PSP_I2C_REQ_ACQUIRE ) ?
220
+ "release" : "acquire" );
218
221
goto cleanup ;
222
+ }
219
223
220
224
ret = status ;
221
- if (ret )
225
+ if (ret ) {
226
+ dev_err (psp_i2c_dev , "PSP communication error\n" );
222
227
goto cleanup ;
228
+ }
223
229
224
230
dev_dbg (psp_i2c_dev , "Request accepted by PSP after %ums\n" ,
225
231
jiffies_to_msecs (jiffies - start ));
226
232
227
233
cleanup :
234
+ if (ret ) {
235
+ dev_err (psp_i2c_dev , "Assume i2c bus is for exclusive host usage\n" );
236
+ psp_i2c_mbox_fail = true;
237
+ }
238
+
228
239
kfree (req );
229
240
return ret ;
230
241
}
@@ -249,16 +260,8 @@ static int psp_acquire_i2c_bus(void)
249
260
}
250
261
251
262
status = psp_send_i2c_req (PSP_I2C_REQ_ACQUIRE );
252
- if (status ) {
253
- if (status == - ETIMEDOUT )
254
- dev_err (psp_i2c_dev , "Timed out waiting for PSP to release I2C bus\n" );
255
- else
256
- dev_err (psp_i2c_dev , "PSP communication error\n" );
257
-
258
- dev_err (psp_i2c_dev , "Assume i2c bus is for exclusive host usage\n" );
259
- psp_i2c_mbox_fail = true;
263
+ if (status )
260
264
goto cleanup ;
261
- }
262
265
263
266
psp_i2c_sem_acquired = jiffies ;
264
267
psp_i2c_access_count ++ ;
@@ -294,16 +297,8 @@ static void psp_release_i2c_bus(void)
294
297
295
298
/* Send a release command to PSP */
296
299
status = psp_send_i2c_req (PSP_I2C_REQ_RELEASE );
297
- if (status ) {
298
- if (status == - ETIMEDOUT )
299
- dev_err (psp_i2c_dev , "Timed out waiting for PSP to acquire I2C bus\n" );
300
- else
301
- dev_err (psp_i2c_dev , "PSP communication error\n" );
302
-
303
- dev_err (psp_i2c_dev , "Assume i2c bus is for exclusive host usage\n" );
304
- psp_i2c_mbox_fail = true;
300
+ if (status )
305
301
goto cleanup ;
306
- }
307
302
308
303
dev_dbg (psp_i2c_dev , "PSP semaphore held for %ums\n" ,
309
304
jiffies_to_msecs (jiffies - psp_i2c_sem_acquired ));
0 commit comments