treewide: devm_kzalloc() -> devm_kcalloc()

The devm_kzalloc() function has a 2-factor argument form, devm_kcalloc().
This patch replaces cases of:

        devm_kzalloc(handle, a * b, gfp)

with:
        devm_kcalloc(handle, a * b, gfp)

as well as handling cases of:

        devm_kzalloc(handle, a * b * c, gfp)

with:

        devm_kzalloc(handle, array3_size(a, b, c), gfp)

as it's slightly less ugly than:

        devm_kcalloc(handle, array_size(a, b), c, gfp)

This does, however, attempt to ignore constant size factors like:

        devm_kzalloc(handle, 4 * 1024, gfp)

though any constants defined via macros get caught up in the conversion.

Any factors with a sizeof() of "unsigned char", "char", and "u8" were
dropped, since they're redundant.

Some manual whitespace fixes were needed in this patch, as Coccinelle
really liked to write "=devm_kcalloc..." instead of "= devm_kcalloc...".

The Coccinelle script used for this was:

// Fix redundant parens around sizeof().
@@
expression HANDLE;
type TYPE;
expression THING, E;
@@

(
  devm_kzalloc(HANDLE,
-	(sizeof(TYPE)) * E
+	sizeof(TYPE) * E
  , ...)
|
  devm_kzalloc(HANDLE,
-	(sizeof(THING)) * E
+	sizeof(THING) * E
  , ...)
)

// Drop single-byte sizes and redundant parens.
@@
expression HANDLE;
expression COUNT;
typedef u8;
typedef __u8;
@@

(
  devm_kzalloc(HANDLE,
-	sizeof(u8) * (COUNT)
+	COUNT
  , ...)
|
  devm_kzalloc(HANDLE,
-	sizeof(__u8) * (COUNT)
+	COUNT
  , ...)
|
  devm_kzalloc(HANDLE,
-	sizeof(char) * (COUNT)
+	COUNT
  , ...)
|
  devm_kzalloc(HANDLE,
-	sizeof(unsigned char) * (COUNT)
+	COUNT
  , ...)
|
  devm_kzalloc(HANDLE,
-	sizeof(u8) * COUNT
+	COUNT
  , ...)
|
  devm_kzalloc(HANDLE,
-	sizeof(__u8) * COUNT
+	COUNT
  , ...)
|
  devm_kzalloc(HANDLE,
-	sizeof(char) * COUNT
+	COUNT
  , ...)
|
  devm_kzalloc(HANDLE,
-	sizeof(unsigned char) * COUNT
+	COUNT
  , ...)
)

// 2-factor product with sizeof(type/expression) and identifier or constant.
@@
expression HANDLE;
type TYPE;
expression THING;
identifier COUNT_ID;
constant COUNT_CONST;
@@

(
- devm_kzalloc
+ devm_kcalloc
  (HANDLE,
-	sizeof(TYPE) * (COUNT_ID)
+	COUNT_ID, sizeof(TYPE)
  , ...)
|
- devm_kzalloc
+ devm_kcalloc
  (HANDLE,
-	sizeof(TYPE) * COUNT_ID
+	COUNT_ID, sizeof(TYPE)
  , ...)
|
- devm_kzalloc
+ devm_kcalloc
  (HANDLE,
-	sizeof(TYPE) * (COUNT_CONST)
+	COUNT_CONST, sizeof(TYPE)
  , ...)
|
- devm_kzalloc
+ devm_kcalloc
  (HANDLE,
-	sizeof(TYPE) * COUNT_CONST
+	COUNT_CONST, sizeof(TYPE)
  , ...)
|
- devm_kzalloc
+ devm_kcalloc
  (HANDLE,
-	sizeof(THING) * (COUNT_ID)
+	COUNT_ID, sizeof(THING)
  , ...)
|
- devm_kzalloc
+ devm_kcalloc
  (HANDLE,
-	sizeof(THING) * COUNT_ID
+	COUNT_ID, sizeof(THING)
  , ...)
|
- devm_kzalloc
+ devm_kcalloc
  (HANDLE,
-	sizeof(THING) * (COUNT_CONST)
+	COUNT_CONST, sizeof(THING)
  , ...)
|
- devm_kzalloc
+ devm_kcalloc
  (HANDLE,
-	sizeof(THING) * COUNT_CONST
+	COUNT_CONST, sizeof(THING)
  , ...)
)

// 2-factor product, only identifiers.
@@
expression HANDLE;
identifier SIZE, COUNT;
@@

- devm_kzalloc
+ devm_kcalloc
  (HANDLE,
-	SIZE * COUNT
+	COUNT, SIZE
  , ...)

// 3-factor product with 1 sizeof(type) or sizeof(expression), with
// redundant parens removed.
@@
expression HANDLE;
expression THING;
identifier STRIDE, COUNT;
type TYPE;
@@

(
  devm_kzalloc(HANDLE,
-	sizeof(TYPE) * (COUNT) * (STRIDE)
+	array3_size(COUNT, STRIDE, sizeof(TYPE))
  , ...)
|
  devm_kzalloc(HANDLE,
-	sizeof(TYPE) * (COUNT) * STRIDE
+	array3_size(COUNT, STRIDE, sizeof(TYPE))
  , ...)
|
  devm_kzalloc(HANDLE,
-	sizeof(TYPE) * COUNT * (STRIDE)
+	array3_size(COUNT, STRIDE, sizeof(TYPE))
  , ...)
|
  devm_kzalloc(HANDLE,
-	sizeof(TYPE) * COUNT * STRIDE
+	array3_size(COUNT, STRIDE, sizeof(TYPE))
  , ...)
|
  devm_kzalloc(HANDLE,
-	sizeof(THING) * (COUNT) * (STRIDE)
+	array3_size(COUNT, STRIDE, sizeof(THING))
  , ...)
|
  devm_kzalloc(HANDLE,
-	sizeof(THING) * (COUNT) * STRIDE
+	array3_size(COUNT, STRIDE, sizeof(THING))
  , ...)
|
  devm_kzalloc(HANDLE,
-	sizeof(THING) * COUNT * (STRIDE)
+	array3_size(COUNT, STRIDE, sizeof(THING))
  , ...)
|
  devm_kzalloc(HANDLE,
-	sizeof(THING) * COUNT * STRIDE
+	array3_size(COUNT, STRIDE, sizeof(THING))
  , ...)
)

// 3-factor product with 2 sizeof(variable), with redundant parens removed.
@@
expression HANDLE;
expression THING1, THING2;
identifier COUNT;
type TYPE1, TYPE2;
@@

(
  devm_kzalloc(HANDLE,
-	sizeof(TYPE1) * sizeof(TYPE2) * COUNT
+	array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
  , ...)
|
  devm_kzalloc(HANDLE,
-	sizeof(TYPE1) * sizeof(THING2) * (COUNT)
+	array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
  , ...)
|
  devm_kzalloc(HANDLE,
-	sizeof(THING1) * sizeof(THING2) * COUNT
+	array3_size(COUNT, sizeof(THING1), sizeof(THING2))
  , ...)
|
  devm_kzalloc(HANDLE,
-	sizeof(THING1) * sizeof(THING2) * (COUNT)
+	array3_size(COUNT, sizeof(THING1), sizeof(THING2))
  , ...)
|
  devm_kzalloc(HANDLE,
-	sizeof(TYPE1) * sizeof(THING2) * COUNT
+	array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
  , ...)
|
  devm_kzalloc(HANDLE,
-	sizeof(TYPE1) * sizeof(THING2) * (COUNT)
+	array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
  , ...)
)

// 3-factor product, only identifiers, with redundant parens removed.
@@
expression HANDLE;
identifier STRIDE, SIZE, COUNT;
@@

(
  devm_kzalloc(HANDLE,
-	(COUNT) * STRIDE * SIZE
+	array3_size(COUNT, STRIDE, SIZE)
  , ...)
|
  devm_kzalloc(HANDLE,
-	COUNT * (STRIDE) * SIZE
+	array3_size(COUNT, STRIDE, SIZE)
  , ...)
|
  devm_kzalloc(HANDLE,
-	COUNT * STRIDE * (SIZE)
+	array3_size(COUNT, STRIDE, SIZE)
  , ...)
|
  devm_kzalloc(HANDLE,
-	(COUNT) * (STRIDE) * SIZE
+	array3_size(COUNT, STRIDE, SIZE)
  , ...)
|
  devm_kzalloc(HANDLE,
-	COUNT * (STRIDE) * (SIZE)
+	array3_size(COUNT, STRIDE, SIZE)
  , ...)
|
  devm_kzalloc(HANDLE,
-	(COUNT) * STRIDE * (SIZE)
+	array3_size(COUNT, STRIDE, SIZE)
  , ...)
|
  devm_kzalloc(HANDLE,
-	(COUNT) * (STRIDE) * (SIZE)
+	array3_size(COUNT, STRIDE, SIZE)
  , ...)
|
  devm_kzalloc(HANDLE,
-	COUNT * STRIDE * SIZE
+	array3_size(COUNT, STRIDE, SIZE)
  , ...)
)

// Any remaining multi-factor products, first at least 3-factor products,
// when they're not all constants...
@@
expression HANDLE;
expression E1, E2, E3;
constant C1, C2, C3;
@@

(
  devm_kzalloc(HANDLE, C1 * C2 * C3, ...)
|
  devm_kzalloc(HANDLE,
-	(E1) * E2 * E3
+	array3_size(E1, E2, E3)
  , ...)
|
  devm_kzalloc(HANDLE,
-	(E1) * (E2) * E3
+	array3_size(E1, E2, E3)
  , ...)
|
  devm_kzalloc(HANDLE,
-	(E1) * (E2) * (E3)
+	array3_size(E1, E2, E3)
  , ...)
|
  devm_kzalloc(HANDLE,
-	E1 * E2 * E3
+	array3_size(E1, E2, E3)
  , ...)
)

// And then all remaining 2 factors products when they're not all constants,
// keeping sizeof() as the second factor argument.
@@
expression HANDLE;
expression THING, E1, E2;
type TYPE;
constant C1, C2, C3;
@@

(
  devm_kzalloc(HANDLE, sizeof(THING) * C2, ...)
|
  devm_kzalloc(HANDLE, sizeof(TYPE) * C2, ...)
|
  devm_kzalloc(HANDLE, C1 * C2 * C3, ...)
|
  devm_kzalloc(HANDLE, C1 * C2, ...)
|
- devm_kzalloc
+ devm_kcalloc
  (HANDLE,
-	sizeof(TYPE) * (E2)
+	E2, sizeof(TYPE)
  , ...)
|
- devm_kzalloc
+ devm_kcalloc
  (HANDLE,
-	sizeof(TYPE) * E2
+	E2, sizeof(TYPE)
  , ...)
|
- devm_kzalloc
+ devm_kcalloc
  (HANDLE,
-	sizeof(THING) * (E2)
+	E2, sizeof(THING)
  , ...)
|
- devm_kzalloc
+ devm_kcalloc
  (HANDLE,
-	sizeof(THING) * E2
+	E2, sizeof(THING)
  , ...)
|
- devm_kzalloc
+ devm_kcalloc
  (HANDLE,
-	(E1) * E2
+	E1, E2
  , ...)
|
- devm_kzalloc
+ devm_kcalloc
  (HANDLE,
-	(E1) * (E2)
+	E1, E2
  , ...)
|
- devm_kzalloc
+ devm_kcalloc
  (HANDLE,
-	E1 * E2
+	E1, E2
  , ...)
)

Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Adam W. Willis <return.of.octobot@gmail.com>
Signed-off-by: UtsavBalar1231 <utsavbalar1231@gmail.com>
This commit is contained in:
Kees Cook
2018-06-12 14:07:58 -07:00
committed by UtsavBalar1231
parent b9863689f7
commit 7076e86f97
304 changed files with 1284 additions and 1053 deletions

