Skip to content

Commit d0c79cd

Browse files
Uwe Kleine-Königgregkh
Uwe Kleine-König
authored andcommitted
pwm: lpc18xx-sct: Reduce number of devm memory allocations
[ Upstream commit 20d9de9 ] Each devm allocations has an overhead of 24 bytes to store the related struct devres_node additionally to the fragmentation of the allocator. So allocating 16 struct lpc18xx_pwm_data (which only hold a single int) adds quite some overhead. Instead put the per-channel data into the driver data struct and allocate it in one go. Signed-off-by: Uwe Kleine-König <[email protected]> Signed-off-by: Thierry Reding <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 009b384 commit d0c79cd

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

drivers/pwm/pwm-lpc18xx-sct.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@
7676
#define LPC18XX_PWM_EVENT_PERIOD 0
7777
#define LPC18XX_PWM_EVENT_MAX 16
7878

79+
#define LPC18XX_NUM_PWMS 16
80+
7981
/* SCT conflict resolution */
8082
enum lpc18xx_pwm_res_action {
8183
LPC18XX_PWM_RES_NONE,
@@ -101,6 +103,7 @@ struct lpc18xx_pwm_chip {
101103
unsigned long event_map;
102104
struct mutex res_lock;
103105
struct mutex period_lock;
106+
struct lpc18xx_pwm_data channeldata[LPC18XX_NUM_PWMS];
104107
};
105108

106109
static inline struct lpc18xx_pwm_chip *
@@ -370,7 +373,7 @@ static int lpc18xx_pwm_probe(struct platform_device *pdev)
370373

371374
lpc18xx_pwm->chip.dev = &pdev->dev;
372375
lpc18xx_pwm->chip.ops = &lpc18xx_pwm_ops;
373-
lpc18xx_pwm->chip.npwm = 16;
376+
lpc18xx_pwm->chip.npwm = LPC18XX_NUM_PWMS;
374377

375378
/* SCT counter must be in unify (32 bit) mode */
376379
lpc18xx_pwm_writel(lpc18xx_pwm, LPC18XX_PWM_CONFIG,
@@ -400,12 +403,7 @@ static int lpc18xx_pwm_probe(struct platform_device *pdev)
400403

401404
pwm = &lpc18xx_pwm->chip.pwms[i];
402405

403-
data = devm_kzalloc(lpc18xx_pwm->dev, sizeof(*data),
404-
GFP_KERNEL);
405-
if (!data) {
406-
ret = -ENOMEM;
407-
goto disable_pwmclk;
408-
}
406+
data = &lpc18xx_pwm->channeldata[i];
409407

410408
pwm_set_chip_data(pwm, data);
411409
}

0 commit comments

Comments
 (0)