Source
383
383
int count;
384
384
385
385
count = of_get_child_count(np);
386
386
if (!count || count > chip->bits)
387
387
return ERR_PTR(-ENODEV);
388
388
389
389
pdata = devm_kzalloc(&client->dev, sizeof(*pdata), GFP_KERNEL);
390
390
if (!pdata)
391
391
return ERR_PTR(-ENOMEM);
392
392
393
-
pdata->leds = devm_kzalloc(&client->dev,
394
-
sizeof(struct pca955x_led) * chip->bits,
393
+
pdata->leds = devm_kcalloc(&client->dev,
394
+
chip->bits, sizeof(struct pca955x_led),
395
395
GFP_KERNEL);
396
396
if (!pdata->leds)
397
397
return ERR_PTR(-ENOMEM);
398
398
399
399
for_each_child_of_node(np, child) {
400
400
const char *name;
401
401
u32 reg;
402
402
int res;
403
403
404
404
res = of_property_read_u32(child, "reg", ®);
487
487
dev_err(&client->dev,
488
488
"board info claims %d LEDs on a %d-bit chip\n",
489
489
pdata->num_leds, chip->bits);
490
490
return -ENODEV;
491
491
}
492
492
493
493
pca955x = devm_kzalloc(&client->dev, sizeof(*pca955x), GFP_KERNEL);
494
494
if (!pca955x)
495
495
return -ENOMEM;
496
496
497
-
pca955x->leds = devm_kzalloc(&client->dev,
498
-
sizeof(*pca955x_led) * chip->bits, GFP_KERNEL);
497
+
pca955x->leds = devm_kcalloc(&client->dev,
498
+
chip->bits, sizeof(*pca955x_led), GFP_KERNEL);
499
499
if (!pca955x->leds)
500
500
return -ENOMEM;
501
501
502
502
i2c_set_clientdata(client, pca955x);
503
503
504
504
mutex_init(&pca955x->lock);
505
505
pca955x->client = client;
506
506
pca955x->chipdef = chip;
507
507
508
508
for (i = 0; i < chip->bits; i++) {