View File

@@ -298,8 +298,8 @@ static int acpi_fan_get_fps(struct acpi_device *device)
}
fan->fps_count = obj->package.count - 1; /* minus revision field */
fan->fps = devm_kzalloc(&device->dev,
fan->fps_count * sizeof(struct acpi_fan_fps),
fan->fps = devm_kcalloc(&device->dev,
fan->fps_count, sizeof(struct acpi_fan_fps),
GFP_KERNEL);
if (!fan->fps) {
dev_err(&device->dev, "Not enough memory\n");

View File

@@ -866,9 +866,10 @@ static int __nfit_mem_init(struct acpi_nfit_desc *acpi_desc,
continue;
nfit_mem->nfit_flush = nfit_flush;
flush = nfit_flush->flush;
nfit_mem->flush_wpq = devm_kzalloc(acpi_desc->dev,
flush->hint_count
* sizeof(struct resource), GFP_KERNEL);
nfit_mem->flush_wpq = devm_kcalloc(acpi_desc->dev,
flush->hint_count,
sizeof(struct resource),
GFP_KERNEL);
if (!nfit_mem->flush_wpq)
return -ENOMEM;
for (i = 0; i < flush->hint_count; i++) {

View File

@@ -4116,13 +4116,13 @@ static int mv_platform_probe(struct platform_device *pdev)
if (!host || !hpriv)
return -ENOMEM;
hpriv->port_clks = devm_kzalloc(&pdev->dev,
sizeof(struct clk *) * n_ports,
hpriv->port_clks = devm_kcalloc(&pdev->dev,
n_ports, sizeof(struct clk *),
GFP_KERNEL);
if (!hpriv->port_clks)
return -ENOMEM;
hpriv->port_phys = devm_kzalloc(&pdev->dev,
sizeof(struct phy *) * n_ports,
hpriv->port_phys = devm_kcalloc(&pdev->dev,
n_ports, sizeof(struct phy *),
GFP_KERNEL);
if (!hpriv->port_phys)
return -ENOMEM;

View File

@@ -1027,7 +1027,7 @@ static int tpm2_get_cc_attrs_tbl(struct tpm_chip *chip)
goto out;
}
chip->cc_attrs_tbl = devm_kzalloc(&chip->dev, 4 * nr_commands,
chip->cc_attrs_tbl = devm_kcalloc(&chip->dev, 4, nr_commands,
GFP_KERNEL);
if (!chip->cc_attrs_tbl) {
rc = -ENOMEM;

View File

@@ -768,7 +768,7 @@ static int bcm2835_pll_debug_init(struct clk_hw *hw,
const struct bcm2835_pll_data *data = pll->data;
struct debugfs_reg32 *regs;
regs = devm_kzalloc(cprman->dev, 7 * sizeof(*regs), GFP_KERNEL);
regs = devm_kcalloc(cprman->dev, 7, sizeof(*regs), GFP_KERNEL);
if (!regs)
return -ENOMEM;
@@ -899,7 +899,7 @@ static int bcm2835_pll_divider_debug_init(struct clk_hw *hw,
const struct bcm2835_pll_divider_data *data = divider->data;
struct debugfs_reg32 *regs;
regs = devm_kzalloc(cprman->dev, 7 * sizeof(*regs), GFP_KERNEL);
regs = devm_kcalloc(cprman->dev, 7, sizeof(*regs), GFP_KERNEL);
if (!regs)
return -ENOMEM;

View File

@@ -196,23 +196,23 @@ static int of_get_fmax_vdd_class(struct platform_device *pdev, struct clk *c,
}
prop_len /= 2;
vdd->level_votes = devm_kzalloc(&pdev->dev, prop_len * sizeof(int),
vdd->level_votes = devm_kcalloc(&pdev->dev, prop_len, sizeof(int),
GFP_KERNEL);
if (!vdd->level_votes)
return -ENOMEM;
vdd->vdd_uv = devm_kzalloc(&pdev->dev, prop_len * sizeof(int),
vdd->vdd_uv = devm_kcalloc(&pdev->dev, prop_len, sizeof(int),
GFP_KERNEL);
if (!vdd->vdd_uv)
return -ENOMEM;
c->fmax = devm_kzalloc(&pdev->dev, prop_len * sizeof(unsigned long),
c->fmax = devm_kcalloc(&pdev->dev, prop_len, sizeof(unsigned long),
GFP_KERNEL);
if (!c->fmax)
return -ENOMEM;
array = devm_kzalloc(&pdev->dev,
prop_len * sizeof(u32) * 2, GFP_KERNEL);
array3_size(prop_len, sizeof(u32), 2), GFP_KERNEL);
if (!array)
return -ENOMEM;

View File

@@ -2485,7 +2485,7 @@ struct clk_src *msmclk_parse_clk_src(struct device *dev,
}
num_parents = prop_len / len;
clks = devm_kzalloc(dev, sizeof(*clks) * num_parents, GFP_KERNEL);
clks = devm_kcalloc(dev, num_parents, sizeof(*clks), GFP_KERNEL);
if (!clks)
return ERR_PTR(-ENOMEM);
@@ -2538,8 +2538,8 @@ static int rcg_parse_freq_tbl(struct device *dev,
num_rows = prop_len / 6;
/* Array is null terminated. */
rcg->freq_tbl = devm_kzalloc(dev,
sizeof(*rcg->freq_tbl) * (num_rows + 1),
rcg->freq_tbl = devm_kcalloc(dev,
num_rows + 1, sizeof(*rcg->freq_tbl),
GFP_KERNEL);
if (!rcg->freq_tbl) {
@@ -2646,8 +2646,8 @@ static int parse_rec_parents(struct device *dev,
if (mux->num_rec_parents <= 0)
return 0;
mux->rec_parents = devm_kzalloc(dev,
sizeof(*mux->rec_parents) * mux->num_rec_parents,
mux->rec_parents = devm_kcalloc(dev,
mux->num_rec_parents, sizeof(*mux->rec_parents),
GFP_KERNEL);
if (!mux->rec_parents) {

View File

@@ -530,8 +530,8 @@ static int gdsc_probe(struct platform_device *pdev)
return -EINVAL;
}
sc->clocks = devm_kzalloc(&pdev->dev,
sizeof(struct clk *) * sc->clock_count, GFP_KERNEL);
sc->clocks = devm_kcalloc(&pdev->dev,
sc->clock_count, sizeof(struct clk *), GFP_KERNEL);
if (!sc->clocks)
return -ENOMEM;
@@ -616,9 +616,9 @@ static int gdsc_probe(struct platform_device *pdev)
return -EINVAL;
}
sc->reset_clocks = devm_kzalloc(&pdev->dev,
sizeof(struct reset_control *) *
sc->reset_clocks = devm_kcalloc(&pdev->dev,
sc->reset_count,
sizeof(struct reset_control *),
GFP_KERNEL);
if (!sc->reset_clocks)
return -ENOMEM;

View File

@@ -75,8 +75,8 @@ static int generic_vdd_parse_regulators(struct device *dev,
return -EINVAL;
}
vdd->regulator = devm_kzalloc(dev,
sizeof(*vdd->regulator) * num_regulators,
vdd->regulator = devm_kcalloc(dev,
num_regulators, sizeof(*vdd->regulator),
GFP_KERNEL);
if (!vdd->regulator) {
dt_err(np, "memory alloc failure\n");
@@ -121,10 +121,10 @@ static int generic_vdd_parse_levels(struct device *dev,
}
vdd->num_levels = len / vdd->num_regulators;
vdd->vdd_uv = devm_kzalloc(dev, len * sizeof(*vdd->vdd_uv),
vdd->vdd_uv = devm_kcalloc(dev, len, sizeof(*vdd->vdd_uv),
GFP_KERNEL);
vdd->level_votes = devm_kzalloc(dev,
vdd->num_levels * sizeof(*vdd->level_votes),
vdd->level_votes = devm_kcalloc(dev,
vdd->num_levels, sizeof(*vdd->level_votes),
GFP_KERNEL);
if (!vdd->vdd_uv || !vdd->level_votes) {
@@ -150,7 +150,7 @@ static int generic_vdd_parse_levels(struct device *dev,
return -EINVAL;
}
vdd->vdd_ua = devm_kzalloc(dev, len * sizeof(*vdd->vdd_ua),
vdd->vdd_ua = devm_kcalloc(dev, len, sizeof(*vdd->vdd_ua),
GFP_KERNEL);
if (!vdd->vdd_ua)
return -ENOMEM;
@@ -290,7 +290,8 @@ static int generic_clk_parse_fmax(struct device *dev, struct clk *c,
return rc;
}
c->fmax = devm_kzalloc(dev, sizeof(*c->fmax) * c->num_fmax, GFP_KERNEL);
c->fmax = devm_kcalloc(dev, c->num_fmax, sizeof(*c->fmax),
GFP_KERNEL);
if (!c->fmax)
return -ENOMEM;

View File

@@ -367,23 +367,24 @@ static int cpucc_clk_get_fmax_vdd_class(struct platform_device *pdev,
}
prop_len /= num;
vdd->level_votes = devm_kzalloc(&pdev->dev, prop_len * sizeof(int),
vdd->level_votes = devm_kcalloc(&pdev->dev, prop_len, sizeof(int),
GFP_KERNEL);
if (!vdd->level_votes)
return -ENOMEM;
vdd->vdd_uv = devm_kzalloc(&pdev->dev,
prop_len * sizeof(int) * (num - 1), GFP_KERNEL);
array3_size(prop_len, sizeof(int), (num - 1)),
GFP_KERNEL);
if (!vdd->vdd_uv)
return -ENOMEM;
clk_intd->rate_max = devm_kzalloc(&pdev->dev,
prop_len * sizeof(unsigned long), GFP_KERNEL);
clk_intd->rate_max = devm_kcalloc(&pdev->dev,
prop_len, sizeof(unsigned long), GFP_KERNEL);
if (!clk_intd->rate_max)
return -ENOMEM;
array = devm_kzalloc(&pdev->dev,
prop_len * sizeof(u32) * num, GFP_KERNEL);
array3_size(prop_len, num, sizeof(u32)), GFP_KERNEL);
if (!array)
return -ENOMEM;

View File

@@ -326,23 +326,24 @@ static int cpucc_clk_get_fmax_vdd_class(struct platform_device *pdev,
}
prop_len /= num;
vdd->level_votes = devm_kzalloc(&pdev->dev, prop_len * sizeof(int),
vdd->level_votes = devm_kcalloc(&pdev->dev, prop_len, sizeof(int),
GFP_KERNEL);
if (!vdd->level_votes)
return -ENOMEM;
vdd->vdd_uv = devm_kzalloc(&pdev->dev,
prop_len * sizeof(int) * (num - 1), GFP_KERNEL);
array3_size(prop_len, sizeof(int), (num - 1)),
GFP_KERNEL);
if (!vdd->vdd_uv)
return -ENOMEM;
clk_intd->rate_max = devm_kzalloc(&pdev->dev,
prop_len * sizeof(unsigned long), GFP_KERNEL);
clk_intd->rate_max = devm_kcalloc(&pdev->dev,
prop_len, sizeof(unsigned long), GFP_KERNEL);
if (!clk_intd->rate_max)
return -ENOMEM;
array = devm_kzalloc(&pdev->dev,
prop_len * sizeof(u32) * num, GFP_KERNEL);
array3_size(prop_len, num, sizeof(u32)), GFP_KERNEL);
if (!array)
return -ENOMEM;

View File

@@ -1620,8 +1620,9 @@ int clk_rcg2_get_dfs_clock_rate(struct clk_rcg2 *clk, struct device *dev,
if (!(val & SE_CMD_DFS_EN))
return ret;
dfs_freq_tbl = devm_kzalloc(dev, MAX_PERF_LEVEL *
sizeof(struct freq_tbl), GFP_KERNEL);
dfs_freq_tbl = devm_kcalloc(dev,
MAX_PERF_LEVEL, sizeof(struct freq_tbl),
GFP_KERNEL);
if (!dfs_freq_tbl)
return -ENOMEM;

View File

@@ -738,8 +738,8 @@ static int clk_debug_atoll_probe(struct platform_device *pdev)
return -EINVAL;
}
gcc_debug_mux.regmap = devm_kzalloc(&pdev->dev,
sizeof(struct regmap *) * count, GFP_KERNEL);
gcc_debug_mux.regmap = devm_kcalloc(&pdev->dev,
count, sizeof(struct regmap *), GFP_KERNEL);
if (!gcc_debug_mux.regmap)
return -ENOMEM;

View File

@@ -789,8 +789,8 @@ static int clk_debug_sdmmagpie_probe(struct platform_device *pdev)
return -EINVAL;
}
gcc_debug_mux.regmap = devm_kzalloc(&pdev->dev,
sizeof(struct regmap *) * count, GFP_KERNEL);
gcc_debug_mux.regmap = devm_kcalloc(&pdev->dev,
count, sizeof(struct regmap *), GFP_KERNEL);
if (!gcc_debug_mux.regmap)
return -ENOMEM;

View File

@@ -772,8 +772,8 @@ static int gdsc_probe(struct platform_device *pdev)
return -EINVAL;
}
sc->clocks = devm_kzalloc(&pdev->dev,
sizeof(struct clk *) * sc->clock_count, GFP_KERNEL);
sc->clocks = devm_kcalloc(&pdev->dev,
sc->clock_count, sizeof(struct clk *), GFP_KERNEL);
if (!sc->clocks)
return -ENOMEM;
@@ -938,9 +938,9 @@ static int gdsc_probe(struct platform_device *pdev)
goto err;
}
sc->reset_clocks = devm_kzalloc(&pdev->dev,
sizeof(struct reset_control *) * sc->reset_count,
GFP_KERNEL);
sc->reset_clocks = devm_kcalloc(&pdev->dev,
sc->reset_count, sizeof(struct reset_control *),
GFP_KERNEL);
if (!sc->reset_clocks) {
ret = -ENOMEM;
goto err;

View File

@@ -172,8 +172,9 @@ static int mdss_pll_util_parse_dt_supply(struct platform_device *pdev,
}
pr_debug("vreg found. count=%d\n", mp->num_vreg);
mp->vreg_config = devm_kzalloc(&pdev->dev, sizeof(struct dss_vreg) *
mp->num_vreg, GFP_KERNEL);
mp->vreg_config = devm_kcalloc(&pdev->dev,
mp->num_vreg, sizeof(struct dss_vreg),
GFP_KERNEL);
if (!mp->vreg_config) {
rc = -ENOMEM;
return rc;
@@ -299,8 +300,8 @@ static int mdss_pll_util_parse_dt_clock(struct platform_device *pdev,
goto clk_err;
}
mp->clk_config = devm_kzalloc(&pdev->dev,
sizeof(struct dss_clk) * mp->num_clk, GFP_KERNEL);
mp->clk_config = devm_kcalloc(&pdev->dev,
mp->num_clk, sizeof(struct dss_clk), GFP_KERNEL);
if (!mp->clk_config) {
rc = -ENOMEM;
mp->num_clk = 0;

View File

@@ -501,8 +501,9 @@ static int ti_adpll_init_dco(struct ti_adpll_data *d)
const char *postfix;
int width, err;
d->outputs.clks = devm_kzalloc(d->dev, sizeof(struct clk *) *
d->outputs.clks = devm_kcalloc(d->dev,
MAX_ADPLL_OUTPUTS,
sizeof(struct clk *),
GFP_KERNEL);
if (!d->outputs.clks)
return -ENOMEM;
@@ -915,8 +916,9 @@ static int ti_adpll_probe(struct platform_device *pdev)
if (err)
return err;
d->clocks = devm_kzalloc(d->dev, sizeof(struct ti_adpll_clock) *
d->clocks = devm_kcalloc(d->dev,
TI_ADPLL_NR_CLOCKS,
sizeof(struct ti_adpll_clock),
GFP_KERNEL);
if (!d->clocks)
return -ENOMEM;

View File

@@ -494,7 +494,7 @@ brcm_avs_get_freq_table(struct device *dev, struct private_data *priv)
if (ret)
return ERR_PTR(ret);
table = devm_kzalloc(dev, (AVS_PSTATE_MAX + 1) * sizeof(*table),
table = devm_kcalloc(dev, AVS_PSTATE_MAX + 1, sizeof(*table),
GFP_KERNEL);
if (!table)
return ERR_PTR(-ENOMEM);

View File

@@ -288,7 +288,8 @@ static int imx6q_cpufreq_probe(struct platform_device *pdev)
}
/* Make imx6_soc_volt array's size same as arm opp number */
imx6_soc_volt = devm_kzalloc(cpu_dev, sizeof(*imx6_soc_volt) * num, GFP_KERNEL);
imx6_soc_volt = devm_kcalloc(cpu_dev, num, sizeof(*imx6_soc_volt),
GFP_KERNEL);
if (imx6_soc_volt == NULL) {
ret = -ENOMEM;
goto free_freq_table;

View File

@@ -382,7 +382,7 @@ static struct cpufreq_frequency_table *cpufreq_parse_dt(struct device *dev,
if (nf == 0)
return ERR_PTR(-EINVAL);
data = devm_kzalloc(dev, nf * sizeof(*data), GFP_KERNEL);
data = devm_kcalloc(dev, nf, sizeof(*data), GFP_KERNEL);
if (!data)
return ERR_PTR(-ENOMEM);
@@ -390,7 +390,7 @@ static struct cpufreq_frequency_table *cpufreq_parse_dt(struct device *dev,
if (ret)
return ERR_PTR(ret);
ftbl = devm_kzalloc(dev, (nf + 1) * sizeof(*ftbl), GFP_KERNEL);
ftbl = devm_kcalloc(dev, nf + 1, sizeof(*ftbl), GFP_KERNEL);
if (!ftbl)
return ERR_PTR(-ENOMEM);

View File

@@ -157,8 +157,8 @@ static int create_lvl_avail_nodes(const char *name,
goto failed;
}
attr = devm_kzalloc(&lpm_pdev->dev,
sizeof(*attr) * (LPM_TYPE_NR + 1), GFP_KERNEL);
attr = devm_kcalloc(&lpm_pdev->dev,
LPM_TYPE_NR + 1, sizeof(*attr), GFP_KERNEL);
if (!attr) {
ret = -ENOMEM;
goto failed;
@@ -218,8 +218,10 @@ static int create_cpu_lvl_nodes(struct lpm_cluster *p, struct kobject *parent)
int ret = 0;
struct list_head *pos;
cpu_kobj = devm_kzalloc(&lpm_pdev->dev, sizeof(*cpu_kobj) *
cpumask_weight(&p->child_cpus), GFP_KERNEL);
cpu_kobj = devm_kcalloc(&lpm_pdev->dev,
cpumask_weight(&p->child_cpus),
sizeof(*cpu_kobj),
GFP_KERNEL);
if (!cpu_kobj)
return -ENOMEM;
@@ -236,8 +238,8 @@ static int create_cpu_lvl_nodes(struct lpm_cluster *p, struct kobject *parent)
goto release_kobj;
}
level_list = devm_kzalloc(&lpm_pdev->dev,
lpm_cpu->nlevels * sizeof(*level_list),
level_list = devm_kcalloc(&lpm_pdev->dev,
lpm_cpu->nlevels, sizeof(*level_list),
GFP_KERNEL);
if (!level_list) {
ret = -ENOMEM;

View File

@@ -476,7 +476,7 @@ static int mv_cesa_probe(struct platform_device *pdev)
sram_size = CESA_SA_MIN_SRAM_SIZE;
cesa->sram_size = sram_size;
cesa->engines = devm_kzalloc(dev, caps->nengines * sizeof(*engines),
cesa->engines = devm_kcalloc(dev, caps->nengines, sizeof(*engines),
GFP_KERNEL);
if (!cesa->engines)
return -ENOMEM;

View File

@@ -596,7 +596,7 @@ static int qcom_ice_parse_clock_info(struct platform_device *pdev,
if (len != cnt)
goto out;
clkfreq = devm_kzalloc(dev, len * sizeof(*clkfreq), GFP_KERNEL);
clkfreq = devm_kcalloc(dev, len, sizeof(*clkfreq), GFP_KERNEL);
if (!clkfreq) {
ret = -ENOMEM;
goto out;

View File

@@ -308,13 +308,17 @@ static int arm_memlat_mon_driver_probe(struct platform_device *pdev)
}
hw->num_cores = cpumask_weight(&cpu_grp->cpus);
hw->core_stats = devm_kzalloc(dev, hw->num_cores *
sizeof(*(hw->core_stats)), GFP_KERNEL);
hw->core_stats = devm_kcalloc(dev,
hw->num_cores,
sizeof(*(hw->core_stats)),
GFP_KERNEL);
if (!hw->core_stats)
return -ENOMEM;
cpu_grp->cpustats = devm_kzalloc(dev, hw->num_cores *
sizeof(*(cpu_grp->cpustats)), GFP_KERNEL);
cpu_grp->cpustats = devm_kcalloc(dev,
hw->num_cores,
sizeof(*(cpu_grp->cpustats)),
GFP_KERNEL);
if (!cpu_grp->cpustats)
return -ENOMEM;

View File

@@ -1155,7 +1155,7 @@ static int bimc_bwmon_driver_probe(struct platform_device *pdev)
return -EINVAL;
}
m->clks = devm_kzalloc(dev, sizeof(struct clk *) * m->nr_clks,
m->clks = devm_kcalloc(dev, m->nr_clks, sizeof(struct clk *),
GFP_KERNEL);
if (!m->clks)
return -ENOMEM;

View File

@@ -595,13 +595,11 @@ struct devfreq *devfreq_add_device(struct device *dev,
}
devfreq->trans_table = devm_kzalloc(&devfreq->dev,
sizeof(unsigned int) *
devfreq->profile->max_state *
devfreq->profile->max_state,
array3_size(sizeof(unsigned int), devfreq->profile->max_state, devfreq->profile->max_state),
GFP_KERNEL);
devfreq->time_in_state = devm_kzalloc(&devfreq->dev,
sizeof(unsigned long) *
devfreq->time_in_state = devm_kcalloc(&devfreq->dev,
devfreq->profile->max_state,
sizeof(unsigned long),
GFP_KERNEL);
devfreq->last_stat_updated = jiffies;

View File

@@ -105,11 +105,11 @@ static int parse_freq_table(struct device *dev, struct dev_data *d)
d->freq_in_khz = true;
len /= sizeof(*data);
data = devm_kzalloc(dev, len * sizeof(*data), GFP_KERNEL);
data = devm_kcalloc(dev, len, sizeof(*data), GFP_KERNEL);
if (!data)
return -ENOMEM;
p->freq_table = devm_kzalloc(dev, len * sizeof(*p->freq_table),
p->freq_table = devm_kcalloc(dev, len, sizeof(*p->freq_table),
GFP_KERNEL);
if (!p->freq_table)
return -ENOMEM;

View File

@@ -518,7 +518,7 @@ static int of_get_devfreq_events(struct device_node *np,
event_ops = exynos_bus_get_ops(np);
count = of_get_child_count(events_np);
desc = devm_kzalloc(dev, sizeof(*desc) * count, GFP_KERNEL);
desc = devm_kcalloc(dev, count, sizeof(*desc), GFP_KERNEL);
if (!desc)
return -ENOMEM;
info->num_events = count;

View File

@@ -447,8 +447,8 @@ static struct core_dev_map *init_core_dev_map(struct device *dev,
return NULL;
nf = len / NUM_COLS;
tbl = devm_kzalloc(dev, (nf + 1) * sizeof(struct core_dev_map),
GFP_KERNEL);
tbl = devm_kcalloc(dev, nf + 1, sizeof(struct core_dev_map),
GFP_KERNEL);
if (!tbl)
return NULL;

View File

@@ -847,8 +847,8 @@ static int k3_dma_probe(struct platform_device *op)
return -ENOMEM;
/* init phy channel */
d->phy = devm_kzalloc(&op->dev,
d->dma_channels * sizeof(struct k3_dma_phy), GFP_KERNEL);
d->phy = devm_kcalloc(&op->dev,
d->dma_channels, sizeof(struct k3_dma_phy), GFP_KERNEL);
if (d->phy == NULL)
return -ENOMEM;
@@ -877,8 +877,8 @@ static int k3_dma_probe(struct platform_device *op)
d->slave.copy_align = DMAENGINE_ALIGN_8_BYTES;
/* init virtual channel */
d->chans = devm_kzalloc(&op->dev,
d->dma_requests * sizeof(struct k3_dma_chan), GFP_KERNEL);
d->chans = devm_kcalloc(&op->dev,
d->dma_requests, sizeof(struct k3_dma_chan), GFP_KERNEL);
if (d->chans == NULL)
return -ENOMEM;

View File

@@ -809,8 +809,9 @@ static int mv_xor_v2_probe(struct platform_device *pdev)
}
/* alloc memory for the SW descriptors */
xor_dev->sw_desq = devm_kzalloc(&pdev->dev, sizeof(*sw_desc) *
MV_XOR_V2_DESC_NUM, GFP_KERNEL);
xor_dev->sw_desq = devm_kcalloc(&pdev->dev,
MV_XOR_V2_DESC_NUM, sizeof(*sw_desc),
GFP_KERNEL);
if (!xor_dev->sw_desq) {
ret = -ENOMEM;
goto free_hw_desq;

View File

@@ -2985,8 +2985,8 @@ static int gpi_probe(struct platform_device *pdev)
return ret;
}
gpi_dev->gpiis = devm_kzalloc(gpi_dev->dev,
sizeof(*gpi_dev->gpiis) * gpi_dev->max_gpii,
gpi_dev->gpiis = devm_kcalloc(gpi_dev->dev,
gpi_dev->max_gpii, sizeof(*gpi_dev->gpiis),
GFP_KERNEL);
if (!gpi_dev->gpiis)
return -ENOMEM;

View File

@@ -1216,9 +1216,9 @@ static int s3c24xx_dma_probe(struct platform_device *pdev)
if (IS_ERR(s3cdma->base))
return PTR_ERR(s3cdma->base);
s3cdma->phy_chans = devm_kzalloc(&pdev->dev,
sizeof(struct s3c24xx_dma_phy) *
pdata->num_phy_channels,
s3cdma->phy_chans = devm_kcalloc(&pdev->dev,
pdata->num_phy_channels,
sizeof(struct s3c24xx_dma_phy),
GFP_KERNEL);
if (!s3cdma->phy_chans)
return -ENOMEM;

View File

@@ -798,8 +798,8 @@ static int zx_dma_probe(struct platform_device *op)
return -ENOMEM;
/* init phy channel */
d->phy = devm_kzalloc(&op->dev,
d->dma_channels * sizeof(struct zx_dma_phy), GFP_KERNEL);
d->phy = devm_kcalloc(&op->dev,
d->dma_channels, sizeof(struct zx_dma_phy), GFP_KERNEL);
if (!d->phy)
return -ENOMEM;
@@ -834,8 +834,8 @@ static int zx_dma_probe(struct platform_device *op)
d->slave.residue_granularity = DMA_RESIDUE_GRANULARITY_SEGMENT;
/* init virtual channel */
d->chans = devm_kzalloc(&op->dev,
d->dma_requests * sizeof(struct zx_dma_chan), GFP_KERNEL);
d->chans = devm_kcalloc(&op->dev,
d->dma_requests, sizeof(struct zx_dma_chan), GFP_KERNEL);
if (!d->chans)
return -ENOMEM;

View File

@@ -427,8 +427,8 @@ static int qcom_llcc_erp_probe(struct platform_device *pdev)
drv->num_banks = num_banks;
drv->llcc_map = llcc_map;
drv->llcc_banks = devm_kzalloc(&pdev->dev,
sizeof(u32) * drv->num_banks, GFP_KERNEL);
drv->llcc_banks = devm_kcalloc(&pdev->dev,
drv->num_banks, sizeof(u32), GFP_KERNEL);
if (!drv->llcc_banks) {
dev_err(dev, "Cannot allocate memory for llcc_banks\n");

View File

@@ -1317,8 +1317,8 @@ int extcon_dev_register(struct extcon_dev *edev)
goto err_dev;
}
edev->bnh = devm_kzalloc(&edev->dev,
sizeof(*edev->bnh) * edev->max_supported, GFP_KERNEL);
edev->bnh = devm_kcalloc(&edev->dev,
edev->max_supported, sizeof(*edev->bnh), GFP_KERNEL);
if (!edev->bnh) {
ret = -ENOMEM;
goto err_dev;

View File

@@ -930,7 +930,7 @@ static int scpi_alloc_xfer_list(struct device *dev, struct scpi_chan *ch)
int i;
struct scpi_xfer *xfers;
xfers = devm_kzalloc(dev, MAX_SCPI_XFERS * sizeof(*xfers), GFP_KERNEL);
xfers = devm_kcalloc(dev, MAX_SCPI_XFERS, sizeof(*xfers), GFP_KERNEL);
if (!xfers)
return -ENOMEM;

View File

@@ -1862,9 +1862,9 @@ static int ti_sci_probe(struct platform_device *pdev)
if (!minfo->xfer_block)
return -ENOMEM;
minfo->xfer_alloc_table = devm_kzalloc(dev,
BITS_TO_LONGS(desc->max_msgs)
* sizeof(unsigned long),
minfo->xfer_alloc_table = devm_kcalloc(dev,
BITS_TO_LONGS(desc->max_msgs),
sizeof(unsigned long),
GFP_KERNEL);
if (!minfo->xfer_alloc_table)
return -ENOMEM;

View File

@@ -432,7 +432,7 @@ static int adnp_irq_setup(struct adnp *adnp)
* is chosen to match the register layout of the hardware in that
* each segment contains the corresponding bits for all interrupts.
*/
adnp->irq_enable = devm_kzalloc(chip->parent, num_regs * 6,
adnp->irq_enable = devm_kcalloc(chip->parent, num_regs, 6,
GFP_KERNEL);
if (!adnp->irq_enable)
return -ENOMEM;

View File

@@ -600,9 +600,10 @@ static int bcm_kona_gpio_probe(struct platform_device *pdev)
GPIO_MAX_BANK_NUM);
return -ENXIO;
}
kona_gpio->banks = devm_kzalloc(dev,
kona_gpio->num_bank *
sizeof(*kona_gpio->banks), GFP_KERNEL);
kona_gpio->banks = devm_kcalloc(dev,
kona_gpio->num_bank,
sizeof(*kona_gpio->banks),
GFP_KERNEL);
if (!kona_gpio->banks)
return -ENOMEM;

View File

@@ -197,8 +197,8 @@ static int davinci_gpio_probe(struct platform_device *pdev)
ngpio = ARCH_NR_GPIOS;
nbank = DIV_ROUND_UP(ngpio, 32);
chips = devm_kzalloc(dev,
nbank * sizeof(struct davinci_gpio_controller),
chips = devm_kcalloc(dev,
nbank, sizeof(struct davinci_gpio_controller),
GFP_KERNEL);
if (!chips)
return -ENOMEM;

View File

@@ -380,7 +380,8 @@ static int etraxfs_gpio_probe(struct platform_device *pdev)
info = match->data;
chips = devm_kzalloc(dev, sizeof(*chips) * info->num_ports, GFP_KERNEL);
chips = devm_kcalloc(dev, info->num_ports, sizeof(*chips),
GFP_KERNEL);
if (!chips)
return -ENOMEM;

View File

@@ -320,8 +320,8 @@ static int __init egpio_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, ei);
ei->nchips = pdata->num_chips;
ei->chip = devm_kzalloc(&pdev->dev,
sizeof(struct egpio_chip) * ei->nchips,
ei->chip = devm_kcalloc(&pdev->dev,
ei->nchips, sizeof(struct egpio_chip),
GFP_KERNEL);
if (!ei->chip) {
ret = -ENOMEM;

View File

@@ -517,16 +517,17 @@ static int thunderx_gpio_probe(struct pci_dev *pdev,
txgpio->base_msi = (c >> 8) & 0xff;
}
txgpio->msix_entries = devm_kzalloc(dev,
sizeof(struct msix_entry) * ngpio,
txgpio->msix_entries = devm_kcalloc(dev,
ngpio, sizeof(struct msix_entry),
GFP_KERNEL);
if (!txgpio->msix_entries) {
err = -ENOMEM;
goto out;
}
txgpio->line_entries = devm_kzalloc(dev,
sizeof(struct thunderx_line) * ngpio,
txgpio->line_entries = devm_kcalloc(dev,
ngpio,
sizeof(struct thunderx_line),
GFP_KERNEL);
if (!txgpio->line_entries) {
err = -ENOMEM;

View File

@@ -1343,8 +1343,10 @@ static int lt9611_get_dt_supply(struct device *dev,
}
pr_debug("vreg found. count=%d\n", pdata->num_vreg);
pdata->vreg_config = devm_kzalloc(dev, sizeof(struct lt9611_vreg) *
pdata->num_vreg, GFP_KERNEL);
pdata->vreg_config = devm_kcalloc(dev,
pdata->num_vreg,
sizeof(struct lt9611_vreg),
GFP_KERNEL);
if (!pdata->vreg_config)
return -ENOMEM;

View File

@@ -1744,8 +1744,8 @@ static int exynos_dsi_probe(struct platform_device *pdev)
return ret;
}
dsi->clks = devm_kzalloc(dev,
sizeof(*dsi->clks) * dsi->driver_data->num_clks,
dsi->clks = devm_kcalloc(dev,
dsi->driver_data->num_clks, sizeof(*dsi->clks),
GFP_KERNEL);
if (!dsi->clks)
return -ENOMEM;

View File

@@ -1577,7 +1577,7 @@ static int hdmi_clk_init(struct hdmi_context *hdata)
if (!count)
return 0;
clks = devm_kzalloc(dev, sizeof(*clks) * count, GFP_KERNEL);
clks = devm_kcalloc(dev, count, sizeof(*clks), GFP_KERNEL);
if (!clks)
return -ENOMEM;

View File

@@ -43,8 +43,8 @@ static int dp_parser_reg(struct dp_parser *parser)
}
io->len = reg_count;
io->data = devm_kzalloc(dev, sizeof(struct dp_io_data) * reg_count,
GFP_KERNEL);
io->data = devm_kcalloc(dev, reg_count, sizeof(struct dp_io_data),
GFP_KERNEL);
if (!io->data)
return -ENOMEM;
@@ -287,8 +287,8 @@ static int dp_parser_gpio(struct dp_parser *parser)
if (of_find_property(of_node, "qcom,dp-gpio-aux-switch", NULL))
parser->gpio_aux_switch = true;
mp->gpio_config = devm_kzalloc(dev,
sizeof(struct dss_gpio) * ARRAY_SIZE(dp_gpios), GFP_KERNEL);
mp->gpio_config = devm_kcalloc(dev,
ARRAY_SIZE(dp_gpios), sizeof(struct dss_gpio), GFP_KERNEL);
if (!mp->gpio_config)
return -ENOMEM;
@@ -354,8 +354,8 @@ static int dp_parser_get_vreg(struct dp_parser *parser,
pr_debug("vreg found. count=%d\n", mp->num_vreg);
}
mp->vreg_config = devm_kzalloc(&parser->pdev->dev,
sizeof(struct dss_vreg) * mp->num_vreg, GFP_KERNEL);
mp->vreg_config = devm_kcalloc(&parser->pdev->dev,
mp->num_vreg, sizeof(struct dss_vreg), GFP_KERNEL);
if (!mp->vreg_config) {
rc = -ENOMEM;
goto error;
@@ -558,8 +558,8 @@ static int dp_parser_init_clk_data(struct dp_parser *parser)
}
core_power->num_clk = core_clk_count;
core_power->clk_config = devm_kzalloc(dev,
sizeof(struct dss_clk) * core_power->num_clk,
core_power->clk_config = devm_kcalloc(dev,
core_power->num_clk, sizeof(struct dss_clk),
GFP_KERNEL);
if (!core_power->clk_config) {
rc = -EINVAL;
@@ -571,8 +571,8 @@ static int dp_parser_init_clk_data(struct dp_parser *parser)
pr_debug("no strm0 clocks are defined\n");
} else {
strm0_power->num_clk = strm0_clk_count;
strm0_power->clk_config = devm_kzalloc(dev,
sizeof(struct dss_clk) * strm0_power->num_clk,
strm0_power->clk_config = devm_kcalloc(dev,
strm0_power->num_clk, sizeof(struct dss_clk),
GFP_KERNEL);
if (!strm0_power->clk_config) {
strm0_power->num_clk = 0;
@@ -586,8 +586,8 @@ static int dp_parser_init_clk_data(struct dp_parser *parser)
pr_debug("no strm1 clocks are defined\n");
} else {
strm1_power->num_clk = strm1_clk_count;
strm1_power->clk_config = devm_kzalloc(dev,
sizeof(struct dss_clk) * strm1_power->num_clk,
strm1_power->clk_config = devm_kcalloc(dev,
strm1_power->num_clk, sizeof(struct dss_clk),
GFP_KERNEL);
if (!strm1_power->clk_config) {
strm1_power->num_clk = 0;
@@ -604,8 +604,8 @@ static int dp_parser_init_clk_data(struct dp_parser *parser)
}
link_power->num_clk = link_clk_count;
link_power->clk_config = devm_kzalloc(dev,
sizeof(struct dss_clk) * link_power->num_clk,
link_power->clk_config = devm_kcalloc(dev,
link_power->num_clk, sizeof(struct dss_clk),
GFP_KERNEL);
if (!link_power->clk_config) {
link_power->num_clk = 0;

View File

@@ -254,7 +254,7 @@ static bool dsi_parser_parse_prop(struct device *dev,
if (dsi_parser_get_strings(dev, prop, buf))
goto end;
prop->items = devm_kzalloc(dev, strlen(buf) * 2, GFP_KERNEL);
prop->items = devm_kcalloc(dev, strlen(buf), 2, GFP_KERNEL);
if (!prop->items)
goto end;

View File

@@ -157,8 +157,10 @@ static struct hdmi *msm_hdmi_init(struct platform_device *pdev)
hdmi->qfprom_mmio = NULL;
}
hdmi->hpd_regs = devm_kzalloc(&pdev->dev, sizeof(hdmi->hpd_regs[0]) *
config->hpd_reg_cnt, GFP_KERNEL);
hdmi->hpd_regs = devm_kcalloc(&pdev->dev,
config->hpd_reg_cnt,
sizeof(hdmi->hpd_regs[0]),
GFP_KERNEL);
if (!hdmi->hpd_regs) {
ret = -ENOMEM;
goto fail;
@@ -178,8 +180,10 @@ static struct hdmi *msm_hdmi_init(struct platform_device *pdev)
hdmi->hpd_regs[i] = reg;
}
hdmi->pwr_regs = devm_kzalloc(&pdev->dev, sizeof(hdmi->pwr_regs[0]) *
config->pwr_reg_cnt, GFP_KERNEL);
hdmi->pwr_regs = devm_kcalloc(&pdev->dev,
config->pwr_reg_cnt,
sizeof(hdmi->pwr_regs[0]),
GFP_KERNEL);
if (!hdmi->pwr_regs) {
ret = -ENOMEM;
goto fail;
@@ -199,8 +203,10 @@ static struct hdmi *msm_hdmi_init(struct platform_device *pdev)
hdmi->pwr_regs[i] = reg;
}
hdmi->hpd_clks = devm_kzalloc(&pdev->dev, sizeof(hdmi->hpd_clks[0]) *
config->hpd_clk_cnt, GFP_KERNEL);
hdmi->hpd_clks = devm_kcalloc(&pdev->dev,
config->hpd_clk_cnt,
sizeof(hdmi->hpd_clks[0]),
GFP_KERNEL);
if (!hdmi->hpd_clks) {
ret = -ENOMEM;
goto fail;
@@ -219,8 +225,10 @@ static struct hdmi *msm_hdmi_init(struct platform_device *pdev)
hdmi->hpd_clks[i] = clk;
}
hdmi->pwr_clks = devm_kzalloc(&pdev->dev, sizeof(hdmi->pwr_clks[0]) *
config->pwr_clk_cnt, GFP_KERNEL);
hdmi->pwr_clks = devm_kcalloc(&pdev->dev,
config->pwr_clk_cnt,
sizeof(hdmi->pwr_clks[0]),
GFP_KERNEL);
if (!hdmi->pwr_clks) {
ret = -ENOMEM;
goto fail;

View File

@@ -21,12 +21,12 @@ static int msm_hdmi_phy_resource_init(struct hdmi_phy *phy)
struct device *dev = &phy->pdev->dev;
int i, ret;
phy->regs = devm_kzalloc(dev, sizeof(phy->regs[0]) * cfg->num_regs,
phy->regs = devm_kcalloc(dev, cfg->num_regs, sizeof(phy->regs[0]),
GFP_KERNEL);
if (!phy->regs)
return -ENOMEM;
phy->clks = devm_kzalloc(dev, sizeof(phy->clks[0]) * cfg->num_clks,
phy->clks = devm_kcalloc(dev, cfg->num_clks, sizeof(phy->clks[0]),
GFP_KERNEL);
if (!phy->clks)
return -ENOMEM;

View File

@@ -164,8 +164,9 @@ static int sde_power_parse_dt_supply(struct platform_device *pdev,
}
pr_debug("vreg found. count=%d\n", mp->num_vreg);
mp->vreg_config = devm_kzalloc(&pdev->dev, sizeof(struct dss_vreg) *
mp->num_vreg, GFP_KERNEL);
mp->vreg_config = devm_kcalloc(&pdev->dev,
mp->num_vreg, sizeof(struct dss_vreg),
GFP_KERNEL);
if (!mp->vreg_config) {
rc = -ENOMEM;
return rc;
@@ -299,8 +300,8 @@ static int sde_power_parse_dt_clock(struct platform_device *pdev,
}
mp->num_clk = num_clk;
mp->clk_config = devm_kzalloc(&pdev->dev,
sizeof(struct dss_clk) * num_clk, GFP_KERNEL);
mp->clk_config = devm_kcalloc(&pdev->dev,
num_clk, sizeof(struct dss_clk), GFP_KERNEL);
if (!mp->clk_config) {
rc = -ENOMEM;
mp->num_clk = 0;

View File

@@ -428,8 +428,8 @@ static int shp_parse(struct platform_device *pdev, struct shp_device *shp)
system_count = priv->num_planes;
total_count = dup_count + system_count;
shp->planes = devm_kzalloc(&pdev->dev,
sizeof(*shp_plane) * total_count, GFP_KERNEL);
shp->planes = devm_kcalloc(&pdev->dev,
total_count, sizeof(*shp_plane), GFP_KERNEL);
if (!shp->planes) {
rc = -ENOMEM;
goto out;

View File

@@ -653,7 +653,8 @@ static int sensor_hub_probe(struct hid_device *hdev,
ret = -EINVAL;
goto err_stop_hw;
}
sd->hid_sensor_hub_client_devs = devm_kzalloc(&hdev->dev, dev_cnt *
sd->hid_sensor_hub_client_devs = devm_kcalloc(&hdev->dev,
dev_cnt,
sizeof(struct mfd_cell),
GFP_KERNEL);
if (sd->hid_sensor_hub_client_devs == NULL) {

View File

@@ -121,9 +121,9 @@ static void process_recv(struct ishtp_cl *hid_ishtp_cl, void *recv_buf,
}
client_data->hid_dev_count = (unsigned int)*payload;
if (!client_data->hid_devices)
client_data->hid_devices = devm_kzalloc(
client_data->hid_devices = devm_kcalloc(
&client_data->cl_device->dev,
client_data->hid_dev_count *
client_data->hid_dev_count,
sizeof(struct device_info),
GFP_KERNEL);
if (!client_data->hid_devices) {

View File

@@ -1267,7 +1267,7 @@ static int wacom_led_groups_alloc_and_register_one(struct device *dev,
if (!devres_open_group(dev, &wacom->led.groups[group_id], GFP_KERNEL))
return -ENOMEM;
leds = devm_kzalloc(dev, sizeof(struct wacom_led) * count, GFP_KERNEL);
leds = devm_kcalloc(dev, count, sizeof(struct wacom_led), GFP_KERNEL);
if (!leds) {
error = -ENOMEM;
goto err;
@@ -1367,7 +1367,7 @@ static int wacom_led_groups_allocate(struct wacom *wacom, int count)
struct wacom_group_leds *groups;
int error;
groups = devm_kzalloc(dev, sizeof(struct wacom_group_leds) * count,
groups = devm_kcalloc(dev, count, sizeof(struct wacom_group_leds),
GFP_KERNEL);
if (!groups)
return -ENOMEM;

View File

@@ -894,7 +894,7 @@ static int aspeed_create_fan(struct device *dev,
count = of_property_count_u8_elems(child, "aspeed,fan-tach-ch");
if (count < 1)
return -EINVAL;
fan_tach_ch = devm_kzalloc(dev, sizeof(*fan_tach_ch) * count,
fan_tach_ch = devm_kcalloc(dev, count, sizeof(*fan_tach_ch),
GFP_KERNEL);
if (!fan_tach_ch)
return -ENOMEM;

View File

@@ -477,7 +477,7 @@ static int gpio_fan_get_of_pdata(struct device *dev,
dev_err(dev, "DT properties empty / missing");
return -ENODEV;
}
ctrl = devm_kzalloc(dev, pdata->num_ctrl * sizeof(unsigned),
ctrl = devm_kcalloc(dev, pdata->num_ctrl, sizeof(unsigned),
GFP_KERNEL);
if (!ctrl)
return -ENOMEM;
@@ -509,8 +509,8 @@ static int gpio_fan_get_of_pdata(struct device *dev,
* Speed map is in the form <RPM ctrl_val RPM ctrl_val ...>
* this needs splitting into pairs to create gpio_fan_speed structs
*/
speed = devm_kzalloc(dev,
pdata->num_speed * sizeof(struct gpio_fan_speed),
speed = devm_kcalloc(dev,
pdata->num_speed, sizeof(struct gpio_fan_speed),
GFP_KERNEL);
if (!speed)
return -ENOMEM;

View File

@@ -322,9 +322,9 @@ static int populate_attr_groups(struct platform_device *pdev)
of_node_put(opal);
for (type = 0; type < MAX_SENSOR_TYPE; type++) {
sensor_groups[type].group.attrs = devm_kzalloc(&pdev->dev,
sizeof(struct attribute *) *
(sensor_groups[type].attr_count + 1),
sensor_groups[type].group.attrs = devm_kcalloc(&pdev->dev,
sensor_groups[type].attr_count + 1,
sizeof(struct attribute *),
GFP_KERNEL);
if (!sensor_groups[type].group.attrs)
return -ENOMEM;
@@ -405,7 +405,8 @@ static int create_device_attrs(struct platform_device *pdev)
int err = 0;
opal = of_find_node_by_path("/ibm,opal/sensors");
sdata = devm_kzalloc(&pdev->dev, pdata->sensors_count * sizeof(*sdata),
sdata = devm_kcalloc(&pdev->dev,
pdata->sensors_count, sizeof(*sdata),
GFP_KERNEL);
if (!sdata) {
err = -ENOMEM;

View File

@@ -91,8 +91,8 @@ static int iio_hwmon_probe(struct platform_device *pdev)
while (st->channels[st->num_channels].indio_dev)
st->num_channels++;
st->attrs = devm_kzalloc(dev,
sizeof(*st->attrs) * (st->num_channels + 1),
st->attrs = devm_kcalloc(dev,
st->num_channels + 1, sizeof(*st->attrs),
GFP_KERNEL);
if (st->attrs == NULL) {
ret = -ENOMEM;

View File

@@ -426,12 +426,12 @@ nct6683_create_attr_group(struct device *dev,
if (group == NULL)
return ERR_PTR(-ENOMEM);
attrs = devm_kzalloc(dev, sizeof(*attrs) * (repeat * count + 1),
attrs = devm_kcalloc(dev, repeat * count + 1, sizeof(*attrs),
GFP_KERNEL);
if (attrs == NULL)
return ERR_PTR(-ENOMEM);
su = devm_kzalloc(dev, sizeof(*su) * repeat * count,
su = devm_kzalloc(dev, array3_size(repeat, count, sizeof(*su)),
GFP_KERNEL);
if (su == NULL)
return ERR_PTR(-ENOMEM);

View File

@@ -1149,12 +1149,12 @@ nct6775_create_attr_group(struct device *dev,
if (group == NULL)
return ERR_PTR(-ENOMEM);
attrs = devm_kzalloc(dev, sizeof(*attrs) * (repeat * count + 1),
attrs = devm_kcalloc(dev, repeat * count + 1, sizeof(*attrs),
GFP_KERNEL);
if (attrs == NULL)
return ERR_PTR(-ENOMEM);
su = devm_kzalloc(dev, sizeof(*su) * repeat * count,
su = devm_kzalloc(dev, array3_size(repeat, count, sizeof(*su)),
GFP_KERNEL);
if (su == NULL)
return ERR_PTR(-ENOMEM);

View File

@@ -1992,8 +1992,8 @@ static int pmbus_init_debugfs(struct i2c_client *client,
}
/* Allocate the max possible entries we need. */
entries = devm_kzalloc(data->dev,
sizeof(*entries) * (data->info->pages * 10),
entries = devm_kcalloc(data->dev,
data->info->pages * 10, sizeof(*entries),
GFP_KERNEL);
if (!entries)
return -ENOMEM;

View File

@@ -180,7 +180,7 @@ static int pwm_fan_of_get_cooling_data(struct device *dev,
}
num = ret;
ctx->pwm_fan_cooling_levels = devm_kzalloc(dev, num * sizeof(u32),
ctx->pwm_fan_cooling_levels = devm_kcalloc(dev, num, sizeof(u32),
GFP_KERNEL);
if (!ctx->pwm_fan_cooling_levels)
return -ENOMEM;

View File

@@ -748,8 +748,8 @@ static int etb_probe(struct amba_device *adev, const struct amba_id *id)
if (drvdata->buffer_depth & 0x80000000)
return -EINVAL;
drvdata->buf = devm_kzalloc(dev,
drvdata->buffer_depth * 4, GFP_KERNEL);
drvdata->buf = devm_kcalloc(dev,
drvdata->buffer_depth, 4, GFP_KERNEL);
if (!drvdata->buf)
return -ENOMEM;

View File

@@ -204,7 +204,8 @@ static int hwevent_probe(struct platform_device *pdev)
drvdata->nr_hmux = 0;
if (drvdata->nr_hmux > 0) {
drvdata->hmux = devm_kzalloc(dev, drvdata->nr_hmux *
drvdata->hmux = devm_kcalloc(dev,
drvdata->nr_hmux,
sizeof(*drvdata->hmux),
GFP_KERNEL);
if (!drvdata->hmux)
@@ -236,7 +237,8 @@ static int hwevent_probe(struct platform_device *pdev)
"qcom,hwevent-regs");
if (drvdata->nr_hclk > 0) {
drvdata->hclk = devm_kzalloc(dev, drvdata->nr_hclk *
drvdata->hclk = devm_kcalloc(dev,
drvdata->nr_hclk,
sizeof(*drvdata->hclk),
GFP_KERNEL);
if (!drvdata->hclk)
@@ -255,7 +257,8 @@ static int hwevent_probe(struct platform_device *pdev)
}
}
if (drvdata->nr_hreg > 0) {
drvdata->hreg = devm_kzalloc(dev, drvdata->nr_hreg *
drvdata->hreg = devm_kcalloc(dev,
drvdata->nr_hreg,
sizeof(*drvdata->hreg),
GFP_KERNEL);
if (!drvdata->hreg)

View File

@@ -458,34 +458,39 @@ static int tgu_probe(struct amba_device *adev, const struct amba_id *id)
return -EINVAL;
/* Alloc memory for Grps, Conditions and Steps */
drvdata->grp_data = devm_kzalloc(dev, MAX_GROUP_SETS *
sizeof(*drvdata->grp_data),
GFP_KERNEL);
drvdata->grp_data = devm_kcalloc(dev,
MAX_GROUP_SETS,
sizeof(*drvdata->grp_data),
GFP_KERNEL);
if (!drvdata->grp_data)
return -ENOMEM;
drvdata->condition_data = devm_kzalloc(dev, MAX_CONDITION_SETS *
sizeof(*drvdata->condition_data),
GFP_KERNEL);
drvdata->condition_data = devm_kcalloc(dev,
MAX_CONDITION_SETS,
sizeof(*drvdata->condition_data),
GFP_KERNEL);
if (!drvdata->condition_data)
return -ENOMEM;
drvdata->select_data = devm_kzalloc(dev, MAX_CONDITION_SETS *
sizeof(*drvdata->select_data),
GFP_KERNEL);
drvdata->select_data = devm_kcalloc(dev,
MAX_CONDITION_SETS,
sizeof(*drvdata->select_data),
GFP_KERNEL);
if (!drvdata->select_data)
return -ENOMEM;
drvdata->timer_data = devm_kzalloc(dev, MAX_TIMER_COUNTER_SETS *
sizeof(*drvdata->timer_data),
GFP_KERNEL);
drvdata->timer_data = devm_kcalloc(dev,
MAX_TIMER_COUNTER_SETS,
sizeof(*drvdata->timer_data),
GFP_KERNEL);
if (!drvdata->timer_data)
return -ENOMEM;
drvdata->counter_data = devm_kzalloc(dev, MAX_TIMER_COUNTER_SETS *
sizeof(*drvdata->counter_data),
GFP_KERNEL);
drvdata->counter_data = devm_kcalloc(dev,
MAX_TIMER_COUNTER_SETS,
sizeof(*drvdata->counter_data),
GFP_KERNEL);
if (!drvdata->counter_data)
return -ENOMEM;

View File

@@ -4437,7 +4437,8 @@ static int tpdm_probe(struct amba_device *adev, const struct amba_id *id)
drvdata->nr_tclk = of_property_count_strings(adev->dev.of_node,
"qcom,tpdm-clks");
if (drvdata->nr_tclk > 0) {
drvdata->tclk = devm_kzalloc(dev, drvdata->nr_tclk *
drvdata->tclk = devm_kcalloc(dev,
drvdata->nr_tclk,
sizeof(*drvdata->tclk),
GFP_KERNEL);
if (!drvdata->tclk)
@@ -4459,7 +4460,8 @@ static int tpdm_probe(struct amba_device *adev, const struct amba_id *id)
drvdata->nr_treg = of_property_count_strings(adev->dev.of_node,
"qcom,tpdm-regs");
if (drvdata->nr_treg > 0) {
drvdata->treg = devm_kzalloc(dev, drvdata->nr_treg *
drvdata->treg = devm_kcalloc(dev,
drvdata->nr_treg,
sizeof(*drvdata->treg),
GFP_KERNEL);
if (!drvdata->treg)

View File

@@ -85,27 +85,31 @@ static int of_coresight_alloc_memory(struct device *dev,
struct coresight_platform_data *pdata)
{
/* List of output port on this component */
pdata->outports = devm_kzalloc(dev, pdata->nr_outport *
pdata->outports = devm_kcalloc(dev,
pdata->nr_outport,
sizeof(*pdata->outports),
GFP_KERNEL);
if (!pdata->outports)
return -ENOMEM;
pdata->source_names = devm_kzalloc(dev, pdata->nr_outport *
sizeof(*pdata->source_names),
GFP_KERNEL);
pdata->source_names = devm_kcalloc(dev,
pdata->nr_outport,
sizeof(*pdata->source_names),
GFP_KERNEL);
if (!pdata->source_names)
return -ENOMEM;
/* Children connected to this component via @outports */
pdata->child_names = devm_kzalloc(dev, pdata->nr_outport *
pdata->child_names = devm_kcalloc(dev,
pdata->nr_outport,
sizeof(*pdata->child_names),
GFP_KERNEL);
if (!pdata->child_names)
return -ENOMEM;
/* Port number on the child this component is connected to */
pdata->child_ports = devm_kzalloc(dev, pdata->nr_outport *
pdata->child_ports = devm_kcalloc(dev,
pdata->nr_outport,
sizeof(*pdata->child_ports),
GFP_KERNEL);
if (!pdata->child_ports)
@@ -149,8 +153,9 @@ of_coresight_get_reg_clk(struct device *dev, const struct device_node *node)
reg_clk->nr_reg = nr_reg;
reg_clk->nr_clk = nr_clk;
if (nr_reg > 0) {
reg_clk->reg = devm_kzalloc(dev, nr_reg *
sizeof(reg_clk->reg), GFP_KERNEL);
reg_clk->reg = devm_kcalloc(dev,
nr_reg, sizeof(reg_clk->reg),
GFP_KERNEL);
if (!reg_clk->reg)
return ERR_PTR(-ENOMEM);
@@ -165,8 +170,9 @@ of_coresight_get_reg_clk(struct device *dev, const struct device_node *node)
}
}
if (nr_clk > 0) {
reg_clk->clk = devm_kzalloc(dev, nr_clk *
sizeof(reg_clk->clk), GFP_KERNEL);
reg_clk->clk = devm_kcalloc(dev,
nr_clk, sizeof(reg_clk->clk),
GFP_KERNEL);
if (!reg_clk->clk)
return ERR_PTR(-ENOMEM);
@@ -336,7 +342,8 @@ struct coresight_cti_data *of_get_coresight_cti_data(
return ERR_PTR(-EINVAL);
if (ctidata->nr_ctis) {
ctidata->names = devm_kzalloc(dev, ctidata->nr_ctis *
ctidata->names = devm_kcalloc(dev,
ctidata->nr_ctis,
sizeof(*ctidata->names),
GFP_KERNEL);
if (!ctidata->names)

View File

@@ -1598,11 +1598,11 @@ static int i2c_msm_clk_path_init_structs(struct i2c_msm_ctrl *ctrl)
i2c_msm_dbg(ctrl, MSM_PROF, "initializes path clock voting structs\n");
paths = devm_kzalloc(ctrl->dev, sizeof(*paths) * 2, GFP_KERNEL);
paths = devm_kcalloc(ctrl->dev, 2, sizeof(*paths), GFP_KERNEL);
if (!paths)
return -ENOMEM;
usecases = devm_kzalloc(ctrl->dev, sizeof(*usecases) * 2, GFP_KERNEL);
usecases = devm_kcalloc(ctrl->dev, 2, sizeof(*usecases), GFP_KERNEL);
if (!usecases)
goto path_init_err;

View File

@@ -1459,8 +1459,8 @@ static int qup_i2c_probe(struct platform_device *pdev)
goto nodma;
blocks = (MX_BLOCKS << 1) + 1;
qup->btx.sg = devm_kzalloc(&pdev->dev,
sizeof(*qup->btx.sg) * blocks,
qup->btx.sg = devm_kcalloc(&pdev->dev,
blocks, sizeof(*qup->btx.sg),
GFP_KERNEL);
if (!qup->btx.sg) {
ret = -ENOMEM;
@@ -1468,8 +1468,8 @@ static int qup_i2c_probe(struct platform_device *pdev)
}
sg_init_table(qup->btx.sg, blocks);
qup->brx.sg = devm_kzalloc(&pdev->dev,
sizeof(*qup->brx.sg) * blocks,
qup->brx.sg = devm_kcalloc(&pdev->dev,
blocks, sizeof(*qup->brx.sg),
GFP_KERNEL);
if (!qup->brx.sg) {
ret = -ENOMEM;

View File

@@ -88,8 +88,8 @@ static int i2c_mux_gpio_probe_dt(struct gpiomux *mux,
mux->data.n_values = of_get_child_count(np);
values = devm_kzalloc(&pdev->dev,
sizeof(*mux->data.values) * mux->data.n_values,
values = devm_kcalloc(&pdev->dev,
mux->data.n_values, sizeof(*mux->data.values),
GFP_KERNEL);
if (!values) {
dev_err(&pdev->dev, "Cannot allocate values array");
@@ -111,8 +111,9 @@ static int i2c_mux_gpio_probe_dt(struct gpiomux *mux,
return -EINVAL;
}
gpios = devm_kzalloc(&pdev->dev,
sizeof(*mux->data.gpios) * mux->data.n_gpios, GFP_KERNEL);
gpios = devm_kcalloc(&pdev->dev,
mux->data.n_gpios, sizeof(*mux->data.gpios),
GFP_KERNEL);
if (!gpios) {
dev_err(&pdev->dev, "Cannot allocate gpios array");
return -ENOMEM;

View File

@@ -127,8 +127,8 @@ static int i2c_mux_reg_probe_dt(struct regmux *mux,
else
mux->data.write_only = false;
values = devm_kzalloc(&pdev->dev,
sizeof(*mux->data.values) * mux->data.n_values,
values = devm_kcalloc(&pdev->dev,
mux->data.n_values, sizeof(*mux->data.values),
GFP_KERNEL);
if (!values) {
dev_err(&pdev->dev, "Cannot allocate values array");

View File

@@ -629,8 +629,8 @@ static int at91_adc_trigger_init(struct iio_dev *idev)
struct at91_adc_state *st = iio_priv(idev);
int i, ret;
st->trig = devm_kzalloc(&idev->dev,
st->trigger_number * sizeof(*st->trig),
st->trig = devm_kcalloc(&idev->dev,
st->trigger_number, sizeof(*st->trig),
GFP_KERNEL);
if (st->trig == NULL) {
@@ -919,7 +919,8 @@ static int at91_adc_probe_dt(struct at91_adc_state *st,
st->registers = &st->caps->registers;
st->num_channels = st->caps->num_channels;
st->trigger_number = of_get_child_count(node);
st->trigger_list = devm_kzalloc(&idev->dev, st->trigger_number *
st->trigger_list = devm_kcalloc(&idev->dev,
st->trigger_number,
sizeof(struct at91_adc_trigger),
GFP_KERNEL);
if (!st->trigger_list) {

View File

@@ -1455,8 +1455,8 @@ static int max1363_alloc_scan_masks(struct iio_dev *indio_dev)
int i;
masks = devm_kzalloc(&indio_dev->dev,
BITS_TO_LONGS(MAX1363_MAX_CHANNELS) * sizeof(long) *
(st->chip_info->num_modes + 1), GFP_KERNEL);
array3_size(BITS_TO_LONGS(MAX1363_MAX_CHANNELS), sizeof(long), (st->chip_info->num_modes + 1)),
GFP_KERNEL);
if (!masks)
return -ENOMEM;

View File

@@ -899,9 +899,10 @@ static int twl6030_gpadc_probe(struct platform_device *pdev)
gpadc = iio_priv(indio_dev);
gpadc->twl6030_cal_tbl = devm_kzalloc(dev,
sizeof(*gpadc->twl6030_cal_tbl) *
pdata->nchannels, GFP_KERNEL);
gpadc->twl6030_cal_tbl = devm_kcalloc(dev,
pdata->nchannels,
sizeof(*gpadc->twl6030_cal_tbl),
GFP_KERNEL);
if (!gpadc->twl6030_cal_tbl)
return -ENOMEM;

View File

@@ -537,8 +537,9 @@ static int ad5592r_alloc_channels(struct ad5592r_state *st)
st->channel_offstate[reg] = tmp;
}
channels = devm_kzalloc(st->dev,
(1 + 2 * num_channels) * sizeof(*channels), GFP_KERNEL);
channels = devm_kcalloc(st->dev,
1 + 2 * num_channels, sizeof(*channels),
GFP_KERNEL);
if (!channels)
return -ENOMEM;

View File

@@ -282,9 +282,10 @@ static int mux_configure_channel(struct device *dev, struct mux *mux,
if (!page)
return -ENOMEM;
}
child->ext_info_cache = devm_kzalloc(dev,
sizeof(*child->ext_info_cache) *
num_ext_info, GFP_KERNEL);
child->ext_info_cache = devm_kcalloc(dev,
num_ext_info,
sizeof(*child->ext_info_cache),
GFP_KERNEL);
if (!child->ext_info_cache)
return -ENOMEM;

View File

@@ -109,8 +109,8 @@ static int clps711x_keypad_probe(struct platform_device *pdev)
if (priv->row_count < 1)
return -EINVAL;
priv->gpio_data = devm_kzalloc(dev,
sizeof(*priv->gpio_data) * priv->row_count,
priv->gpio_data = devm_kcalloc(dev,
priv->row_count, sizeof(*priv->gpio_data),
GFP_KERNEL);
if (!priv->gpio_data)
return -ENOMEM;

View File

@@ -443,9 +443,9 @@ matrix_keypad_parse_dt(struct device *dev)
of_property_read_u32(np, "col-scan-delay-us",
&pdata->col_scan_delay_us);
gpios = devm_kzalloc(dev,
sizeof(unsigned int) *
(pdata->num_row_gpios + pdata->num_col_gpios),
gpios = devm_kcalloc(dev,
pdata->num_row_gpios + pdata->num_col_gpios,
sizeof(unsigned int),
GFP_KERNEL);
if (!gpios) {
dev_err(dev, "could not allocate memory for gpios\n");

View File

@@ -281,7 +281,7 @@ samsung_keypad_parse_dt(struct device *dev)
key_count = of_get_child_count(np);
keymap_data->keymap_size = key_count;
keymap = devm_kzalloc(dev, sizeof(uint32_t) * key_count, GFP_KERNEL);
keymap = devm_kcalloc(dev, key_count, sizeof(uint32_t), GFP_KERNEL);
if (!keymap) {
dev_err(dev, "could not allocate memory for keymap\n");
return ERR_PTR(-ENOMEM);

View File

@@ -170,8 +170,8 @@ int matrix_keypad_build_keymap(const struct matrix_keymap_data *keymap_data,
return -EINVAL;
if (!keymap) {
keymap = devm_kzalloc(input_dev->dev.parent,
max_keys * sizeof(*keymap),
keymap = devm_kcalloc(input_dev->dev.parent,
max_keys, sizeof(*keymap),
GFP_KERNEL);
if (!keymap) {
dev_err(input_dev->dev.parent,

View File

@@ -283,8 +283,8 @@ static int rotary_encoder_probe(struct platform_device *pdev)
}
encoder->irq =
devm_kzalloc(dev,
sizeof(*encoder->irq) * encoder->gpios->ndescs,
devm_kcalloc(dev,
encoder->gpios->ndescs, sizeof(*encoder->irq),
GFP_KERNEL);
if (!encoder->irq)
return -ENOMEM;

View File

@@ -636,9 +636,10 @@ int rmi_read_register_desc(struct rmi_device *d, u16 addr,
rdesc->num_registers = bitmap_weight(rdesc->presense_map,
RMI_REG_DESC_PRESENSE_BITS);
rdesc->registers = devm_kzalloc(&d->dev, rdesc->num_registers *
sizeof(struct rmi_register_desc_item),
GFP_KERNEL);
rdesc->registers = devm_kcalloc(&d->dev,
rdesc->num_registers,
sizeof(struct rmi_register_desc_item),
GFP_KERNEL);
if (!rdesc->registers)
return -ENOMEM;
@@ -1057,7 +1058,7 @@ int rmi_probe_interrupts(struct rmi_driver_data *data)
data->num_of_irq_regs = (data->irq_count + 7) / 8;
size = BITS_TO_LONGS(data->irq_count) * sizeof(unsigned long);
data->irq_memory = devm_kzalloc(dev, size * 4, GFP_KERNEL);
data->irq_memory = devm_kcalloc(dev, size, 4, GFP_KERNEL);
if (!data->irq_memory) {
dev_err(dev, "Failed to allocate memory for irq masks.\n");
return -ENOMEM;

View File

@@ -1190,14 +1190,15 @@ static int rmi_f11_initialize(struct rmi_function *fn)
f11->sensor.attn_size += f11->sensor.nbr_fingers * 2;
/* allocate the in-kernel tracking buffers */
sensor->tracking_pos = devm_kzalloc(&fn->dev,
sizeof(struct input_mt_pos) * sensor->nbr_fingers,
sensor->tracking_pos = devm_kcalloc(&fn->dev,
sensor->nbr_fingers, sizeof(struct input_mt_pos),
GFP_KERNEL);
sensor->tracking_slots = devm_kcalloc(&fn->dev,
sensor->nbr_fingers, sizeof(int), GFP_KERNEL);
sensor->objs = devm_kcalloc(&fn->dev,
sensor->nbr_fingers,
sizeof(struct rmi_2d_sensor_abs_object),
GFP_KERNEL);
sensor->tracking_slots = devm_kzalloc(&fn->dev,
sizeof(int) * sensor->nbr_fingers, GFP_KERNEL);
sensor->objs = devm_kzalloc(&fn->dev,
sizeof(struct rmi_2d_sensor_abs_object)
* sensor->nbr_fingers, GFP_KERNEL);
if (!sensor->tracking_pos || !sensor->tracking_slots || !sensor->objs)
return -ENOMEM;

View File

@@ -526,14 +526,15 @@ static int rmi_f12_probe(struct rmi_function *fn)
}
/* allocate the in-kernel tracking buffers */
sensor->tracking_pos = devm_kzalloc(&fn->dev,
sizeof(struct input_mt_pos) * sensor->nbr_fingers,
sensor->tracking_pos = devm_kcalloc(&fn->dev,
sensor->nbr_fingers, sizeof(struct input_mt_pos),
GFP_KERNEL);
sensor->tracking_slots = devm_kcalloc(&fn->dev,
sensor->nbr_fingers, sizeof(int), GFP_KERNEL);
sensor->objs = devm_kcalloc(&fn->dev,
sensor->nbr_fingers,
sizeof(struct rmi_2d_sensor_abs_object),
GFP_KERNEL);
sensor->tracking_slots = devm_kzalloc(&fn->dev,
sizeof(int) * sensor->nbr_fingers, GFP_KERNEL);
sensor->objs = devm_kzalloc(&fn->dev,
sizeof(struct rmi_2d_sensor_abs_object)
* sensor->nbr_fingers, GFP_KERNEL);
if (!sensor->tracking_pos || !sensor->tracking_slots || !sensor->objs)
return -ENOMEM;

View File

@@ -685,7 +685,7 @@ static int rmi_f54_probe(struct rmi_function *fn)
rx = f54->num_rx_electrodes;
tx = f54->num_tx_electrodes;
f54->report_data = devm_kzalloc(&fn->dev,
sizeof(u16) * tx * rx,
array3_size(tx, rx, sizeof(u16)),
GFP_KERNEL);
if (f54->report_data == NULL)
return -ENOMEM;

View File

@@ -69,7 +69,7 @@ static int rmi_spi_manage_pools(struct rmi_spi_xport *rmi_spi, int len)
buf_size = RMI_SPI_XFER_SIZE_LIMIT;
tmp = rmi_spi->rx_buf;
buf = devm_kzalloc(&spi->dev, buf_size * 2,
buf = devm_kcalloc(&spi->dev, buf_size, 2,
GFP_KERNEL | GFP_DMA);
if (!buf)
return -ENOMEM;
@@ -96,9 +96,10 @@ static int rmi_spi_manage_pools(struct rmi_spi_xport *rmi_spi, int len)
* per byte delays.
*/
tmp = rmi_spi->rx_xfers;
xfer_buf = devm_kzalloc(&spi->dev,
(rmi_spi->rx_xfer_count + rmi_spi->tx_xfer_count)
* sizeof(struct spi_transfer), GFP_KERNEL);
xfer_buf = devm_kcalloc(&spi->dev,
rmi_spi->rx_xfer_count + rmi_spi->tx_xfer_count,
sizeof(struct spi_transfer),
GFP_KERNEL);
if (!xfer_buf)
return -ENOMEM;

View File

@@ -4584,8 +4584,8 @@ static int arm_smmu_init_clocks(struct arm_smmu_power_resources *pwr)
return 0;
}
pwr->clocks = devm_kzalloc(
dev, sizeof(*pwr->clocks) * pwr->num_clocks,
pwr->clocks = devm_kcalloc(
dev, pwr->num_clocks, sizeof(*pwr->clocks),
GFP_KERNEL);
if (!pwr->clocks)
@@ -4630,8 +4630,8 @@ static int arm_smmu_init_regulators(struct arm_smmu_power_resources *pwr)
return 0;
}
pwr->gdscs = devm_kzalloc(
dev, sizeof(*pwr->gdscs) * pwr->num_gdscs, GFP_KERNEL);
pwr->gdscs = devm_kcalloc(
dev, pwr->num_gdscs, sizeof(*pwr->gdscs), GFP_KERNEL);
if (!pwr->gdscs)
return -ENOMEM;
@@ -5141,7 +5141,7 @@ static int arm_smmu_device_dt_probe(struct platform_device *pdev)
return -ENODEV;
}
smmu->irqs = devm_kzalloc(dev, sizeof(*smmu->irqs) * num_irqs,
smmu->irqs = devm_kcalloc(dev, num_irqs, sizeof(*smmu->irqs),
GFP_KERNEL);
if (!smmu->irqs) {
dev_err(dev, "failed to allocate %d irqs\n", num_irqs);
@@ -5933,7 +5933,7 @@ static int qsmmuv500_read_actlr_tbl(struct arm_smmu_device *smmu)
if (len < 0)
return 0;
actlrs = devm_kzalloc(dev, sizeof(*actlrs) * len, GFP_KERNEL);
actlrs = devm_kcalloc(dev, len, sizeof(*actlrs), GFP_KERNEL);
if (!actlrs)
return -ENOMEM;
@@ -6632,7 +6632,7 @@ static int qsmmuv500_tbu_probe(struct platform_device *pdev)
while ((res = platform_get_resource(pdev, IORESOURCE_IRQ, num_irqs)))
num_irqs++;
tbu->irqs = devm_kzalloc(dev, sizeof(*tbu->irqs) * num_irqs,
tbu->irqs = devm_kcalloc(dev, num_irqs, sizeof(*tbu->irqs),
GFP_KERNEL);
if (!tbu->irqs)
return -ENOMEM;

View File

@@ -1148,7 +1148,7 @@ static int rk_iommu_probe(struct platform_device *pdev)
iommu->dev = dev;
iommu->num_mmu = 0;
iommu->bases = devm_kzalloc(dev, sizeof(*iommu->bases) * num_res,
iommu->bases = devm_kcalloc(dev, num_res, sizeof(*iommu->bases),
GFP_KERNEL);
if (!iommu->bases)
return -ENOMEM;

View File

@@ -354,7 +354,7 @@ static int pdc_intc_probe(struct platform_device *pdev)
priv->nr_syswakes = val;
/* Get peripheral IRQ numbers */
priv->perip_irqs = devm_kzalloc(&pdev->dev, 4 * priv->nr_perips,
priv->perip_irqs = devm_kcalloc(&pdev->dev, 4, priv->nr_perips,
GFP_KERNEL);
if (!priv->perip_irqs) {
dev_err(&pdev->dev, "cannot allocate perip IRQ list\n");

View File

@@ -207,8 +207,8 @@ static int mvebu_gicp_probe(struct platform_device *pdev)
gicp->spi_ranges_cnt = ret / 2;
gicp->spi_ranges =
devm_kzalloc(&pdev->dev,
gicp->spi_ranges_cnt *
devm_kcalloc(&pdev->dev,
gicp->spi_ranges_cnt,
sizeof(struct mvebu_gicp_spi_range),
GFP_KERNEL);
if (!gicp->spi_ranges)
@@ -226,8 +226,8 @@ static int mvebu_gicp_probe(struct platform_device *pdev)
gicp->spi_cnt += gicp->spi_ranges[i].count;
}
gicp->spi_bitmap = devm_kzalloc(&pdev->dev,
BITS_TO_LONGS(gicp->spi_cnt) * sizeof(long),
gicp->spi_bitmap = devm_kcalloc(&pdev->dev,
BITS_TO_LONGS(gicp->spi_cnt), sizeof(long),
GFP_KERNEL);
if (!gicp->spi_bitmap)
return -ENOMEM;

View File

@@ -108,7 +108,7 @@ static int adp5520_led_probe(struct platform_device *pdev)
return -EFAULT;
}
led = devm_kzalloc(&pdev->dev, sizeof(*led) * pdata->num_leds,
led = devm_kcalloc(&pdev->dev, pdata->num_leds, sizeof(*led),
GFP_KERNEL);
if (!led)
return -ENOMEM;

View File

@@ -113,8 +113,8 @@ static int da9052_led_probe(struct platform_device *pdev)
goto err;
}
led = devm_kzalloc(&pdev->dev,
sizeof(struct da9052_led) * pled->num_leds,
led = devm_kcalloc(&pdev->dev,
pled->num_leds, sizeof(struct da9052_led),
GFP_KERNEL);
if (!led) {
error = -ENOMEM;

View File

@@ -533,8 +533,8 @@ static int lp5521_probe(struct i2c_client *client,
if (!chip)
return -ENOMEM;
led = devm_kzalloc(&client->dev,
sizeof(*led) * pdata->num_channels, GFP_KERNEL);
led = devm_kcalloc(&client->dev,
pdata->num_channels, sizeof(*led), GFP_KERNEL);
if (!led)
return -ENOMEM;

View File

@@ -900,8 +900,8 @@ static int lp5523_probe(struct i2c_client *client,
if (!chip)
return -ENOMEM;
led = devm_kzalloc(&client->dev,
sizeof(*led) * pdata->num_channels, GFP_KERNEL);
led = devm_kcalloc(&client->dev,
pdata->num_channels, sizeof(*led), GFP_KERNEL);
if (!led)
return -ENOMEM;

View File

@@ -538,8 +538,8 @@ static int lp5562_probe(struct i2c_client *client,
if (!chip)
return -ENOMEM;
led = devm_kzalloc(&client->dev,
sizeof(*led) * pdata->num_channels, GFP_KERNEL);
led = devm_kcalloc(&client->dev,
pdata->num_channels, sizeof(*led), GFP_KERNEL);
if (!led)
return -ENOMEM;

View File

@@ -560,7 +560,7 @@ struct lp55xx_platform_data *lp55xx_of_populate_pdata(struct device *dev,
return ERR_PTR(-EINVAL);
}
cfg = devm_kzalloc(dev, sizeof(*cfg) * num_channels, GFP_KERNEL);
cfg = devm_kcalloc(dev, num_channels, sizeof(*cfg), GFP_KERNEL);
if (!cfg)
return ERR_PTR(-ENOMEM);

View File

@@ -327,8 +327,8 @@ static int lp8501_probe(struct i2c_client *client,
if (!chip)
return -ENOMEM;
led = devm_kzalloc(&client->dev,
sizeof(*led) * pdata->num_channels, GFP_KERNEL);
led = devm_kcalloc(&client->dev,
pdata->num_channels, sizeof(*led), GFP_KERNEL);
if (!led)
return -ENOMEM;

View File

@@ -128,8 +128,8 @@ static int lt3593_led_probe(struct platform_device *pdev)
if (!pdata)
return -EBUSY;
leds_data = devm_kzalloc(&pdev->dev,
sizeof(struct lt3593_led_data) * pdata->num_leds,
leds_data = devm_kcalloc(&pdev->dev,
pdata->num_leds, sizeof(struct lt3593_led_data),
GFP_KERNEL);
if (!leds_data)
return -ENOMEM;

Some files were not shown because too many files have changed in this diff Show More