Skip to content

Commit

Permalink
clocksource: sh_cmt earlytimer support
Browse files Browse the repository at this point in the history
Add Early Platform Driver support to the sh_cmt driver
using the earlytimer class.

Signed-off-by: Magnus Damm <damm@igel.co.jp>
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
  • Loading branch information
Magnus Damm authored and Paul Mundt committed Apr 19, 2009
1 parent aefe647 commit e475eed
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions drivers/clocksource/sh_cmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -566,17 +566,30 @@ static int sh_cmt_setup(struct sh_cmt_priv *p, struct platform_device *pdev)
static int __devinit sh_cmt_probe(struct platform_device *pdev)
{
struct sh_cmt_priv *p = platform_get_drvdata(pdev);
struct sh_cmt_config *cfg = pdev->dev.platform_data;
int ret;

p = kmalloc(sizeof(*p), GFP_KERNEL);
if (p) {
pr_info("sh_cmt: %s kept as earlytimer\n", cfg->name);
return 0;
}

if (is_early_platform_device(pdev))
p = alloc_bootmem(sizeof(*p));
else
p = kmalloc(sizeof(*p), GFP_KERNEL);

if (p == NULL) {
dev_err(&pdev->dev, "failed to allocate driver data\n");
return -ENOMEM;
}

ret = sh_cmt_setup(p, pdev);
if (ret) {
kfree(p);
if (is_early_platform_device(pdev))
free_bootmem(__pa(p), sizeof(*p));
else
kfree(p);

platform_set_drvdata(pdev, NULL);
}
Expand Down Expand Up @@ -606,6 +619,7 @@ static void __exit sh_cmt_exit(void)
platform_driver_unregister(&sh_cmt_device_driver);
}

early_platform_init("earlytimer", &sh_cmt_device_driver);
module_init(sh_cmt_init);
module_exit(sh_cmt_exit);

Expand Down

0 comments on commit e475eed

Please sign in to comment.