Commit f5ec9b19 authored by Laurent Pinchart's avatar Laurent Pinchart

clocksource: sh_cmt: Allocate channels dynamically

This prepares the driver for multi-channel support.
Signed-off-by: default avatarLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
parent b262bc74
...@@ -62,7 +62,8 @@ struct sh_cmt_device { ...@@ -62,7 +62,8 @@ struct sh_cmt_device {
void __iomem *mapbase; void __iomem *mapbase;
struct clk *clk; struct clk *clk;
struct sh_cmt_channel channel; struct sh_cmt_channel *channels;
unsigned int num_channels;
unsigned long width; /* 16 or 32 bit version of hardware block */ unsigned long width; /* 16 or 32 bit version of hardware block */
unsigned long overflow_bit; unsigned long overflow_bit;
...@@ -822,7 +823,15 @@ static int sh_cmt_setup(struct sh_cmt_device *cmt, struct platform_device *pdev) ...@@ -822,7 +823,15 @@ static int sh_cmt_setup(struct sh_cmt_device *cmt, struct platform_device *pdev)
cmt->clear_bits = ~0xc000; cmt->clear_bits = ~0xc000;
} }
ret = sh_cmt_setup_channel(&cmt->channel, cfg->timer_bit, cmt); cmt->channels = kzalloc(sizeof(*cmt->channels), GFP_KERNEL);
if (cmt->channels == NULL) {
ret = -ENOMEM;
goto err4;
}
cmt->num_channels = 1;
ret = sh_cmt_setup_channel(&cmt->channels[0], cfg->timer_bit, cmt);
if (ret < 0) if (ret < 0)
goto err4; goto err4;
...@@ -830,6 +839,7 @@ static int sh_cmt_setup(struct sh_cmt_device *cmt, struct platform_device *pdev) ...@@ -830,6 +839,7 @@ static int sh_cmt_setup(struct sh_cmt_device *cmt, struct platform_device *pdev)
return 0; return 0;
err4: err4:
kfree(cmt->channels);
clk_unprepare(cmt->clk); clk_unprepare(cmt->clk);
err3: err3:
clk_put(cmt->clk); clk_put(cmt->clk);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment