]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
Merge remote-tracking branch 'driver-core/driver-core-next'
authorStephen Rothwell <sfr@canb.auug.org.au>
Thu, 11 Feb 2016 02:40:39 +0000 (13:40 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Thu, 11 Feb 2016 02:40:39 +0000 (13:40 +1100)
1  2 
drivers/base/component.c

diff --combined drivers/base/component.c
index 2738039aae9eea49f1ce6c593dc0392199f7ebb9,2085b234f7c8b83b4f15413c6cb13528f672f235..0ed3b72b814b37ec16944ac5a88937390f01d80c
@@@ -206,8 -206,6 +206,8 @@@ static void component_match_release(str
                if (mc->release)
                        mc->release(master, mc->data);
        }
 +
 +      kfree(match->compare);
  }
  
  static void devm_component_match_release(struct device *dev, void *res)
@@@ -223,14 -221,14 +223,14 @@@ static int component_match_realloc(stru
        if (match->alloc == num)
                return 0;
  
 -      new = devm_kmalloc_array(dev, num, sizeof(*new), GFP_KERNEL);
 +      new = kmalloc_array(num, sizeof(*new), GFP_KERNEL);
        if (!new)
                return -ENOMEM;
  
        if (match->compare) {
                memcpy(new, match->compare, sizeof(*new) *
                                            min(match->num, num));
 -              devm_kfree(dev, match->compare);
 +              kfree(match->compare);
        }
        match->compare = new;
        match->alloc = num;
@@@ -267,7 -265,7 +267,7 @@@ void component_match_add_release(struc
        }
  
        if (match->num == match->alloc) {
-               size_t new_size = match ? match->alloc + 16 : 15;
+               size_t new_size = match->alloc + 16;
                int ret;
  
                ret = component_match_realloc(master, match, new_size);
  }
  EXPORT_SYMBOL(component_match_add_release);
  
 +static void free_master(struct master *master)
 +{
 +      struct component_match *match = master->match;
 +      int i;
 +
 +      list_del(&master->node);
 +
 +      if (match) {
 +              for (i = 0; i < match->num; i++) {
 +                      struct component *c = match->compare[i].component;
 +                      if (c)
 +                              c->master = NULL;
 +              }
 +      }
 +
 +      kfree(master);
 +}
 +
  int component_master_add_with_match(struct device *dev,
        const struct component_master_ops *ops,
        struct component_match *match)
  
        ret = try_to_bring_up_master(master, NULL);
  
 -      if (ret < 0) {
 -              /* Delete off the list if we weren't successful */
 -              list_del(&master->node);
 -              kfree(master);
 -      }
 +      if (ret < 0)
 +              free_master(master);
 +
        mutex_unlock(&component_mutex);
  
        return ret < 0 ? ret : 0;
@@@ -342,12 -324,25 +342,12 @@@ void component_master_del(struct devic
        const struct component_master_ops *ops)
  {
        struct master *master;
 -      int i;
  
        mutex_lock(&component_mutex);
        master = __master_find(dev, ops);
        if (master) {
 -              struct component_match *match = master->match;
 -
                take_down_master(master);
 -
 -              list_del(&master->node);
 -
 -              if (match) {
 -                      for (i = 0; i < match->num; i++) {
 -                              struct component *c = match->compare[i].component;
 -                              if (c)
 -                                      c->master = NULL;
 -                      }
 -              }
 -              kfree(master);
 +              free_master(master);
        }
        mutex_unlock(&component_mutex);
  }