Source
404
404
405
405
/*
406
406
* A count of zero implies a single SPI device without any chip-select.
407
407
* Note that of_gpio_count counts all gpios assigned to this spi master.
408
408
* This includes both "null" gpio's and real ones.
409
409
*/
410
410
num_gpios = of_gpio_count(np);
411
411
if (num_gpios > 0) {
412
412
int i;
413
413
414
-
hw->gpios = kzalloc(sizeof(int) * num_gpios, GFP_KERNEL);
414
+
hw->gpios = kcalloc(num_gpios, sizeof(*hw->gpios), GFP_KERNEL);
415
415
if (!hw->gpios) {
416
416
ret = -ENOMEM;
417
417
goto free_master;
418
418
}
419
419
420
420
for (i = 0; i < num_gpios; i++) {
421
421
int gpio;
422
422
enum of_gpio_flags flags;
423
423
424
424
gpio = of_get_gpio_flags(np, i, &flags);