864-gpiommc_configfs_locking.patch 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. The gpiommc configfs context structure needs locking, as configfs
  2. does not lock access between files.
  3. --- a/drivers/mmc/host/gpiommc.c
  4. +++ b/drivers/mmc/host/gpiommc.c
  5. @@ -144,6 +144,8 @@ struct gpiommc_configfs_device {
  6. struct platform_device *pdev;
  7. /* The configuration */
  8. struct gpiommc_platform_data pdata;
  9. + /* Mutex to protect this structure */
  10. + struct mutex mutex;
  11. };
  12. #define GPIO_INVALID -1
  13. @@ -234,6 +236,8 @@ static ssize_t gpiommc_config_attr_show(
  14. unsigned int gpio;
  15. int err = 0;
  16. + mutex_lock(&dev->mutex);
  17. +
  18. if (attr == &gpiommc_attr_DI) {
  19. gpio = dev->pdata.pins.gpio_di;
  20. if (gpio == GPIO_INVALID)
  21. @@ -294,6 +298,8 @@ static ssize_t gpiommc_config_attr_show(
  22. WARN_ON(1);
  23. err = -ENOSYS;
  24. out:
  25. + mutex_unlock(&dev->mutex);
  26. +
  27. return err ? err : count;
  28. }
  29. @@ -353,6 +359,8 @@ static ssize_t gpiommc_config_attr_store
  30. int err = -EINVAL;
  31. unsigned long data;
  32. + mutex_lock(&dev->mutex);
  33. +
  34. if (attr == &gpiommc_attr_register) {
  35. err = kstrtoul(page, 10, &data);
  36. if (err)
  37. @@ -478,6 +486,8 @@ static ssize_t gpiommc_config_attr_store
  38. WARN_ON(1);
  39. err = -ENOSYS;
  40. out:
  41. + mutex_unlock(&dev->mutex);
  42. +
  43. return err ? err : count;
  44. }
  45. @@ -514,6 +524,7 @@ static struct config_item *gpiommc_make_
  46. if (!dev)
  47. return NULL;
  48. + mutex_init(&dev->mutex);
  49. config_item_init_type_name(&dev->item, name,
  50. &gpiommc_dev_ci_type);