greybus: endo: fix device-id allocation
authorJohan Hovold <johan@hovoldconsulting.com>
Wed, 21 Oct 2015 09:51:43 +0000 (11:51 +0200)
committerGreg Kroah-Hartman <gregkh@google.com>
Wed, 21 Oct 2015 23:12:42 +0000 (16:12 -0700)
During endo registration, a unique device id was allocated but then
never used. Instead the default dev_id 0 (due to kzalloc) was used for
device-generation and later for id-deallocation.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
drivers/staging/greybus/endo.c

index c0dc43f..37d2dec 100644 (file)
@@ -438,11 +438,14 @@ static int create_modules(struct gb_endo *endo)
 static int gb_endo_register(struct greybus_host_device *hd,
                            struct gb_endo *endo)
 {
+       int dev_id;
        int retval;
 
-       retval = ida_simple_get(&greybus_endo_id_map, 0, 0, GFP_KERNEL);
-       if (retval < 0)
-               return retval;
+       dev_id = ida_simple_get(&greybus_endo_id_map, 0, 0, GFP_KERNEL);
+       if (dev_id < 0)
+               return dev_id;
+
+       endo->dev_id = dev_id;
 
        endo->dev.parent = hd->parent;
        endo->dev.bus = &greybus_bus_type;