forked from Minki/linux
Simplify i2c acess in OP-TEE driver
-----BEGIN PGP SIGNATURE----- iQJOBAABCgA4FiEEFV+gSSXZJY9ZyuB5LinzTIcAHJcFAmAhMfEaHGplbnMud2lr bGFuZGVyQGxpbmFyby5vcmcACgkQLinzTIcAHJcIQBAArhVQWNNouxrFlDZgZ4fV 0Gowe9tHmDCJDQFpHVsVwIXXGYBfE4keAE5yxTd0mgbPe1/8vua9EjEfpPWoyonH UdlxPxWOYJ3aMEe4cU1Ok76wIrYvpEAgeFti1up9vTIaeEuFHgYMPqf42P3q882Y gOycRIBTtoLzpSzrxl3H2GkG/362NMpqdLAzhyNA5dxFm6D++7gSai1PPr7exikg c1NkDoawK9X9mqtCwnI4jBaCio57P1iuHmIig4abod3+0G2WMja4Gs/fmarJDJx8 ktBNNsJc1W07024jOr4MS8lvTseQ5wM7csUFwst6fRAEmB578c0XVz4GqPWm3TKP /6yYpL/qku2txT5kr2YacfDqnLeJ96y5YtpC9rh18cXs8NIJzJS7QCKDYvsYQxr3 MLyHF6KS1sQWxi7dej+NOg3fRHigoZTliM7G451eSmEnFF96Gbwb1VIQ9DTFQKwm tKwwR5vpo6uSCbZKNh4nelCcrnH7404tqcjkpKo1DtphEXFs4MAs35qitgF+dTBE DElz8EDYVvGVxnhADV0OoG5LIWGLsgaIWLiOpuBS8M/M5M+6sI7w+ZFUbQUv2woV IOwHChkFqXVtWPa0DxHysYn/6Jo5biydncLxxmGx9KhIt4PL64eajSoBNkiqod1k lfyQQbexeU0zUbriKN/PIrM= =yi2I -----END PGP SIGNATURE----- Merge tag 'optee-simplify-i2c-access_for-v5.12' of git://git.linaro.org/people/jens.wiklander/linux-tee into arm/drivers Simplify i2c acess in OP-TEE driver * tag 'optee-simplify-i2c-access_for-v5.12' of git://git.linaro.org/people/jens.wiklander/linux-tee: optee: simplify i2c access Link: https://lore.kernel.org/soc/20210208125853.GA288348%40jade Signed-off-by: Arnd Bergmann <arnd@arndb.de>
This commit is contained in:
commit
d0236f17c3
@ -55,8 +55,9 @@ bad:
|
||||
static void handle_rpc_func_cmd_i2c_transfer(struct tee_context *ctx,
|
||||
struct optee_msg_arg *arg)
|
||||
{
|
||||
struct i2c_client client = { 0 };
|
||||
struct tee_param *params;
|
||||
struct i2c_adapter *adapter;
|
||||
struct i2c_msg msg = { };
|
||||
size_t i;
|
||||
int ret = -EOPNOTSUPP;
|
||||
u8 attr[] = {
|
||||
@ -86,48 +87,48 @@ static void handle_rpc_func_cmd_i2c_transfer(struct tee_context *ctx,
|
||||
goto bad;
|
||||
}
|
||||
|
||||
client.adapter = i2c_get_adapter(params[0].u.value.b);
|
||||
if (!client.adapter)
|
||||
adapter = i2c_get_adapter(params[0].u.value.b);
|
||||
if (!adapter)
|
||||
goto bad;
|
||||
|
||||
if (params[1].u.value.a & OPTEE_RPC_I2C_FLAGS_TEN_BIT) {
|
||||
if (!i2c_check_functionality(client.adapter,
|
||||
if (!i2c_check_functionality(adapter,
|
||||
I2C_FUNC_10BIT_ADDR)) {
|
||||
i2c_put_adapter(client.adapter);
|
||||
i2c_put_adapter(adapter);
|
||||
goto bad;
|
||||
}
|
||||
|
||||
client.flags = I2C_CLIENT_TEN;
|
||||
msg.flags = I2C_M_TEN;
|
||||
}
|
||||
|
||||
client.addr = params[0].u.value.c;
|
||||
snprintf(client.name, I2C_NAME_SIZE, "i2c%d", client.adapter->nr);
|
||||
msg.addr = params[0].u.value.c;
|
||||
msg.buf = params[2].u.memref.shm->kaddr;
|
||||
msg.len = params[2].u.memref.size;
|
||||
|
||||
switch (params[0].u.value.a) {
|
||||
case OPTEE_RPC_I2C_TRANSFER_RD:
|
||||
ret = i2c_master_recv(&client, params[2].u.memref.shm->kaddr,
|
||||
params[2].u.memref.size);
|
||||
msg.flags |= I2C_M_RD;
|
||||
break;
|
||||
case OPTEE_RPC_I2C_TRANSFER_WR:
|
||||
ret = i2c_master_send(&client, params[2].u.memref.shm->kaddr,
|
||||
params[2].u.memref.size);
|
||||
break;
|
||||
default:
|
||||
i2c_put_adapter(client.adapter);
|
||||
i2c_put_adapter(adapter);
|
||||
goto bad;
|
||||
}
|
||||
|
||||
ret = i2c_transfer(adapter, &msg, 1);
|
||||
|
||||
if (ret < 0) {
|
||||
arg->ret = TEEC_ERROR_COMMUNICATION;
|
||||
} else {
|
||||
params[3].u.value.a = ret;
|
||||
params[3].u.value.a = msg.len;
|
||||
if (optee_to_msg_param(arg->params, arg->num_params, params))
|
||||
arg->ret = TEEC_ERROR_BAD_PARAMETERS;
|
||||
else
|
||||
arg->ret = TEEC_SUCCESS;
|
||||
}
|
||||
|
||||
i2c_put_adapter(client.adapter);
|
||||
i2c_put_adapter(adapter);
|
||||
kfree(params);
|
||||
return;
|
||||
bad:
|
||||
|
Loading…
Reference in New Issue
Block a user