mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2026-01-06 15:01:35 +00:00
This removes a bunch of unnecessary typecasts, since you can assign to/from void * without them. This also uncovered a few cases where const was being cast away for the input params; now fixed. BUG=none TEST=mkbp hash from u-boot console, and/or system boots ok Change-Id: Ic314b9d2ca06226ea8a09703ef5c1a912eb7146d Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/28500
54 lines
1.3 KiB
C
54 lines
1.3 KiB
C
/* Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*/
|
|
|
|
/* I2C host commands for Chrome EC */
|
|
|
|
#include "host_command.h"
|
|
#include "i2c.h"
|
|
#include "system.h"
|
|
|
|
int i2c_command_read(struct host_cmd_handler_args *args)
|
|
{
|
|
const struct ec_params_i2c_read *p = args->params;
|
|
struct ec_response_i2c_read *r = args->response;
|
|
int data, rv = -1;
|
|
|
|
if (system_is_locked())
|
|
return EC_RES_ACCESS_DENIED;
|
|
|
|
if (p->read_size == 16)
|
|
rv = i2c_read16(p->port, p->addr, p->offset, &data);
|
|
else if (p->read_size == 8)
|
|
rv = i2c_read8(p->port, p->addr, p->offset, &data);
|
|
|
|
if (rv)
|
|
return EC_RES_ERROR;
|
|
r->data = data;
|
|
args->response_size = sizeof(*r);
|
|
|
|
return EC_RES_SUCCESS;
|
|
}
|
|
DECLARE_HOST_COMMAND(EC_CMD_I2C_READ, i2c_command_read, EC_VER_MASK(0));
|
|
|
|
int i2c_command_write(struct host_cmd_handler_args *args)
|
|
{
|
|
const struct ec_params_i2c_write *p = args->params;
|
|
int rv = -1;
|
|
|
|
if (system_is_locked())
|
|
return EC_RES_ACCESS_DENIED;
|
|
|
|
if (p->write_size == 16)
|
|
rv = i2c_write16(p->port, p->addr, p->offset, p->data);
|
|
else if (p->write_size == 8)
|
|
rv = i2c_write8(p->port, p->addr, p->offset, p->data);
|
|
|
|
if (rv)
|
|
return EC_RES_ERROR;
|
|
|
|
return EC_RES_SUCCESS;
|
|
}
|
|
DECLARE_HOST_COMMAND(EC_CMD_I2C_WRITE, i2c_command_write, EC_VER_MASK(0));
|