diff options
| -rw-r--r-- | drivers/mfd/cros_ec.c | 10 | ||||
| -rw-r--r-- | drivers/mfd/cros_ec_spi.c | 11 |
2 files changed, 9 insertions, 12 deletions
diff --git a/drivers/mfd/cros_ec.c b/drivers/mfd/cros_ec.c index a9faebdcfa14..c53804a1451d 100644 --- a/drivers/mfd/cros_ec.c +++ b/drivers/mfd/cros_ec.c | |||
| @@ -65,7 +65,13 @@ EXPORT_SYMBOL(cros_ec_check_result); | |||
| 65 | int cros_ec_cmd_xfer(struct cros_ec_device *ec_dev, | 65 | int cros_ec_cmd_xfer(struct cros_ec_device *ec_dev, |
| 66 | struct cros_ec_command *msg) | 66 | struct cros_ec_command *msg) |
| 67 | { | 67 | { |
| 68 | return ec_dev->cmd_xfer(ec_dev, msg); | 68 | int ret; |
| 69 | |||
| 70 | mutex_lock(&ec_dev->lock); | ||
| 71 | ret = ec_dev->cmd_xfer(ec_dev, msg); | ||
| 72 | mutex_unlock(&ec_dev->lock); | ||
| 73 | |||
| 74 | return ret; | ||
| 69 | } | 75 | } |
| 70 | EXPORT_SYMBOL(cros_ec_cmd_xfer); | 76 | EXPORT_SYMBOL(cros_ec_cmd_xfer); |
| 71 | 77 | ||
| @@ -98,6 +104,8 @@ int cros_ec_register(struct cros_ec_device *ec_dev) | |||
| 98 | return -ENOMEM; | 104 | return -ENOMEM; |
| 99 | } | 105 | } |
| 100 | 106 | ||
| 107 | mutex_init(&ec_dev->lock); | ||
| 108 | |||
| 101 | err = mfd_add_devices(dev, 0, cros_devs, | 109 | err = mfd_add_devices(dev, 0, cros_devs, |
| 102 | ARRAY_SIZE(cros_devs), | 110 | ARRAY_SIZE(cros_devs), |
| 103 | NULL, ec_dev->irq, NULL); | 111 | NULL, ec_dev->irq, NULL); |
diff --git a/drivers/mfd/cros_ec_spi.c b/drivers/mfd/cros_ec_spi.c index b396705203fc..bf6e08e8013e 100644 --- a/drivers/mfd/cros_ec_spi.c +++ b/drivers/mfd/cros_ec_spi.c | |||
| @@ -79,13 +79,11 @@ | |||
| 79 | * if no record | 79 | * if no record |
| 80 | * @end_of_msg_delay: used to set the delay_usecs on the spi_transfer that | 80 | * @end_of_msg_delay: used to set the delay_usecs on the spi_transfer that |
| 81 | * is sent when we want to turn off CS at the end of a transaction. | 81 | * is sent when we want to turn off CS at the end of a transaction. |
| 82 | * @lock: mutex to ensure only one user of cros_ec_cmd_xfer_spi at a time | ||
| 83 | */ | 82 | */ |
| 84 | struct cros_ec_spi { | 83 | struct cros_ec_spi { |
| 85 | struct spi_device *spi; | 84 | struct spi_device *spi; |
| 86 | s64 last_transfer_ns; | 85 | s64 last_transfer_ns; |
| 87 | unsigned int end_of_msg_delay; | 86 | unsigned int end_of_msg_delay; |
| 88 | struct mutex lock; | ||
| 89 | }; | 87 | }; |
| 90 | 88 | ||
| 91 | static void debug_packet(struct device *dev, const char *name, u8 *ptr, | 89 | static void debug_packet(struct device *dev, const char *name, u8 *ptr, |
| @@ -232,13 +230,6 @@ static int cros_ec_cmd_xfer_spi(struct cros_ec_device *ec_dev, | |||
| 232 | int sum; | 230 | int sum; |
| 233 | int ret = 0, final_ret; | 231 | int ret = 0, final_ret; |
| 234 | 232 | ||
| 235 | /* | ||
| 236 | * We have the shared ec_dev buffer plus we do lots of separate spi_sync | ||
| 237 | * calls, so we need to make sure only one person is using this at a | ||
| 238 | * time. | ||
| 239 | */ | ||
| 240 | mutex_lock(&ec_spi->lock); | ||
| 241 | |||
| 242 | len = cros_ec_prepare_tx(ec_dev, ec_msg); | 233 | len = cros_ec_prepare_tx(ec_dev, ec_msg); |
| 243 | dev_dbg(ec_dev->dev, "prepared, len=%d\n", len); | 234 | dev_dbg(ec_dev->dev, "prepared, len=%d\n", len); |
| 244 | 235 | ||
| @@ -327,7 +318,6 @@ exit: | |||
| 327 | if (ec_msg->command == EC_CMD_REBOOT_EC) | 318 | if (ec_msg->command == EC_CMD_REBOOT_EC) |
| 328 | msleep(EC_REBOOT_DELAY_MS); | 319 | msleep(EC_REBOOT_DELAY_MS); |
| 329 | 320 | ||
| 330 | mutex_unlock(&ec_spi->lock); | ||
| 331 | return ret; | 321 | return ret; |
| 332 | } | 322 | } |
| 333 | 323 | ||
| @@ -359,7 +349,6 @@ static int cros_ec_spi_probe(struct spi_device *spi) | |||
| 359 | if (ec_spi == NULL) | 349 | if (ec_spi == NULL) |
| 360 | return -ENOMEM; | 350 | return -ENOMEM; |
| 361 | ec_spi->spi = spi; | 351 | ec_spi->spi = spi; |
| 362 | mutex_init(&ec_spi->lock); | ||
| 363 | ec_dev = devm_kzalloc(dev, sizeof(*ec_dev), GFP_KERNEL); | 352 | ec_dev = devm_kzalloc(dev, sizeof(*ec_dev), GFP_KERNEL); |
| 364 | if (!ec_dev) | 353 | if (!ec_dev) |
| 365 | return -ENOMEM; | 354 | return -ENOMEM; |
