Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

rtc: armada38x: zalloc + calloc to single allocation

Use a flexible array member to simplify allocation.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
Reviewed-by: Gregory CLEMENT <gregory.clement@bootlin.com>
Link: https://patch.msgid.link/20260304225329.24510-1-rosenp@gmail.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

authored by

Rosen Penev and committed by
Alexandre Belloni
5827fe59 5ff89ef4

+2 -7
+2 -7
drivers/rtc/rtc-armada38x.c
··· 72 72 spinlock_t lock; 73 73 int irq; 74 74 bool initialized; 75 - struct value_to_freq *val_to_freq; 76 75 const struct armada38x_rtc_data *data; 76 + struct value_to_freq val_to_freq[]; 77 77 }; 78 78 79 79 #define ALARM1 0 ··· 490 490 { 491 491 struct armada38x_rtc *rtc; 492 492 493 - rtc = devm_kzalloc(&pdev->dev, sizeof(struct armada38x_rtc), 493 + rtc = devm_kzalloc(&pdev->dev, struct_size(rtc, val_to_freq, SAMPLE_NR), 494 494 GFP_KERNEL); 495 495 if (!rtc) 496 496 return -ENOMEM; 497 497 498 498 rtc->data = of_device_get_match_data(&pdev->dev); 499 - 500 - rtc->val_to_freq = devm_kcalloc(&pdev->dev, SAMPLE_NR, 501 - sizeof(struct value_to_freq), GFP_KERNEL); 502 - if (!rtc->val_to_freq) 503 - return -ENOMEM; 504 499 505 500 spin_lock_init(&rtc->lock); 506 501