Message ID | 20190407211646.14962-1-alexandre.belloni@bootlin.com |
---|---|
State | Deferred |
Headers | show |
Series | [1/3] rtc: tegra: set range | expand |
On Sun, Apr 07, 2019 at 11:16:44PM +0200, Alexandre Belloni wrote: > The Tegra 20 RTC is a 32bit seconds counter (with an unused millisecond > counter). > > Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> > --- > drivers/rtc/rtc-tegra.c | 24 ++++++++++++++---------- > 1 file changed, 14 insertions(+), 10 deletions(-) > > diff --git a/drivers/rtc/rtc-tegra.c b/drivers/rtc/rtc-tegra.c > index c6b0a99aa3a9..3f93a1f7abb5 100644 > --- a/drivers/rtc/rtc-tegra.c > +++ b/drivers/rtc/rtc-tegra.c > @@ -306,6 +306,13 @@ static int __init tegra_rtc_probe(struct platform_device *pdev) > > info->tegra_rtc_irq = ret; > > + info->rtc_dev = devm_rtc_allocate_device(&pdev->dev); > + if (IS_ERR(info->rtc_dev)) > + return PTR_ERR(info->rtc_dev); > + > + info->rtc_dev->ops = &tegra_rtc_ops; > + info->rtc_dev->range_max = U32_MAX; The placement of this new block seems somewhat arbitrary, but either way: Acked-by: Thierry Reding <treding@nvidia.com>
On 08/04/2019 12:22:49+0200, Thierry Reding wrote: > On Sun, Apr 07, 2019 at 11:16:44PM +0200, Alexandre Belloni wrote: > > The Tegra 20 RTC is a 32bit seconds counter (with an unused millisecond > > counter). > > > > Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> > > --- > > drivers/rtc/rtc-tegra.c | 24 ++++++++++++++---------- > > 1 file changed, 14 insertions(+), 10 deletions(-) > > > > diff --git a/drivers/rtc/rtc-tegra.c b/drivers/rtc/rtc-tegra.c > > index c6b0a99aa3a9..3f93a1f7abb5 100644 > > --- a/drivers/rtc/rtc-tegra.c > > +++ b/drivers/rtc/rtc-tegra.c > > @@ -306,6 +306,13 @@ static int __init tegra_rtc_probe(struct platform_device *pdev) > > > > info->tegra_rtc_irq = ret; > > > > + info->rtc_dev = devm_rtc_allocate_device(&pdev->dev); > > + if (IS_ERR(info->rtc_dev)) > > + return PTR_ERR(info->rtc_dev); > > + > > + info->rtc_dev->ops = &tegra_rtc_ops; > > + info->rtc_dev->range_max = U32_MAX; > > The placement of this new block seems somewhat arbitrary, but either > way: > Well, I needed it to be before the clk_prepare_enable call so it can just return and I thought it would be better to leave devm_clk_get close to that clk_prepare_enable call. I don't mind, I can respin with it placed somewhere else. > Acked-by: Thierry Reding <treding@nvidia.com>
On Mon, Apr 08, 2019 at 01:54:06PM +0200, Alexandre Belloni wrote: > On 08/04/2019 12:22:49+0200, Thierry Reding wrote: > > On Sun, Apr 07, 2019 at 11:16:44PM +0200, Alexandre Belloni wrote: > > > The Tegra 20 RTC is a 32bit seconds counter (with an unused millisecond > > > counter). > > > > > > Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> > > > --- > > > drivers/rtc/rtc-tegra.c | 24 ++++++++++++++---------- > > > 1 file changed, 14 insertions(+), 10 deletions(-) > > > > > > diff --git a/drivers/rtc/rtc-tegra.c b/drivers/rtc/rtc-tegra.c > > > index c6b0a99aa3a9..3f93a1f7abb5 100644 > > > --- a/drivers/rtc/rtc-tegra.c > > > +++ b/drivers/rtc/rtc-tegra.c > > > @@ -306,6 +306,13 @@ static int __init tegra_rtc_probe(struct platform_device *pdev) > > > > > > info->tegra_rtc_irq = ret; > > > > > > + info->rtc_dev = devm_rtc_allocate_device(&pdev->dev); > > > + if (IS_ERR(info->rtc_dev)) > > > + return PTR_ERR(info->rtc_dev); > > > + > > > + info->rtc_dev->ops = &tegra_rtc_ops; > > > + info->rtc_dev->range_max = U32_MAX; > > > > The placement of this new block seems somewhat arbitrary, but either > > way: > > > > Well, I needed it to be before the clk_prepare_enable call so it can > just return and I thought it would be better to leave devm_clk_get close > to that clk_prepare_enable call. I don't mind, I can respin with it > placed somewhere else. Don't bother. It's really just a cosmetic change and I couldn't tell you a much better place without moving some other pieces around either. If somebody really cares a lot, this can be done in a separate follow-up. Thierry
diff --git a/drivers/rtc/rtc-tegra.c b/drivers/rtc/rtc-tegra.c index c6b0a99aa3a9..3f93a1f7abb5 100644 --- a/drivers/rtc/rtc-tegra.c +++ b/drivers/rtc/rtc-tegra.c @@ -306,6 +306,13 @@ static int __init tegra_rtc_probe(struct platform_device *pdev) info->tegra_rtc_irq = ret; + info->rtc_dev = devm_rtc_allocate_device(&pdev->dev); + if (IS_ERR(info->rtc_dev)) + return PTR_ERR(info->rtc_dev); + + info->rtc_dev->ops = &tegra_rtc_ops; + info->rtc_dev->range_max = U32_MAX; + info->clk = devm_clk_get(&pdev->dev, NULL); if (IS_ERR(info->clk)) return PTR_ERR(info->clk); @@ -327,16 +334,6 @@ static int __init tegra_rtc_probe(struct platform_device *pdev) device_init_wakeup(&pdev->dev, 1); - info->rtc_dev = devm_rtc_device_register(&pdev->dev, - dev_name(&pdev->dev), &tegra_rtc_ops, - THIS_MODULE); - if (IS_ERR(info->rtc_dev)) { - ret = PTR_ERR(info->rtc_dev); - dev_err(&pdev->dev, "Unable to register device (err=%d).\n", - ret); - goto disable_clk; - } - ret = devm_request_irq(&pdev->dev, info->tegra_rtc_irq, tegra_rtc_irq_handler, IRQF_TRIGGER_HIGH, dev_name(&pdev->dev), &pdev->dev); @@ -347,6 +344,13 @@ static int __init tegra_rtc_probe(struct platform_device *pdev) goto disable_clk; } + ret = rtc_register_device(info->rtc_dev); + if (ret) { + dev_err(&pdev->dev, "Unable to register device (err=%d).\n", + ret); + goto disable_clk; + } + dev_notice(&pdev->dev, "Tegra internal Real Time Clock\n"); return 0;
The Tegra 20 RTC is a 32bit seconds counter (with an unused millisecond counter). Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> --- drivers/rtc/rtc-tegra.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-)