]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
stm32mp: stm32f7_i2c: use calloc instead of kmalloc
authorPatrick Delaunay <patrick.delaunay@st.com>
Mon, 12 Mar 2018 09:46:09 +0000 (10:46 +0100)
committerTom Rini <trini@konsulko.com>
Mon, 19 Mar 2018 20:14:21 +0000 (16:14 -0400)
Kmalloc is using memalign allocation function. It is not necessary to
align this structure so to save bytes, we move to calloc.

And kmalloc function can't be used in SPL early stage (in board_init_f())

Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
drivers/i2c/stm32f7_i2c.c

index 86624878e2eacc77cfe2cf42bd8793d5d8a44b04..81f061aecd8da97fa0e66a060ae99ed163edeade 100644 (file)
@@ -533,7 +533,7 @@ static int stm32_i2c_compute_solutions(struct stm32_i2c_setup *setup,
                                if (((sdadel >= sdadel_min) &&
                                     (sdadel <= sdadel_max)) &&
                                    (p != p_prev)) {
-                                       v = kmalloc(sizeof(*v), GFP_KERNEL);
+                                       v = calloc(1, sizeof(*v));
                                        if (!v)
                                                return -ENOMEM;
 
@@ -689,7 +689,7 @@ exit:
        /* Release list and memory */
        list_for_each_entry_safe(v, _v, &solutions, node) {
                list_del(&v->node);
-               kfree(v);
+               free(v);
        }
 
        return ret;