Commit 0a72aa39 authored by Laurent Pinchart's avatar Laurent Pinchart

clocksource: sh_tmu: Rename struct sh_tmu_priv to sh_tmu_device

Channel data is private as well, rename priv to device to make the
distrinction between the core device and the channels clearer.
Signed-off-by: default avatarLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
parent de2d12c7
...@@ -35,10 +35,10 @@ ...@@ -35,10 +35,10 @@
#include <linux/pm_domain.h> #include <linux/pm_domain.h>
#include <linux/pm_runtime.h> #include <linux/pm_runtime.h>
struct sh_tmu_priv; struct sh_tmu_device;
struct sh_tmu_channel { struct sh_tmu_channel {
struct sh_tmu_priv *tmu; struct sh_tmu_device *tmu;
int irq; int irq;
...@@ -50,7 +50,7 @@ struct sh_tmu_channel { ...@@ -50,7 +50,7 @@ struct sh_tmu_channel {
unsigned int enable_count; unsigned int enable_count;
}; };
struct sh_tmu_priv { struct sh_tmu_device {
struct platform_device *pdev; struct platform_device *pdev;
void __iomem *mapbase; void __iomem *mapbase;
...@@ -436,59 +436,59 @@ static int sh_tmu_register(struct sh_tmu_channel *ch, char *name, ...@@ -436,59 +436,59 @@ static int sh_tmu_register(struct sh_tmu_channel *ch, char *name,
return 0; return 0;
} }
static int sh_tmu_setup(struct sh_tmu_priv *p, struct platform_device *pdev) static int sh_tmu_setup(struct sh_tmu_device *tmu, struct platform_device *pdev)
{ {
struct sh_timer_config *cfg = pdev->dev.platform_data; struct sh_timer_config *cfg = pdev->dev.platform_data;
struct resource *res; struct resource *res;
int ret; int ret;
ret = -ENXIO; ret = -ENXIO;
memset(p, 0, sizeof(*p)); memset(tmu, 0, sizeof(*tmu));
p->pdev = pdev; tmu->pdev = pdev;
if (!cfg) { if (!cfg) {
dev_err(&p->pdev->dev, "missing platform data\n"); dev_err(&tmu->pdev->dev, "missing platform data\n");
goto err0; goto err0;
} }
platform_set_drvdata(pdev, p); platform_set_drvdata(pdev, tmu);
res = platform_get_resource(p->pdev, IORESOURCE_MEM, 0); res = platform_get_resource(tmu->pdev, IORESOURCE_MEM, 0);
if (!res) { if (!res) {
dev_err(&p->pdev->dev, "failed to get I/O memory\n"); dev_err(&tmu->pdev->dev, "failed to get I/O memory\n");
goto err0; goto err0;
} }
p->channel.irq = platform_get_irq(p->pdev, 0); tmu->channel.irq = platform_get_irq(tmu->pdev, 0);
if (p->channel.irq < 0) { if (tmu->channel.irq < 0) {
dev_err(&p->pdev->dev, "failed to get irq\n"); dev_err(&tmu->pdev->dev, "failed to get irq\n");
goto err0; goto err0;
} }
/* map memory, let mapbase point to our channel */ /* map memory, let mapbase point to our channel */
p->mapbase = ioremap_nocache(res->start, resource_size(res)); tmu->mapbase = ioremap_nocache(res->start, resource_size(res));
if (p->mapbase == NULL) { if (tmu->mapbase == NULL) {
dev_err(&p->pdev->dev, "failed to remap I/O memory\n"); dev_err(&tmu->pdev->dev, "failed to remap I/O memory\n");
goto err0; goto err0;
} }
/* get hold of clock */ /* get hold of clock */
p->clk = clk_get(&p->pdev->dev, "tmu_fck"); tmu->clk = clk_get(&tmu->pdev->dev, "tmu_fck");
if (IS_ERR(p->clk)) { if (IS_ERR(tmu->clk)) {
dev_err(&p->pdev->dev, "cannot get clock\n"); dev_err(&tmu->pdev->dev, "cannot get clock\n");
ret = PTR_ERR(p->clk); ret = PTR_ERR(tmu->clk);
goto err1; goto err1;
} }
ret = clk_prepare(p->clk); ret = clk_prepare(tmu->clk);
if (ret < 0) if (ret < 0)
goto err2; goto err2;
p->channel.cs_enabled = false; tmu->channel.cs_enabled = false;
p->channel.enable_count = 0; tmu->channel.enable_count = 0;
p->channel.tmu = p; tmu->channel.tmu = tmu;
ret = sh_tmu_register(&p->channel, (char *)dev_name(&p->pdev->dev), ret = sh_tmu_register(&tmu->channel, (char *)dev_name(&tmu->pdev->dev),
cfg->clockevent_rating, cfg->clockevent_rating,
cfg->clocksource_rating); cfg->clocksource_rating);
if (ret < 0) if (ret < 0)
...@@ -497,18 +497,18 @@ static int sh_tmu_setup(struct sh_tmu_priv *p, struct platform_device *pdev) ...@@ -497,18 +497,18 @@ static int sh_tmu_setup(struct sh_tmu_priv *p, struct platform_device *pdev)
return 0; return 0;
err3: err3:
clk_unprepare(p->clk); clk_unprepare(tmu->clk);
err2: err2:
clk_put(p->clk); clk_put(tmu->clk);
err1: err1:
iounmap(p->mapbase); iounmap(tmu->mapbase);
err0: err0:
return ret; return ret;
} }
static int sh_tmu_probe(struct platform_device *pdev) static int sh_tmu_probe(struct platform_device *pdev)
{ {
struct sh_tmu_priv *p = platform_get_drvdata(pdev); struct sh_tmu_device *tmu = platform_get_drvdata(pdev);
struct sh_timer_config *cfg = pdev->dev.platform_data; struct sh_timer_config *cfg = pdev->dev.platform_data;
int ret; int ret;
...@@ -517,20 +517,20 @@ static int sh_tmu_probe(struct platform_device *pdev) ...@@ -517,20 +517,20 @@ static int sh_tmu_probe(struct platform_device *pdev)
pm_runtime_enable(&pdev->dev); pm_runtime_enable(&pdev->dev);
} }
if (p) { if (tmu) {
dev_info(&pdev->dev, "kept as earlytimer\n"); dev_info(&pdev->dev, "kept as earlytimer\n");
goto out; goto out;
} }
p = kmalloc(sizeof(*p), GFP_KERNEL); tmu = kmalloc(sizeof(*tmu), GFP_KERNEL);
if (p == NULL) { if (tmu == NULL) {
dev_err(&pdev->dev, "failed to allocate driver data\n"); dev_err(&pdev->dev, "failed to allocate driver data\n");
return -ENOMEM; return -ENOMEM;
} }
ret = sh_tmu_setup(p, pdev); ret = sh_tmu_setup(tmu, pdev);
if (ret) { if (ret) {
kfree(p); kfree(tmu);
pm_runtime_idle(&pdev->dev); pm_runtime_idle(&pdev->dev);
return ret; return ret;
} }
......
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