The gpiommc configfs interface needs locking.
[openwrt.git] / target / linux / generic-2.6 / patches-2.6.25 / 923-gpiommc-configfs-locking.patch
1 The gpiommc configfs context structure needs locking, as configfs
2 does not lock access between files.
3
4 Index: linux-2.6.25.10/drivers/mmc/host/gpiommc.c
5 ===================================================================
6 --- linux-2.6.25.10.orig/drivers/mmc/host/gpiommc.c     2008-07-21 11:57:01.000000000 +0200
7 +++ linux-2.6.25.10/drivers/mmc/host/gpiommc.c  2008-07-21 12:01:33.000000000 +0200
8 @@ -143,6 +143,8 @@ struct gpiommc_configfs_device {
9         struct platform_device *pdev;
10         /* The configuration */
11         struct gpiommc_platform_data pdata;
12 +       /* Mutex to protect this structure */
13 +       struct mutex mutex;
14  };
15  
16  #define GPIO_INVALID   -1
17 @@ -233,6 +235,8 @@ static ssize_t gpiommc_config_attr_show(
18         unsigned int gpio;
19         int err = 0;
20  
21 +       mutex_lock(&dev->mutex);
22 +
23         if (attr == &gpiommc_attr_DI) {
24                 gpio = dev->pdata.pins.gpio_di;
25                 if (gpio == GPIO_INVALID)
26 @@ -293,6 +297,8 @@ static ssize_t gpiommc_config_attr_show(
27         WARN_ON(1);
28         err = -ENOSYS;
29  out:
30 +       mutex_unlock(&dev->mutex);
31 +
32         return err ? err : count;
33  }
34  
35 @@ -352,6 +358,8 @@ static ssize_t gpiommc_config_attr_store
36         int err = -EINVAL;
37         unsigned long data;
38  
39 +       mutex_lock(&dev->mutex);
40 +
41         if (attr == &gpiommc_attr_register) {
42                 err = strict_strtoul(page, 10, &data);
43                 if (err)
44 @@ -477,6 +485,8 @@ static ssize_t gpiommc_config_attr_store
45         WARN_ON(1);
46         err = -ENOSYS;
47  out:
48 +       mutex_unlock(&dev->mutex);
49 +
50         return err ? err : count;
51  }
52  
53 @@ -513,6 +523,7 @@ static struct config_item *gpiommc_make_
54         if (!dev)
55                 return NULL;
56  
57 +       mutex_init(&dev->mutex);
58         config_item_init_type_name(&dev->item, name,
59                                    &gpiommc_dev_ci_type);
60