summaryrefslogtreecommitdiffstats
path: root/drivers/staging/greybus/module.c
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <greg@kroah.com>2014-10-24 18:46:15 +0800
committerGreg Kroah-Hartman <greg@kroah.com>2014-10-24 19:00:21 +0800
commit066799c18ff476642858fb0e4050c5c600c47e4c (patch)
treeaedbb8adc98c91a22b88fbeff79220b25e69a677 /drivers/staging/greybus/module.c
parent3e6d5f3a6103b20c70f4d75b90d2c798045cc7ef (diff)
downloadlinux-066799c18ff476642858fb0e4050c5c600c47e4c.tar.gz
linux-066799c18ff476642858fb0e4050c5c600c47e4c.tar.bz2
linux-066799c18ff476642858fb0e4050c5c600c47e4c.zip
greybus: module: don't create duplicate module ids
If we somehow get a hotplug event for a module id that we already have created[1], don't try to create it again, or sysfs will complain loudly. Instead, abort the creation properly. [1] If, for example, you happened to run a script on a greybus emulator twice in a row... Signed-off-by: Greg Kroah-Hartman <greg@kroah.com> Reviewed-by: Alex Elder <elder@linaro.org>
Diffstat (limited to 'drivers/staging/greybus/module.c')
-rw-r--r--drivers/staging/greybus/module.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/drivers/staging/greybus/module.c b/drivers/staging/greybus/module.c
index f9415c0f735e..54e8f9e68d25 100644
--- a/drivers/staging/greybus/module.c
+++ b/drivers/staging/greybus/module.c
@@ -70,6 +70,13 @@ struct gb_module *gb_module_create(struct greybus_host_device *hd, u8 module_id)
struct gb_module *gmod;
int retval;
+ gmod = gb_module_find(hd, module_id);
+ if (gmod) {
+ dev_err(hd->parent, "Duplicate module id %d will not be created\n",
+ module_id);
+ return NULL;
+ }
+
gmod = kzalloc(sizeof(*gmod), GFP_KERNEL);
if (!gmod)
return NULL;