From 10b4802867f6c3026c4aebe3d4e048b95e60fd19 Mon Sep 17 00:00:00 2001 From: nbd Date: Tue, 17 Jul 2012 11:35:10 -0400 Subject: [PATCH 031/123] 864-gpiommc_configfs_locking The gpiommc configfs context structure needs locking, as configfs does not lock access between files. Import of the above patch from openwrt trunk, as of this commit: ---------- commit c1d79f64eed0a7ac36b5b9bca52275b397bec424 Author: nbd Date: Mon Jul 16 16:26:51 2012 +0000 uboot-ar71xx: fix compile on recent mac os x versions git-svn-id: svn://svn.openwrt.org/openwrt/trunk@32750 3c298f89-4303-0410-b956-a3cf2f4a3e73 ---------- Path to patch in the repo is: target/linux/generic/patches-3.3 Repo is: git://nbd.name/openwrt.git Signed-off-by: Paul Gortmaker --- drivers/mmc/host/gpiommc.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/mmc/host/gpiommc.c b/drivers/mmc/host/gpiommc.c index 1fa4d5d..7a0e2ee 100644 --- a/drivers/mmc/host/gpiommc.c +++ b/drivers/mmc/host/gpiommc.c @@ -144,6 +144,8 @@ struct gpiommc_configfs_device { struct platform_device *pdev; /* The configuration */ struct gpiommc_platform_data pdata; + /* Mutex to protect this structure */ + struct mutex mutex; }; #define GPIO_INVALID -1 @@ -234,6 +236,8 @@ static ssize_t gpiommc_config_attr_show(struct config_item *item, unsigned int gpio; int err = 0; + mutex_lock(&dev->mutex); + if (attr == &gpiommc_attr_DI) { gpio = dev->pdata.pins.gpio_di; if (gpio == GPIO_INVALID) @@ -294,6 +298,8 @@ static ssize_t gpiommc_config_attr_show(struct config_item *item, WARN_ON(1); err = -ENOSYS; out: + mutex_unlock(&dev->mutex); + return err ? err : count; } @@ -353,6 +359,8 @@ static ssize_t gpiommc_config_attr_store(struct config_item *item, int err = -EINVAL; unsigned long data; + mutex_lock(&dev->mutex); + if (attr == &gpiommc_attr_register) { err = strict_strtoul(page, 10, &data); if (err) @@ -478,6 +486,8 @@ static ssize_t gpiommc_config_attr_store(struct config_item *item, WARN_ON(1); err = -ENOSYS; out: + mutex_unlock(&dev->mutex); + return err ? err : count; } @@ -514,6 +524,7 @@ static struct config_item *gpiommc_make_item(struct config_group *group, if (!dev) return NULL; + mutex_init(&dev->mutex); config_item_init_type_name(&dev->item, name, &gpiommc_dev_ci_type); -- 1.7.9.7