Re: [PATCH 3/7] rtc: rzn1: Add new RTC driver

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Miquèl,

On 13/04/2022 17:23:27+0200, Miquel Raynal wrote:
> > > +static int rzn1_rtc_probe(struct platform_device *pdev)
> > > +{
> > > +	struct rzn1_rtc *rtc;
> > > +	int ret;
> > > +
> > > +	rtc = devm_kzalloc(&pdev->dev, sizeof(*rtc), GFP_KERNEL);
> > > +	if (!rtc)
> > > +		return -ENOMEM;
> > > +
> > > +	platform_set_drvdata(pdev, rtc);
> > > +
> > > +	rtc->clk = devm_clk_get(&pdev->dev, "hclk");
> > > +	if (IS_ERR(rtc->clk))
> > > +		return dev_err_probe(&pdev->dev, PTR_ERR(rtc->clk), "Missing hclk\n");
> > > +
> > > +	rtc->base = devm_platform_ioremap_resource(pdev, 0);
> > > +	if (IS_ERR(rtc->base))
> > > +		return dev_err_probe(&pdev->dev, PTR_ERR(rtc->base), "Missing reg\n");
> > > +
> > > +	rtc->rtcdev = devm_rtc_allocate_device(&pdev->dev);
> > > +	if (IS_ERR(rtc->rtcdev))
> > > +		return PTR_ERR(rtc);
> > > +
> > > +	rtc->rtcdev->range_max = 3178591199UL; /* 100 years */  
> > 
> > I'm not sure how you came to this value, this is 2070-09-22T05:59:59.
> > I'm pretty sure the RTC will not fail at that time. Also, the comment
> > seems fishy.
> 
> The RTC itself as no "starting point", but just a counter that can
> count up to 100. So the max range is start-year + 100 years. But at
> this point I don't yet have access to the start-year value. What's
> your advise?

The question is why is this limited to 100 years? My guess is that it
doesn't handle leap years properly if this is the case, there is only
one range that works, this is 2000-01-01 to 2099-12-31 like many other
RTCs.

You can run rtc-range from rtc-tools after removing range_max to find
out.

Cheers

-- 
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com



[Index of Archives]     [Linux Sound]     [ALSA Users]     [ALSA Devel]     [Linux Audio Users]     [Linux Media]     [Kernel]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux