diff options
| author | Andrew Bresticker <abrestic@chromium.org> | 2014-09-18 11:18:56 -0400 |
|---|---|---|
| committer | Lee Jones <lee.jones@linaro.org> | 2014-10-06 16:29:07 -0400 |
| commit | a6551a76fff15056fde2342d0f7de41ee605264e (patch) | |
| tree | 94ff2a687fc6c8d7ef55a741b2d7db2634eb508d /include/linux/mfd | |
| parent | 659e142be09482cfd8b9017f616afebc7cf48fa3 (diff) | |
mfd: cros_ec: stop calling ->cmd_xfer() directly
Instead of having users of the ChromeOS EC call the interface-specific
cmd_xfer() callback directly, introduce a central cros_ec_cmd_xfer()
to use instead. This will allow us to put all the locking and retry
logic in one place instead of duplicating it across the different
drivers.
Signed-off-by: Andrew Bresticker <abrestic@chromium.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Javier Martinez Canillas <javier.martinez@collabora.co.uk>
Reviewed-by: Doug Anderson <dianders@chromium.org>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Diffstat (limited to 'include/linux/mfd')
| -rw-r--r-- | include/linux/mfd/cros_ec.h | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/include/linux/mfd/cros_ec.h b/include/linux/mfd/cros_ec.h index fcbe9d129a9d..0e166b92f5b4 100644 --- a/include/linux/mfd/cros_ec.h +++ b/include/linux/mfd/cros_ec.h | |||
| @@ -62,10 +62,6 @@ struct cros_ec_command { | |||
| 62 | * @dev: Device pointer | 62 | * @dev: Device pointer |
| 63 | * @was_wake_device: true if this device was set to wake the system from | 63 | * @was_wake_device: true if this device was set to wake the system from |
| 64 | * sleep at the last suspend | 64 | * sleep at the last suspend |
| 65 | * @cmd_xfer: send command to EC and get response | ||
| 66 | * Returns the number of bytes received if the communication succeeded, but | ||
| 67 | * that doesn't mean the EC was happy with the command. The caller | ||
| 68 | * should check msg.result for the EC's result code. | ||
| 69 | * | 65 | * |
| 70 | * @priv: Private data | 66 | * @priv: Private data |
| 71 | * @irq: Interrupt to use | 67 | * @irq: Interrupt to use |
| @@ -82,6 +78,10 @@ struct cros_ec_command { | |||
| 82 | * @dout_size: size of dout buffer to allocate (zero to use static dout) | 78 | * @dout_size: size of dout buffer to allocate (zero to use static dout) |
| 83 | * @parent: pointer to parent device (e.g. i2c or spi device) | 79 | * @parent: pointer to parent device (e.g. i2c or spi device) |
| 84 | * @wake_enabled: true if this device can wake the system from sleep | 80 | * @wake_enabled: true if this device can wake the system from sleep |
| 81 | * @cmd_xfer: send command to EC and get response | ||
| 82 | * Returns the number of bytes received if the communication succeeded, but | ||
| 83 | * that doesn't mean the EC was happy with the command. The caller | ||
| 84 | * should check msg.result for the EC's result code. | ||
| 85 | * @lock: one transaction at a time | 85 | * @lock: one transaction at a time |
| 86 | */ | 86 | */ |
| 87 | struct cros_ec_device { | 87 | struct cros_ec_device { |
| @@ -92,8 +92,6 @@ struct cros_ec_device { | |||
| 92 | struct device *dev; | 92 | struct device *dev; |
| 93 | bool was_wake_device; | 93 | bool was_wake_device; |
| 94 | struct class *cros_class; | 94 | struct class *cros_class; |
| 95 | int (*cmd_xfer)(struct cros_ec_device *ec, | ||
| 96 | struct cros_ec_command *msg); | ||
| 97 | 95 | ||
| 98 | /* These are used to implement the platform-specific interface */ | 96 | /* These are used to implement the platform-specific interface */ |
| 99 | void *priv; | 97 | void *priv; |
| @@ -104,6 +102,8 @@ struct cros_ec_device { | |||
| 104 | int dout_size; | 102 | int dout_size; |
| 105 | struct device *parent; | 103 | struct device *parent; |
| 106 | bool wake_enabled; | 104 | bool wake_enabled; |
| 105 | int (*cmd_xfer)(struct cros_ec_device *ec, | ||
| 106 | struct cros_ec_command *msg); | ||
| 107 | struct mutex lock; | 107 | struct mutex lock; |
| 108 | }; | 108 | }; |
| 109 | 109 | ||
| @@ -153,6 +153,18 @@ int cros_ec_check_result(struct cros_ec_device *ec_dev, | |||
| 153 | struct cros_ec_command *msg); | 153 | struct cros_ec_command *msg); |
| 154 | 154 | ||
| 155 | /** | 155 | /** |
| 156 | * cros_ec_cmd_xfer - Send a command to the ChromeOS EC | ||
| 157 | * | ||
| 158 | * Call this to send a command to the ChromeOS EC. This should be used | ||
| 159 | * instead of calling the EC's cmd_xfer() callback directly. | ||
| 160 | * | ||
| 161 | * @ec_dev: EC device | ||
| 162 | * @msg: Message to write | ||
| 163 | */ | ||
| 164 | int cros_ec_cmd_xfer(struct cros_ec_device *ec_dev, | ||
| 165 | struct cros_ec_command *msg); | ||
| 166 | |||
| 167 | /** | ||
| 156 | * cros_ec_remove - Remove a ChromeOS EC | 168 | * cros_ec_remove - Remove a ChromeOS EC |
| 157 | * | 169 | * |
| 158 | * Call this to deregister a ChromeOS EC, then clean up any private data. | 170 | * Call this to deregister a ChromeOS EC, then clean up any private data. |
