Skip to content

Commit 923b138

Browse files
tititiou36vinodkoul
authored andcommitted
dmaengine: mcf-edma: Use struct_size()
Use struct_size() instead of hand writing it. This is less verbose and more informative. 'mcf_chan' is now unused and can be removed. In fact, it is shadowed by another variable in the 'for' loop below. Keep this one. Signed-off-by: Christophe JAILLET <[email protected]> Link: https://lore.kernel.org/r/97c2bb1c9b69d0739da3762a7752ae6582c4ad02.1683390112.git.christophe.jaillet@wanadoo.fr Signed-off-by: Vinod Koul <[email protected]>
1 parent 8674ca3 commit 923b138

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

drivers/dma/mcf-edma.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,8 @@ static int mcf_edma_probe(struct platform_device *pdev)
180180
{
181181
struct mcf_edma_platform_data *pdata;
182182
struct fsl_edma_engine *mcf_edma;
183-
struct fsl_edma_chan *mcf_chan;
184183
struct edma_regs *regs;
185-
int ret, i, len, chans;
184+
int ret, i, chans;
186185

187186
pdata = dev_get_platdata(&pdev->dev);
188187
if (!pdata) {
@@ -191,8 +190,8 @@ static int mcf_edma_probe(struct platform_device *pdev)
191190
}
192191

193192
chans = pdata->dma_channels;
194-
len = sizeof(*mcf_edma) + sizeof(*mcf_chan) * chans;
195-
mcf_edma = devm_kzalloc(&pdev->dev, len, GFP_KERNEL);
193+
mcf_edma = devm_kzalloc(&pdev->dev, struct_size(mcf_edma, chans, chans),
194+
GFP_KERNEL);
196195
if (!mcf_edma)
197196
return -ENOMEM;
198197

0 commit comments

Comments
 (0)