struct device *dev = &ofdev->dev;
struct device_node *np = ofdev->dev.of_node;
struct talitos_private *priv;
+ unsigned int num_channels;
int i, err;
int stride;
struct resource *res;
- priv = devm_kzalloc(dev, sizeof(struct talitos_private), GFP_KERNEL);
+ if (of_property_read_u32(np, "fsl,num-channels", &num_channels))
+ return -EINVAL;
+
+ priv = devm_kzalloc(dev, struct_size(priv, chan, num_channels), GFP_KERNEL);
if (!priv)
return -ENOMEM;
+ priv->num_channels = num_channels;
+
INIT_LIST_HEAD(&priv->alg_list);
dev_set_drvdata(dev, priv);
}
/* get SEC version capabilities from device tree */
- of_property_read_u32(np, "fsl,num-channels", &priv->num_channels);
of_property_read_u32(np, "fsl,channel-fifo-len", &priv->chfifo_len);
of_property_read_u32(np, "fsl,exec-units-mask", &priv->exec_units);
of_property_read_u32(np, "fsl,descriptor-types-mask",
}
}
- priv->chan = devm_kcalloc(dev,
- priv->num_channels,
- sizeof(struct talitos_channel),
- GFP_KERNEL);
- if (!priv->chan) {
- dev_err(dev, "failed to allocate channel management space\n");
- err = -ENOMEM;
- goto err_out;
- }
-
priv->fifo_len = roundup_pow_of_two(priv->chfifo_len);
for (i = 0; i < priv->num_channels; i++) {