Commit 583facb6 authored by Dan Carpenter's avatar Dan Carpenter Committed by Linus Walleij

pinctrl: samsung: remove "out of memory" messages

Checkpatch.pl complains about these:

WARNING: Possible unnecessary 'out of memory' message

The messages use a little extra RAM and they add a few extra lines of
code.  We're probably never going to hit these out of memory situations
but if we did then kmalloc() has pretty good error messages built-in.
Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: default avatarKrzysztof Kozlowski <k.kozlowski@samsung.com>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent 8749f8ed
...@@ -203,10 +203,8 @@ static int exynos5440_dt_node_to_map(struct pinctrl_dev *pctldev, ...@@ -203,10 +203,8 @@ static int exynos5440_dt_node_to_map(struct pinctrl_dev *pctldev,
/* Allocate memory for pin-map entries */ /* Allocate memory for pin-map entries */
map = kzalloc(sizeof(*map) * map_cnt, GFP_KERNEL); map = kzalloc(sizeof(*map) * map_cnt, GFP_KERNEL);
if (!map) { if (!map)
dev_err(dev, "could not alloc memory for pin-maps\n");
return -ENOMEM; return -ENOMEM;
}
*nmaps = 0; *nmaps = 0;
/* /*
...@@ -214,10 +212,8 @@ static int exynos5440_dt_node_to_map(struct pinctrl_dev *pctldev, ...@@ -214,10 +212,8 @@ static int exynos5440_dt_node_to_map(struct pinctrl_dev *pctldev,
* from the node name from which these map entries are be created. * from the node name from which these map entries are be created.
*/ */
gname = kasprintf(GFP_KERNEL, "%s%s", np->name, GROUP_SUFFIX); gname = kasprintf(GFP_KERNEL, "%s%s", np->name, GROUP_SUFFIX);
if (!gname) { if (!gname)
dev_err(dev, "failed to alloc memory for group name\n");
goto free_map; goto free_map;
}
/* /*
* don't have config options? then skip over to creating function * don't have config options? then skip over to creating function
...@@ -228,10 +224,8 @@ static int exynos5440_dt_node_to_map(struct pinctrl_dev *pctldev, ...@@ -228,10 +224,8 @@ static int exynos5440_dt_node_to_map(struct pinctrl_dev *pctldev,
/* Allocate memory for config entries */ /* Allocate memory for config entries */
cfg = kzalloc(sizeof(*cfg) * cfg_cnt, GFP_KERNEL); cfg = kzalloc(sizeof(*cfg) * cfg_cnt, GFP_KERNEL);
if (!cfg) { if (!cfg)
dev_err(dev, "failed to alloc memory for configs\n");
goto free_gname; goto free_gname;
}
/* Prepare a list of config settings */ /* Prepare a list of config settings */
for (idx = 0, cfg_cnt = 0; idx < ARRAY_SIZE(pcfgs); idx++) { for (idx = 0, cfg_cnt = 0; idx < ARRAY_SIZE(pcfgs); idx++) {
...@@ -253,10 +247,8 @@ static int exynos5440_dt_node_to_map(struct pinctrl_dev *pctldev, ...@@ -253,10 +247,8 @@ static int exynos5440_dt_node_to_map(struct pinctrl_dev *pctldev,
if (of_find_property(np, "samsung,exynos5440-pin-function", NULL)) { if (of_find_property(np, "samsung,exynos5440-pin-function", NULL)) {
fname = kasprintf(GFP_KERNEL, fname = kasprintf(GFP_KERNEL,
"%s%s", np->name, FUNCTION_SUFFIX); "%s%s", np->name, FUNCTION_SUFFIX);
if (!fname) { if (!fname)
dev_err(dev, "failed to alloc memory for func name\n");
goto free_cfg; goto free_cfg;
}
map[*nmaps].data.mux.group = gname; map[*nmaps].data.mux.group = gname;
map[*nmaps].data.mux.function = fname; map[*nmaps].data.mux.function = fname;
...@@ -647,10 +639,8 @@ static int exynos5440_pinctrl_parse_dt_pins(struct platform_device *pdev, ...@@ -647,10 +639,8 @@ static int exynos5440_pinctrl_parse_dt_pins(struct platform_device *pdev,
} }
*pin_list = devm_kzalloc(dev, *npins * sizeof(**pin_list), GFP_KERNEL); *pin_list = devm_kzalloc(dev, *npins * sizeof(**pin_list), GFP_KERNEL);
if (!*pin_list) { if (!*pin_list)
dev_err(dev, "failed to allocate memory for pin list\n");
return -ENOMEM; return -ENOMEM;
}
return of_property_read_u32_array(cfg_np, "samsung,exynos5440-pins", return of_property_read_u32_array(cfg_np, "samsung,exynos5440-pins",
*pin_list, *npins); *pin_list, *npins);
...@@ -678,17 +668,15 @@ static int exynos5440_pinctrl_parse_dt(struct platform_device *pdev, ...@@ -678,17 +668,15 @@ static int exynos5440_pinctrl_parse_dt(struct platform_device *pdev,
return -EINVAL; return -EINVAL;
groups = devm_kzalloc(dev, grp_cnt * sizeof(*groups), GFP_KERNEL); groups = devm_kzalloc(dev, grp_cnt * sizeof(*groups), GFP_KERNEL);
if (!groups) { if (!groups)
dev_err(dev, "failed allocate memory for ping group list\n");
return -EINVAL; return -EINVAL;
}
grp = groups; grp = groups;
functions = devm_kzalloc(dev, grp_cnt * sizeof(*functions), GFP_KERNEL); functions = devm_kzalloc(dev, grp_cnt * sizeof(*functions), GFP_KERNEL);
if (!functions) { if (!functions)
dev_err(dev, "failed to allocate memory for function list\n");
return -EINVAL; return -EINVAL;
}
func = functions; func = functions;
/* /*
...@@ -708,10 +696,8 @@ static int exynos5440_pinctrl_parse_dt(struct platform_device *pdev, ...@@ -708,10 +696,8 @@ static int exynos5440_pinctrl_parse_dt(struct platform_device *pdev,
/* derive pin group name from the node name */ /* derive pin group name from the node name */
gname = devm_kasprintf(dev, GFP_KERNEL, gname = devm_kasprintf(dev, GFP_KERNEL,
"%s%s", cfg_np->name, GROUP_SUFFIX); "%s%s", cfg_np->name, GROUP_SUFFIX);
if (!gname) { if (!gname)
dev_err(dev, "failed to alloc memory for group name\n");
return -ENOMEM; return -ENOMEM;
}
grp->name = gname; grp->name = gname;
grp->pins = pin_list; grp->pins = pin_list;
...@@ -727,18 +713,13 @@ static int exynos5440_pinctrl_parse_dt(struct platform_device *pdev, ...@@ -727,18 +713,13 @@ static int exynos5440_pinctrl_parse_dt(struct platform_device *pdev,
/* derive function name from the node name */ /* derive function name from the node name */
fname = devm_kasprintf(dev, GFP_KERNEL, fname = devm_kasprintf(dev, GFP_KERNEL,
"%s%s", cfg_np->name, FUNCTION_SUFFIX); "%s%s", cfg_np->name, FUNCTION_SUFFIX);
if (!fname) { if (!fname)
dev_err(dev, "failed to alloc memory for func name\n");
return -ENOMEM; return -ENOMEM;
}
func->name = fname; func->name = fname;
func->groups = devm_kzalloc(dev, sizeof(char *), GFP_KERNEL); func->groups = devm_kzalloc(dev, sizeof(char *), GFP_KERNEL);
if (!func->groups) { if (!func->groups)
dev_err(dev, "failed to alloc memory for group list "
"in pin function");
return -ENOMEM; return -ENOMEM;
}
func->groups[0] = gname; func->groups[0] = gname;
func->num_groups = gname ? 1 : 0; func->num_groups = gname ? 1 : 0;
func->function = function; func->function = function;
...@@ -766,10 +747,8 @@ static int exynos5440_pinctrl_register(struct platform_device *pdev, ...@@ -766,10 +747,8 @@ static int exynos5440_pinctrl_register(struct platform_device *pdev,
int pin, ret; int pin, ret;
ctrldesc = devm_kzalloc(dev, sizeof(*ctrldesc), GFP_KERNEL); ctrldesc = devm_kzalloc(dev, sizeof(*ctrldesc), GFP_KERNEL);
if (!ctrldesc) { if (!ctrldesc)
dev_err(dev, "could not allocate memory for pinctrl desc\n");
return -ENOMEM; return -ENOMEM;
}
ctrldesc->name = "exynos5440-pinctrl"; ctrldesc->name = "exynos5440-pinctrl";
ctrldesc->owner = THIS_MODULE; ctrldesc->owner = THIS_MODULE;
...@@ -779,10 +758,8 @@ static int exynos5440_pinctrl_register(struct platform_device *pdev, ...@@ -779,10 +758,8 @@ static int exynos5440_pinctrl_register(struct platform_device *pdev,
pindesc = devm_kzalloc(&pdev->dev, sizeof(*pindesc) * pindesc = devm_kzalloc(&pdev->dev, sizeof(*pindesc) *
EXYNOS5440_MAX_PINS, GFP_KERNEL); EXYNOS5440_MAX_PINS, GFP_KERNEL);
if (!pindesc) { if (!pindesc)
dev_err(&pdev->dev, "mem alloc for pin descriptors failed\n");
return -ENOMEM; return -ENOMEM;
}
ctrldesc->pins = pindesc; ctrldesc->pins = pindesc;
ctrldesc->npins = EXYNOS5440_MAX_PINS; ctrldesc->npins = EXYNOS5440_MAX_PINS;
...@@ -796,10 +773,8 @@ static int exynos5440_pinctrl_register(struct platform_device *pdev, ...@@ -796,10 +773,8 @@ static int exynos5440_pinctrl_register(struct platform_device *pdev,
*/ */
pin_names = devm_kzalloc(&pdev->dev, sizeof(char) * PIN_NAME_LENGTH * pin_names = devm_kzalloc(&pdev->dev, sizeof(char) * PIN_NAME_LENGTH *
ctrldesc->npins, GFP_KERNEL); ctrldesc->npins, GFP_KERNEL);
if (!pin_names) { if (!pin_names)
dev_err(&pdev->dev, "mem alloc for pin names failed\n");
return -ENOMEM; return -ENOMEM;
}
/* for each pin, set the name of the pin */ /* for each pin, set the name of the pin */
for (pin = 0; pin < ctrldesc->npins; pin++) { for (pin = 0; pin < ctrldesc->npins; pin++) {
...@@ -836,10 +811,8 @@ static int exynos5440_gpiolib_register(struct platform_device *pdev, ...@@ -836,10 +811,8 @@ static int exynos5440_gpiolib_register(struct platform_device *pdev,
int ret; int ret;
gc = devm_kzalloc(&pdev->dev, sizeof(*gc), GFP_KERNEL); gc = devm_kzalloc(&pdev->dev, sizeof(*gc), GFP_KERNEL);
if (!gc) { if (!gc)
dev_err(&pdev->dev, "mem alloc for gpio_chip failed\n");
return -ENOMEM; return -ENOMEM;
}
priv->gc = gc; priv->gc = gc;
gc->base = 0; gc->base = 0;
...@@ -941,10 +914,8 @@ static int exynos5440_gpio_irq_init(struct platform_device *pdev, ...@@ -941,10 +914,8 @@ static int exynos5440_gpio_irq_init(struct platform_device *pdev,
intd = devm_kzalloc(dev, sizeof(*intd) * EXYNOS5440_MAX_GPIO_INT, intd = devm_kzalloc(dev, sizeof(*intd) * EXYNOS5440_MAX_GPIO_INT,
GFP_KERNEL); GFP_KERNEL);
if (!intd) { if (!intd)
dev_err(dev, "failed to allocate memory for gpio intr data\n");
return -ENOMEM; return -ENOMEM;
}
for (i = 0; i < EXYNOS5440_MAX_GPIO_INT; i++) { for (i = 0; i < EXYNOS5440_MAX_GPIO_INT; i++) {
irq = irq_of_parse_and_map(dev->of_node, i); irq = irq_of_parse_and_map(dev->of_node, i);
...@@ -987,10 +958,8 @@ static int exynos5440_pinctrl_probe(struct platform_device *pdev) ...@@ -987,10 +958,8 @@ static int exynos5440_pinctrl_probe(struct platform_device *pdev)
} }
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
if (!priv) { if (!priv)
dev_err(dev, "could not allocate memory for private data\n");
return -ENOMEM; return -ENOMEM;
}
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
priv->reg_base = devm_ioremap_resource(&pdev->dev, res); priv->reg_base = devm_ioremap_resource(&pdev->dev, res);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment