Skip to content

Commit 5827fe5

Browse files
nehebalexandrebelloni
authored andcommitted
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>
1 parent 5ff89ef commit 5827fe5

1 file changed

Lines changed: 2 additions & 7 deletions

File tree

drivers/rtc/rtc-armada38x.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ struct armada38x_rtc {
7272
spinlock_t lock;
7373
int irq;
7474
bool initialized;
75-
struct value_to_freq *val_to_freq;
7675
const struct armada38x_rtc_data *data;
76+
struct value_to_freq val_to_freq[];
7777
};
7878

7979
#define ALARM1 0
@@ -490,18 +490,13 @@ static __init int armada38x_rtc_probe(struct platform_device *pdev)
490490
{
491491
struct armada38x_rtc *rtc;
492492

493-
rtc = devm_kzalloc(&pdev->dev, sizeof(struct armada38x_rtc),
493+
rtc = devm_kzalloc(&pdev->dev, struct_size(rtc, val_to_freq, SAMPLE_NR),
494494
GFP_KERNEL);
495495
if (!rtc)
496496
return -ENOMEM;
497497

498498
rtc->data = of_device_get_match_data(&pdev->dev);
499499

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-
505500
spin_lock_init(&rtc->lock);
506501

507502
rtc->regs = devm_platform_ioremap_resource_byname(pdev, "rtc");

0 commit comments

Comments
 (0)