Skip to content

Commit

Permalink
drivers: se050: Avoid calling i2c functions
Browse files Browse the repository at this point in the history
If CFG_CORE_SE05X_I2C_TRAMPOLINE is set to y, it means there are no
i2c native implementations inside OP-TEE and we should avoid calling
those functions either at compile or run time.

Signed-off-by: Donald Chan <[email protected]>
  • Loading branch information
hoihochan committed Sep 16, 2024
1 parent b78dd3f commit a5d8baf
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion core/drivers/crypto/se050/adaptors/apis/sss.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ sss_status_t se050_enable_scp03(sss_se05x_session_t *session)
if (status != kStatus_SSS_Success)
continue;

if (session->subsystem)
if (session && session->subsystem)
sss_se05x_session_close(session);

if (!se050_core_early_init(&keys)) {
Expand Down
5 changes: 5 additions & 0 deletions core/drivers/crypto/se050/glue/i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,14 @@ int glue_i2c_init(void)
if (transfer == rpc_io_i2c_transfer)
return 0;

#if !CFG_CORE_SE05X_I2C_TRAMPOLINE
transfer = native_i2c_transfer;

return native_i2c_init();
#else
/* not reached */
return 0;
#endif
}

static TEE_Result load_trampoline(void)
Expand Down
5 changes: 4 additions & 1 deletion core/drivers/crypto/se050/session.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,10 @@ static TEE_Result se050_session_init(void)
if (IS_ENABLED(CFG_CORE_SCP03_ONLY))
return se050_early_init_scp03();

return se050_early_init_default();
if (!IS_ENABLED(CFG_CORE_SE05X_I2C_TRAMPOLINE))
return se050_early_init_default();

return TEE_SUCCESS;
}

driver_init(se050_session_init);

0 comments on commit a5d8baf

Please sign in to comment.