Skip to content

Commit d7e8d14

Browse files
committed
Merge tag 'timers-v5.4-rc6' of https://git.linaro.org/people/daniel.lezcano/linux into timers/urgent
Pull clockevent fixes from Daniel Lezcano: - Fix scary messages in sh_mtu2 by using platform_irq_count() helper function (Geert Uytterhoeven) - Fix double free when using timer-of in the mediatek timer driver (Fabien Parent)
2 parents a99d808 + 7693de9 commit d7e8d14

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

drivers/clocksource/sh_mtu2.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -328,12 +328,13 @@ static int sh_mtu2_register(struct sh_mtu2_channel *ch, const char *name)
328328
return 0;
329329
}
330330

331+
static const unsigned int sh_mtu2_channel_offsets[] = {
332+
0x300, 0x380, 0x000,
333+
};
334+
331335
static int sh_mtu2_setup_channel(struct sh_mtu2_channel *ch, unsigned int index,
332336
struct sh_mtu2_device *mtu)
333337
{
334-
static const unsigned int channel_offsets[] = {
335-
0x300, 0x380, 0x000,
336-
};
337338
char name[6];
338339
int irq;
339340
int ret;
@@ -356,7 +357,7 @@ static int sh_mtu2_setup_channel(struct sh_mtu2_channel *ch, unsigned int index,
356357
return ret;
357358
}
358359

359-
ch->base = mtu->mapbase + channel_offsets[index];
360+
ch->base = mtu->mapbase + sh_mtu2_channel_offsets[index];
360361
ch->index = index;
361362

362363
return sh_mtu2_register(ch, dev_name(&mtu->pdev->dev));
@@ -408,7 +409,12 @@ static int sh_mtu2_setup(struct sh_mtu2_device *mtu,
408409
}
409410

410411
/* Allocate and setup the channels. */
411-
mtu->num_channels = 3;
412+
ret = platform_irq_count(pdev);
413+
if (ret < 0)
414+
goto err_unmap;
415+
416+
mtu->num_channels = min_t(unsigned int, ret,
417+
ARRAY_SIZE(sh_mtu2_channel_offsets));
412418

413419
mtu->channels = kcalloc(mtu->num_channels, sizeof(*mtu->channels),
414420
GFP_KERNEL);

drivers/clocksource/timer-mediatek.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -268,15 +268,12 @@ static int __init mtk_syst_init(struct device_node *node)
268268

269269
ret = timer_of_init(node, &to);
270270
if (ret)
271-
goto err;
271+
return ret;
272272

273273
clockevents_config_and_register(&to.clkevt, timer_of_rate(&to),
274274
TIMER_SYNC_TICKS, 0xffffffff);
275275

276276
return 0;
277-
err:
278-
timer_of_cleanup(&to);
279-
return ret;
280277
}
281278

282279
static int __init mtk_gpt_init(struct device_node *node)
@@ -293,7 +290,7 @@ static int __init mtk_gpt_init(struct device_node *node)
293290

294291
ret = timer_of_init(node, &to);
295292
if (ret)
296-
goto err;
293+
return ret;
297294

298295
/* Configure clock source */
299296
mtk_gpt_setup(&to, TIMER_CLK_SRC, GPT_CTRL_OP_FREERUN);
@@ -311,9 +308,6 @@ static int __init mtk_gpt_init(struct device_node *node)
311308
mtk_gpt_enable_irq(&to, TIMER_CLK_EVT);
312309

313310
return 0;
314-
err:
315-
timer_of_cleanup(&to);
316-
return ret;
317311
}
318312
TIMER_OF_DECLARE(mtk_mt6577, "mediatek,mt6577-timer", mtk_gpt_init);
319313
TIMER_OF_DECLARE(mtk_mt6765, "mediatek,mt6765-timer", mtk_syst_init);

0 commit comments

Comments
 (0)