2024-04-24 07:36:22

by Jingbao Qiu

[permalink] [raw]
Subject: Re: [PATCH v8 2/2] rtc: sophgo: add rtc support for Sophgo CV1800 SoC

Hi, Alexandre

I'm glad to receive your reply.

> I don't feel like these two macros make your code clearer, you should
> probably simply use 0 and 1 in the proper locations.
>

I will use 0/1 replace this macros.

> > +static irqreturn_t cv1800_rtc_irq_handler(int irq, void *dev_id)
> > +{
> > + struct rtc_device *rtc = dev_id;
> > +
> > + rtc_update_irq(rtc, 1, RTC_IRQF | RTC_AF);
>
> I'm pretty sure this would result in a crash...

Yes, it did happen. Because I inserted an incorrect pointer.

>
> > +
> > + return IRQ_HANDLED;
> > +}
> > +
> > + ret = devm_request_irq(&pdev->dev, rtc->irq, cv1800_rtc_irq_handler,
> > + IRQF_TRIGGER_HIGH, "alarm", &pdev->dev);
>
> ... you probably want to use rtc->rtc_dev here to fix this.
>
> This also means that you have to request the irq late, else you are open
> t a race condition anyway.

I am very sorry about this bug.
I will use rtc->rtc_dev to fix it and request irq after
devm_rtc_allocate_device.

Best regards
Jingbao Qiu