reset: sti: Use devm_kcalloc() in syscfg_reset_controller_register()
* A multiplication for the size determination of a memory allocation indicated that an array data structure should be processed. Thus use the corresponding function "devm_kcalloc". * Replace the specification of a data structure by a pointer dereference to make the corresponding size determination a bit safer according to the Linux coding style convention. * Delete the local variable "size" which became unnecessary with this refactoring. Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
This commit is contained in:
parent
2ea659a9ef
commit
aa248927d8
|
@ -145,16 +145,14 @@ static int syscfg_reset_controller_register(struct device *dev,
|
||||||
const struct syscfg_reset_controller_data *data)
|
const struct syscfg_reset_controller_data *data)
|
||||||
{
|
{
|
||||||
struct syscfg_reset_controller *rc;
|
struct syscfg_reset_controller *rc;
|
||||||
size_t size;
|
|
||||||
int i, err;
|
int i, err;
|
||||||
|
|
||||||
rc = devm_kzalloc(dev, sizeof(*rc), GFP_KERNEL);
|
rc = devm_kzalloc(dev, sizeof(*rc), GFP_KERNEL);
|
||||||
if (!rc)
|
if (!rc)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
size = sizeof(struct syscfg_reset_channel) * data->nr_channels;
|
rc->channels = devm_kcalloc(dev, data->nr_channels,
|
||||||
|
sizeof(*rc->channels), GFP_KERNEL);
|
||||||
rc->channels = devm_kzalloc(dev, size, GFP_KERNEL);
|
|
||||||
if (!rc->channels)
|
if (!rc->channels)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue