Commit 5799f95a authored by Bill Richardson's avatar Bill Richardson Committed by Lee Jones

mfd: cros_ec: cleanup: Remove EC wrapper functions

Remove the three wrapper functions that talk to the EC without passing all
the desired arguments and just use the underlying communication function
that passes everything in a struct intead.

This is internal code refactoring only. Nothing should change.
Signed-off-by: default avatarBill Richardson <wfrichar@chromium.org>
Signed-off-by: default avatarDoug Anderson <dianders@chromium.org>
Reviewed-by: default avatarSimon Glass <sjg@chromium.org>
Acked-by: default avatarWolfram Sang <wsa@the-dreams.de>
Acked-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: default avatarLee Jones <lee.jones@linaro.org>
parent 533cec8f
...@@ -183,6 +183,7 @@ static int ec_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg i2c_msgs[], ...@@ -183,6 +183,7 @@ static int ec_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg i2c_msgs[],
u8 *request = NULL; u8 *request = NULL;
u8 *response = NULL; u8 *response = NULL;
int result; int result;
struct cros_ec_command msg;
request_len = ec_i2c_count_message(i2c_msgs, num); request_len = ec_i2c_count_message(i2c_msgs, num);
if (request_len < 0) { if (request_len < 0) {
...@@ -218,9 +219,15 @@ static int ec_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg i2c_msgs[], ...@@ -218,9 +219,15 @@ static int ec_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg i2c_msgs[],
} }
ec_i2c_construct_message(request, i2c_msgs, num, bus_num); ec_i2c_construct_message(request, i2c_msgs, num, bus_num);
result = bus->ec->command_sendrecv(bus->ec, EC_CMD_I2C_PASSTHRU,
request, request_len, msg.version = 0;
response, response_len); msg.command = EC_CMD_I2C_PASSTHRU;
msg.outdata = request;
msg.outsize = request_len;
msg.indata = response;
msg.insize = response_len;
result = bus->ec->cmd_xfer(bus->ec, &msg);
if (result) if (result)
goto exit; goto exit;
...@@ -258,7 +265,7 @@ static int ec_i2c_probe(struct platform_device *pdev) ...@@ -258,7 +265,7 @@ static int ec_i2c_probe(struct platform_device *pdev)
u32 remote_bus; u32 remote_bus;
int err; int err;
if (!ec->command_sendrecv) { if (!ec->cmd_xfer) {
dev_err(dev, "Missing sendrecv\n"); dev_err(dev, "Missing sendrecv\n");
return -EINVAL; return -EINVAL;
} }
......
...@@ -191,8 +191,16 @@ static void cros_ec_keyb_close(struct input_dev *dev) ...@@ -191,8 +191,16 @@ static void cros_ec_keyb_close(struct input_dev *dev)
static int cros_ec_keyb_get_state(struct cros_ec_keyb *ckdev, uint8_t *kb_state) static int cros_ec_keyb_get_state(struct cros_ec_keyb *ckdev, uint8_t *kb_state)
{ {
return ckdev->ec->command_recv(ckdev->ec, EC_CMD_MKBP_STATE, struct cros_ec_command msg = {
kb_state, ckdev->cols); .version = 0,
.command = EC_CMD_MKBP_STATE,
.outdata = NULL,
.outsize = 0,
.indata = kb_state,
.insize = ckdev->cols,
};
return ckdev->ec->cmd_xfer(ckdev->ec, &msg);
} }
static int cros_ec_keyb_work(struct notifier_block *nb, static int cros_ec_keyb_work(struct notifier_block *nb,
......
...@@ -44,34 +44,6 @@ int cros_ec_prepare_tx(struct cros_ec_device *ec_dev, ...@@ -44,34 +44,6 @@ int cros_ec_prepare_tx(struct cros_ec_device *ec_dev,
} }
EXPORT_SYMBOL(cros_ec_prepare_tx); EXPORT_SYMBOL(cros_ec_prepare_tx);
static int cros_ec_command_sendrecv(struct cros_ec_device *ec_dev,
uint16_t cmd, void *out_buf, int out_len,
void *in_buf, int in_len)
{
struct cros_ec_command msg;
msg.version = cmd >> 8;
msg.command = cmd & 0xff;
msg.outdata = out_buf;
msg.outsize = out_len;
msg.indata = in_buf;
msg.insize = in_len;
return ec_dev->cmd_xfer(ec_dev, &msg);
}
static int cros_ec_command_recv(struct cros_ec_device *ec_dev,
uint16_t cmd, void *buf, int buf_len)
{
return cros_ec_command_sendrecv(ec_dev, cmd, NULL, 0, buf, buf_len);
}
static int cros_ec_command_send(struct cros_ec_device *ec_dev,
uint16_t cmd, void *buf, int buf_len)
{
return cros_ec_command_sendrecv(ec_dev, cmd, buf, buf_len, NULL, 0);
}
static irqreturn_t ec_irq_thread(int irq, void *data) static irqreturn_t ec_irq_thread(int irq, void *data)
{ {
struct cros_ec_device *ec_dev = data; struct cros_ec_device *ec_dev = data;
...@@ -104,10 +76,6 @@ int cros_ec_register(struct cros_ec_device *ec_dev) ...@@ -104,10 +76,6 @@ int cros_ec_register(struct cros_ec_device *ec_dev)
BLOCKING_INIT_NOTIFIER_HEAD(&ec_dev->event_notifier); BLOCKING_INIT_NOTIFIER_HEAD(&ec_dev->event_notifier);
ec_dev->command_send = cros_ec_command_send;
ec_dev->command_recv = cros_ec_command_recv;
ec_dev->command_sendrecv = cros_ec_command_sendrecv;
if (ec_dev->din_size) { if (ec_dev->din_size) {
ec_dev->din = devm_kzalloc(dev, ec_dev->din_size, GFP_KERNEL); ec_dev->din = devm_kzalloc(dev, ec_dev->din_size, GFP_KERNEL);
if (!ec_dev->din) if (!ec_dev->din)
......
...@@ -63,9 +63,10 @@ struct cros_ec_command { ...@@ -63,9 +63,10 @@ struct cros_ec_command {
* @was_wake_device: true if this device was set to wake the system from * @was_wake_device: true if this device was set to wake the system from
* sleep at the last suspend * sleep at the last suspend
* @event_notifier: interrupt event notifier for transport devices * @event_notifier: interrupt event notifier for transport devices
* @command_send: send a command * @cmd_xfer: send command to EC and get response
* @command_recv: receive a response * Returns 0 if the communication succeeded, but that doesn't mean the EC
* @command_sendrecv: send a command and receive a response * was happy with the command it got. Caller should check msg.result for
* the EC's result code.
* *
* @priv: Private data * @priv: Private data
* @irq: Interrupt to use * @irq: Interrupt to use
...@@ -83,7 +84,6 @@ struct cros_ec_command { ...@@ -83,7 +84,6 @@ struct cros_ec_command {
* @parent: pointer to parent device (e.g. i2c or spi device) * @parent: pointer to parent device (e.g. i2c or spi device)
* @wake_enabled: true if this device can wake the system from sleep * @wake_enabled: true if this device can wake the system from sleep
* @lock: one transaction at a time * @lock: one transaction at a time
* @cmd_xfer: low-level channel to the EC
*/ */
struct cros_ec_device { struct cros_ec_device {
...@@ -94,13 +94,8 @@ struct cros_ec_device { ...@@ -94,13 +94,8 @@ struct cros_ec_device {
bool was_wake_device; bool was_wake_device;
struct class *cros_class; struct class *cros_class;
struct blocking_notifier_head event_notifier; struct blocking_notifier_head event_notifier;
int (*command_send)(struct cros_ec_device *ec, int (*cmd_xfer)(struct cros_ec_device *ec,
uint16_t cmd, void *out_buf, int out_len); struct cros_ec_command *msg);
int (*command_recv)(struct cros_ec_device *ec,
uint16_t cmd, void *in_buf, int in_len);
int (*command_sendrecv)(struct cros_ec_device *ec,
uint16_t cmd, void *out_buf, int out_len,
void *in_buf, int in_len);
/* These are used to implement the platform-specific interface */ /* These are used to implement the platform-specific interface */
void *priv; void *priv;
...@@ -112,8 +107,6 @@ struct cros_ec_device { ...@@ -112,8 +107,6 @@ struct cros_ec_device {
struct device *parent; struct device *parent;
bool wake_enabled; bool wake_enabled;
struct mutex lock; struct mutex lock;
int (*cmd_xfer)(struct cros_ec_device *ec,
struct cros_ec_command *msg);
}; };
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment